diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 286ff68cdd2..14522c8149c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,29 @@ +2003-10-21 Benjamin Kosnik + + PR libstdc++/9858 + * include/bits/locale_facets.h (ctype): Remove + __ctype_abstract_base. + (ctype::do_is): Remove. + (ctype::do_scan_is): Remove. + * src/ctype.cc: Same. Inline the rest. + * testsuite/22_locale/ctype/is/char/9858.cc: New. + * config/os/aix/ctype_noninline.h: Adjust ctor. + * config/os/bsd/freebsd/ctype_noninline.h: Same. + * config/os/bsd/netbsd/ctype_noninline.h: Same. + * config/os/djgpp/ctype_noninline.h: Same. + * config/os/generic/ctype_noninline.h: Same. + * config/os/gnu-linux/ctype_noninline.h: Same. + * config/os/hpux/ctype_noninline.h: Same. + * config/os/irix/irix5.2/ctype_noninline.h: Same. + * config/os/irix/irix6.5/ctype_noninline.h: Same. + * config/os/mingw32/ctype_noninline.h: Same. + * config/os/newlib/ctype_noninline.h: Same. + * config/os/qnx/qnx6.1/ctype_noninline.h: Same. + * config/os/solaris/solaris2.5/ctype_noninline.h: Same. + * config/os/solaris/solaris2.6/ctype_noninline.h: Same. + * config/os/solaris/solaris2.7/ctype_noninline.h: Same. + * config/os/windiss/ctype_noninline.h: Same. + 2003-10-21 Paolo Carlini * src/locale.cc: Tweak a comment. diff --git a/libstdc++-v3/config/os/aix/ctype_noninline.h b/libstdc++-v3/config/os/aix/ctype_noninline.h index 7cf919afca9..78fce2ef176 100644 --- a/libstdc++-v3/config/os/aix/ctype_noninline.h +++ b/libstdc++-v3/config/os/aix/ctype_noninline.h @@ -39,13 +39,13 @@ ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) { } ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) { } diff --git a/libstdc++-v3/config/os/bsd/freebsd/ctype_noninline.h b/libstdc++-v3/config/os/bsd/freebsd/ctype_noninline.h index 0e108fdcf45..27cd28c082e 100644 --- a/libstdc++-v3/config/os/bsd/freebsd/ctype_noninline.h +++ b/libstdc++-v3/config/os/bsd/freebsd/ctype_noninline.h @@ -39,13 +39,13 @@ ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) { } ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) { } diff --git a/libstdc++-v3/config/os/bsd/netbsd/ctype_noninline.h b/libstdc++-v3/config/os/bsd/netbsd/ctype_noninline.h index 578e0a42e31..0cc08aef248 100644 --- a/libstdc++-v3/config/os/bsd/netbsd/ctype_noninline.h +++ b/libstdc++-v3/config/os/bsd/netbsd/ctype_noninline.h @@ -41,13 +41,13 @@ ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) { } ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) { } diff --git a/libstdc++-v3/config/os/djgpp/ctype_noninline.h b/libstdc++-v3/config/os/djgpp/ctype_noninline.h index 0ec0f84aafa..848f5e2bde7 100644 --- a/libstdc++-v3/config/os/djgpp/ctype_noninline.h +++ b/libstdc++-v3/config/os/djgpp/ctype_noninline.h @@ -39,13 +39,13 @@ ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(__dj_ctype_toupper), _M_tolower(__dj_ctype_tolower), _M_table(__table ? __table : __dj_ctype_flags) { } ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(__dj_ctype_toupper), _M_tolower(__dj_ctype_tolower), _M_table(__table ? __table : __dj_ctype_flags) { } diff --git a/libstdc++-v3/config/os/generic/ctype_noninline.h b/libstdc++-v3/config/os/generic/ctype_noninline.h index d07dc8b9d7c..92e1173ed67 100644 --- a/libstdc++-v3/config/os/generic/ctype_noninline.h +++ b/libstdc++-v3/config/os/generic/ctype_noninline.h @@ -40,13 +40,13 @@ ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) { } ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) { } diff --git a/libstdc++-v3/config/os/gnu-linux/ctype_noninline.h b/libstdc++-v3/config/os/gnu-linux/ctype_noninline.h index 83a93cb9dfe..8d38627f7bd 100644 --- a/libstdc++-v3/config/os/gnu-linux/ctype_noninline.h +++ b/libstdc++-v3/config/os/gnu-linux/ctype_noninline.h @@ -59,7 +59,7 @@ #if _GLIBCXX_C_LOCALE_GNU ctype::ctype(__c_locale __cloc, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del) + : facet(__refs), _M_del(__table != 0 && __del) { _M_c_locale_ctype = _S_clone_c_locale(__cloc); _M_toupper = _M_c_locale_ctype->__ctype_toupper; @@ -69,7 +69,7 @@ #else ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del) + : facet(__refs), _M_del(__table != 0 && __del) { char* __old=strdup(setlocale(LC_CTYPE, NULL)); setlocale(LC_CTYPE, "C"); @@ -89,8 +89,8 @@ #endif #if _GLIBCXX_C_LOCALE_GNU - ctype::ctype(const mask* __table, bool __del, size_t __refs) : - __ctype_abstract_base(__refs), _M_del(__table != 0 && __del) + ctype::ctype(const mask* __table, bool __del, size_t __refs) + : facet(__refs), _M_del(__table != 0 && __del) { _M_c_locale_ctype = _S_get_c_locale(); _M_toupper = _M_c_locale_ctype->__ctype_toupper; @@ -98,8 +98,8 @@ _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) + ctype::ctype(const mask* __table, bool __del, size_t __refs) + : facet(__refs), _M_del(__table != 0 && __del) { char* __old=strdup(setlocale(LC_CTYPE, NULL)); setlocale(LC_CTYPE, "C"); diff --git a/libstdc++-v3/config/os/hpux/ctype_noninline.h b/libstdc++-v3/config/os/hpux/ctype_noninline.h index a85bc9cff82..c42fd8a49ee 100644 --- a/libstdc++-v3/config/os/hpux/ctype_noninline.h +++ b/libstdc++-v3/config/os/hpux/ctype_noninline.h @@ -40,13 +40,13 @@ ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : (const mask *) __SB_masks) { } ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : (const mask *) __SB_masks) { } diff --git a/libstdc++-v3/config/os/irix/irix5.2/ctype_noninline.h b/libstdc++-v3/config/os/irix/irix5.2/ctype_noninline.h index 3cb29b601ae..2268a9b9e2c 100644 --- a/libstdc++-v3/config/os/irix/irix5.2/ctype_noninline.h +++ b/libstdc++-v3/config/os/irix/irix5.2/ctype_noninline.h @@ -40,13 +40,13 @@ ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(!__table ? classic_table() : __table) { } ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(!__table ? classic_table() : __table) { } diff --git a/libstdc++-v3/config/os/irix/irix6.5/ctype_noninline.h b/libstdc++-v3/config/os/irix/irix6.5/ctype_noninline.h index 009e6110b73..c0e6e56d515 100644 --- a/libstdc++-v3/config/os/irix/irix6.5/ctype_noninline.h +++ b/libstdc++-v3/config/os/irix/irix6.5/ctype_noninline.h @@ -39,14 +39,14 @@ ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(!__table ? (const mask*) (__libc_attr._ctype_tbl->_class + 1) : __table) { } ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(!__table ? (const mask*) (__libc_attr._ctype_tbl->_class + 1) : __table) diff --git a/libstdc++-v3/config/os/mingw32/ctype_noninline.h b/libstdc++-v3/config/os/mingw32/ctype_noninline.h index 998547c9186..4ea7b892cca 100644 --- a/libstdc++-v3/config/os/mingw32/ctype_noninline.h +++ b/libstdc++-v3/config/os/mingw32/ctype_noninline.h @@ -43,13 +43,13 @@ ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) { } ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) { } diff --git a/libstdc++-v3/config/os/newlib/ctype_noninline.h b/libstdc++-v3/config/os/newlib/ctype_noninline.h index b511c4a86aa..7c5f053528a 100644 --- a/libstdc++-v3/config/os/newlib/ctype_noninline.h +++ b/libstdc++-v3/config/os/newlib/ctype_noninline.h @@ -39,13 +39,13 @@ ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) { } ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) { } diff --git a/libstdc++-v3/config/os/qnx/qnx6.1/ctype_noninline.h b/libstdc++-v3/config/os/qnx/qnx6.1/ctype_noninline.h index cf34bd422da..f4e2ca5f6c6 100644 --- a/libstdc++-v3/config/os/qnx/qnx6.1/ctype_noninline.h +++ b/libstdc++-v3/config/os/qnx/qnx6.1/ctype_noninline.h @@ -39,12 +39,12 @@ ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : _Ctype) { } ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : _Ctype) { } diff --git a/libstdc++-v3/config/os/solaris/solaris2.5/ctype_noninline.h b/libstdc++-v3/config/os/solaris/solaris2.5/ctype_noninline.h index a3c27b06b87..25eec3418b0 100644 --- a/libstdc++-v3/config/os/solaris/solaris2.5/ctype_noninline.h +++ b/libstdc++-v3/config/os/solaris/solaris2.5/ctype_noninline.h @@ -39,13 +39,13 @@ ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) { } ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table ? __table : classic_table()) { } diff --git a/libstdc++-v3/config/os/solaris/solaris2.6/ctype_noninline.h b/libstdc++-v3/config/os/solaris/solaris2.6/ctype_noninline.h index f65cfe70f79..659c81a3ffe 100644 --- a/libstdc++-v3/config/os/solaris/solaris2.6/ctype_noninline.h +++ b/libstdc++-v3/config/os/solaris/solaris2.6/ctype_noninline.h @@ -39,13 +39,13 @@ ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(__trans_upper), _M_tolower(__trans_lower), _M_table(__table ? __table : classic_table()) { } ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(__trans_upper), _M_tolower(__trans_lower), _M_table(__table ? __table : classic_table()) { } diff --git a/libstdc++-v3/config/os/solaris/solaris2.7/ctype_noninline.h b/libstdc++-v3/config/os/solaris/solaris2.7/ctype_noninline.h index c8b11a9bd6b..81536b5fc87 100644 --- a/libstdc++-v3/config/os/solaris/solaris2.7/ctype_noninline.h +++ b/libstdc++-v3/config/os/solaris/solaris2.7/ctype_noninline.h @@ -40,13 +40,13 @@ ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(__trans_upper), _M_tolower(__trans_lower), _M_table(__table ? __table : classic_table()) { } ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(__trans_upper), _M_tolower(__trans_lower), _M_table(__table ? __table : classic_table()) { } diff --git a/libstdc++-v3/config/os/windiss/ctype_noninline.h b/libstdc++-v3/config/os/windiss/ctype_noninline.h index 0d346952870..a22b65d46d0 100644 --- a/libstdc++-v3/config/os/windiss/ctype_noninline.h +++ b/libstdc++-v3/config/os/windiss/ctype_noninline.h @@ -40,13 +40,13 @@ ctype::ctype(__c_locale, const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table == 0 ? classic_table() : __table) { } ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + : facet(__refs), _M_del(__table != 0 && __del), _M_toupper(NULL), _M_tolower(NULL), _M_table(__table == 0 ? classic_table() : __table) { } diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h index 96fc3a0da35..13383d8d36f 100644 --- a/libstdc++-v3/include/bits/locale_facets.h +++ b/libstdc++-v3/include/bits/locale_facets.h @@ -334,7 +334,7 @@ namespace std // 22.2.1.3 ctype specialization. template<> - class ctype : public __ctype_abstract_base + class ctype : public locale::facet, public ctype_base { public: // Types: @@ -371,6 +371,39 @@ namespace std inline const char* scan_not(mask __m, const char* __lo, const char* __hi) const; + char_type + toupper(char_type __c) const + { return this->do_toupper(__c); } + + const char_type* + toupper(char_type *__lo, const char_type* __hi) const + { return this->do_toupper(__lo, __hi); } + + char_type + tolower(char_type __c) const + { return this->do_tolower(__c); } + + const char_type* + tolower(char_type* __lo, const char_type* __hi) const + { return this->do_tolower(__lo, __hi); } + + char_type + widen(char __c) const + { return this->do_widen(__c); } + + const char* + widen(const char* __lo, const char* __hi, char_type* __to) const + { return this->do_widen(__lo, __hi, __to); } + + char + narrow(char_type __c, char __dfault) const + { return this->do_narrow(__c, __dfault); } + + const char_type* + narrow(const char_type* __lo, const char_type* __hi, + char __dfault, char *__to) const + { return this->do_narrow(__lo, __hi, __dfault, __to); } + protected: const mask* table() const throw() @@ -382,19 +415,6 @@ namespace std virtual ~ctype(); - 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; @@ -408,17 +428,27 @@ namespace std do_tolower(char_type* __lo, const char_type* __hi) const; virtual char_type - do_widen(char) const; + do_widen(char __c) const + { return __c; } virtual const char* - do_widen(const char* __lo, const char* __hi, char_type* __dest) const; + do_widen(const char* __lo, const char* __hi, char_type* __dest) const + { + memcpy(__dest, __lo, __hi - __lo); + return __hi; + } virtual char - do_narrow(char_type, char __dfault) const; + do_narrow(char_type __c, char) const + { return __c; } virtual const char_type* do_narrow(const char_type* __lo, const char_type* __hi, - char __dfault, char* __dest) const; + char, char* __dest) const + { + memcpy(__dest, __lo, __hi - __lo); + return __hi; + } }; template<> @@ -492,7 +522,6 @@ namespace std virtual const char_type* do_narrow(const char_type* __lo, const char_type* __hi, char __dfault, char* __dest) const; - }; template<> diff --git a/libstdc++-v3/src/ctype.cc b/libstdc++-v3/src/ctype.cc index 1a84ced453a..e97d39dfe1c 100644 --- a/libstdc++-v3/src/ctype.cc +++ b/libstdc++-v3/src/ctype.cc @@ -30,10 +30,18 @@ namespace std { - // XXX At some point, just rename this file to ctype_members_char.cc - // and compile it as a separate file instead of including it here. - // Platform-specific initialization code for ctype tables. - #include + // Definitions for static const data members of ctype_base. + const ctype_base::mask ctype_base::space; + const ctype_base::mask ctype_base::print; + const ctype_base::mask ctype_base::cntrl; + const ctype_base::mask ctype_base::upper; + const ctype_base::mask ctype_base::lower; + const ctype_base::mask ctype_base::alpha; + const ctype_base::mask ctype_base::digit; + const ctype_base::mask ctype_base::punct; + const ctype_base::mask ctype_base::xdigit; + const ctype_base::mask ctype_base::alnum; + const ctype_base::mask ctype_base::graph; // Definitions for locale::id of standard facets that are specialized. locale::id ctype::id; @@ -62,18 +70,10 @@ namespace std } #endif - // Definitions for static const data members of ctype_base. - const ctype_base::mask ctype_base::space; - const ctype_base::mask ctype_base::print; - const ctype_base::mask ctype_base::cntrl; - const ctype_base::mask ctype_base::upper; - const ctype_base::mask ctype_base::lower; - const ctype_base::mask ctype_base::alpha; - const ctype_base::mask ctype_base::digit; - const ctype_base::mask ctype_base::punct; - const ctype_base::mask ctype_base::xdigit; - const ctype_base::mask ctype_base::alnum; - const ctype_base::mask ctype_base::graph; + // XXX At some point, just rename this file to ctype_configure_char.cc + // and compile it as a separate file instead of including it here. + // Platform-specific initialization code for ctype tables. + #include const size_t ctype::table_size; @@ -84,46 +84,6 @@ namespace std delete[] this->table(); } - // These are dummy placeholders as these virtual functions are never called. - bool - ctype::do_is(mask, char_type) const - { return false; } - - const char* - ctype::do_is(const char_type* __c, const char_type*, mask*) const - { return __c; } - - const char* - ctype::do_scan_is(mask, const char_type* __c, const char_type*) const - { return __c; } - - const char* - ctype::do_scan_not(mask, const char_type* __c, const char_type*) const - { return __c; } - - char - ctype::do_widen(char __c) const - { return __c; } - - const char* - ctype::do_widen(const char* __lo, const char* __hi, char* __dest) const - { - memcpy(__dest, __lo, __hi - __lo); - return __hi; - } - - char - ctype::do_narrow(char __c, char /*__dfault*/) const - { return __c; } - - const char* - ctype::do_narrow(const char* __lo, const char* __hi, - char /*__dfault*/, char* __dest) const - { - memcpy(__dest, __lo, __hi - __lo); - return __hi; - } - #ifdef _GLIBCXX_USE_WCHAR_T ctype::ctype(size_t __refs) : __ctype_abstract_base(__refs) diff --git a/libstdc++-v3/testsuite/22_locale/ctype/is/char/9858.cc b/libstdc++-v3/testsuite/22_locale/ctype/is/char/9858.cc new file mode 100644 index 00000000000..e7482255d48 --- /dev/null +++ b/libstdc++-v3/testsuite/22_locale/ctype/is/char/9858.cc @@ -0,0 +1,103 @@ +// Copyright (C) 2003 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// 22.2.1.3 - ctype specializations [lib.facet.ctype.special] + +#include +#include + +int called; + +class Derived : public std::ctype +{ +public: + bool + do_is(mask, char_type) const { return true; } + + const char_type* + do_is(const char_type* lo, const char_type* hi, mask* vec) const + { return hi; } + + const char_type* + do_scan_is(mask m, const char_type* lo, const char_type* hi) const + { return hi; } + + const char_type* + do_scan_not(mask m, const char_type* lo, const char_type* hi) const + { return hi; } +}; + +class Derived2 : public Derived +{ +public: + bool + do_is(mask, char_type) const { called = 1; return true; } + + const char_type* + do_is(const char_type* lo, const char_type* hi, mask* vec) const + { called = 5; return hi; } + + const char_type* + do_scan_is(mask m, const char_type* lo, const char_type* hi) const + { called = 10; return hi; } + + const char_type* + do_scan_not(mask m, const char_type* lo, const char_type* hi) const + { called = 15; return hi; } +}; + +int main() +{ + using namespace std; + bool test __attribute__((unused)) = true; + Derived2 d2; + const Derived& dr = d2; + + const char* lit = "jaylib champion sound"; + ctype_base::mask m00 = static_cast(0); + ctype_base::mask vec[5]; + for (std::size_t i = 0; i < 5; ++i) + vec[i] = m00; + + called = 0; + dr.do_is(ctype_base::space, 'a'); + VERIFY( called != 1); + + called = 0; + dr.do_is(lit, lit + 5, vec); + VERIFY( called != 5); + + called = 0; + dr.do_scan_is(ctype_base::space, lit, lit + 5); + VERIFY( called != 10); + + called = 0; + dr.do_scan_not(ctype_base::space, lit, lit + 5); + VERIFY( called != 15); + + return 0; +}