00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #if _GLIBCXX_C_LOCALE_GNU
00043 const ctype_base::mask*
00044 ctype<char>::classic_table() throw()
00045 { return _S_get_c_locale()->__ctype_b; }
00046 #else
00047 const ctype_base::mask*
00048 ctype<char>::classic_table() throw()
00049 {
00050 const ctype_base::mask* __ret;
00051 char* __old = strdup(setlocale(LC_CTYPE, NULL));
00052 setlocale(LC_CTYPE, "C");
00053 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
00054 __ret = *__ctype_b_loc();
00055 #else
00056 __ret = __ctype_b;
00057 #endif
00058 setlocale(LC_CTYPE, __old);
00059 free(__old);
00060 return __ret;
00061 }
00062 #endif
00063
00064 #if _GLIBCXX_C_LOCALE_GNU
00065 ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del,
00066 size_t __refs)
00067 : facet(__refs), _M_c_locale_ctype(_S_clone_c_locale(__cloc)),
00068 _M_del(__table != 0 && __del),
00069 _M_toupper(_M_c_locale_ctype->__ctype_toupper),
00070 _M_tolower(_M_c_locale_ctype->__ctype_tolower),
00071 _M_table(__table ? __table : _M_c_locale_ctype->__ctype_b),
00072 _M_widen_ok(0), _M_narrow_ok(0)
00073 {
00074 memset(_M_widen, 0, sizeof(_M_widen));
00075 memset(_M_narrow, 0, sizeof(_M_narrow));
00076 }
00077 #else
00078 ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
00079 size_t __refs)
00080 : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
00081 _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
00082 {
00083 char* __old=strdup(setlocale(LC_CTYPE, NULL));
00084 setlocale(LC_CTYPE, "C");
00085 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
00086 _M_toupper = *__ctype_toupper_loc();
00087 _M_tolower = *__ctype_tolower_loc();
00088 _M_table = __table ? __table : *__ctype_b_loc();
00089 #else
00090 _M_toupper = __ctype_toupper;
00091 _M_tolower = __ctype_tolower;
00092 _M_table = __table ? __table : __ctype_b;
00093 #endif
00094 setlocale(LC_CTYPE, __old);
00095 free(__old);
00096 memset(_M_widen, 0, sizeof(_M_widen));
00097 memset(_M_narrow, 0, sizeof(_M_narrow));
00098 }
00099 #endif
00100
00101 #if _GLIBCXX_C_LOCALE_GNU
00102 ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
00103 : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
00104 _M_del(__table != 0 && __del),
00105 _M_toupper(_M_c_locale_ctype->__ctype_toupper),
00106 _M_tolower(_M_c_locale_ctype->__ctype_tolower),
00107 _M_table(__table ? __table : _M_c_locale_ctype->__ctype_b),
00108 _M_widen_ok(0), _M_narrow_ok(0)
00109 {
00110 memset(_M_widen, 0, sizeof(_M_widen));
00111 memset(_M_narrow, 0, sizeof(_M_narrow));
00112 }
00113 #else
00114 ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
00115 : facet(__refs), _M_c_locale_ctype(_S_get_c_locale()),
00116 _M_del(__table != 0 && __del), _M_widen_ok(0), _M_narrow_ok(0)
00117 {
00118 char* __old=strdup(setlocale(LC_CTYPE, NULL));
00119 setlocale(LC_CTYPE, "C");
00120 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
00121 _M_toupper = *__ctype_toupper_loc();
00122 _M_tolower = *__ctype_tolower_loc();
00123 _M_table = __table ? __table : *__ctype_b_loc();
00124 #else
00125 _M_toupper = __ctype_toupper;
00126 _M_tolower = __ctype_tolower;
00127 _M_table = __table ? __table : __ctype_b;
00128 #endif
00129 setlocale(LC_CTYPE, __old);
00130 free(__old);
00131 memset(_M_widen, 0, sizeof(_M_widen));
00132 memset(_M_narrow, 0, sizeof(_M_narrow));
00133 }
00134 #endif
00135
00136 char
00137 ctype<char>::do_toupper(char __c) const
00138 { return _M_toupper[static_cast<unsigned char>(__c)]; }
00139
00140 const char*
00141 ctype<char>::do_toupper(char* __low, const char* __high) const
00142 {
00143 while (__low < __high)
00144 {
00145 *__low = _M_toupper[static_cast<unsigned char>(*__low)];
00146 ++__low;
00147 }
00148 return __high;
00149 }
00150
00151 char
00152 ctype<char>::do_tolower(char __c) const
00153 { return _M_tolower[static_cast<unsigned char>(__c)]; }
00154
00155 const char*
00156 ctype<char>::do_tolower(char* __low, const char* __high) const
00157 {
00158 while (__low < __high)
00159 {
00160 *__low = _M_tolower[static_cast<unsigned char>(*__low)];
00161 ++__low;
00162 }
00163 return __high;
00164 }