From 1c28b93579f6082bde3b6fb9f548151be63152a3 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 6 Sep 2002 19:58:27 +0200 Subject: [PATCH] ctype_noninline.h [...]: Remove using _C_legacy::__ctype_*. * config/os/gnu-linux/ctype_noninline.h [_GLIBCPP_USE_SHADOW_HEADERS]: Remove using _C_legacy::__ctype_*. (ctype::classic_table): If _GLIBCPP_C_LOCALE_GNU, return _S_c_locale->__ctype_b, otherwise temporarily switch to "C" locale and return __ctype_b. (ctype::ctype(__c_locale, const mask*, bool, size_t)): If not _GLIBCPP_C_LOCALE_GNU, temporarily switch to "C" locale and initialize using __ctype_{b,tolower,toupper}. (ctype::ctype(const mask*, bool, size_t)): If _GLIBCPP_C_LOCALE_GNU, initialize using _S_c_locale->__ctype_{b,tolower,toupper}, otherwise temporarily switch to "C" locale and initialize using __ctype_{b,tolower,toupper}. From-SVN: r56893 --- libstdc++-v3/ChangeLog | 15 ++++ .../config/os/gnu-linux/ctype_noninline.h | 85 +++++++++++++++---- 2 files changed, 84 insertions(+), 16 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 89804df5295..b86ca41f4cc 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,18 @@ +2002-09-06 Jakub Jelinek + + * config/os/gnu-linux/ctype_noninline.h + [_GLIBCPP_USE_SHADOW_HEADERS]: Remove using _C_legacy::__ctype_*. + (ctype::classic_table): If _GLIBCPP_C_LOCALE_GNU, return + _S_c_locale->__ctype_b, otherwise temporarily switch to "C" locale + and return __ctype_b. + (ctype::ctype(__c_locale, const mask*, bool, size_t)): If not + _GLIBCPP_C_LOCALE_GNU, temporarily switch to "C" locale and + initialize using __ctype_{b,tolower,toupper}. + (ctype::ctype(const mask*, bool, size_t)): If + _GLIBCPP_C_LOCALE_GNU, initialize using + _S_c_locale->__ctype_{b,tolower,toupper}, otherwise temporarily + switch to "C" locale and initialize using __ctype_{b,tolower,toupper}. + 2002-09-05 Paolo Carlini Roland McGrath diff --git a/libstdc++-v3/config/os/gnu-linux/ctype_noninline.h b/libstdc++-v3/config/os/gnu-linux/ctype_noninline.h index ee70ab46c3b..1578828cced 100644 --- a/libstdc++-v3/config/os/gnu-linux/ctype_noninline.h +++ b/libstdc++-v3/config/os/gnu-linux/ctype_noninline.h @@ -34,16 +34,32 @@ // Information as gleaned from /usr/include/ctype.h -#if _GLIBCPP_USE_SHADOW_HEADERS - using _C_legacy::__ctype_toupper; - using _C_legacy::__ctype_tolower; - using _C_legacy::__ctype_b; -#endif - +#if _GLIBCPP_C_LOCALE_GNU const ctype_base::mask* ctype::classic_table() throw() - { return __ctype_b; } - + { + if (!_S_c_locale) + _S_create_c_locale(_S_c_locale, "C"); + return _S_c_locale->__ctype_b; + } +#else + const ctype_base::mask* + ctype::classic_table() throw() + { + const ctype_base::mask* __ret; + char* __old = strdup(setlocale(LC_CTYPE, NULL)); + setlocale(LC_CTYPE, "C"); +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + __ret = *__ctype_b_loc(); +#else + __ret = __ctype_b; +#endif + setlocale(LC_CTYPE, __old); + free(__old); + return __ret; + } +#endif + #if _GLIBCPP_C_LOCALE_GNU ctype::ctype(__c_locale __cloc, const mask* __table, bool __del, size_t __refs) @@ -57,17 +73,54 @@ #else ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), - _M_toupper(__ctype_toupper), _M_tolower(__ctype_tolower), - _M_table(__table ? __table : classic_table()) - { _M_c_locale_ctype = _S_c_locale; } + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del) + { + char* __old=strdup(setlocale(LC_CTYPE, NULL)); + setlocale(LC_CTYPE, "C"); +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + _M_toupper = *__ctype_toupper_loc(); + _M_tolower = *__ctype_tolower_loc(); + _M_table = __table ? __table : *__ctype_b_loc(); +#else + _M_toupper = __ctype_toupper; + _M_tolower = __ctype_tolower; + _M_table = __table ? __table : __ctype_b; +#endif + setlocale(LC_CTYPE, __old); + free(__old); + _M_c_locale_ctype = _S_c_locale; + } #endif +#if _GLIBCPP_C_LOCALE_GNU + ctype::ctype(const mask* __table, bool __del, size_t __refs) : + __ctype_abstract_base(__refs), _M_del(__table != 0 && __del) + { + _M_c_locale_ctype = _S_c_locale; + _M_toupper = _M_c_locale_ctype->__ctype_toupper; + _M_tolower = _M_c_locale_ctype->__ctype_tolower; + _M_table = __table ? __table : _M_c_locale_ctype->__ctype_b; + } +#else ctype::ctype(const mask* __table, bool __del, size_t __refs) : - __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), - _M_toupper(__ctype_toupper), _M_tolower(__ctype_tolower), - _M_table(__table ? __table : classic_table()) - { _M_c_locale_ctype = _S_c_locale; } + __ctype_abstract_base(__refs), _M_del(__table != 0 && __del) + { + char* __old=strdup(setlocale(LC_CTYPE, NULL)); + setlocale(LC_CTYPE, "C"); +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) + _M_toupper = *__ctype_toupper_loc(); + _M_tolower = *__ctype_tolower_loc(); + _M_table = __table ? __table : *__ctype_b_loc(); +#else + _M_toupper = __ctype_toupper; + _M_tolower = __ctype_tolower; + _M_table = __table ? __table : __ctype_b; +#endif + setlocale(LC_CTYPE, __old); + free(__old); + _M_c_locale_ctype = _S_c_locale; + } +#endif char ctype::do_toupper(char __c) const -- 2.30.2