Named locale support for ctype<char>.
authorBenjamin Kosnik <bkoz@redhat.com>
Wed, 12 Dec 2001 23:16:35 +0000 (23:16 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Wed, 12 Dec 2001 23:16:35 +0000 (23:16 +0000)
2001-12-12  Benjamin Kosnik  <bkoz@redhat.com>

Named locale support for ctype<char>.
* config/locale/c_locale_gnu.h (_GLIBCPP_C_LOCALE_GNU): New.
* config/os/gnu-linux/bits/ctype_noninline.h (ctype<char>): 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<char>::ctype(__c_locale, const
mask*, bool, size_t): Add.
(ctype<wchar_t>::ctype(__c_locale, size_t): Add.
* src/locale.cc (ctype<wchar_t>::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

20 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/config/locale/c_locale_gnu.h
libstdc++-v3/config/os/aix/bits/ctype_noninline.h
libstdc++-v3/config/os/bsd/freebsd/bits/ctype_noninline.h
libstdc++-v3/config/os/bsd/netbsd/bits/ctype_noninline.h
libstdc++-v3/config/os/djgpp/bits/ctype_noninline.h
libstdc++-v3/config/os/generic/bits/ctype_noninline.h
libstdc++-v3/config/os/gnu-linux/bits/ctype_inline.h
libstdc++-v3/config/os/gnu-linux/bits/ctype_noninline.h
libstdc++-v3/config/os/hpux/bits/ctype_noninline.h
libstdc++-v3/config/os/irix/irix5.2/bits/ctype_noninline.h
libstdc++-v3/config/os/irix/irix6.5/bits/ctype_noninline.h
libstdc++-v3/config/os/newlib/bits/ctype_noninline.h
libstdc++-v3/config/os/solaris/solaris2.5/bits/ctype_noninline.h
libstdc++-v3/config/os/solaris/solaris2.6/bits/ctype_noninline.h
libstdc++-v3/config/os/solaris/solaris2.7/bits/ctype_noninline.h
libstdc++-v3/include/bits/locale_facets.h
libstdc++-v3/src/locale.cc
libstdc++-v3/src/localename.cc
libstdc++-v3/testsuite/22_locale/ctype_members_char.cc

index 8081d4cf26a4681cd90dad52afee177818ccae79..3ce299eebb0b6bfd6e29ba8f1e811859283dfb64 100644 (file)
@@ -1,3 +1,36 @@
+2001-12-12  Benjamin Kosnik  <bkoz@redhat.com>
+
+       Named locale support for ctype<char>.
+       * config/locale/c_locale_gnu.h (_GLIBCPP_C_LOCALE_GNU): New.
+       * config/os/gnu-linux/bits/ctype_noninline.h (ctype<char>): 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<char>::ctype(__c_locale, const
+       mask*, bool, size_t): Add.
+       (ctype<wchar_t>::ctype(__c_locale, size_t): Add.
+       * src/locale.cc (ctype<wchar_t>::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  <philip@codematters.co.uk>
             Ross Smith     <r-smith@ihug.co.nz>
             Paolo Carlini  <pcarlini@unitus.it>
index f3c680238820e7e59f96c69234199b02c6a79bed..3ce1781e23be3092a01b0d51898015b53bb659ce 100644 (file)
 #include <iconv.h>             // For codecvt using iconv, iconv_t
 #include <libintl.h>           // For messages
 
+#define _GLIBCPP_C_LOCALE_GNU 1
+
 namespace std
 {
   typedef __locale_t           __c_locale;
 }
-
-
-
-
-
index 30a36d2784683b5465aba7ef7dde5b15a9af8a62..2e13e3f59885b80c04ae149600859842f35079a3 100644 (file)
@@ -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
   
 // Information as gleaned from /usr/include/ctype.h
   
+  ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
+                    size_t __refs) 
+  : __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) 
+  { }
+
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) 
-    : __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) 
-    { }
+  : __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) 
+  { }
 
   char
   ctype<char>::do_toupper(char __c) const
index 40262f7ce2688286145aadadda5452ced2aaf6dc..3aee4dabe3f7623cc638c854eb1f7214f051603f 100644 (file)
@@ -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
   
 // Information as gleaned from /usr/include/ctype.h
   
+  ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
+                    size_t __refs) 
+  : __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) 
+  { }
+
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) 
-    : __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) 
-    { }
+  : __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) 
+  { }
 
   char
   ctype<char>::do_toupper(char __c) const
index 8ea1b8d9827a72472c833d13b676a33dc731d48f..dcadbbed26bd05bc6822c731832f4cbae777c1b1 100644 (file)
@@ -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
   
 // Information as gleaned from /usr/include/ctype.h
   
+  ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
+                    size_t __refs) 
+  : __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) 
+  { }
+
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) 
-    : __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) 
-    { }
+  : __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) 
+  { }
 
   char
   ctype<char>::do_toupper(char __c) const
