1*03a78d15Sespie // Locale support -*- C++ -*- 2*03a78d15Sespie 3*03a78d15Sespie // Copyright (C) 2000, 2003 Free Software Foundation, Inc. 4*03a78d15Sespie // 5*03a78d15Sespie // This file is part of the GNU ISO C++ Library. This library is free 6*03a78d15Sespie // software; you can redistribute it and/or modify it under the 7*03a78d15Sespie // terms of the GNU General Public License as published by the 8*03a78d15Sespie // Free Software Foundation; either version 2, or (at your option) 9*03a78d15Sespie // any later version. 10*03a78d15Sespie 11*03a78d15Sespie // This library is distributed in the hope that it will be useful, 12*03a78d15Sespie // but WITHOUT ANY WARRANTY; without even the implied warranty of 13*03a78d15Sespie // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*03a78d15Sespie // GNU General Public License for more details. 15*03a78d15Sespie 16*03a78d15Sespie // You should have received a copy of the GNU General Public License along 17*03a78d15Sespie // with this library; see the file COPYING. If not, write to the Free 18*03a78d15Sespie // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 19*03a78d15Sespie // USA. 20*03a78d15Sespie 21*03a78d15Sespie // As a special exception, you may use this file as part of a free software 22*03a78d15Sespie // library without restriction. Specifically, if other files instantiate 23*03a78d15Sespie // templates or use macros or inline functions from this file, or you compile 24*03a78d15Sespie // this file and link it with other files to produce an executable, this 25*03a78d15Sespie // file does not by itself cause the resulting executable to be covered by 26*03a78d15Sespie // the GNU General Public License. This exception does not however 27*03a78d15Sespie // invalidate any other reasons why the executable file might be covered by 28*03a78d15Sespie // the GNU General Public License. 29*03a78d15Sespie 30*03a78d15Sespie // 31*03a78d15Sespie // ISO C++ 14882: 22.1 Locales 32*03a78d15Sespie // 33*03a78d15Sespie 34*03a78d15Sespie // ctype bits to be inlined go here. Non-inlinable (ie virtual do_*) 35*03a78d15Sespie // functions go in ctype.cc 36*03a78d15Sespie 37*03a78d15Sespie bool 38*03a78d15Sespie ctype<char>:: is(mask __m,char __c)39*03a78d15Sespie is(mask __m, char __c) const 40*03a78d15Sespie { 41*03a78d15Sespie if (_M_table) 42*03a78d15Sespie return _M_table[static_cast<unsigned char>(__c)] & __m; 43*03a78d15Sespie else 44*03a78d15Sespie return __istype(__c, __m); 45*03a78d15Sespie } 46*03a78d15Sespie 47*03a78d15Sespie const char* 48*03a78d15Sespie ctype<char>:: is(const char * __low,const char * __high,mask * __vec)49*03a78d15Sespie is(const char* __low, const char* __high, mask* __vec) const 50*03a78d15Sespie { 51*03a78d15Sespie if (_M_table) 52*03a78d15Sespie while (__low < __high) 53*03a78d15Sespie *__vec++ = _M_table[static_cast<unsigned char>(*__low++)]; 54*03a78d15Sespie else 55*03a78d15Sespie for (;__low < __high; ++__vec, ++__low) 56*03a78d15Sespie { 57*03a78d15Sespie #if defined (_CTYPE_S) || defined (__istype) 58*03a78d15Sespie *__vec = __maskrune (*__low, upper | lower | alpha | digit | xdigit 59*03a78d15Sespie | space | print | graph | cntrl | punct | alnum); 60*03a78d15Sespie #else 61*03a78d15Sespie mask __m = 0; 62*03a78d15Sespie if (this->is(upper, *__low)) __m |= upper; 63*03a78d15Sespie if (this->is(lower, *__low)) __m |= lower; 64*03a78d15Sespie if (this->is(alpha, *__low)) __m |= alpha; 65*03a78d15Sespie if (this->is(digit, *__low)) __m |= digit; 66*03a78d15Sespie if (this->is(xdigit, *__low)) __m |= xdigit; 67*03a78d15Sespie if (this->is(space, *__low)) __m |= space; 68*03a78d15Sespie if (this->is(print, *__low)) __m |= print; 69*03a78d15Sespie if (this->is(graph, *__low)) __m |= graph; 70*03a78d15Sespie if (this->is(cntrl, *__low)) __m |= cntrl; 71*03a78d15Sespie if (this->is(punct, *__low)) __m |= punct; 72*03a78d15Sespie // Do not include explicit line for alnum mask since it is a 73*03a78d15Sespie // pure composite of masks on FreeBSD. 74*03a78d15Sespie *__vec = __m; 75*03a78d15Sespie #endif 76*03a78d15Sespie } 77*03a78d15Sespie return __high; 78*03a78d15Sespie } 79*03a78d15Sespie 80*03a78d15Sespie const char* 81*03a78d15Sespie ctype<char>:: scan_is(mask __m,const char * __low,const char * __high)82*03a78d15Sespie scan_is(mask __m, const char* __low, const char* __high) const 83*03a78d15Sespie { 84*03a78d15Sespie if (_M_table) 85*03a78d15Sespie while (__low < __high 86*03a78d15Sespie && !(_M_table[static_cast<unsigned char>(*__low)] & __m)) 87*03a78d15Sespie ++__low; 88*03a78d15Sespie else 89*03a78d15Sespie while (__low < __high && !this->is(__m, *__low)) 90*03a78d15Sespie ++__low; 91*03a78d15Sespie return __low; 92*03a78d15Sespie } 93*03a78d15Sespie 94*03a78d15Sespie const char* 95*03a78d15Sespie ctype<char>:: scan_not(mask __m,const char * __low,const char * __high)96*03a78d15Sespie scan_not(mask __m, const char* __low, const char* __high) const 97*03a78d15Sespie { 98*03a78d15Sespie if (_M_table) 99*03a78d15Sespie while (__low < __high 100*03a78d15Sespie && (_M_table[static_cast<unsigned char>(*__low)] & __m) != 0) 101*03a78d15Sespie ++__low; 102*03a78d15Sespie else 103*03a78d15Sespie while (__low < __high && this->is(__m, *__low) != 0) 104*03a78d15Sespie ++__low; 105*03a78d15Sespie return __low; 106*03a78d15Sespie } 107