diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d6872895737fb187d236f0093ea27eb330f13855..686a3501140e03d555d4bd2cd4a63f40ef23b265 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,37 @@ +2000-12-06 Benjamin Kosnik <bkoz@kredhat.com> + + * include/bits/locale_facets.h (ctype): Remove _Ctype_nois and + _Ctype and replace with common __ctype_abstract_base. + (ctype<wchar_t>::_M_convert_to_wmask): Move to locale.cc. + * config/os/gnu-linux/bits/ctype_noninline.h (ctype<char>::ctype): + And here. + * config/os/solaris/solaris2.7/bits/ctype_noninline.h (ctype): Same. + * config/os/solaris/solaris2.6/bits/ctype_noninline.h (ctype): Same. + * config/os/solaris/solaris2.5/bits/ctype_noninline.h (ctype): Same. + * config/os/newlib/bits/ctype_noninline.h (ctype): Same. + * config/os/irix/bits/ctype_noninline.h (ctype): Same. + * config/os/hpux/bits/ctype_noninline.h (ctype): Same. + * config/os/generic/bits/ctype_noninline.h (ctype): Same. + * config/os/aix/bits/ctype_noninline.h (ctype): Same. + * config/os/bsd/netbsd/bits/ctype_noninline.h (ctype): Same. + * config/os/bsd/freebsd/bits/ctype_noninline.h (ctype): Same. + * src/locale-inst.cc: Clean instantiations. + * src/locale.cc (ctype<char>): Add definitions here. + (ctype<wchar_t>::_M_wmask): Move definitions here. + + * config/os/generic/bits/ctype_inline.h (ctype<char>::is): + Implement in a generic way, with only "C" functionality and no + knowlege of the target os. + * config/os/generic/bits/os_defines.h: Change comments to C++ style. + * testsuite/22_locale/ctype_char_members.cc (test01): Add tests. + + * include/bits/codecvt.h (ctype_byname): Remove specializations, + as not required. + * include/bits/localefwd.h (codecvt_byname): And here. + * src/codecvt.cc: Remove codecvt_byname specializations. + + * include/c/bits/std_cstdio.h: Include c++config.h. + 2000-12-06 Phil Edwards <pme@sources.redhat.com> * acinclude.m4 (GLIBCPP_CHECK_*_DECL_AND_LINKAGE_*): Pre-test @@ -15,7 +49,7 @@ * configure.target (*-*-freebsd, *-*-netbsd): Correct paths to os_include_dir. -Tue Dec 5 20:24:15 2000 Jeffrey A Law (law@cygnus.com) +2000-12-05 Jeffrey A Law <law@cygnus.com> * configure.target (hpux): Set os_include_dir. * config/os/hpux/bits/ctype_base.h: New file diff --git a/libstdc++-v3/config/os/aix/bits/ctype_noninline.h b/libstdc++-v3/config/os/aix/bits/ctype_noninline.h index c58fbaa7f7cc205aa68b7e7adef4c1aab72b6ae1..54f546c75cb29b63cc863e4bbd6ee651f5224d31 100644 --- a/libstdc++-v3/config/os/aix/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/aix/bits/ctype_noninline.h @@ -35,7 +35,7 @@ ctype<char>::ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0) - : _Ctype_nois<char>(__refs), _M_del(__table != 0 && __del), + : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), _M_table(__table == 0 ? _M_ctable: __table) { } diff --git a/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_noninline.h b/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_noninline.h index 24fdcdb23eac1056e9d6f9d6c8ceba65cfa2d311..5de223ba8529c08e52329c6ecf8cbac204382253 100644 --- a/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_noninline.h @@ -35,7 +35,7 @@ ctype<char>::ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0) - : _Ctype_nois<char>(__refs), _M_del(__table != 0 && __del), + : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), _M_table(__table == 0 ? _M_ctable: __table) { } diff --git a/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_noninline.h b/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_noninline.h index c5b3370cda79ae714c9fcb55eef471a1e403f48e..395c066da53f6e10a0719a3043135416380dfa87 100644 --- a/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_noninline.h @@ -35,7 +35,7 @@ ctype<char>::ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0) - : _Ctype_nois<char>(__refs), _M_del(__table != 0 && __del), + : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), _M_table(__table == 0 ? (_ctype_ + 1) : __table) { } diff --git a/libstdc++-v3/config/os/generic/bits/ctype_inline.h b/libstdc++-v3/config/os/generic/bits/ctype_inline.h index 952b0da8c9808c7fb5e2297070ee5be2744ed436..20648a1dcbf24ddd75159f0949fa17aaf91e2514 100644 --- a/libstdc++-v3/config/os/generic/bits/ctype_inline.h +++ b/libstdc++-v3/config/os/generic/bits/ctype_inline.h @@ -34,11 +34,57 @@ // ctype bits to be inlined go here. Non-inlinable (ie virtual do_*) // functions go in ctype.cc +// The following definitions are portable, but insanely slow. If one +// cares at all about performance, then specialized ctype +// functionality should be added for the native os in question: see +// the config/os/bits/ctype_*.h files. + bool ctype<char>:: is(mask __m, char __c) const throw() - { return _M_table[(unsigned char)(__c)] & __m; } - + { + bool __ret = false; + switch (__m) + { + case space: + __ret = isspace(__c); + break; + case print: + __ret = isprint(__c); + break; + case cntrl: + __ret = iscntrl(__c); + break; + case upper: + __ret = isupper(__c); + break; + case lower: + __ret = islower(__c); + break; + case alpha: + __ret = isalpha(__c); + break; + case digit: + __ret = isdigit(__c); + break; + case punct: + __ret = ispunct(__c); + break; + case xdigit: + __ret = isxdigit(__c); + break; + case alnum: + __ret = isalnum(__c); + break; + case graph: + __ret = isgraph(__c); + break; + default: + break; + } + return __ret; + } + const char* ctype<char>:: is(const char* __low, const char* __high, mask* __vec) const throw() diff --git a/libstdc++-v3/config/os/generic/bits/ctype_noninline.h b/libstdc++-v3/config/os/generic/bits/ctype_noninline.h index bc99064b0dc51e42d60b52ad1c264c8be8a7344c..38edd40c7a9122c18ea3bae78f8fa60366b8723f 100644 --- a/libstdc++-v3/config/os/generic/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/generic/bits/ctype_noninline.h @@ -35,7 +35,7 @@ ctype<char>::ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0) - : _Ctype_nois<char>(__refs), _M_del(__table != 0 && __del), + : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), _M_table(__table == 0 ? _M_ctable: __table) { } diff --git a/libstdc++-v3/config/os/generic/bits/os_defines.h b/libstdc++-v3/config/os/generic/bits/os_defines.h index c21e775be265f1ea11af6c8a14b8b169ddce3302..5c99e09428cb89e2389c55640d55d2e07d33657f 100644 --- a/libstdc++-v3/config/os/generic/bits/os_defines.h +++ b/libstdc++-v3/config/os/generic/bits/os_defines.h @@ -31,11 +31,7 @@ #ifndef _GLIBCPP_OS_DEFINES # define _GLIBCPP_OS_DEFINES - -/* System-specific #define, typedefs, corrections, etc, go here. This - file will come before all others. */ - +// System-specific #define, typedefs, corrections, etc, go here. This +// file will come before all others. #endif - - diff --git a/libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h b/libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h index 63032425c702f0dc18d3e5a0a9c95d4dcc908cd2..a03af5932223ceee70f866478758558900591144 100644 --- a/libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h @@ -40,7 +40,7 @@ #endif ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) - : _Ctype_nois<char>(__refs), _M_del(__table != 0 && __del), + : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), _M_toupper(__ctype_toupper), _M_tolower(__ctype_tolower), _M_ctable(__ctype_b), _M_table(__table == 0 ? _M_ctable: __table) { } diff --git a/libstdc++-v3/config/os/hpux/bits/ctype_noninline.h b/libstdc++-v3/config/os/hpux/bits/ctype_noninline.h index bc99064b0dc51e42d60b52ad1c264c8be8a7344c..38edd40c7a9122c18ea3bae78f8fa60366b8723f 100644 --- a/libstdc++-v3/config/os/hpux/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/hpux/bits/ctype_noninline.h @@ -35,7 +35,7 @@ ctype<char>::ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0) - : _Ctype_nois<char>(__refs), _M_del(__table != 0 && __del), + : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), _M_table(__table == 0 ? _M_ctable: __table) { } diff --git a/libstdc++-v3/config/os/irix/bits/ctype_noninline.h b/libstdc++-v3/config/os/irix/bits/ctype_noninline.h index 50f87a9c51d891984d9b721b1730c6194876cb80..0fb25d189c0c963db524426eec564673846c16e1 100644 --- a/libstdc++-v3/config/os/irix/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/irix/bits/ctype_noninline.h @@ -35,10 +35,8 @@ ctype<char>::ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0) - : _Ctype_nois<char>(__refs), _M_del(__table != 0 && __del), - _M_toupper(NULL), - _M_tolower(NULL), - _M_ctable(NULL), + : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), _M_table(!__table ? (const mask*) (__libc_attr._ctype_tbl->_class + 1) : __table) diff --git a/libstdc++-v3/config/os/newlib/bits/ctype_noninline.h b/libstdc++-v3/config/os/newlib/bits/ctype_noninline.h index 63c400f2493668b5e19d73ca5151893f3f1d62ff..30494d34b30738ddf0ebd311d2422c97341f2ba3 100644 --- a/libstdc++-v3/config/os/newlib/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/newlib/bits/ctype_noninline.h @@ -35,7 +35,7 @@ ctype<char>::ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0) - : _Ctype_nois<char>(__refs), _M_del(__table != 0 && __del), + : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_ctable(_ctype_), _M_table(__table == 0 ? _M_ctable: __table) { } diff --git a/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_noninline.h b/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_noninline.h index 7c518406b8e8669079368459a8259664b4784bbb..867607742b860f7c65281b9b14bd1202fda61869 100644 --- a/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_noninline.h @@ -35,7 +35,7 @@ ctype<char>::ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0) - : _Ctype_nois<char>(__refs), _M_del(__table != 0 && __del), + : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_ctable(__ctype), _M_table(__table == 0 ? _M_ctable: __table) { } diff --git a/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_noninline.h b/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_noninline.h index 32381112d6011cff48601e50db529bffc9e762a4..29ecc9eb7a1e55515414ce6342e2c3d9a6094b7a 100644 --- a/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_noninline.h @@ -35,7 +35,7 @@ ctype<char>::ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0) - : _Ctype_nois<char>(__refs), _M_del(__table != 0 && __del), + : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), _M_toupper(__trans_upper), _M_tolower(__trans_lower), _M_ctable(__ctype_mask), _M_table(__table == 0 ? _M_ctable: __table) { } diff --git a/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_noninline.h b/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_noninline.h index f5ec1717ce8b5c03b12f0c2d034d7fa5ed76279d..ae3d6fb07beaeabac7ff43194e7e6067bc418763 100644 --- a/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_noninline.h @@ -35,7 +35,7 @@ ctype<char>::ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0) - : _Ctype_nois<char>(__refs), _M_del(__table != 0 && __del), + : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), _M_toupper(__trans_upper), _M_tolower(__trans_lower), _M_ctable(__ctype_mask), _M_table(__table == 0 ? _M_ctable: __table) { } diff --git a/libstdc++-v3/include/bits/codecvt.h b/libstdc++-v3/include/bits/codecvt.h index c8ec65a28dd58c9a731b6373dd455130d84a3b92..8b90b94bfb3640f7c62cf907e6f8126f3f2239e9 100644 --- a/libstdc++-v3/include/bits/codecvt.h +++ b/libstdc++-v3/include/bits/codecvt.h @@ -385,11 +385,11 @@ namespace std // in the future. Using this adaptor, g++ will do the work for us. template<typename _T> inline size_t - __iconv_adaptor(size_t(*iconv_func)(iconv_t, _T, size_t *, char**, size_t*), - iconv_t cd, char **inbuf, size_t *inbytesleft, - char **outbuf, size_t *outbytesleft) + __iconv_adaptor(size_t(*iconv_func)(iconv_t, _T, size_t*, char**, size_t*), + iconv_t cd, char** inbuf, size_t* inbytesleft, + char** outbuf, size_t* outbytesleft) { - return iconv_func (cd, (_T)inbuf, inbytesleft, outbuf, outbytesleft); + return iconv_func(cd, (_T)inbuf, inbytesleft, outbuf, outbytesleft); } template<typename _InternT, typename _ExternT> @@ -709,40 +709,11 @@ namespace std public: explicit codecvt_byname(const char*, size_t __refs = 0) - : codecvt<_InternT,_ExternT,_StateT> (__refs) { } + : codecvt<_InternT, _ExternT, _StateT>(__refs) { } protected: virtual ~codecvt_byname() { } }; - - template<> - class codecvt_byname<char, char, mbstate_t> - : public codecvt<char, char, mbstate_t> - { - public: - explicit - codecvt_byname(const char*, size_t __refs = 0); - - protected: - virtual - ~codecvt_byname(); - }; - -#ifdef _GLIBCPP_USE_WCHAR_T - template<> - class codecvt_byname<wchar_t, char, mbstate_t> - : public codecvt<wchar_t, char, mbstate_t> - { - public: - explicit - codecvt_byname(const char*, size_t __refs = 0); - - protected: - virtual - ~codecvt_byname(); - }; -#endif - } // namespace std #endif // _CPP_BITS_CODECVT_H diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h index 6525bda6dc8162d097a7c7113c5b4ec9ca4949de..e7ba4941f56edac50fbb909c8a546905b95b0f14 100644 --- a/libstdc++-v3/include/bits/locale_facets.h +++ b/libstdc++-v3/include/bits/locale_facets.h @@ -40,8 +40,8 @@ #include <typeinfo> // For bad_cast, which shouldn't be here. #include <bits/std_ios.h> // For ios_base #ifdef _GLIBCPP_USE_WCHAR_T -#include <bits/std_cwctype.h> // For wctype_t -#endif /* _GLIBCPP_USE_WCHAR_T */ +# include <bits/std_cwctype.h> // For wctype_t +#endif namespace std { @@ -83,15 +83,30 @@ namespace std #include <bits/ctype_base.h> // 22.2.1.1 Template class ctype - // _Ctype_nois is the common base for ctype<char>. It lacks "do_is" - // and related virtuals. These are filled in by _Ctype, below. + // __ctype_abstract_base is the common base for ctype<_CharT>. template<typename _CharT> - class _Ctype_nois : public locale::facet, public ctype_base + class __ctype_abstract_base : public locale::facet, public ctype_base { public: // Types: typedef _CharT char_type; + bool + is(mask __m, char_type __c) const + { return this->do_is(__m, __c); } + + const char_type* + is(const char_type *__lo, const char_type *__hi, mask *__vec) const + { return this->do_is(__lo, __hi, __vec); } + + const char_type* + scan_is(mask __m, const char_type* __lo, const char_type* __hi) const + { return this->do_scan_is(__m, __lo, __hi); } + + const char_type* + scan_not(mask __m, const char_type* __lo, const char_type* __hi) const + { return this->do_scan_not(__m, __lo, __hi); } + char_type toupper(char_type __c) const { return this->do_toupper(__c); } @@ -127,11 +142,26 @@ namespace std protected: explicit - _Ctype_nois(size_t __refs = 0): locale::facet(__refs) { } + __ctype_abstract_base(size_t __refs = 0): locale::facet(__refs) { } virtual - ~_Ctype_nois() { } + ~__ctype_abstract_base() { } + virtual bool + do_is(mask __m, char_type __c) const = 0; + + virtual const char_type* + do_is(const char_type* __lo, const char_type* __hi, + mask* __vec) const = 0; + + virtual const char_type* + do_scan_is(mask __m, const char_type* __lo, + const char_type* __hi) const = 0; + + virtual const char_type* + do_scan_not(mask __m, const char_type* __lo, + const char_type* __hi) const = 0; + virtual char_type do_toupper(char_type) const = 0; @@ -159,163 +189,28 @@ namespace std char __dfault, char* __dest) const = 0; }; - + // NB: Generic, mostly useless implementation. template<typename _CharT> - class _Ctype : public _Ctype_nois<_CharT> + class ctype : public __ctype_abstract_base<_CharT> { public: // Types: - typedef _CharT char_type; - typedef typename _Ctype_nois<_CharT>::mask mask; - - bool - is(mask __m, char_type __c) const - { return this->do_is(__m, __c); } + typedef _CharT char_type; + typedef typename ctype::mask mask; - const char_type* - is(const char_type *__lo, const char_type *__hi, mask *__vec) const - { return this->do_is(__lo, __hi, __vec); } - - const char_type* - scan_is(mask __m, const char_type* __lo, const char_type* __hi) const - { return this->do_scan_is(__m, __lo, __hi); } - - const char_type* - scan_not(mask __m, const char_type* __lo, const char_type* __hi) const - { return this->do_scan_not(__m, __lo, __hi); } - - protected: explicit - _Ctype(size_t __refs = 0) : _Ctype_nois<_CharT>(__refs) { } - - virtual - ~_Ctype() { } - - virtual bool - do_is(mask __m, char_type __c) const = 0; - - virtual const char_type* - do_is(const char_type* __lo, const char_type* __hi, - mask* __vec) const = 0; - - virtual const char_type* - do_scan_is(mask __m, const char_type* __lo, - const char_type* __hi) const = 0; - - virtual const char_type* - do_scan_not(mask __m, const char_type* __lo, - const char_type* __hi) const = 0; - }; - - template<typename _CharT> - class ctype : public _Ctype<_CharT> - { - public: - // Types: - typedef _CharT char_type; - typedef typename ctype::mask mask; - - explicit - ctype(size_t __refs = 0) : _Ctype<_CharT>(__refs) { } + ctype(size_t __refs = 0) : __ctype_abstract_base<_CharT>(__refs) { } static locale::id id; protected: virtual ~ctype() { } - - virtual bool - do_is(mask, char_type) const - { - // XXX Need definitions for these abstract mf's. - return true; - } - - virtual const char_type* - do_is(const char_type* __lo, const char_type*, mask*) const - { - // XXX Need definitions for these abstract mf's. - return __lo; - } - - virtual const char_type* - do_scan_is(mask, const char_type* __lo, const char_type*) const - { - // XXX Need definitions for these abstract mf's. - return __lo; - } - - virtual const char_type* - do_scan_not(mask, const char_type* __lo, const char_type*) const - { - // XXX Need definitions for these abstract mf's. - return __lo; - } - - virtual char_type - do_toupper(char_type __c) const - { - // XXX Need definitions for these abstract mf's. - return __c; - } - - virtual const char_type* - do_toupper(char_type* __lo, const char_type*) const - { - // XXX Need definitions for these abstract mf's. - return __lo; - } - - virtual char_type - do_tolower(char_type __c) const - { - // XXX Need definitions for these abstract mf's. - return __c; - } - - virtual const char_type* - do_tolower(char_type* __lo, const char_type*) const - { - // XXX Need definitions for these abstract mf's. - return __lo; - } - - virtual char_type - do_widen(char __c) const - { - // XXX Need definitions for these abstract mf's. - return __c; - } - - virtual const char* - do_widen(const char* __lo, const char*, char_type*) const - { - // XXX Need definitions for these abstract mf's. - return __lo; - } - - virtual char - do_narrow(char_type, char __c) const - { - // XXX Need definitions for these abstract mf's. - return __c; - } - - virtual const char_type* - do_narrow(const char_type* __lo, const char_type*, char, char*) const - { - // XXX Need definitions for these abstract mf's. - return __lo; - } }; - // 22.2.1.3 ctype specializations - // NB: Can use _Ctype_nois to actually implement the "is" - // functionality in the non-virtual (thus inline-able) member - // fuctions. template<> - class ctype<char> : public _Ctype_nois<char> + class ctype<char> : public __ctype_abstract_base<char> { public: // Types: @@ -363,6 +258,21 @@ namespace std classic_table() throw() { return _M_ctable; } + virtual bool + do_is(mask __m, char_type __c) const; + + virtual const char_type* + do_is(const char_type* __lo, const char_type* __hi, + mask* __vec) const; + + virtual const char_type* + do_scan_is(mask __m, const char_type* __lo, + const char_type* __hi) const; + + virtual const char_type* + do_scan_not(mask __m, const char_type* __lo, + const char_type* __hi) const; + virtual char_type do_toupper(char_type) const; @@ -397,7 +307,7 @@ namespace std #ifdef _GLIBCPP_USE_WCHAR_T // ctype<wchar_t> specialization template<> - class ctype<wchar_t> : public _Ctype<wchar_t> + class ctype<wchar_t> : public __ctype_abstract_base<wchar_t> { public: // Types: @@ -413,49 +323,7 @@ namespace std protected: __wmask_type - _M_convert_to_wmask(const mask __m) const - { - __wmask_type __ret; - switch (__m) - { - case space: - __ret = wctype("space"); - break; - case print: - __ret = wctype("print"); - break; - case cntrl: - __ret = wctype("cntrl"); - break; - case upper: - __ret = wctype("upper"); - break; - case lower: - __ret = wctype("lower"); - break; - case alpha: - __ret = wctype("alpha"); - break; - case digit: - __ret = wctype("digit"); - break; - case punct: - __ret = wctype("punct"); - break; - case xdigit: - __ret = wctype("xdigit"); - break; - case alnum: - __ret = wctype("alnum"); - break; - case graph: - __ret = wctype("graph"); - break; - default: - __ret = 0; - } - return __ret; - }; + _M_convert_to_wmask(const mask __m) const; virtual ~ctype(); @@ -526,13 +394,9 @@ namespace std ~ctype_byname() { } }; - // 22.2.1.4 Class ctype_byname specializations + // 22.2.1.4 Class ctype_byname specialization template<> ctype_byname<char>::ctype_byname(const char*, size_t refs); -#ifdef _GLIBCPP_USE_WCHAR_T - template<> - ctype_byname<wchar_t>::ctype_byname(const char*, size_t refs); -#endif template<typename _CharT, typename _InIter> diff --git a/libstdc++-v3/include/bits/localefwd.h b/libstdc++-v3/include/bits/localefwd.h index 73dba99788dbdf49b8598c60436b63e97a32266b..be2908c80428bb262acdb0b8c9603a17688eb45e 100644 --- a/libstdc++-v3/include/bits/localefwd.h +++ b/libstdc++-v3/include/bits/localefwd.h @@ -153,10 +153,6 @@ namespace std template<typename _InternT, typename _ExternT, typename _StateT> class codecvt_byname; - template<> class codecvt_byname<char, char, mbstate_t>; -#ifdef _GLIBCPP_USE_WCHAR_T - template<> class codecvt_byname<wchar_t, char, mbstate_t>; -#endif // 22.2.2 and 22.2.3 numeric template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> > diff --git a/libstdc++-v3/include/c/bits/std_cstdio.h b/libstdc++-v3/include/c/bits/std_cstdio.h index dc590319984f83655f74476936a2c387410e0dca..60ed76d24f9d0c0a7ba8ffa1b237b99ba7500c56 100644 --- a/libstdc++-v3/include/c/bits/std_cstdio.h +++ b/libstdc++-v3/include/c/bits/std_cstdio.h @@ -36,6 +36,7 @@ #ifndef _CPP_CSTDIO #define _CPP_CSTDIO 1 +#include <bits/c++config.h> #include <bits/std_cstdarg.h> #pragma GCC system_header diff --git a/libstdc++-v3/src/codecvt.cc b/libstdc++-v3/src/codecvt.cc index 688381f07c63dd35b61c33fab29f5b4a50f75ca4..cfc76821ac2b9bf7a41d74b137319730ff9ed26e 100644 --- a/libstdc++-v3/src/codecvt.cc +++ b/libstdc++-v3/src/codecvt.cc @@ -105,13 +105,6 @@ namespace std { do_max_length() const throw() { return 1; } - codecvt_byname<char, char, mbstate_t>:: - codecvt_byname(const char* /*__s*/, size_t __refs) - : codecvt<char, char, mbstate_t>(__refs) { } - - codecvt_byname<char, char, mbstate_t>:: - ~codecvt_byname() { } - #ifdef _GLIBCPP_USE_WCHAR_T // codecvt<wchar_t, char, mbstate_t> required specialization locale::id codecvt<wchar_t, char, mbstate_t>::id; @@ -210,13 +203,6 @@ namespace std { codecvt<wchar_t, char, mbstate_t>:: do_max_length() const throw() { return 1; } - - codecvt_byname<wchar_t, char, mbstate_t>:: - codecvt_byname(const char* /*__s*/, size_t __refs) - : codecvt<wchar_t, char, mbstate_t> (__refs) { } - - codecvt_byname<wchar_t, char, mbstate_t>:: - ~codecvt_byname() { } #endif // _GLIBCPP_USE_WCHAR_T } // namespace std diff --git a/libstdc++-v3/src/locale-inst.cc b/libstdc++-v3/src/locale-inst.cc index c762bd9e762fa27f7957ce9b41eb57ee7b6fd5f1..5531bc8e907701e698281eeddd030e3969880493 100644 --- a/libstdc++-v3/src/locale-inst.cc +++ b/libstdc++-v3/src/locale-inst.cc @@ -118,20 +118,20 @@ namespace std { #endif // ctype - // template class ctype<unsigned char>; // No definitions avail. - // template class ctype<signed char>; // No definitions avail. - template class _Ctype<char>; - template class _Ctype_nois<char>; + template class __ctype_abstract_base<char>; template class ctype_byname<char>; #ifdef _GLIBCPP_USE_WCHAR_T - template class _Ctype<wchar_t>; - template class _Ctype_nois<wchar_t>; + template class __ctype_abstract_base<wchar_t>; template class ctype_byname<wchar_t>; #endif // codecvt template class __codecvt_abstract_base<char, char, mbstate_t>; template class __codecvt_abstract_base<wchar_t, char, mbstate_t>; + template class codecvt_byname<char, char, mbstate_t>; +#ifdef _GLIBCPP_USE_WCHAR_T + template class codecvt_byname<wchar_t, char, mbstate_t>; +#endif // collate template class _Collate<char>; diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc index 782cec0a234b7dcf7bb32cf07715f427218d9fb8..7cdbd540c7a52b618179edfa283ba9d56f84ad61 100644 --- a/libstdc++-v3/src/locale.cc +++ b/libstdc++-v3/src/locale.cc @@ -788,6 +788,23 @@ namespace std { ctype<char>::~ctype() { if (_M_del) delete[] this->table(); } + // These are dummy placeholders as these virtual functions are never called. + bool + ctype<char>::do_is(mask, char_type) const + { return false; } + + const char* + ctype<char>::do_is(const char_type* __c, const char_type*, mask*) const + { return __c; } + + const char* + ctype<char>::do_scan_is(mask, const char_type* __c, const char_type*) const + { return __c; } + + const char* + ctype<char>::do_scan_not(mask, const char_type* __c, const char_type*) const + { return __c; } + char ctype<char>::do_widen(char __c) const { return __c; } @@ -875,12 +892,58 @@ namespace std { #ifdef _GLIBCPP_USE_WCHAR_T locale::id ctype<wchar_t>::id; + ctype<wchar_t>::__wmask_type + ctype<wchar_t>::_M_convert_to_wmask(const mask __m) const + { + __wmask_type __ret; + switch (__m) + { + case space: + __ret = wctype("space"); + break; + case print: + __ret = wctype("print"); + break; + case cntrl: + __ret = wctype("cntrl"); + break; + case upper: + __ret = wctype("upper"); + break; + case lower: + __ret = wctype("lower"); + break; + case alpha: + __ret = wctype("alpha"); + break; + case digit: + __ret = wctype("digit"); + break; + case punct: + __ret = wctype("punct"); + break; + case xdigit: + __ret = wctype("xdigit"); + break; + case alnum: + __ret = wctype("alnum"); + break; + case graph: + __ret = wctype("graph"); + break; + default: + __ret = 0; + } + return __ret; + }; + ctype<wchar_t>:: ~ctype() { } // NB: These ctype<wchar_t> methods are not configuration-specific, // unlike the ctype<char> bits. - ctype<wchar_t>::ctype(size_t __refs) : _Ctype<wchar_t>(__refs) { } + ctype<wchar_t>::ctype(size_t __refs) : __ctype_abstract_base<wchar_t>(__refs) + { } wchar_t ctype<wchar_t>::do_toupper(wchar_t __c) const diff --git a/libstdc++-v3/testsuite/22_locale/ctype_char_members.cc b/libstdc++-v3/testsuite/22_locale/ctype_char_members.cc index 2e91710c795075db4c53336129ae3f873e56538d..a12b2f72dacf0dd9ad5578115fb159cc887c490e 100644 --- a/libstdc++-v3/testsuite/22_locale/ctype_char_members.cc +++ b/libstdc++-v3/testsuite/22_locale/ctype_char_members.cc @@ -33,7 +33,7 @@ // NB: Don't include any other headers in this file. #include <debug_assert.h> -class gnu_ctype: public std::ctype<char> {}; +class gnu_ctype: public std::ctype<char> { }; void test01() { @@ -71,6 +71,22 @@ void test01() VERIFY( gctype.is(std::ctype_base::graph, c40) ); VERIFY( gctype.is(std::ctype_base::graph, c20) ); + // const char* is(const char* low, const char* high, mask* vec) const + std::ctype_base::mask m01 = static_cast<std::ctype_base::mask>(0); + std::ctype_base::mask m02 = std::ctype_base::digit; + const char* cc0 = strlit00; + const char* cc1 = NULL; + const char* cc2 = NULL; +#if 1 + cc1 = gctype.is(cc0, cc0, &m01); + VERIFY( cc1 == strlit00 ); + cc2 = gctype.is(cc0, cc0 + 3, &m01); + VERIFY( cc2 == strlit00 + 3); + + cc1 = gctype.is(cc0, cc0 + 13, &m02); + VERIFY( cc1 == strlit00 + 13); +#endif + // char toupper(char c) const c100 = gctype.toupper(c10); VERIFY( c100 == c00 );