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 #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 }