OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc4/] [libstdc++-v3/] [config/] [os/] [generic/] [ctype_inline.h] - Diff between revs 424 and 519

Only display areas with differences | Details | Blame | View Log

Rev 424 Rev 519
// Locale support -*- C++ -*-
// Locale support -*- C++ -*-
 
 
// Copyright (C) 2000, 2003, 2009 Free Software Foundation, Inc.
// Copyright (C) 2000, 2003, 2009 Free Software Foundation, Inc.
//
//
// This file is part of the GNU ISO C++ Library.  This library is free
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// any later version.
 
 
// This library is distributed in the hope that it will be useful,
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// GNU General Public License for more details.
 
 
// Under Section 7 of GPL version 3, you are granted additional
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// 3.1, as published by the Free Software Foundation.
 
 
// You should have received a copy of the GNU General Public License and
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.
// <http://www.gnu.org/licenses/>.
 
 
/** @file ctype_inline.h
/** @file ctype_inline.h
 *  This is an internal header file, included by other library headers.
 *  This is an internal header file, included by other library headers.
 *  You should not attempt to use it directly.
 *  You should not attempt to use it directly.
 */
 */
 
 
//
//
// ISO C++ 14882: 22.1  Locales
// ISO C++ 14882: 22.1  Locales
//
//
 
 
// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
// ctype bits to be inlined go here. Non-inlinable (ie virtual do_*)
// functions go in ctype.cc
// functions go in ctype.cc
 
 
// The following definitions are portable, but insanely slow. If one
// The following definitions are portable, but insanely slow. If one
// cares at all about performance, then specialized ctype
// cares at all about performance, then specialized ctype
// functionality should be added for the native os in question: see
// functionality should be added for the native os in question: see
// the config/os/bits/ctype_*.h files.
// the config/os/bits/ctype_*.h files.
 
 
// Constructing a synthetic "C" table should be seriously considered...
// Constructing a synthetic "C" table should be seriously considered...
 
 
_GLIBCXX_BEGIN_NAMESPACE(std)
_GLIBCXX_BEGIN_NAMESPACE(std)
 
 
  bool
  bool
  ctype<char>::
  ctype<char>::
  is(mask __m, char __c) const
  is(mask __m, char __c) const
  {
  {
    if (_M_table)
    if (_M_table)
      return _M_table[static_cast<unsigned char>(__c)] & __m;
      return _M_table[static_cast<unsigned char>(__c)] & __m;
    else
    else
      {
      {
        bool __ret = false;
        bool __ret = false;
        const size_t __bitmasksize = 15;
        const size_t __bitmasksize = 15;
        size_t __bitcur = 0; // Lowest bitmask in ctype_base == 0
        size_t __bitcur = 0; // Lowest bitmask in ctype_base == 0
        for (; __bitcur <= __bitmasksize; ++__bitcur)
        for (; __bitcur <= __bitmasksize; ++__bitcur)
          {
          {
            const mask __bit = static_cast<mask>(1 << __bitcur);
            const mask __bit = static_cast<mask>(1 << __bitcur);
            if (__m & __bit)
            if (__m & __bit)
              {
              {
                bool __testis;
                bool __testis;
                switch (__bit)
                switch (__bit)
                  {
                  {
                  case space:
                  case space:
                    __testis = isspace(__c);
                    __testis = isspace(__c);
                    break;
                    break;
                  case print:
                  case print:
                    __testis = isprint(__c);
                    __testis = isprint(__c);
                    break;
                    break;
                  case cntrl:
                  case cntrl:
                    __testis = iscntrl(__c);
                    __testis = iscntrl(__c);
                    break;
                    break;
                  case upper:
                  case upper:
                    __testis = isupper(__c);
                    __testis = isupper(__c);
                    break;
                    break;
                  case lower:
                  case lower:
                    __testis = islower(__c);
                    __testis = islower(__c);
                    break;
                    break;
                  case alpha:
                  case alpha:
                    __testis = isalpha(__c);
                    __testis = isalpha(__c);
                    break;
                    break;
                  case digit:
                  case digit:
                    __testis = isdigit(__c);
                    __testis = isdigit(__c);
                    break;
                    break;
                  case punct:
                  case punct:
                    __testis = ispunct(__c);
                    __testis = ispunct(__c);
                    break;
                    break;
                  case xdigit:
                  case xdigit:
                    __testis = isxdigit(__c);
                    __testis = isxdigit(__c);
                    break;
                    break;
                  case alnum:
                  case alnum:
                    __testis = isalnum(__c);
                    __testis = isalnum(__c);
                    break;
                    break;
                  case graph:
                  case graph:
                    __testis = isgraph(__c);
                    __testis = isgraph(__c);
                    break;
                    break;
                  default:
                  default:
                    __testis = false;
                    __testis = false;
                    break;
                    break;
                  }
                  }
                __ret |= __testis;
                __ret |= __testis;
              }
              }
          }
          }
        return __ret;
        return __ret;
      }
      }
  }
  }
 
 
  const char*
  const char*
  ctype<char>::
  ctype<char>::
  is(const char* __low, const char* __high, mask* __vec) const
  is(const char* __low, const char* __high, mask* __vec) const
  {
  {
    if (_M_table)
    if (_M_table)
      while (__low < __high)
      while (__low < __high)
        *__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
        *__vec++ = _M_table[static_cast<unsigned char>(*__low++)];
    else
    else
      {
      {
        // Highest bitmask in ctype_base == 10.
        // Highest bitmask in ctype_base == 10.
        const size_t __bitmasksize = 15;
        const size_t __bitmasksize = 15;
        for (;__low < __high; ++__vec, ++__low)
        for (;__low < __high; ++__vec, ++__low)
          {
          {
            mask __m = 0;
            mask __m = 0;
            // Lowest bitmask in ctype_base == 0
            // Lowest bitmask in ctype_base == 0
            size_t __i = 0;
            size_t __i = 0;
            for (;__i <= __bitmasksize; ++__i)
            for (;__i <= __bitmasksize; ++__i)
              {
              {
                const mask __bit = static_cast<mask>(1 << __i);
                const mask __bit = static_cast<mask>(1 << __i);
                if (this->is(__bit, *__low))
                if (this->is(__bit, *__low))
                  __m |= __bit;
                  __m |= __bit;
              }
              }
            *__vec = __m;
            *__vec = __m;
          }
          }
      }
      }
    return __high;
    return __high;
  }
  }
 
 
  const char*
  const char*
  ctype<char>::
  ctype<char>::
  scan_is(mask __m, const char* __low, const char* __high) const
  scan_is(mask __m, const char* __low, const char* __high) const
  {
  {
    if (_M_table)
    if (_M_table)
      while (__low < __high
      while (__low < __high
             && !(_M_table[static_cast<unsigned char>(*__low)] & __m))
             && !(_M_table[static_cast<unsigned char>(*__low)] & __m))
        ++__low;
        ++__low;
    else
    else
      while (__low < __high && !this->is(__m, *__low))
      while (__low < __high && !this->is(__m, *__low))
        ++__low;
        ++__low;
    return __low;
    return __low;
  }
  }
 
 
  const char*
  const char*
  ctype<char>::
  ctype<char>::
  scan_not(mask __m, const char* __low, const char* __high) const
  scan_not(mask __m, const char* __low, const char* __high) const
  {
  {
    if (_M_table)
    if (_M_table)
      while (__low < __high
      while (__low < __high
             && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
             && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0)
        ++__low;
        ++__low;
    else
    else
      while (__low < __high && this->is(__m, *__low) != 0)
      while (__low < __high && this->is(__m, *__low) != 0)
        ++__low;
        ++__low;
    return __low;
    return __low;
  }
  }
 
 
_GLIBCXX_END_NAMESPACE
_GLIBCXX_END_NAMESPACE
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.