From 088eb5a274b3e2d90d15b5ef5706463abbc6b847 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Tue, 13 Jun 2000 02:13:54 +0000 Subject: [PATCH] [multiple changes] 2000-06-12 Benjamin Kosnik * bits/locale_facets.h (ctype): Remove unnecessary data members. * src/locale.cc: Add cwchar include here. Remove incorrect definitions, and stub them out. * config/generic/ctype.cc (ctype): Remove ctype bits. * config/solaris/solaris2.7/ctype.cc (ctype): Same. * config/solaris/solaris2.5/ctype.cc (ctype): Same. * config/newlib/ctype.cc: Same. * config/gnu-linux/ctype.cc: Same. * config/bsd/ctype.cc: Same. * config/aix/ctype.cc: Same. 2000-06-12 Branko Cibej * config/solaris/solaris2.6/ctype.cc (do_toupper, do_tolower): Use towupper and towlower to convert wide characters. From-SVN: r34511 --- libstdc++-v3/ChangeLog | 19 ++++ libstdc++-v3/bits/locale_facets.h | 8 -- libstdc++-v3/config/aix/ctype.cc | 39 ------- libstdc++-v3/config/bsd/ctype.cc | 35 ------ libstdc++-v3/config/generic/ctype.cc | 35 ------ libstdc++-v3/config/gnu-linux/ctype.cc | 40 ------- libstdc++-v3/config/newlib/ctype.cc | 42 ------- .../config/solaris/solaris2.5/ctype.cc | 46 -------- .../config/solaris/solaris2.6/ctype.cc | 36 ------ .../config/solaris/solaris2.7/ctype.cc | 37 ------- libstdc++-v3/src/locale.cc | 104 +++++++++++------- 11 files changed, 86 insertions(+), 355 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 988901e9564..c0b73b61946 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,22 @@ +2000-06-12 Benjamin Kosnik + + * bits/locale_facets.h (ctype): Remove unnecessary data + members. + * src/locale.cc: Add cwchar include here. Remove incorrect + definitions, and stub them out. + * config/generic/ctype.cc (ctype): Remove ctype bits. + * config/solaris/solaris2.7/ctype.cc (ctype): Same. + * config/solaris/solaris2.5/ctype.cc (ctype): Same. + * config/newlib/ctype.cc: Same. + * config/gnu-linux/ctype.cc: Same. + * config/bsd/ctype.cc: Same. + * config/aix/ctype.cc: Same. + +2000-06-12 Branko Cibej + + * config/solaris/solaris2.6/ctype.cc (do_toupper, do_tolower): Use + towupper and towlower to convert wide characters. + 2000-06-12 Benjamin Kosnik * mkcheck.in: Clean up confusion regarding NAME, PRE_NAME. diff --git a/libstdc++-v3/bits/locale_facets.h b/libstdc++-v3/bits/locale_facets.h index 2568585f82b..f987f01665d 100644 --- a/libstdc++-v3/bits/locale_facets.h +++ b/libstdc++-v3/bits/locale_facets.h @@ -390,15 +390,7 @@ namespace std // Types: typedef wchar_t char_type; typedef ctype::mask mask; - typedef size_t __table_type; - - private: - __to_type const& _M_toupper; - __to_type const& _M_tolower; - const mask* const& _M_ctable; - static const __table_type _S_table_size = ctype::table_size; - public: static locale::id id; explicit diff --git a/libstdc++-v3/config/aix/ctype.cc b/libstdc++-v3/config/aix/ctype.cc index 2c600f0e0db..67972999ee1 100644 --- a/libstdc++-v3/config/aix/ctype.cc +++ b/libstdc++-v3/config/aix/ctype.cc @@ -69,42 +69,3 @@ } return __high; } - -#ifdef _GLIBCPP_USE_WCHAR_T - ctype::ctype(size_t /*__refs*/) throw() - : _M_toupper(NULL), _M_tolower(NULL), - _M_ctable(NULL) - { } - - wchar_t - ctype::do_toupper(wchar_t __c) const - { return towupper(__c); } - - const wchar_t* - ctype::do_toupper(wchar_t* low, const wchar_t* high) const - { - for (;low < high; ++low) - if (*low < _S_table_size) - *low = this->do_toupper(*low); - return high; - } - - wchar_t - ctype::do_tolower(wchar_t __c) const - { return towlower(__c); } - - const wchar_t* - ctype::do_tolower(wchar_t* __low, const wchar_t* __high) const - { - for (; __low < __high; ++__low) - if (*__low < _S_table_size) - *__low = this->do_tolower(*__low); - return __high; - } -#endif - - - - - - diff --git a/libstdc++-v3/config/bsd/ctype.cc b/libstdc++-v3/config/bsd/ctype.cc index 01a73157d26..f4198657635 100644 --- a/libstdc++-v3/config/bsd/ctype.cc +++ b/libstdc++-v3/config/bsd/ctype.cc @@ -69,38 +69,3 @@ } return __high; } - -#ifdef _GLIBCPP_USE_WCHAR_T - ctype::ctype(size_t /*__refs*/) throw() - : _M_toupper(NULL), _M_tolower(NULL), - _M_ctable(NULL) - { } - - wchar_t - ctype::do_toupper(char_type __c) const - { return (__c < _S_table_size) ? _S_toupper[__c] : __c; } - - const wchar_t* - ctype::do_toupper(char_type* low, const char_type* high) const - { - for (;low < high; ++low) - if (*low < _S_table_size) - *low = _S_toupper[*low]; - return high; - } - - wchar_t - ctype::do_tolower(char_type __c) const - { return (__c < _S_table_size) ? _S_tolower[__c] : __c; } - - const wchar_t* - ctype::do_tolower(char_type* __low, const char_type* __high) const - { - for (; __low < __high; ++__low) - if (*__low < _S_table_size) - *__low = _S_toupper[*__low]; - return __high; - } -#endif - - diff --git a/libstdc++-v3/config/generic/ctype.cc b/libstdc++-v3/config/generic/ctype.cc index 0bf6b6be040..e4de5c2eae9 100644 --- a/libstdc++-v3/config/generic/ctype.cc +++ b/libstdc++-v3/config/generic/ctype.cc @@ -69,38 +69,3 @@ } return __high; } - -#ifdef _GLIBCPP_USE_WCHAR_T - ctype::ctype(size_t /*__refs*/) throw() - : _M_toupper(NULL), _M_tolower(NULL), - _M_ctable(NULL) - { } - - wchar_t - ctype::do_toupper(char_type __c) const - { return (__c < _S_table_size) ? _S_toupper[__c] : __c; } - - const wchar_t* - ctype::do_toupper(char_type* low, const char_type* high) const - { - for (;low < high; ++low) - if (*low < _S_table_size) - *low = _S_toupper[*low]; - return high; - } - - wchar_t - ctype::do_tolower(char_type __c) const - { return (__c < _S_table_size) ? _S_tolower[__c] : __c; } - - const wchar_t* - ctype::do_tolower(char_type* __low, const char_type* __high) const - { - for (; __low < __high; ++__low) - if (*__low < _S_table_size) - *__low = _S_toupper[*__low]; - return __high; - } -#endif - - diff --git a/libstdc++-v3/config/gnu-linux/ctype.cc b/libstdc++-v3/config/gnu-linux/ctype.cc index f6abe08cc10..dc10a63a684 100644 --- a/libstdc++-v3/config/gnu-linux/ctype.cc +++ b/libstdc++-v3/config/gnu-linux/ctype.cc @@ -70,43 +70,3 @@ return __high; } -#ifdef _GLIBCPP_USE_WCHAR_T - ctype::ctype(size_t /*__refs*/) throw() - : _M_toupper(__ctype_toupper), _M_tolower(__ctype_tolower), - _M_ctable(__ctype_b) - { } - - wchar_t - ctype::do_toupper(wchar_t __c) const - { - return ((static_cast<__table_type>(__c) < _S_table_size) - ? _M_toupper[__c] : __c); - } - - const wchar_t* - ctype::do_toupper(wchar_t* low, const wchar_t* high) const - { - for (;low < high; ++low) - if (static_cast<__table_type>(*low) < _S_table_size) - *low = _M_toupper[*low]; - return high; - } - - wchar_t - ctype::do_tolower(wchar_t __c) const - { - return ((static_cast<__table_type>(__c) < _S_table_size) - ? _M_tolower[__c] : __c); - } - - const wchar_t* - ctype::do_tolower(wchar_t* __low, const wchar_t* __high) const - { - for (; __low < __high; ++__low) - if (static_cast<__table_type>(*__low) < _S_table_size) - *__low = _M_toupper[*__low]; - return __high; - } -#endif - - diff --git a/libstdc++-v3/config/newlib/ctype.cc b/libstdc++-v3/config/newlib/ctype.cc index db401bdc5c2..1984d654393 100644 --- a/libstdc++-v3/config/newlib/ctype.cc +++ b/libstdc++-v3/config/newlib/ctype.cc @@ -76,45 +76,3 @@ return __high; } -#ifdef _GLIBCPP_USE_WCHAR_T - ctype::ctype(size_t /*__refs*/) throw() - : _M_toupper(NULL), _M_tolower(NULL), - _M_ctable(_ctype_) - { } - - wchar_t - ctype::do_toupper(wchar_t __c) const - { - int __x = __c; - bool __testok = __c < _S_table_size && this->is(ctype_base::upper, __c); - return (__testok ? (__x - 'A' + 'a') : __x); - } - - const wchar_t* - ctype::do_toupper(wchar_t* low, const wchar_t* high) const - { - for (;low < high; ++low) - if (*low < _S_table_size) - *low = this->do_toupper(*low); - return high; - } - - wchar_t - ctype::do_tolower(wchar_t __c) const - { - int __x = __c; - bool __testok = __c < _S_table_size && this->is(ctype_base::lower, __c); - return (__testok ? (__x - 'A' + 'a') : __x); - } - - const wchar_t* - ctype::do_tolower(wchar_t* __low, const wchar_t* __high) const - { - for (; __low < __high; ++__low) - if (*__low < _S_table_size) - *__low = this->do_tolower(*__low); - return __high; - } -#endif - - diff --git a/libstdc++-v3/config/solaris/solaris2.5/ctype.cc b/libstdc++-v3/config/solaris/solaris2.5/ctype.cc index 7e01ad6ecf7..c02a31ead51 100644 --- a/libstdc++-v3/config/solaris/solaris2.5/ctype.cc +++ b/libstdc++-v3/config/solaris/solaris2.5/ctype.cc @@ -70,49 +70,3 @@ return __high; } -#ifdef _GLIBCPP_USE_WCHAR_T - ctype::ctype(size_t /*__refs*/) throw() - : _M_toupper(NULL), _M_tolower(NULL), - _M_ctable(__ctype) - { } - - wchar_t - ctype::do_toupper(wchar_t __c) const - { - int __x = __c; - bool __testok = __c < _S_table_size && this->is(ctype_base::upper, __c); - return (__testok ? __x : (__x - 'a' + 'A')); - } - - const wchar_t* - ctype::do_toupper(wchar_t* low, const wchar_t* high) const - { - for (;low < high; ++low) - if (*low < _S_table_size) - *low = this->do_toupper(*low); - return high; - } - - wchar_t - ctype::do_tolower(wchar_t __c) const - { - int __x = __c; - bool __testok = __c < _S_table_size && this->is(ctype_base::lower, __c); - return (__testok ? __x: (__x - 'A' + 'a')); - } - - const wchar_t* - ctype::do_tolower(wchar_t* __low, const wchar_t* __high) const - { - for (; __low < __high; ++__low) - if (*__low < _S_table_size) - *__low = this->do_tolower(*__low); - return __high; - } -#endif - - - - - - diff --git a/libstdc++-v3/config/solaris/solaris2.6/ctype.cc b/libstdc++-v3/config/solaris/solaris2.6/ctype.cc index 97a9a561f21..f760ac934ae 100644 --- a/libstdc++-v3/config/solaris/solaris2.6/ctype.cc +++ b/libstdc++-v3/config/solaris/solaris2.6/ctype.cc @@ -69,39 +69,3 @@ } return __high; } - -#ifdef _GLIBCPP_USE_WCHAR_T - ctype::ctype(size_t /*__refs*/) throw() - : _M_toupper(__trans_upper), _M_tolower(__trans_lower), - _M_ctable(__ctype_mask) - { } - - wchar_t - ctype::do_toupper(wchar_t __c) const - { return (__c < _S_table_size) ? _M_toupper[__c] : __c; } - - const wchar_t* - ctype::do_toupper(wchar_t* low, const wchar_t* high) const - { - for (;low < high; ++low) - if (*low < _S_table_size) - *low = _M_toupper[*low]; - return high; - } - - wchar_t - ctype::do_tolower(wchar_t __c) const - { return (__c < _S_table_size) ? _M_tolower[__c] : __c; } - - const wchar_t* - ctype::do_tolower(wchar_t* __low, const wchar_t* __high) const - { - for (; __low < __high; ++__low) - if (*__low < _S_table_size) - *__low = _M_toupper[*__low]; - return __high; - } -#endif - - - diff --git a/libstdc++-v3/config/solaris/solaris2.7/ctype.cc b/libstdc++-v3/config/solaris/solaris2.7/ctype.cc index d8f83709885..348495ecefb 100644 --- a/libstdc++-v3/config/solaris/solaris2.7/ctype.cc +++ b/libstdc++-v3/config/solaris/solaris2.7/ctype.cc @@ -70,41 +70,4 @@ return __high; } -#ifdef _GLIBCPP_USE_WCHAR_T - ctype::ctype(size_t /*__refs*/) throw() - : _M_toupper(__trans_upper), _M_tolower(__trans_lower), - _M_ctable(__ctype_mask) - { } - - wchar_t - ctype::do_toupper(wchar_t __c) const - { return (static_cast<__table_type>(__c) < _S_table_size) ? _M_toupper[__c] : __c; } - - const wchar_t* - ctype::do_toupper(wchar_t* low, const wchar_t* high) const - { - for (;low < high; ++low) - if (static_cast<__table_type>(*low) < _S_table_size) - *low = _M_toupper[*low]; - return high; - } - - wchar_t - ctype::do_tolower(wchar_t __c) const - { return (static_cast<__table_type>(__c) < _S_table_size) ? _M_tolower[__c] : __c; } - - const wchar_t* - ctype::do_tolower(wchar_t* __low, const wchar_t* __high) const - { - for (; __low < __high; ++__low) - if (static_cast<__table_type>(*__low) < _S_table_size) - *__low = _M_toupper[*__low]; - return __high; - } -#endif - - - - - diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc index 3327ea2d6ec..4faa2a40494 100644 --- a/libstdc++-v3/src/locale.cc +++ b/libstdc++-v3/src/locale.cc @@ -37,7 +37,9 @@ #include #include #include // for auto_ptr - +#ifdef _GLIBCPP_USE_WCHAR_T + #include // for towupper, etc. +#endif namespace std { // locale::_Impl @@ -641,76 +643,104 @@ namespace std { ctype:: ~ctype() { } - bool - ctype:: - do_is(mask __m, char_type __c) const - { - return ((static_cast<__table_type>(__c) < _S_table_size) - && (_M_ctable[__c] & __m)); - } - - const wchar_t* - ctype:: - do_is(const wchar_t* __low, const wchar_t* __high, mask* __vec) const + // NB: These ctype methods are not configuration-specific, + // unlike the ctype bits. + ctype::ctype(size_t /*__refs*/) throw() { } + + wchar_t + ctype::do_toupper(wchar_t __c) const + { return ::towupper(__c); } + + const wchar_t* + ctype::do_toupper(wchar_t* __low, const wchar_t* __high) const { - for (; __low < __high; ++__low, ++__vec) - *__vec = ((static_cast<__table_type>(*__low) < _S_table_size) - ? _M_ctable[*__low] : mask(0)); + while (__low < __high) + { + *__low = ::towupper(*__low); + ++__low; + } return __high; } + wchar_t + ctype::do_tolower(wchar_t __c) const + { return ::towlower(__c); } + + const wchar_t* + ctype::do_tolower(wchar_t* __low, const wchar_t* __high) const + { + while (__low < __high) + { + *__low = ::towlower(*__low); + ++__low; + } + return __high; + } + + bool + ctype:: + do_is(mask /*__m*/, char_type /*__c*/) const + { + // XXX + return false; + } + const wchar_t* ctype:: - do_scan_is(mask __m, const wchar_t* __low, const wchar_t* __high) const + do_is(const wchar_t* __low, const wchar_t* /*__high*/, mask* /*__vec*/) const { - while (__low < __high - && (_S_table_size < static_cast<__table_type>(*__low) - || !(_M_ctable[*__low] & __m))) - ++__low; + // XXX + return __low; + } + + const wchar_t* + ctype:: + do_scan_is(mask /*__m*/, const wchar_t* __low, const wchar_t* /*__high*/) const + { + // XXX return __low; } const wchar_t* ctype:: - do_scan_not(mask __m, const char_type* __low, const char_type* __high) const + do_scan_not(mask /*__m*/, const char_type* __low, + const char_type* /*__high*/) const { - while (__low < __high - && static_cast<__table_type>(*__low) < _S_table_size - && (_M_ctable[*__low] & __m)) - ++__low; + // XXX return __low; } wchar_t ctype:: do_widen(char __c) const - { return static_cast((unsigned char)__c); } + { + // XXX + return static_cast((unsigned char)__c); + } const char* ctype:: - do_widen(const char* __low, const char* __high, wchar_t* __dest) const + do_widen(const char* /*__low*/, const char* __high, + wchar_t* /*__dest*/) const { - while (__low < __high) - *__dest++ = static_cast((unsigned char)*__low++); + // XXX return __high; } char ctype:: - do_narrow(wchar_t __c, char __dfault) const + do_narrow(wchar_t /*__c*/, char __dfault) const { - return ((static_cast<__table_type>(__c) < _S_table_size) - ? static_cast(__c) : __dfault); + // XXX + return __dfault; } const wchar_t* ctype:: - do_narrow(const wchar_t* __low, const wchar_t* __high, - char __dfault, char* __dest) const + do_narrow(const wchar_t* /*__low*/, const wchar_t* __high, + char /*__dfault*/, char* /*__dest*/) const { - for (; __low < __high; ++__dest, ++__low) - *__dest = (static_cast<__table_type>(*__low) < _S_table_size) - ? static_cast(*__low) : __dfault; + // XXX return __high; }