ctype_noninline.h

00001 // Locale support -*- C++ -*- 00002 00003 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 00004 // Free Software Foundation, Inc. 00005 // 00006 // This file is part of the GNU ISO C++ Library. This library is free 00007 // software; you can redistribute it and/or modify it under the 00008 // terms of the GNU General Public License as published by the 00009 // Free Software Foundation; either version 2, or (at your option) 00010 // any later version. 00011 00012 // This library is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 00017 // You should have received a copy of the GNU General Public License along 00018 // with this library; see the file COPYING. If not, write to the Free 00019 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00020 // USA. 00021 00022 // As a special exception, you may use this file as part of a free software 00023 // library without restriction. Specifically, if other files instantiate 00024 // templates or use macros or inline functions from this file, or you compile 00025 // this file and link it with other files to produce an executable, this 00026 // file does not by itself cause the resulting executable to be covered by 00027 // the GNU General Public License. This exception does not however 00028 // invalidate any other reasons why the executable file might be covered by 00029 // the GNU General Public License. 00030 00031 // 00032 // ISO C++ 14882: 22.1 Locales 00033 // 00034 00035 // Information as gleaned from /usr/include/ctype.h 00036 00037 #if _GLIBCPP_C_LOCALE_GNU 00038 const ctype_base::mask* 00039 ctype<char>::classic_table() throw() 00040 { 00041 locale::classic(); 00042 return _S_c_locale->__ctype_b; 00043 } 00044 #else 00045 const ctype_base::mask* 00046 ctype<char>::classic_table() throw() 00047 { 00048 const ctype_base::mask* __ret; 00049 char* __old = strdup(setlocale(LC_CTYPE, NULL)); 00050 setlocale(LC_CTYPE, "C"); 00051 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) 00052 __ret = *__ctype_b_loc(); 00053 #else 00054 __ret = __ctype_b; 00055 #endif 00056 setlocale(LC_CTYPE, __old); 00057 free(__old); 00058 return __ret; 00059 } 00060 #endif 00061 00062 #if _GLIBCPP_C_LOCALE_GNU 00063 ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del, 00064 size_t __refs) 00065 : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del) 00066 { 00067 _M_c_locale_ctype = _S_clone_c_locale(__cloc); 00068 _M_toupper = _M_c_locale_ctype->__ctype_toupper; 00069 _M_tolower = _M_c_locale_ctype->__ctype_tolower; 00070 _M_table = __table ? __table : _M_c_locale_ctype->__ctype_b; 00071 } 00072 #else 00073 ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 00074 size_t __refs) 00075 : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del) 00076 { 00077 char* __old=strdup(setlocale(LC_CTYPE, NULL)); 00078 setlocale(LC_CTYPE, "C"); 00079 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) 00080 _M_toupper = *__ctype_toupper_loc(); 00081 _M_tolower = *__ctype_tolower_loc(); 00082 _M_table = __table ? __table : *__ctype_b_loc(); 00083 #else 00084 _M_toupper = __ctype_toupper; 00085 _M_tolower = __ctype_tolower; 00086 _M_table = __table ? __table : __ctype_b; 00087 #endif 00088 setlocale(LC_CTYPE, __old); 00089 free(__old); 00090 _M_c_locale_ctype = _S_c_locale; 00091 } 00092 #endif 00093 00094 #if _GLIBCPP_C_LOCALE_GNU 00095 ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) : 00096 __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del) 00097 { 00098 _M_c_locale_ctype = _S_c_locale; 00099 _M_toupper = _M_c_locale_ctype->__ctype_toupper; 00100 _M_tolower = _M_c_locale_ctype->__ctype_tolower; 00101 _M_table = __table ? __table : _M_c_locale_ctype->__ctype_b; 00102 } 00103 #else 00104 ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) : 00105 __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del) 00106 { 00107 char* __old=strdup(setlocale(LC_CTYPE, NULL)); 00108 setlocale(LC_CTYPE, "C"); 00109 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) 00110 _M_toupper = *__ctype_toupper_loc(); 00111 _M_tolower = *__ctype_tolower_loc(); 00112 _M_table = __table ? __table : *__ctype_b_loc(); 00113 #else 00114 _M_toupper = __ctype_toupper; 00115 _M_tolower = __ctype_tolower; 00116 _M_table = __table ? __table : __ctype_b; 00117 #endif 00118 setlocale(LC_CTYPE, __old); 00119 free(__old); 00120 _M_c_locale_ctype = _S_c_locale; 00121 } 00122 #endif 00123 00124 char 00125 ctype<char>::do_toupper(char __c) const 00126 { return _M_toupper[static_cast<unsigned char>(__c)]; } 00127 00128 const char* 00129 ctype<char>::do_toupper(char* __low, const char* __high) const 00130 { 00131 while (__low < __high) 00132 { 00133 *__low = _M_toupper[static_cast<unsigned char>(*__low)]; 00134 ++__low; 00135 } 00136 return __high; 00137 } 00138 00139 char 00140 ctype<char>::do_tolower(char __c) const 00141 { return _M_tolower[static_cast<unsigned char>(__c)]; } 00142 00143 const char* 00144 ctype<char>::do_tolower(char* __low, const char* __high) const 00145 { 00146 while (__low < __high) 00147 { 00148 *__low = _M_tolower[static_cast<unsigned char>(*__low)]; 00149 ++__low; 00150 } 00151 return __high; 00152 }

Generated on Wed Sep 29 13:54:47 2004 for libstdc++-v3 Source by doxygen 1.3.7