From 9e5c7dba50d3ad60d6920b76c1e20e0e401927e6 Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Wed, 12 Dec 2001 23:16:35 +0000 Subject: [PATCH] Named locale support for ctype. 2001-12-12 Benjamin Kosnik Named locale support for ctype. * config/locale/c_locale_gnu.h (_GLIBCPP_C_LOCALE_GNU): New. * config/os/gnu-linux/bits/ctype_noninline.h (ctype): Add definitions for alternate constructor. * 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/irix6.5/bits/ctype_noninline.h (ctype): Same. * config/os/irix/irix5.2/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/djgpp/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. * config/os/aix/bits/ctype_noninline.h (ctype): Same. * include/bits/locale_facets.h (ctype<_CharT>): Remove dummy definitions for all virtual functions. These are now explicitly undefined for non-required factets, ie any non-char, non-wchar_t instantiations. * src/localename.cc (locale::_Impl::_Impl(string, size_t): Named locales use alternate constructor for ctype facet. * include/bits/locale_facets.h (ctype::ctype(__c_locale, const mask*, bool, size_t): Add. (ctype::ctype(__c_locale, size_t): Add. * src/locale.cc (ctype::ctype(__c_locale, size_t)): Add definition. * testsuite/22_locale/ctype_members_char.cc (test02): Add, mark XFAIL for non-gnu locale models. From-SVN: r47953 --- libstdc++-v3/ChangeLog | 33 +++++++++ libstdc++-v3/config/locale/c_locale_gnu.h | 7 +- .../config/os/aix/bits/ctype_noninline.h | 17 +++-- .../os/bsd/freebsd/bits/ctype_noninline.h | 17 +++-- .../os/bsd/netbsd/bits/ctype_noninline.h | 17 +++-- .../config/os/djgpp/bits/ctype_noninline.h | 20 +++-- .../config/os/generic/bits/ctype_noninline.h | 17 +++-- .../config/os/gnu-linux/bits/ctype_inline.h | 4 - .../os/gnu-linux/bits/ctype_noninline.h | 20 ++++- .../config/os/hpux/bits/ctype_noninline.h | 17 +++-- .../os/irix/irix5.2/bits/ctype_noninline.h | 11 ++- .../os/irix/irix6.5/bits/ctype_noninline.h | 18 +++-- .../config/os/newlib/bits/ctype_noninline.h | 17 +++-- .../solaris/solaris2.5/bits/ctype_noninline.h | 17 +++-- .../solaris/solaris2.6/bits/ctype_noninline.h | 17 +++-- .../solaris/solaris2.7/bits/ctype_noninline.h | 17 +++-- libstdc++-v3/include/bits/locale_facets.h | 51 ++++++------- libstdc++-v3/src/locale.cc | 7 +- libstdc++-v3/src/localename.cc | 4 +- .../testsuite/22_locale/ctype_members_char.cc | 74 ++++++++++++++++++- 20 files changed, 298 insertions(+), 104 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8081d4cf26a..3ce299eebb0 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,36 @@ +2001-12-12 Benjamin Kosnik + + Named locale support for ctype. + * config/locale/c_locale_gnu.h (_GLIBCPP_C_LOCALE_GNU): New. + * config/os/gnu-linux/bits/ctype_noninline.h (ctype): Add + definitions for alternate constructor. + * 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/irix6.5/bits/ctype_noninline.h (ctype): Same. + * config/os/irix/irix5.2/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/djgpp/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. + * config/os/aix/bits/ctype_noninline.h (ctype): Same. + * include/bits/locale_facets.h (ctype<_CharT>): Remove dummy + definitions for all virtual functions. These are now explicitly + undefined for non-required factets, ie any non-char, non-wchar_t + instantiations. + * src/localename.cc (locale::_Impl::_Impl(string, size_t): Named + locales use alternate constructor for ctype facet. + * include/bits/locale_facets.h (ctype::ctype(__c_locale, const + mask*, bool, size_t): Add. + (ctype::ctype(__c_locale, size_t): Add. + * src/locale.cc (ctype::ctype(__c_locale, size_t)): Add + definition. + + * testsuite/22_locale/ctype_members_char.cc (test02): Add, mark + XFAIL for non-gnu locale models. + 2001-12-12 Philip Martin Ross Smith Paolo Carlini diff --git a/libstdc++-v3/config/locale/c_locale_gnu.h b/libstdc++-v3/config/locale/c_locale_gnu.h index f3c68023882..3ce1781e23b 100644 --- a/libstdc++-v3/config/locale/c_locale_gnu.h +++ b/libstdc++-v3/config/locale/c_locale_gnu.h @@ -38,12 +38,9 @@ #include // For codecvt using iconv, iconv_t #include // For messages +#define _GLIBCPP_C_LOCALE_GNU 1 + namespace std { typedef __locale_t __c_locale; } - - - - - diff --git a/libstdc++-v3/config/os/aix/bits/ctype_noninline.h b/libstdc++-v3/config/os/aix/bits/ctype_noninline.h index 30a36d27846..2e13e3f5988 100644 --- a/libstdc++-v3/config/os/aix/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/aix/bits/ctype_noninline.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 2000 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001 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 @@ -33,11 +33,18 @@ // Information as gleaned from /usr/include/ctype.h + ctype::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), + _M_ctable(NULL), _M_table(__table == 0 ? _M_ctable: __table) + { } + ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), - _M_toupper(NULL), _M_tolower(NULL), - _M_ctable(NULL), _M_table(__table == 0 ? _M_ctable: __table) - { } + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), + _M_ctable(NULL), _M_table(__table == 0 ? _M_ctable: __table) + { } char ctype::do_toupper(char __c) const 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 40262f7ce26..3aee4dabe3f 100644 --- a/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/bsd/freebsd/bits/ctype_noninline.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 2000 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001 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 @@ -33,11 +33,18 @@ // Information as gleaned from /usr/include/ctype.h + ctype::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), + _M_ctable(NULL), _M_table(__table == 0 ? _M_ctable: __table) + { } + ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), - _M_toupper(NULL), _M_tolower(NULL), - _M_ctable(NULL), _M_table(__table == 0 ? _M_ctable: __table) - { } + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), + _M_ctable(NULL), _M_table(__table == 0 ? _M_ctable: __table) + { } char ctype::do_toupper(char __c) const 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 8ea1b8d9827..dcadbbed26b 100644 --- a/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/bsd/netbsd/bits/ctype_noninline.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 2000 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001 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 @@ -33,11 +33,18 @@ // Information as gleaned from /usr/include/ctype.h + ctype::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), + _M_ctable(NULL), _M_table(__table == 0 ? (_ctype_ + 1) : __table) + { } + ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), - _M_toupper(NULL), _M_tolower(NULL), - _M_ctable(NULL), _M_table(__table == 0 ? (_ctype_ + 1) : __table) - { } + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), + _M_ctable(NULL), _M_table(__table == 0 ? (_ctype_ + 1) : __table) + { } char ctype::do_toupper(char __c) const diff --git a/libstdc++-v3/config/os/djgpp/bits/ctype_noninline.h b/libstdc++-v3/config/os/djgpp/bits/ctype_noninline.h index dc81d91c9b6..2b075733a96 100644 --- a/libstdc++-v3/config/os/djgpp/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/djgpp/bits/ctype_noninline.h @@ -33,15 +33,19 @@ // Information as gleaned from DJGPP + ctype::ctype(__c_locale, const mask* __table = 0, bool __del = false, + size_t __refs = 0) + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(__dj_ctype_toupper), _M_tolower(__dj_ctype_tolower), + _M_ctable(NULL), _M_table(__table == 0 ? __dj_ctype_flags : __table) + { } + ctype::ctype(const mask* __table = 0, bool __del = false, - size_t __refs = 0) - : __ctype_abstract_base(__refs), - _M_del(__table != 0 && __del), - _M_toupper(__dj_ctype_toupper), - _M_tolower(__dj_ctype_tolower), - _M_ctable(NULL), - _M_table(__table == 0 ? __dj_ctype_flags : __table) - { } + size_t __refs = 0) + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(__dj_ctype_toupper), _M_tolower(__dj_ctype_tolower), + _M_ctable(NULL), _M_table(__table == 0 ? __dj_ctype_flags : __table) + { } char ctype::do_toupper(char __c) const diff --git a/libstdc++-v3/config/os/generic/bits/ctype_noninline.h b/libstdc++-v3/config/os/generic/bits/ctype_noninline.h index e8da46269dd..2b629a6e01d 100644 --- a/libstdc++-v3/config/os/generic/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/generic/bits/ctype_noninline.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc. +// Copyright (C) 1997-2001 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 @@ -33,11 +33,18 @@ // Information as gleaned from /usr/include/ctype.h + ctype::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), + _M_table(__table == 0 ? _M_ctable : __table) + { } + ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), - _M_toupper(NULL), _M_tolower(NULL), - _M_ctable(NULL), _M_table(__table == 0 ? _M_ctable: __table) - { } + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), + _M_table(__table == 0 ? _M_ctable : __table) + { } char ctype::do_toupper(char __c) const diff --git a/libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h b/libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h index 4c248242625..8ec057dfb47 100644 --- a/libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h +++ b/libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h @@ -66,7 +66,3 @@ ++__low; return __low; } - - - - 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 0d649f681fb..54a56e09d9f 100644 --- a/libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc. +// Copyright (C) 1997-2001 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 @@ -39,6 +39,24 @@ using _C_legacy::__ctype_b; #endif +#if _GLIBCPP_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), + _M_toupper(__cloc ? __cloc->__ctype_toupper : __ctype_toupper), + _M_tolower(__cloc ? __cloc->__ctype_tolower : __ctype_tolower), + _M_ctable(__ctype_b), + _M_table(__table ? __table : (__cloc ? __cloc->__ctype_b : __ctype_b)) + { } +#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_ctable(__ctype_b), _M_table(__table ? __table : __ctype_b) + { } +#endif + 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), diff --git a/libstdc++-v3/config/os/hpux/bits/ctype_noninline.h b/libstdc++-v3/config/os/hpux/bits/ctype_noninline.h index e8da46269dd..7dbaced5a1d 100644 --- a/libstdc++-v3/config/os/hpux/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/hpux/bits/ctype_noninline.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc. +// Copyright (C) 1997-2001 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 @@ -33,11 +33,18 @@ // Information as gleaned from /usr/include/ctype.h + ctype::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), + _M_table(__table == 0 ? _M_ctable: __table) + { } + ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), - _M_toupper(NULL), _M_tolower(NULL), - _M_ctable(NULL), _M_table(__table == 0 ? _M_ctable: __table) - { } + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), + _M_table(__table == 0 ? _M_ctable: __table) + { } char ctype::do_toupper(char __c) const diff --git a/libstdc++-v3/config/os/irix/irix5.2/bits/ctype_noninline.h b/libstdc++-v3/config/os/irix/irix5.2/bits/ctype_noninline.h index cf4b5273e2b..dbf13ee60d5 100644 --- a/libstdc++-v3/config/os/irix/irix5.2/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/irix/irix5.2/bits/ctype_noninline.h @@ -33,10 +33,17 @@ // Information as gleaned from /usr/include/ctype.h + ctype::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), + _M_table(!__table ? __ctype : __table) + { } + ctype::ctype(const mask* __table, bool __del, size_t __refs) : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), - _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), - _M_table(!__table ? __ctype : __table) + _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), + _M_table(!__table ? __ctype : __table) { } char diff --git a/libstdc++-v3/config/os/irix/irix6.5/bits/ctype_noninline.h b/libstdc++-v3/config/os/irix/irix6.5/bits/ctype_noninline.h index 8045feb0890..a2f5e10ec44 100644 --- a/libstdc++-v3/config/os/irix/irix6.5/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/irix/irix6.5/bits/ctype_noninline.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997-1999 Free Software Foundation, Inc. +// Copyright (C) 1997-1999, 2001 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 @@ -33,12 +33,20 @@ // Information as gleaned from /usr/include/ctype.h + ctype::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : __ctype_abstract_base(__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) + { } + ctype::ctype(const mask* __table, bool __del, size_t __refs) : __ctype_abstract_base(__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) - { } + _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), + _M_table(!__table ? + (const mask*) (__libc_attr._ctype_tbl->_class + 1) : __table) + { } char ctype::do_toupper(char __c) const diff --git a/libstdc++-v3/config/os/newlib/bits/ctype_noninline.h b/libstdc++-v3/config/os/newlib/bits/ctype_noninline.h index ae0a6e95c9e..ed2867f8f92 100644 --- a/libstdc++-v3/config/os/newlib/bits/ctype_noninline.h +++ b/libstdc++-v3/config/os/newlib/bits/ctype_noninline.h @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 2000 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001 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 @@ -33,11 +33,18 @@ // Information as gleaned from /usr/include/ctype.h + ctype::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), _M_ctable(_ctype_), + _M_table(__table == 0 ? _M_ctable : __table) + { } + ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), - _M_toupper(NULL), _M_tolower(NULL), - _M_ctable(_ctype_), _M_table(__table == 0 ? _M_ctable: __table) - { } + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), _M_ctable(_ctype_), + _M_table(__table == 0 ? _M_ctable : __table) + { } char ctype::do_toupper(char __c) const 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 dd0d4fb7729..a7ec22329cb 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 @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 2000 Cygnus Solutions +// Copyright (C) 2000, 2001 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 @@ -33,11 +33,18 @@ // Information as gleaned from /usr/include/ctype.h + ctype::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), _M_ctable(__ctype), + _M_table(__table == 0 ? _M_ctable: __table) + { } + ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), - _M_toupper(NULL), _M_tolower(NULL), - _M_ctable(__ctype), _M_table(__table == 0 ? _M_ctable: __table) - { } + : __ctype_abstract_base(__refs), _M_del(__table != 0 && __del), + _M_toupper(NULL), _M_tolower(NULL), _M_ctable(__ctype), + _M_table(__table == 0 ? _M_ctable: __table) + { } char ctype::do_toupper(char __c) const 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 e436eb066b3..7f702a49642 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 @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997-1999, 2000 Cygnus Solutions +// Copyright (C) 1997-2001 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 @@ -33,11 +33,18 @@ // Information as gleaned from /usr/include/ctype.h + ctype::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : __ctype_abstract_base(__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) + { } + ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__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) - { } + : __ctype_abstract_base(__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) + { } char ctype::do_toupper(char __c) const 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 8b799219e0c..73951815bde 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 @@ -1,6 +1,6 @@ // Locale support -*- C++ -*- -// Copyright (C) 1997-1999, 2000 Cygnus Solutions +// Copyright (C) 1997-2001 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 @@ -33,11 +33,18 @@ // Information as gleaned from /usr/include/ctype.h + ctype::ctype(__c_locale, const mask* __table, bool __del, + size_t __refs) + : __ctype_abstract_base(__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) + { } + ctype::ctype(const mask* __table, bool __del, size_t __refs) - : __ctype_abstract_base(__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) - { } + : __ctype_abstract_base(__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) + { } char ctype::do_toupper(char __c) const diff --git a/libstdc++-v3/include/bits/locale_facets.h b/libstdc++-v3/include/bits/locale_facets.h index 5d88ea9fc05..967f399de0d 100644 --- a/libstdc++-v3/include/bits/locale_facets.h +++ b/libstdc++-v3/include/bits/locale_facets.h @@ -175,63 +175,51 @@ namespace std protected: virtual - ~ctype() { } + ~ctype(); virtual bool - do_is(mask __m, char_type __c) const - { return false; } + 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 - { return __hi; } + 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 - { return __hi; } + 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 - { return __hi; } + const char_type* __hi) const; virtual char_type - do_toupper(char_type __c) const - { return __c; } + do_toupper(char_type __c) const; virtual const char_type* - do_toupper(char_type* __lo, const char_type* __hi) const - { return __hi; } + do_toupper(char_type* __lo, const char_type* __hi) const; virtual char_type - do_tolower(char_type __c) const - { return __c; } + do_tolower(char_type __c) const; virtual const char_type* - do_tolower(char_type* __lo, const char_type* __hi) const - { return __hi; } - + do_tolower(char_type* __lo, const char_type* __hi) const; + virtual char_type - do_widen(char __c) const - { return char_type(); } + do_widen(char __c) const; virtual const char* - do_widen(const char* __lo, const char* __hi, char_type* __dest) const - { return __hi; } + do_widen(const char* __lo, const char* __hi, char_type* __dest) const; virtual char - do_narrow(char_type, char __dfault) const - { return __dfault; } + do_narrow(char_type, char __dfault) const; virtual const char_type* do_narrow(const char_type* __lo, const char_type* __hi, - char __dfault, char* __dest) const - { return __hi; } + char __dfault, char* __dest) const; }; template locale::id ctype<_CharT>::id; - // 22.2.1.3 ctype specializations + // 22.2.1.3 ctype specialization. template<> class ctype : public __ctype_abstract_base { @@ -254,6 +242,10 @@ namespace std explicit ctype(const mask* __table = 0, bool __del = false, size_t __refs = 0); + explicit + ctype(__c_locale __cloc, const mask* __table = 0, bool __del = false, + size_t __refs = 0); + inline bool is(mask __m, char __c) const; @@ -322,7 +314,7 @@ namespace std use_facet >(const locale& __loc); #ifdef _GLIBCPP_USE_WCHAR_T - // ctype specialization + // 22.2.1.3 ctype specialization template<> class ctype : public __ctype_abstract_base { @@ -337,6 +329,9 @@ namespace std explicit ctype(size_t __refs = 0); + explicit + ctype(__c_locale __cloc, size_t __refs = 0); + protected: __wmask_type _M_convert_to_wmask(const mask __m) const; diff --git a/libstdc++-v3/src/locale.cc b/libstdc++-v3/src/locale.cc index 14938d9d730..d827a256436 100644 --- a/libstdc++-v3/src/locale.cc +++ b/libstdc++-v3/src/locale.cc @@ -484,8 +484,11 @@ namespace std // NB: These ctype methods are not configuration-specific, // unlike the ctype bits. - ctype::ctype(size_t __refs) : __ctype_abstract_base(__refs) - { } + ctype::ctype(size_t __refs) + : __ctype_abstract_base(__refs) { } + + ctype::ctype(__c_locale /*__cloc*/, size_t __refs) + : __ctype_abstract_base(__refs) { } wchar_t ctype::do_toupper(wchar_t __c) const diff --git a/libstdc++-v3/src/localename.cc b/libstdc++-v3/src/localename.cc index 738acdef203..2bd34cd4ac8 100644 --- a/libstdc++-v3/src/localename.cc +++ b/libstdc++-v3/src/localename.cc @@ -92,7 +92,7 @@ namespace std // Construct all standard facets and add them to _M_facets. // XXX How to deal cleanly, consistently with null ("C") __cloc? _M_init_facet(new std::collate(__cloc)); - _M_init_facet(new std::ctype); + _M_init_facet(new std::ctype(__cloc)); _M_init_facet(new codecvt); _M_init_facet(new moneypunct(__cloc)); _M_init_facet(new moneypunct(__cloc)); @@ -108,7 +108,7 @@ namespace std #ifdef _GLIBCPP_USE_WCHAR_T _M_init_facet(new std::collate(__cloc)); - _M_init_facet(new std::ctype); + _M_init_facet(new std::ctype(__cloc)); _M_init_facet(new codecvt); _M_init_facet(new moneypunct(__cloc)); _M_init_facet(new moneypunct(__cloc)); diff --git a/libstdc++-v3/testsuite/22_locale/ctype_members_char.cc b/libstdc++-v3/testsuite/22_locale/ctype_members_char.cc index d13f97e13d9..7a9c1c9662b 100644 --- a/libstdc++-v3/testsuite/22_locale/ctype_members_char.cc +++ b/libstdc++-v3/testsuite/22_locale/ctype_members_char.cc @@ -30,9 +30,14 @@ // 22.2.1.3.2 ctype members #include -// NB: Don't include any other headers in this file. +#include +//#include +//#include #include +// XXX This test (test02) is not working for non-glibc locale models. +// { dg-do run { xfail *-*-* } } + class gnu_ctype: public std::ctype { }; void test01() @@ -168,7 +173,72 @@ void test01() #endif } -int main() { +// libstdc++/4456, libstdc++/4457, libstdc++/4458 +void test02() +{ + using namespace std; + typedef ctype_base::mask mask; + typedef vector vector_type; + + bool test = true; + + // const int max = numeric_limits::max(); + const int max = 255; + const int ctype_mask_max = 10; + vector_type v_c(max); + vector_type v_de(max); + + // "C" + locale loc_c = locale::classic(); + const ctype& ctype_c = use_facet >(loc_c); + for (int i = 0; i < max; ++i) + { + char c = static_cast(i); + mask mask_test = static_cast(0); + mask mask_is = static_cast(0); + for (int j = 0; j <= ctype_mask_max; ++j) + { + mask_test = static_cast(1 << j); + if (ctype_c.is(mask_test, c)) + mask_is |= mask_test; + } + v_c[i] = mask_is; + } + + // "de_DE" + locale loc_de("de_DE"); + const ctype& ctype_de = use_facet >(loc_de); + for (int i = 0; i < max; ++i) + { + char c = static_cast(i); + mask mask_test = static_cast(0); + mask mask_is = static_cast(0); + for (int j = 0; j <= ctype_mask_max; ++j) + { + mask_test = static_cast(1 << j); + if (ctype_de.is(mask_test, c)) + mask_is |= mask_test; + } + v_de[i] = mask_is; + } + +#if QUANNUM_VERBOSE_LYRICALLY_ADEPT_BAY_AREA_MCS_MODE + for (int i = 0; i < max; ++i) + { + char mark = v_c[i] == v_de[i] ? ' ' : '-'; + cout << i << ' ' << mark << ' ' << static_cast(i) << '\t' ; + cout << "v_c: " << setw(4) << v_c[i] << '\t'; + cout << "v_de: " << setw(4) << v_de[i] << endl; + } + cout << (v_c == v_de) << endl; +#endif + + VERIFY( v_c != v_de ); +} + +int main() +{ test01(); + test02(); return 0; } -- 2.30.2