index dc81d91c9b62e74c4678c0e90d13657d8b0fbb98..2b075733a96a0692448fef9bc662baaf0a699480 100644 (file)
   
 // Information as gleaned from DJGPP <ctype.h>
 
+  ctype<char>::ctype(__c_locale, const mask* __table = 0, bool __del = false, 
+                    size_t __refs = 0) 
+  : __ctype_abstract_base<char>(__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<char>::ctype(const mask* __table = 0, bool __del = false, 
-       size_t __refs = 0) 
-    : __ctype_abstract_base<char>(__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<char>(__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<char>::do_toupper(char __c) const
index e8da46269dde3dba2cd7aa525436361efc436cde..2b629a6e01d4a457ad16ae7d5cd88f400c96e14c 100644 (file)
@@ -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
   
 // Information as gleaned from /usr/include/ctype.h
   
+  ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
+                    size_t __refs) 
+  : __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) 
+  { }
+
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) 
-    : __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) 
-    { }
+  : __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) 
+  { }
 
   char
   ctype<char>::do_toupper(char __c) const
index 4c24824262554ffff22e10578866fa888c2527d8..8ec057dfb4756410cb12164652fb38d50faafb8d 100644 (file)
@@ -66,7 +66,3 @@
       ++__low;
     return __low;
   }
-
-
-
-
index 0d649f681fb3fe4624d4959a7a61df0eba695e0b..54a56e09d9faf5d3bb0d4b276891fe82e5da3a55 100644 (file)
@@ -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
   using _C_legacy::__ctype_b;
 #endif
 
+#if _GLIBCPP_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), 
+  _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<char>::ctype(__c_locale, const mask* __table, bool __del, 
+                    size_t __refs) 
+  : __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 ? __table : __ctype_b)
+  { }
+#endif
+
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) : 
   __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), 
   _M_toupper(__ctype_toupper), _M_tolower(__ctype_tolower),
index e8da46269dde3dba2cd7aa525436361efc436cde..7dbaced5a1d54eb22318639cbea559c258868411 100644 (file)
@@ -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
   
 // Information as gleaned from /usr/include/ctype.h
   
+  ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
+                    size_t __refs) 
+  : __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) 
+  { }
+
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) 
-    : __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) 
-    { }
+  : __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) 
+  { }
 
   char
   ctype<char>::do_toupper(char __c) const
index cf4b5273e2bad51606d38d36f5d13ebd8b6fde2c..dbf13ee60d50b7466b634f6aa4673e45e9f91ac9 100644 (file)
   
 // Information as gleaned from /usr/include/ctype.h
 
+  ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
+                    size_t __refs)
+  : __ctype_abstract_base<char>(__refs), _M_del(__table != 0 && __del), 
+  _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), 
+  _M_table(!__table ? __ctype : __table)
+  { }
+
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
   : __ctype_abstract_base<char>(__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
index 8045feb089071c5bc7ed639435a02ceaf75d3b5d..a2f5e10ec44704a01e93b65576fab567b35d694f 100644 (file)
@@ -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
   
 // Information as gleaned from /usr/include/ctype.h
 
+  ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
+                    size_t __refs)
+  : __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) 
+  { }
+
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
   : __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) 
-    { }
+  _M_toupper(NULL), _M_tolower(NULL), _M_ctable(NULL), 
+  _M_table(!__table ? 
+          (const mask*) (__libc_attr._ctype_tbl->_class + 1) : __table) 
+  { }
 
   char
   ctype<char>::do_toupper(char __c) const
index ae0a6e95c9e639785ab984f8c84f13b1908c01c1..ed2867f8f9242978f32b7a7ea9a8019b210431a7 100644 (file)
@@ -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
   
 // Information as gleaned from /usr/include/ctype.h
   
+  ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
+                    size_t __refs) 
+  : __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) 
+  { }
+
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) 
-    : __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) 
-    { }
+  : __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) 
+  { }
 
   char
   ctype<char>::do_toupper(char __c) const
index dd0d4fb7729181daea2f603753159e2d54227943..a7ec22329cb4148bf499458a53bf160394271405 100644 (file)
@@ -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
   
 // Information as gleaned from /usr/include/ctype.h
   
+  ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
+                    size_t __refs) 
+  : __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) 
+  { }
+
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) 
-    : __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) 
-    { }
+  : __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) 
+  { }
 
   char
   ctype<char>::do_toupper(char __c) const
index e436eb066b30acfe6c172786d2f53ebdb593bce0..7f702a496421840fef0447d9e7ee23fc6c2c3686 100644 (file)
@@ -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
   
 // Information as gleaned from /usr/include/ctype.h
   
+  ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
+                    size_t __refs) 
+  : __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) 
+  { }
+
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs) 
-    : __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) 
-    { }
+  : __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) 
+  { }
 
   char
   ctype<char>::do_toupper(char __c) const
