+2003-10-21 Benjamin Kosnik <bkoz@redhat.com>
+
+ PR libstdc++/9858
+ * include/bits/locale_facets.h (ctype<char>): Remove
+ __ctype_abstract_base.
+ (ctype<char>::do_is): Remove.
+ (ctype<char>::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 <pcarlini@suse.de>
* src/locale.cc: Tweak a comment.
ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : __ctype_abstract_base<char>(__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())
{ }
#if _GLIBCXX_C_LOCALE_GNU
ctype<char>::ctype(__c_locale __cloc, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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;
#else
ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del)
+ : facet(__refs), _M_del(__table != 0 && __del)
{
char* __old=strdup(setlocale(LC_CTYPE, NULL));
setlocale(LC_CTYPE, "C");
#endif
#if _GLIBCXX_C_LOCALE_GNU
- ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) :
- __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del)
+ ctype<char>::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;
_M_table = __table ? __table : _M_c_locale_ctype->__ctype_b;
}
#else
- ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) :
- __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del)
+ ctype<char>::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");
ctype<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(__c_locale, const mask* __table, bool __del,
size_t __refs)
- : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table, bool __del, size_t __refs)
- : __ctype_abstract_base<char>(__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)
{ }
// 22.2.1.3 ctype<char> specialization.
template<>
- class ctype<char> : public __ctype_abstract_base<char>
+ class ctype<char> : public locale::facet, public ctype_base
{
public:
// Types:
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()
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;
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<>
virtual const char_type*
do_narrow(const char_type* __lo, const char_type* __hi,
char __dfault, char* __dest) const;
-
};
template<>
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 <bits/ctype_noninline.h>
+ // 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<char>::id;
}
#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 <bits/ctype_noninline.h>
const size_t ctype<char>::table_size;
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; }
-
- const char*
- ctype<char>::do_widen(const char* __lo, const char* __hi, char* __dest) const
- {
- memcpy(__dest, __lo, __hi - __lo);
- return __hi;
- }
-
- char
- ctype<char>::do_narrow(char __c, char /*__dfault*/) const
- { return __c; }
-
- const char*
- ctype<char>::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<wchar_t>::ctype(size_t __refs)
: __ctype_abstract_base<wchar_t>(__refs)
--- /dev/null
+// 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 <locale>
+#include <testsuite_hooks.h>
+
+int called;
+
+class Derived : public std::ctype<char>
+{
+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<std::ctype_base::mask>(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;
+}