index 8b799219e0ce473886a259ce9502b02d9b2ad336..73951815bde32c06aa3b2448b4b1ef1f78780ef0 100644 (file)
@@ -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
   
 // Information as gleaned from /usr/include/ctype.h
   
+  ctype<char>::ctype(__c_locale, const mask* __table, bool __del, 
+                    size_t __refs)
+  : __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) 
+  { }
+
   ctype<char>::ctype(const mask* __table, bool __del, size_t __refs)
-    : __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) 
-    { }
+  : __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) 
+  { }
 
   char
   ctype<char>::do_toupper(char __c) const
index 5d88ea9fc057632c1d8de46b7ef230d836dbc72b..967f399de0d81cd28c7ef00298e87d91a6bb90bd 100644 (file)
@@ -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<typename _CharT>
     locale::id ctype<_CharT>::id;
 
-  // 22.2.1.3  ctype specializations
+  // 22.2.1.3  ctype<char> specialization.
   template<>
     class ctype<char> : public __ctype_abstract_base<char>
     {
@@ -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<ctype<char> >(const locale& __loc);
 
 #ifdef _GLIBCPP_USE_WCHAR_T
-  // ctype<wchar_t> specialization
+  // 22.2.1.3  ctype<wchar_t> specialization
   template<>
     class ctype<wchar_t> : public __ctype_abstract_base<wchar_t>
     {
@@ -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;
index 14938d9d730ba7d077d23c565f2a839a94293651..d827a2564366104aa40cc9eb2c5001e27e503a4d 100644 (file)
@@ -484,8 +484,11 @@ namespace std
 
   // NB: These ctype<wchar_t> methods are not configuration-specific,
   // unlike the ctype<char> bits.
-  ctype<wchar_t>::ctype(size_t __refs) : __ctype_abstract_base<wchar_t>(__refs)
-  { }
+  ctype<wchar_t>::ctype(size_t __refs) 
+  : __ctype_abstract_base<wchar_t>(__refs) { }
+
+  ctype<wchar_t>::ctype(__c_locale /*__cloc*/, size_t __refs) 
+  : __ctype_abstract_base<wchar_t>(__refs) { }
 
   wchar_t
   ctype<wchar_t>::do_toupper(wchar_t __c) const
index 738acdef20389d6a7f4e2c93700365f144e1415d..2bd34cd4ac8cf4bcf50d91b96958618dadd98f95 100644 (file)
@@ -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<char>(__cloc));
-    _M_init_facet(new std::ctype<char>);
+    _M_init_facet(new std::ctype<char>(__cloc));
     _M_init_facet(new codecvt<char, char, mbstate_t>);
     _M_init_facet(new moneypunct<char, false>(__cloc));
     _M_init_facet(new moneypunct<char, true>(__cloc));
@@ -108,7 +108,7 @@ namespace std
     
 #ifdef  _GLIBCPP_USE_WCHAR_T
     _M_init_facet(new std::collate<wchar_t>(__cloc));
-    _M_init_facet(new std::ctype<wchar_t>);
+    _M_init_facet(new std::ctype<wchar_t>(__cloc));
     _M_init_facet(new codecvt<wchar_t, char, mbstate_t>);
     _M_init_facet(new moneypunct<wchar_t, false>(__cloc));
     _M_init_facet(new moneypunct<wchar_t, true>(__cloc));
index d13f97e13d9dd3922ec567e52ea83aca1013335a..7a9c1c9662b358474a99ab0206cae143657edff0 100644 (file)
 // 22.2.1.3.2 ctype<char> members
 
 #include <locale>
-// NB: Don't include any other headers in this file.
+#include <vector>
+//#include <iostream>
+//#include <iomanip>
 #include <testsuite_hooks.h>
 
+// XXX This test (test02) is not working for non-glibc locale models.
+// { dg-do run { xfail *-*-* } }
+
 class gnu_ctype: public std::ctype<char> { };
 
 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<mask>                 vector_type;
+
+  bool test = true;
+
+  //  const int max = numeric_limits<char>::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<char>& ctype_c = use_facet<ctype<char> >(loc_c); 
+  for (int i = 0; i < max; ++i)
+    {
+      char c = static_cast<char>(i);
+      mask mask_test = static_cast<mask>(0);
+      mask mask_is = static_cast<mask>(0);
+      for (int j = 0; j <= ctype_mask_max; ++j)
+       {
+         mask_test = static_cast<mask>(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<char>& ctype_de = use_facet<ctype<char> >(loc_de); 
+  for (int i = 0; i < max; ++i)
+    {
+      char c = static_cast<char>(i);
+      mask mask_test = static_cast<mask>(0);
+      mask mask_is = static_cast<mask>(0);
+      for (int j = 0; j <= ctype_mask_max; ++j)
+       {
+         mask_test = static_cast<mask>(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<char>(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;
 }