]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorJakub Jelinek <jakub@gcc.gnu.org>
Thu, 1 Aug 2002 21:29:18 +0000 (23:29 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 1 Aug 2002 21:29:18 +0000 (23:29 +0200)
2002-08-01  Benjamin Kosnik   <bkoz@redhat.com>

* g++.old-deja/g++.abi/ptrflags.C (expect): Change
__qualifier_flags to __flags.

2002-08-01  Benjamin Kosnik  <bkoz@redhat.com>
    Jakub Jelinek  <jakub@redhat.com>

* config/linker-map.gnu: Change CXXABI_1 to CXXABI_1.2,
GLIBCPP_3.1 to GLIBCPP_3.2.

2002-07-31  Benjamin Kosnik  <bkoz@redhat.com>
    Mark Mitchell  <mark@codesourcery.com>

PR libstdc++/7442
* libsupc++/cxxabi.h (class __base_class_type_info::hwm_bit):
Change to __hwm_bit.
(__class_type_info): And here.

2002-07-31  Benjamin Kosnik  <bkoz@redhat.com>

PR libstdc++/7442
* libsupc++/cxxabi.h
(__base_class_info): Change to __base_class_type_info. 2.9.5p6c
(__base_class_info::__base): Change to __base_type. 2.9.5p6c
(__base_class_info::offset_shift): Change to __offset_shift. 2.9.5p6c
(__vmi_class_type_info::__base_info): Don't make const, of type
__base_class_type_info, as per 2.9.5p6c
(__pbase_type_info::__qualifier_flags): Change to __flags, as per
2.9.5p7.
(__pbase_type_info::__qualifier_masks): Change to __masks, as per
2.9.5p7.
(__pointer_to_member_type_info::__context_class): Change member to
__context, as per 2.9.5p9.
* libsupc++/tinfo2.cc (__pointer_catch): Change __context_class to
__context.
* libsupc++/tinfo2.cc (__do_catch): Change __qualifier_flags to
__flags.
* libsupc++/tinfo.cc (__do_find_public_src): Change __base to
__base_type.
* libsupc++/tinfo.cc (__do_dyncast): Same.
* libsupc++/tinfo.cc (__do_upcast): Same.

2002-07-31  Simon Whomsley  <whomsley@avacadcam.com>

* docs/html/22_locale/howto.html: Fix.

2002-07-31  Alex Kompel  <shurik@sequoiap.com>

PR libstdc++/7445
* src/locale.cc (locale::classic): Move locks inside !_S_classic
block.

2002-07-30  Benjamin Kosnik  <bkoz@redhat.com>
    Gabriel Dos Reis  <gdr@nerim.net>

* include/bits/char_traits.h: Remove generic definitions.
* include/bits/streambuf_iterator.h (istreambuf_iterator): Use
eof, not -2.
* include/bits/istream.tcc (istream::readsome): Don't check
against eof, instead use constants.
(istream::sync): Same.
(istream::sentry::sentry): Use eq_int_type.
(istream::get): Same.
* include/bits/ostream.tcc: Change __pad to
__pad<_CharT, _Traits>::_S_pad.
* include/bits/locale_facets.h: Add __pad_traits generic and
ostreambuf_iterator specialization.
* include/bits/locale_facets.tcc: Change __pad into struct __pad
with a _CharT and _Traits template parameter and _S_pad static
member function.
* src/locale-inst.cc: Update __pad instantiations.

* include/std/std_fstream.h: Declare _M_underflow_common
specializations.
* src/fstream.cc: New. Add _M_underflow_common specializations.
* include/bits/fstream.tcc (filebuf::close): Use traits_type.
(filebuf::_M_underflow_common(bool)): Remove generic version, as
sys_ungetc and custom int_types don't get along.
* include/std/std_streambuf.h: Add _M_pos.
* src/Makefile.am (sources): Add fstream.cc.
* src/Makefile.in: Regenerate.

* testsuite/21_strings/capacity.cc: Add char_traits specializations.
* testsuite/22_locale/codecvt_members_unicode_char.cc: Same.
* testsuite/22_locale/codecvt_members_unicode_wchar_t.cc: Same.
* testsuite/22_locale/ctor_copy_dtor.cc: Same.
* testsuite/27_io/filebuf_virtuals.cc (test07): Move to...
* testsuite/27_io/filebuf.cc: ...here.
* testsuite/testsuite_hooks.h: Add gnu_char, gnu_int, char_traits
specialization for both.
* testsuite/27_io/streambuf.cc: Add instantiation test,
testsuite_hooks include.
* testsuite/27_io/istream.cc: Same.
* testsuite/27_io/ostream.cc: Same.
* testsuite/27_io/fstream.cc: Same.
* testsuite/27_io/stringstream.cc: Same.
* testsuite/27_io/filebuf.cc: Same.
* testsuite/27_io/stringbuf.cc: Same.

From-SVN: r55951

37 files changed:
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.abi/ptrflags.C
libstdc++-v3/ChangeLog
libstdc++-v3/config/linker-map.gnu
libstdc++-v3/docs/html/22_locale/howto.html
libstdc++-v3/include/bits/char_traits.h
libstdc++-v3/include/bits/fpos.h
libstdc++-v3/include/bits/fstream.tcc
libstdc++-v3/include/bits/istream.tcc
libstdc++-v3/include/bits/locale_facets.h
libstdc++-v3/include/bits/locale_facets.tcc
libstdc++-v3/include/bits/ostream.tcc
libstdc++-v3/include/bits/sstream.tcc
libstdc++-v3/include/bits/streambuf_iterator.h
libstdc++-v3/include/std/std_fstream.h
libstdc++-v3/include/std/std_streambuf.h
libstdc++-v3/libsupc++/cxxabi.h
libstdc++-v3/libsupc++/tinfo.cc
libstdc++-v3/libsupc++/tinfo2.cc
libstdc++-v3/src/Makefile.am
libstdc++-v3/src/Makefile.in
libstdc++-v3/src/locale-inst.cc
libstdc++-v3/src/locale.cc
libstdc++-v3/testsuite/21_strings/capacity.cc
libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_char.cc
libstdc++-v3/testsuite/22_locale/codecvt_members_unicode_wchar_t.cc
libstdc++-v3/testsuite/22_locale/ctor_copy_dtor.cc
libstdc++-v3/testsuite/27_io/filebuf.cc
libstdc++-v3/testsuite/27_io/filebuf_virtuals.cc
libstdc++-v3/testsuite/27_io/fstream.cc
libstdc++-v3/testsuite/27_io/ios_init.cc
libstdc++-v3/testsuite/27_io/istream.cc
libstdc++-v3/testsuite/27_io/ostream.cc
libstdc++-v3/testsuite/27_io/streambuf.cc
libstdc++-v3/testsuite/27_io/stringbuf.cc
libstdc++-v3/testsuite/27_io/stringstream.cc
libstdc++-v3/testsuite/testsuite_hooks.h

index 1ad507e6b87fb5e9b0967b1508e3cb76bc95b4b8..a5d117d973c7586ece992fdbbd813c196ae09dcc 100644 (file)
@@ -1,3 +1,8 @@
+2002-08-01  Benjamin Kosnik   <bkoz@redhat.com>
+
+       * g++.old-deja/g++.abi/ptrflags.C (expect): Change
+       __qualifier_flags to __flags.
+
 2002-07-24  Roger Sayle  <roger@eyesopen.com>
 
        * gcc.c-torture/execute/memset-3.c: New testcase.
index 9c645566d2ebbc05543902e368f4e6b4ea13469e..16bf946fc37dac9c2c3c0da955351bcd647f8a7c 100644 (file)
@@ -18,7 +18,7 @@ int expect (int flags, std::type_info const &info)
       dynamic_cast <abi::__pbase_type_info const *> (&info);
   if (!ptr)
     return 0;
-  if (ptr->__qualifier_flags != flags)
+  if (ptr->__flags != flags)
     return 0;
   return 1;
 }
index f1ac5ece41cffc0914bc7444df38dd3d8dbeed1e..6a03683257ffa11228e9432cf5eda2164b1c2e3a 100644 (file)
@@ -1,3 +1,98 @@
+2002-08-01  Benjamin Kosnik  <bkoz@redhat.com>
+           Jakub Jelinek  <jakub@redhat.com>
+       
+       * config/linker-map.gnu: Change CXXABI_1 to CXXABI_1.2,
+       GLIBCPP_3.1 to GLIBCPP_3.2.
+
+2002-07-31  Benjamin Kosnik  <bkoz@redhat.com>
+           Mark Mitchell  <mark@codesourcery.com>
+
+       PR libstdc++/7442
+       * libsupc++/cxxabi.h (class __base_class_type_info::hwm_bit):
+       Change to __hwm_bit.
+       (__class_type_info): And here.
+
+2002-07-31  Benjamin Kosnik  <bkoz@redhat.com>
+
+       PR libstdc++/7442
+       * libsupc++/cxxabi.h 
+       (__base_class_info): Change to __base_class_type_info. 2.9.5p6c
+       (__base_class_info::__base): Change to __base_type. 2.9.5p6c
+       (__base_class_info::offset_shift): Change to __offset_shift. 2.9.5p6c
+       (__vmi_class_type_info::__base_info): Don't make const, of type
+       __base_class_type_info, as per 2.9.5p6c
+       (__pbase_type_info::__qualifier_flags): Change to __flags, as per
+       2.9.5p7.
+       (__pbase_type_info::__qualifier_masks): Change to __masks, as per
+       2.9.5p7.
+       (__pointer_to_member_type_info::__context_class): Change member to
+       __context, as per 2.9.5p9.
+       * libsupc++/tinfo2.cc (__pointer_catch): Change __context_class to
+       __context.
+       * libsupc++/tinfo2.cc (__do_catch): Change __qualifier_flags to
+       __flags.
+       * libsupc++/tinfo.cc (__do_find_public_src): Change __base to
+       __base_type.
+       * libsupc++/tinfo.cc (__do_dyncast): Same.
+       * libsupc++/tinfo.cc (__do_upcast): Same.
+
+2002-07-31  Simon Whomsley  <whomsley@avacadcam.com>
+
+       * docs/html/22_locale/howto.html: Fix.
+
+2002-07-31  Alex Kompel  <shurik@sequoiap.com>
+
+       PR libstdc++/7445
+       * src/locale.cc (locale::classic): Move locks inside !_S_classic
+       block.
+
+2002-07-30  Benjamin Kosnik  <bkoz@redhat.com>
+           Gabriel Dos Reis  <gdr@nerim.net>
+
+       * include/bits/char_traits.h: Remove generic definitions.
+       * include/bits/streambuf_iterator.h (istreambuf_iterator): Use
+       eof, not -2.
+       * include/bits/istream.tcc (istream::readsome): Don't check
+       against eof, instead use constants.
+       (istream::sync): Same.
+       (istream::sentry::sentry): Use eq_int_type.
+       (istream::get): Same.
+       * include/bits/ostream.tcc: Change __pad to 
+       __pad<_CharT, _Traits>::_S_pad. 
+       * include/bits/locale_facets.h: Add __pad_traits generic and
+       ostreambuf_iterator specialization.
+       * include/bits/locale_facets.tcc: Change __pad into struct __pad
+       with a _CharT and _Traits template parameter and _S_pad static
+       member function.
+       * src/locale-inst.cc: Update __pad instantiations.
+       
+       * include/std/std_fstream.h: Declare _M_underflow_common
+       specializations.
+       * src/fstream.cc: New. Add _M_underflow_common specializations.
+       * include/bits/fstream.tcc (filebuf::close): Use traits_type.
+       (filebuf::_M_underflow_common(bool)): Remove generic version, as
+       sys_ungetc and custom int_types don't get along.
+       * include/std/std_streambuf.h: Add _M_pos.
+       * src/Makefile.am (sources): Add fstream.cc.
+       * src/Makefile.in: Regenerate.
+
+       * testsuite/21_strings/capacity.cc: Add char_traits specializations.
+       * testsuite/22_locale/codecvt_members_unicode_char.cc: Same.
+       * testsuite/22_locale/codecvt_members_unicode_wchar_t.cc: Same.
+       * testsuite/22_locale/ctor_copy_dtor.cc: Same.
+       * testsuite/27_io/filebuf_virtuals.cc (test07): Move to...
+       * testsuite/27_io/filebuf.cc: ...here.
+       * testsuite/testsuite_hooks.h: Add gnu_char, gnu_int, char_traits
+       specialization for both.
+       * testsuite/27_io/streambuf.cc: Add instantiation test,
+       testsuite_hooks include.
+       * testsuite/27_io/istream.cc: Same.
+       * testsuite/27_io/ostream.cc: Same.     
+       * testsuite/27_io/fstream.cc: Same.
+       * testsuite/27_io/stringstream.cc: Same.
+       * testsuite/27_io/filebuf.cc: Same.
+       * testsuite/27_io/stringbuf.cc: Same.
+
 2002-07-26  Phil Edwards  <pme@gcc.gnu.org>
 
        * libsupc++/new (placement delete):  Remove unused paramater names.
index 2a55bb2e46339ba84c29b73a95c2305a82303e10..d4346b1c660eb5311961d3c411353336968d6de3 100644 (file)
@@ -21,7 +21,7 @@
 ## USA.
 
 
-GLIBCPP_3.1 {
+GLIBCPP_3.2 {
 
   global:
 
@@ -97,7 +97,7 @@ GLIBCPP_3.1 {
 
 
 # Symbols in the support library (libsupc++) have their own tag.
-CXXABI_1 {
+CXXABI_1.2 {
 
   global:
     __cxa_*;
index d8ada0464b1f99e090f9e4921bb3236c1fc93512..e1e580566044fee490e4398167bd1203e69e4e44 100644 (file)
 
    struct Toupper
    {
-       Toupper (std::locale const&amp; l) : loc(l) {;}
+       Toupper(std::locale const&amp; l) : loc(l) {;}
        char operator() (char c)  { return std::toupper(c,loc); }
    private:
        std::locale const&amp; loc;
    
    struct Tolower
    {
-       Tolower (std::locale const&amp; l) : loc(l) {;}
+       Tolower(std::locale const&amp; l) : loc(l) {;}
        char operator() (char c)  { return std::tolower(c,loc); }
    private:
        std::locale const&amp; loc;
    
    int main ()
    {
-      std::string  s ("Some Kind Of Initial Input Goes Here");
-      Toupper      up   ( std::locale("C") );
-      Tolower      down ( std::locale("C") );
+      std::string  s("Some Kind Of Initial Input Goes Here");
+      std::locale loc_c("C");
+      Toupper      up(loc_c);
+      Tolower      down(loc_c);
    
-      // Change everything into upper case
-      std::transform (s.begin(), s.end(), s.begin(),
-                      up
-                     );
+      // Change everything into upper case.
+      std::transform(s.begin(), s.end(), s.begin(), up);
    
-      // Change everything into lower case
-      std::transform (s.begin(), s.end(), s.begin(),
-                      down
-                     );
+      // Change everything into lower case.
+      std::transform(s.begin(), s.end(), s.begin(), down);
    
       // Change everything back into upper case, but store the
-      // result in a different string
+      // result in a different string.
       std::string  capital_s;
-      std::transform (s.begin(), s.end(), std::back_inserter(capital_s),
-                      up
-                     );
+      std::transform(s.begin(), s.end(), std::back_inserter(capital_s), up);
    }</pre>
    </p>
    <p>The final version of the code uses <code>bind2nd</code> to eliminate
index 7d14838ab2687e917f572d6b02e862f6c77f484d..41f943d9a59b48ab06c97d31ee59e17469537b5d 100644 (file)
@@ -1,6 +1,7 @@
 // Character Traits for use by standard string and iostream -*- C++ -*-
 
-// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+// 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
@@ -53,82 +54,53 @@ namespace std
     struct char_traits
     {
       typedef _CharT           char_type;
-      // Unsigned as wint_t in unsigned.
+      // Unsigned as wint_t is unsigned.
       typedef unsigned long    int_type;
       typedef streampos        pos_type;
       typedef streamoff        off_type;
       typedef mbstate_t        state_type;
       
       static void 
-      assign(char_type& __c1, const char_type& __c2)
-      { __c1 = __c2; }
+      assign(char_type& __c1, const char_type& __c2);
 
       static bool 
-      eq(const char_type& __c1, const char_type& __c2)
-      { return __c1 == __c2; }
+      eq(const char_type& __c1, const char_type& __c2);
 
       static bool 
-      lt(const char_type& __c1, const char_type& __c2)
-      { return __c1 < __c2; }
+      lt(const char_type& __c1, const char_type& __c2);
 
       static int 
-      compare(const char_type* __s1, const char_type* __s2, size_t __n)
-      { 
-       for (size_t __i = 0; __i < __n; ++__i)
-         if (!eq(__s1[__i], __s2[__i]))
-           return lt(__s1[__i], __s2[__i]) ? -1 : 1;
-       return 0; 
-      }
+      compare(const char_type* __s1, const char_type* __s2, size_t __n);
 
       static size_t
-      length(const char_type* __s)
-      { 
-       const char_type* __p = __s; 
-       while (*__p) ++__p; 
-       return (__p - __s); 
-      }
+      length(const char_type* __s);
 
       static const char_type* 
-      find(const char_type* __s, size_t __n, const char_type& __a)
-      { 
-       for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p)
-         if (*__p == __a) return __p;
-       return 0;
-      }
+      find(const char_type* __s, size_t __n, const char_type& __a);
 
       static char_type* 
-      move(char_type* __s1, const char_type* __s2, size_t __n)
-      { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); }
+      move(char_type* __s1, const char_type* __s2, size_t __n);
 
       static char_type* 
-      copy(char_type* __s1, const char_type* __s2, size_t __n)
-      { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); }
+      copy(char_type* __s1, const char_type* __s2, size_t __n);
 
       static char_type* 
-      assign(char_type* __s, size_t __n, char_type __a)
-      { 
-       for (char_type* __p = __s; __p < __s + __n; ++__p) 
-         assign(*__p, __a);
-        return __s; 
-      }
+      assign(char_type* __s, size_t __n, char_type __a);
 
       static char_type 
-      to_char_type(const int_type& __c)
-      { return char_type(__c); }
+      to_char_type(const int_type& __c);
 
       static int_type 
-      to_int_type(const char_type& __c) { return int_type(__c); }
+      to_int_type(const char_type& __c);
 
       static bool 
-      eq_int_type(const int_type& __c1, const int_type& __c2)
-      { return __c1 == __c2; }
+      eq_int_type(const int_type& __c1, const int_type& __c2);
 
       static int_type 
-      eof() { return static_cast<int_type>(-1); }
+      eof()
 
       static int_type 
-      not_eof(const int_type& __c)
-      { return eq_int_type(__c, eof()) ? int_type(0) : __c; }
+      not_eof(const int_type& __c);
     };
 
 
index 3cb3e4b51a2614d0ee9efb572179097a793e992e..279e0ab16ba2e8b590351f032c55d9f04c73f518 100644 (file)
@@ -105,7 +105,7 @@ namespace std
       bool  
       operator!=(const fpos& __pos) const
       { return _M_off != __pos._M_off; }
-      
+
       streamoff 
       _M_position() const { return _M_off; }
 
index 5b7e8bf9eaedd04f2100e35966e68e6baf591cd1..2caeb6e5e5815cfe34b759fe36b22e3d7c654504 100644 (file)
@@ -112,7 +112,8 @@ namespace std
        {
          const int_type __eof = traits_type::eof();
          bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
-         if (__testput && _M_really_overflow(__eof) == __eof)
+         if (__testput 
+             && traits_type::eq_int_type(_M_really_overflow(__eof), __eof))
            return __ret;
 
          // NB: Do this here so that re-opened filebufs will be cool...
@@ -155,96 +156,6 @@ namespace std
       _M_last_overflowed = false;      
       return __ret;
     }
-
-  template<typename _CharT, typename _Traits>
-    typename basic_filebuf<_CharT, _Traits>::int_type 
-    basic_filebuf<_CharT, _Traits>::
-    _M_underflow_common(bool __bump)
-    {
-      int_type __ret = traits_type::eof();
-      bool __testin = _M_mode & ios_base::in;
-      bool __testout = _M_mode & ios_base::out;
-
-      if (__testin)
-       {
-         // Check for pback madness, and if so swich back to the
-         // normal buffers and jet outta here before expensive
-         // fileops happen...
-         if (_M_pback_init)
-           {
-             _M_pback_destroy();
-             if (_M_in_cur < _M_in_end)
-               return traits_type::to_int_type(*_M_in_cur);
-           }
-
-         // Sync internal and external buffers.
-         // NB: __testget -> __testput as _M_buf_unified here.
-         bool __testget = _M_in_cur && _M_in_beg < _M_in_cur;
-         bool __testinit = _M_is_indeterminate();
-         if (__testget)
-           {
-             if (__testout)
-               _M_really_overflow();
-             else if (_M_in_cur != _M_filepos)
-               _M_file.seekoff(_M_in_cur - _M_filepos,
-                               ios_base::cur, ios_base::in);
-           }
-
-         if (__testinit || __testget)
-           {
-             const locale __loc = this->getloc();
-             const __codecvt_type& __cvt = use_facet<__codecvt_type>(__loc); 
-
-             streamsize __elen = 0;
-             streamsize __ilen = 0;
-             if (__cvt.always_noconv())
-               {
-                 __elen = _M_file.xsgetn(reinterpret_cast<char*>(_M_in_beg), 
-                                         _M_buf_size);
-                 __ilen = __elen;
-               }
-             else
-               {
-                 char* __buf = static_cast<char*>(__builtin_alloca(_M_buf_size));
-                 __elen = _M_file.xsgetn(__buf, _M_buf_size);
-
-                 const char* __eend;
-                 char_type* __iend;
-                 __res_type __r = __cvt.in(_M_state_cur, __buf, 
-                                           __buf + __elen, __eend, _M_in_beg, 
-                                           _M_in_beg + _M_buf_size, __iend);
-                 if (__r == codecvt_base::ok)
-                   __ilen = __iend - _M_in_beg;
-                 else 
-                   {
-                     // Unwind.
-                     __ilen = 0;
-                     _M_file.seekoff(-__elen, ios_base::cur, ios_base::in);
-                   }
-               }
-
-             if (0 < __ilen)
-               {
-                 _M_set_determinate(__ilen);
-                 if (__testout)
-                   _M_out_cur = _M_in_cur;
-                 __ret = traits_type::to_int_type(*_M_in_cur);
-                 if (__bump)
-                   _M_in_cur_move(1);
-                 else if (_M_buf_size == 1)
-                   {
-                     // If we are synced with stdio, we have to unget the
-                     // character we just read so that the file pointer
-                     // doesn't move.
-                     _M_file.sys_ungetc(*_M_in_cur);
-                     _M_set_indeterminate();
-                   }
-               }          
-           }
-       }
-      _M_last_overflowed = false;      
-      return __ret;
-    }
   
   template<typename _CharT, typename _Traits>
     typename basic_filebuf<_CharT, _Traits>::int_type 
index fc0adea69e37c60550bcd4cc8c72d275562b595a..798fd332b90620aa0f1c65c2857f04e20f212c5d 100644 (file)
@@ -54,13 +54,14 @@ namespace std
              __int_type __c = __sb->sgetc();
 
              if (__in._M_check_facet(__in._M_fctype))
-               while (__c != __eof
-                      && __in._M_fctype->is(ctype_base::space, __c))
+               while (!traits_type::eq_int_type(__c, __eof)
+                      && __in._M_fctype->is(ctype_base::space, 
+                                            traits_type::to_char_type(__c)))
                  __c = __sb->snextc();
 
 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
 //195.  Should basic_istream::sentry's constructor ever set eofbit? 
-             if (__c == __eof)
+             if (traits_type::eq_int_type(__c, __eof))
                __in.setstate(ios_base::eofbit);
 #endif
            }
@@ -521,7 +522,7 @@ namespace std
            {
              __c = this->rdbuf()->sbumpc();
              // 27.6.1.1 paragraph 3
-             if (__c != __eof)
+             if (!traits_type::eq_int_type(__c, __eof))
                _M_gcount = 1;
              else
                this->setstate(ios_base::eofbit | ios_base::failbit);
@@ -552,7 +553,7 @@ namespace std
              const int_type __eof = traits_type::eof();
              int_type __bufval = this->rdbuf()->sbumpc();
              // 27.6.1.1 paragraph 3
-             if (__bufval != __eof)
+             if (!traits_type::eq_int_type(__bufval, __eof))
                {
                  _M_gcount = 1;
                  __c = traits_type::to_char_type(__bufval);
@@ -588,13 +589,15 @@ namespace std
              __streambuf_type* __sb = this->rdbuf();
              int_type __c = __sb->sgetc();     
              
-             while (_M_gcount + 1 < __n && __c != __eof && __c != __idelim)
+             while (_M_gcount + 1 < __n 
+                    && !traits_type::eq_int_type(__c, __eof)
+                    && !traits_type::eq_int_type(__c, __idelim))
                {
                  *__s++ = traits_type::to_char_type(__c);
                  __c = __sb->snextc();
                  ++_M_gcount;
                }
-             if (__c == __eof)
+             if (traits_type::eq_int_type(__c, __eof))
                this->setstate(ios_base::eofbit);
            }
          catch(exception& __fail)
@@ -627,14 +630,17 @@ namespace std
              const int_type __eof = traits_type::eof();              
              __streambuf_type* __this_sb = this->rdbuf();
              int_type __c = __this_sb->sgetc();
+             char_type __c2 = traits_type::to_char_type(__c);
              
-             while (__c != __eof && __c != __idelim 
-                    && (__sb.sputc(traits_type::to_char_type(__c)) != __eof))
+             while (!traits_type::eq_int_type(__c, __eof) 
+                    && !traits_type::eq_int_type(__c, __idelim) 
+                    && !traits_type::eq_int_type(__sb.sputc(__c2), __eof))
                {
                  ++_M_gcount;
                  __c = __this_sb->snextc();
+                 __c2 = traits_type::to_char_type(__c);
                }
-             if (__c == __eof)
+             if (traits_type::eq_int_type(__c, __eof))
                this->setstate(ios_base::eofbit);
            }
          catch(exception& __fail)
@@ -667,17 +673,19 @@ namespace std
              __streambuf_type* __sb = this->rdbuf();
              int_type __c = __sb->sgetc();
            
-             while (_M_gcount + 1 < __n && __c != __eof && __c != __idelim)
+             while (_M_gcount + 1 < __n 
+                    && !traits_type::eq_int_type(__c, __eof)
+                    && !traits_type::eq_int_type(__c, __idelim))
                {
                  *__s++ = traits_type::to_char_type(__c);
                  __c = __sb->snextc();
                  ++_M_gcount;
                }
-             if (__c == __eof)
+             if (traits_type::eq_int_type(__c, __eof))
                this->setstate(ios_base::eofbit);
              else
                {
-                 if (__c == __idelim)
+                 if (traits_type::eq_int_type(__c, __idelim))
                    {
                      __sb->sbumpc();
                      ++_M_gcount;
@@ -717,14 +725,16 @@ namespace std
              int_type __c = __sb->sgetc();     
              
              __n = min(__n, numeric_limits<streamsize>::max());
-             while (_M_gcount < __n  && __c !=__eof && __c != __delim)
+             while (_M_gcount < __n  
+                    && !traits_type::eq_int_type(__c, __eof) 
+                    && !traits_type::eq_int_type(__c, __delim))
                {
                  __c = __sb->snextc();
                  ++_M_gcount;
                }
-             if (__c == __eof)
+             if (traits_type::eq_int_type(__c, __eof))
                this->setstate(ios_base::eofbit);
-             else if (__c == __delim)
+             else if (traits_type::eq_int_type(__c, __delim))
                {
                  __sb->sbumpc();
                  ++_M_gcount;
@@ -806,9 +816,8 @@ namespace std
        {
          try 
            {
-             const int_type __eof = traits_type::eof(); 
              streamsize __num = this->rdbuf()->in_avail();
-             if (__num != static_cast<streamsize>(__eof))
+             if (__num > 0)
                {
                  __num = min(__num, __n);
                  if (__num)
@@ -843,7 +852,8 @@ namespace std
            {
              const int_type __eof = traits_type::eof();
              __streambuf_type* __sb = this->rdbuf();
-             if (!__sb || __sb->sputbackc(__c) == __eof) 
+             if (!__sb 
+                 || traits_type::eq_int_type(__sb->sputbackc(__c), __eof))
                this->setstate(ios_base::badbit);                   
            }
          catch(exception& __fail)
@@ -873,7 +883,8 @@ namespace std
            {
              const int_type __eof = traits_type::eof();
              __streambuf_type* __sb = this->rdbuf();
-             if (!__sb || __eof == __sb->sungetc())
+             if (!__sb 
+                 || traits_type::eq_int_type(__sb->sungetc(), __eof))
                this->setstate(ios_base::badbit);                   
            }
          catch(exception& __fail)
@@ -895,7 +906,7 @@ namespace std
     basic_istream<_CharT, _Traits>::
     sync(void)
     {
-      int __ret = traits_type::eof();
+      int __ret = -1;
       _M_gcount = 0;
       sentry __cerb(*this, true);
       if (__cerb) 
@@ -903,10 +914,13 @@ namespace std
          try 
            {
              __streambuf_type* __sb = this->rdbuf();
-             if (!__sb || __ret == __sb->pubsync())
-               this->setstate(ios_base::badbit);                   
-             else 
-               __ret = 0;
+             if (__sb)
+               {
+                 if (__sb->pubsync() == -1)
+                   this->setstate(ios_base::badbit);               
+                 else 
+                   __ret = 0;
+               }
            }
          catch(exception& __fail)
            {
@@ -1186,16 +1200,18 @@ namespace std
          __streambuf_type* __sb = __in.rdbuf();
          __int_type __c = __sb->sbumpc();
          const __int_type __eof = _Traits::eof();
-         __testdelim = __c ==  __idelim;
+         __testdelim = _Traits::eq_int_type(__c, __idelim);
 
-         while (__extracted <= __n && __c != __eof && !__testdelim)
+         while (__extracted <= __n 
+                && !_Traits::eq_int_type(__c, __eof)
+                && !__testdelim)
            {
              __str += _Traits::to_char_type(__c);
              ++__extracted;
              __c = __sb->sbumpc();
-             __testdelim = __c == __idelim;
+             __testdelim = _Traits::eq_int_type(__c, __idelim);
            }
-         if (__c == __eof)
+         if (_Traits::eq_int_type(__c, __eof))
            __in.setstate(ios_base::eofbit);
        }
       if (!__extracted && !__testdelim)
index 241c4655dc2856af73a44e1a5c614e3606eb90f0..159cecccdcb1adf8302a0527b7e27082efe2634d 100644 (file)
@@ -55,6 +55,9 @@ namespace std
 # define  _GLIBCPP_NUM_FACETS 14
 #endif
 
+  template<typename _CharT, typename _Traits>
+    struct __pad;
+
   // 22.2.1.1  Template class ctype
   // Include host and configuration specific ctype enums for ctype_base.
   #include <bits/ctype_base.h>
@@ -652,6 +655,7 @@ namespace std
       virtual iter_type 
       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
 
+
       virtual iter_type 
       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, long&) const;
 
@@ -697,6 +701,23 @@ namespace std
   template<typename _CharT, typename _InIter>
     locale::id num_get<_CharT, _InIter>::id;
 
+#if 0
+  // Partial specialization for istreambuf_iterator, so can use traits_type.
+  template<typename _CharT>
+    class num_get<_CharT, istreambuf_iterator<_CharT> >;
+
+      iter_type 
+      _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&, 
+                      string& __xtrc) const;
+
+      iter_type 
+      _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&, 
+                    string& __xtrc, int& __base) const;
+
+      virtual iter_type 
+      do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
+#endif
+
   template<typename _CharT, typename _OutIter>
     class num_put : public locale::facet, public __num_base
     {
index dea2fdfdac24b2f481dfe0b2cd8536c455e61b65..63e52c0058511997f885920db598dd8f35e057e2 100644 (file)
@@ -94,6 +94,7 @@ namespace std
     _M_extract_float(_InIter __beg, _InIter __end, ios_base& __io,
                     ios_base::iostate& __err, string& __xtrc) const
     {
+      typedef char_traits<_CharT>              __traits_type;
       const locale __loc = __io.getloc();
       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
       const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
@@ -103,7 +104,8 @@ namespace std
       const char_type __minus = __ctype.widen('-');
       int __pos = 0;
       char_type  __c = *__beg;
-      if ((__c == __plus || __c == __minus) && __beg != __end)
+      if ((__traits_type::eq(__c, __plus) || __traits_type::eq(__c, __minus))
+         && __beg != __end)
        {
          __xtrc += __ctype.narrow(__c, char());
          ++__pos;
@@ -113,7 +115,7 @@ namespace std
       // Next, strip leading zeros.
       const char_type __zero = __ctype.widen(_S_atoms[_M_zero]);
       bool __found_zero = false;
-      while (__c == __zero && __beg != __end)
+      while (__traits_type::eq(__c, __zero) && __beg != __end)
        {
          __c = *(++__beg);
          __found_zero = true;
@@ -141,11 +143,10 @@ namespace std
       while (__beg != __end)
         {
          // Only look in digits.
-         typedef char_traits<_CharT>   __traits_type;
           const char_type* __p = __traits_type::find(__watoms, 10,  __c);
 
           // NB: strchr returns true for __c == 0x0
-          if (__p && __c)
+          if (__p && !__traits_type::eq(__c, char_type()))
            {
              // Try first for acceptable digit; record it if found.
              ++__pos;
@@ -153,7 +154,8 @@ namespace std
              ++__sep_pos;
              __c = *(++__beg);
            }
-          else if (__c == __sep && __check_grouping && !__found_dec)
+          else if (__traits_type::eq(__c, __sep) 
+                  && __check_grouping && !__found_dec)
            {
               // NB: Thousands separator at the beginning of a string
               // is a no-no, as is two consecutive thousands separators.
@@ -169,7 +171,7 @@ namespace std
                  break;
                }
             }
-         else if (__c == __dec && !__found_dec)
+         else if (__traits_type::eq(__c, __dec) && !__found_dec)
            {
              // According to the standard, if no grouping chars are seen,
              // no grouping check is applied. Therefore __found_grouping
@@ -181,7 +183,8 @@ namespace std
              __c = *(++__beg);
              __found_dec = true;
            }
-         else if ((__c == __watoms[_M_e] || __c == __watoms[_M_E]) 
+         else if ((__traits_type::eq(__c, __watoms[_M_e]) 
+                   || __traits_type::eq(__c, __watoms[_M_E])) 
                   && !__found_sci && __pos)
            {
              // Scientific notation.
@@ -190,7 +193,8 @@ namespace std
              __c = *(++__beg);
 
              // Remove optional plus or minus sign, if they exist.
-             if (__c == __plus || __c == __minus)
+             if (__traits_type::eq(__c, __plus) 
+                 || __traits_type::eq(__c, __minus))
                {
                  ++__pos;
                  __xtrc += __ctype.narrow(__c, char());
@@ -228,6 +232,7 @@ namespace std
     _M_extract_int(_InIter __beg, _InIter __end, ios_base& __io,
                   ios_base::iostate& __err, string& __xtrc, int& __base) const
     {
+      typedef char_traits<_CharT>              __traits_type;
       const locale __loc = __io.getloc();
       const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
       const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
@@ -241,10 +246,13 @@ namespace std
       else
        __base = 10;
 
-     // First check for sign.
+      // First check for sign.
       int __pos = 0;
       char_type  __c = *__beg;
-      if ((__c == __ctype.widen('+') || __c == __ctype.widen('-'))
+      const char_type __plus = __ctype.widen('+');
+      const char_type __minus = __ctype.widen('-');
+
+      if ((__traits_type::eq(__c, __plus) || __traits_type::eq(__c, __minus))
          && __beg != __end)
        {
          __xtrc += __ctype.narrow(__c, char());
@@ -259,7 +267,7 @@ namespace std
       if (__base == 10)
        {
          bool __found_zero = false;
-         while (__c == __zero && __beg != __end)
+         while (__traits_type::eq(__c, __zero) && __beg != __end)
            {
              __c = *(++__beg);
              __found_zero = true;
@@ -270,7 +278,9 @@ namespace std
              ++__pos;
              if (__basefield == 0)
                {             
-                 if ((__c == __x || __c == __X) && __beg != __end)
+                 if ((__traits_type::eq(__c, __x) 
+                      || __traits_type::eq(__c, __X))
+                     && __beg != __end)
                    {
                      __xtrc += __ctype.narrow(__c, char());
                      ++__pos;
@@ -284,12 +294,13 @@ namespace std
        }
       else if (__base == 16)
        {
-         if (__c == __zero && __beg != __end)
+         if (__traits_type::eq(__c, __zero) && __beg != __end)
            {
              __xtrc += _S_atoms[_M_zero];
              ++__pos;
              __c = *(++__beg); 
-             if  ((__c == __x || __c == __X) && __beg != __end)
+             if ((__traits_type::eq(__c, __x) || __traits_type::eq(__c, __X))
+                 && __beg != __end)
                {
                  __xtrc += __ctype.narrow(__c, char());
                  ++__pos;
@@ -316,11 +327,10 @@ namespace std
       const char_type __sep = __np.thousands_sep();
       while (__beg != __end)
         {
-         typedef char_traits<_CharT>   __traits_type;
           const char_type* __p = __traits_type::find(__watoms, __len,  __c);
 
           // NB: strchr returns true for __c == 0x0
-          if (__p && __c)
+          if (__p && !__traits_type::eq(__c, char_type()))
            {
              // Try first for acceptable digit; record it if found.
              __xtrc += _S_atoms[__p - __watoms];
@@ -328,7 +338,7 @@ namespace std
              ++__sep_pos;
              __c = *(++__beg);
            }
-          else if (__c == __sep && __check_grouping)
+          else if (__traits_type::eq(__c, __sep) && __check_grouping)
            {
               // NB: Thousands separator at the beginning of a string
               // is a no-no, as is two consecutive thousands separators.
@@ -394,7 +404,9 @@ namespace std
       // Parse bool values as alphanumeric
       else
         {
-         typedef basic_string<_CharT> __string_type;
+         typedef char_traits<_CharT>           __traits_type;
+         typedef basic_string<_CharT>          __string_type;
+
           locale __loc = __io.getloc();
          const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc); 
          const __string_type __true = __np.truename();
@@ -407,8 +419,10 @@ namespace std
           for (size_t __n = 0; __beg != __end; ++__n)
             {
               char_type __c = *__beg++;
-              bool __testf = __n <= __falsen ? __c == __falses[__n] : false;
-              bool __testt = __n <= __truen ? __c == __trues[__n] : false;
+              bool __testf = __n <= __falsen 
+                            ? __traits_type::eq(__c, __falses[__n]) : false;
+              bool __testt = __n <= __truen 
+                            ? __traits_type::eq(__c, __trues[__n]) : false;
               if (!(__testf || __testt))
                 {
                   __err |= ios_base::failbit;
@@ -708,6 +722,7 @@ namespace std
     _M_widen_float(_OutIter __s, ios_base& __io, _CharT __fill, char* __cs, 
                   int __len) const
     {
+      typedef char_traits<_CharT>              __traits_type;
       // [22.2.2.2.2] Stage 2, convert to char_type, using correct
       // numpunct.decimal_point() values for '.' and adding grouping.
       const locale __loc = __io.getloc();
@@ -723,7 +738,7 @@ namespace std
       // Replace decimal point.
       const _CharT* __p;
       const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
-      if (__p = char_traits<_CharT>::find(__ws, __len, __ctype.widen('.')))
+      if (__p = __traits_type::find(__ws, __len, __ctype.widen('.')))
        __ws[__p - __ws] = __np.decimal_point();
 
 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
@@ -744,7 +759,7 @@ namespace std
          // Tack on decimal part.
          if (__p)
            {
-             char_traits<_CharT>::copy(__p2, __p, __len - __declen);
+             __traits_type::copy(__p2, __p, __len - __declen);
              __newlen += __len - __declen;
            }    
 
@@ -816,13 +831,15 @@ namespace std
     _M_insert(_OutIter __s, ios_base& __io, _CharT __fill, const _CharT* __ws, 
              int __len) const
     {
+      typedef char_traits<_CharT>              __traits_type;
       // [22.2.2.2.2] Stage 3.
       streamsize __w = __io.width();
       _CharT* __ws2 = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) 
                                                            * __w));
       if (__w > static_cast<streamsize>(__len))
        {
-         __pad(__io, __fill, __ws2, __ws, __w, __len, true);
+         __pad<_CharT, __traits_type>::_S_pad(__io, __fill, __ws2, __ws, 
+                                              __w, __len, true);
          __len = static_cast<int>(__w);
          // Switch strings.
          __ws = __ws2;
@@ -845,7 +862,7 @@ namespace std
       if ((__flags & ios_base::boolalpha) == 0)
         {
           unsigned long __uv = __v;
-          __s = _M_convert_int(__s, __io, __fill, 'u', char_type(), __uv);
+          __s = _M_convert_int(__s, __io, __fill, 'u', char(), __uv);
         }
       else
         {
@@ -866,14 +883,14 @@ namespace std
     _OutIter
     num_put<_CharT, _OutIter>::
     do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
-    { return _M_convert_int(__s, __io, __fill, 'd', char_type(), __v); }
+    { return _M_convert_int(__s, __io, __fill, 'd', char(), __v); }
 
   template<typename _CharT, typename _OutIter>
     _OutIter
     num_put<_CharT, _OutIter>::
     do_put(iter_type __s, ios_base& __io, char_type __fill,
            unsigned long __v) const
-    { return _M_convert_int(__s, __io, __fill, 'u', char_type(), __v); }
+    { return _M_convert_int(__s, __io, __fill, 'u', char(), __v); }
 
 #ifdef _GLIBCPP_USE_LONG_LONG
   template<typename _CharT, typename _OutIter>
@@ -894,7 +911,7 @@ namespace std
     _OutIter
     num_put<_CharT, _OutIter>::
     do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
-    { return _M_convert_float(__s, __io, __fill, char_type(), __v); }
+    { return _M_convert_float(__s, __io, __fill, char(), __v); }
 
   template<typename _CharT, typename _OutIter>
     _OutIter
@@ -915,7 +932,7 @@ namespace std
       __io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase));
       try 
        {
-         __s = _M_convert_int(__s, __io, __fill, 'u', char_type(),
+         __s = _M_convert_int(__s, __io, __fill, 'u', char(),
                               reinterpret_cast<unsigned long>(__v));
          __io.flags(__flags);
        }
@@ -1591,7 +1608,7 @@ namespace std
                    const _CharT** __names, size_t __indexlen, 
                    ios_base::iostate& __err) const
     {
-      typedef char_traits<char_type> __traits_type;
+      typedef char_traits<_CharT>              __traits_type;
       int* __matches = static_cast<int*>(__builtin_alloca(sizeof(int) * __indexlen));
       size_t __nmatches = 0;
       size_t __pos = 0;
@@ -1686,7 +1703,7 @@ namespace std
     do_get_weekday(iter_type __beg, iter_type __end, ios_base& __io, 
                   ios_base::iostate& __err, tm* __tm) const
     {
-      typedef char_traits<char_type> __traits_type;
+      typedef char_traits<_CharT>              __traits_type;
       locale __loc = __io.getloc();
       __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
       const char_type*  __days[7];
@@ -1729,7 +1746,7 @@ namespace std
     do_get_monthname(iter_type __beg, iter_type __end,
                      ios_base& __io, ios_base::iostate& __err, tm* __tm) const
     {
-      typedef char_traits<char_type> __traits_type;
+      typedef char_traits<_CharT>              __traits_type;
       locale __loc = __io.getloc();
       __timepunct<_CharT> const& __tp = use_facet<__timepunct<_CharT> >(__loc);
       const char_type*  __months[12];
@@ -1996,22 +2013,31 @@ namespace std
   // internal-adjusted objects are padded according to the rules below
   // concerning 0[xX] and +-, otherwise, exactly as right-adjusted
   // ones are.
+
+  // NB: Of the two parameters, _CharT can be deduced from the
+  // function arguments. The other (_Traits) has to be explicitly specified.
   template<typename _CharT, typename _Traits>
-    void
-    __pad(ios_base& __io, _CharT __fill, _CharT* __news, const _CharT* __olds,
-         const streamsize __newlen, const streamsize __oldlen, 
-         const bool __num)
+    struct __pad
     {
-      typedef _CharT   char_type;
-      typedef _Traits  traits_type;
-      typedef typename traits_type::int_type int_type;
-      
-      int_type __plen = static_cast<size_t>(__newlen - __oldlen); 
-      char_type* __pads = static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __plen));
-      traits_type::assign(__pads, __plen, __fill); 
+      static void
+      _S_pad(ios_base& __io, _CharT __fill, _CharT* __news, 
+            const _CharT* __olds, const streamsize __newlen, 
+            const streamsize __oldlen, const bool __num);
+    };
 
-      char_type* __beg;
-      char_type* __end;
+  template<typename _CharT, typename _Traits>
+    void 
+    __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill, 
+                                  _CharT* __news, const _CharT* __olds, 
+                                  const streamsize __newlen, 
+                                  const streamsize __oldlen, const bool __num)
+    {
+      size_t __plen = static_cast<size_t>(__newlen - __oldlen);
+      _CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __plen));
+      _Traits::assign(__pads, __plen, __fill); 
+
+      _CharT* __beg;
+      _CharT* __end;
       size_t __mod = 0;
       size_t __beglen; //either __plen or __oldlen
       ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield;
@@ -2019,7 +2045,7 @@ namespace std
       if (__adjust == ios_base::left)
        {
          // Padding last.
-         __beg = const_cast<char_type*>(__olds);
+         __beg = const_cast<_CharT*>(__olds);
          __beglen = __oldlen;
          __end = __pads;
        }
@@ -2030,12 +2056,14 @@ namespace std
          // Who came up with these rules, anyway? Jeeze.
           locale __loc = __io.getloc();
          const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); 
-         const char_type __minus = __ctype.widen('-');
-         const char_type __plus = __ctype.widen('+');
-         bool __testsign = __olds[0] == __minus || __olds[0] == __plus;
-         bool __testhex = __ctype.widen('0') == __olds[0] 
-                          && (__ctype.widen('x') == __olds[1] 
-                              || __ctype.widen('X') == __olds[1]);
+         const _CharT __minus = __ctype.widen('-');
+         const _CharT __plus = __ctype.widen('+');
+         bool __testsign = _Traits::eq(__olds[0], __minus)
+                           || _Traits::eq(__olds[0], __plus);
+
+         bool __testhex = _Traits::eq(__ctype.widen('0'), __olds[0]) 
+                          && (_Traits::eq(__ctype.widen('x'), __olds[1]) 
+                              || _Traits::eq(__ctype.widen('X'), __olds[1]));
          if (__testhex)
            {
              __news[0] = __olds[0]; 
@@ -2044,23 +2072,23 @@ namespace std
              __news += 2;
              __beg = __pads;
              __beglen = __plen;
-             __end = const_cast<char_type*>(__olds + __mod);
+             __end = const_cast<_CharT*>(__olds + __mod);
            }
          else if (__testsign)
            {
-             __news[0] = __olds[0] == __plus ? __plus : __minus;
+             _Traits::eq((__news[0] = __olds[0]), __plus) ? __plus : __minus;
              ++__mod;
              ++__news;
              __beg = __pads;
              __beglen = __plen;
-             __end = const_cast<char_type*>(__olds + __mod);
+             __end = const_cast<_CharT*>(__olds + __mod);
            }
          else
            {
              // Padding first.
              __beg = __pads;
              __beglen = __plen;
-             __end = const_cast<char_type*>(__olds);
+             __end = const_cast<_CharT*>(__olds);
            }
        }
       else
@@ -2068,23 +2096,11 @@ namespace std
          // Padding first.
          __beg = __pads;
          __beglen = __plen;
-         __end = const_cast<char_type*>(__olds);
+         __end = const_cast<_CharT*>(__olds);
        }
-      traits_type::copy(__news, __beg, __beglen);
-      traits_type::copy(__news + __beglen, __end, __newlen - __beglen - __mod);
-    }
-
-  // NB: Can't have default argument on non-member template, and
-  // num_put doesn't have a _Traits template parameter, so this
-  // forwarding template adds in the default template argument.
-  template<typename _CharT>
-    void
-    __pad(ios_base& __io, _CharT __fill, _CharT* __news, const _CharT* __olds,
-         const streamsize __newlen, const streamsize __oldlen, 
-         const bool __num)
-    { 
-      return __pad<_CharT, char_traits<_CharT> >(__io, __fill, __news, __olds,
-                                                __newlen, __oldlen, __num); 
+      _Traits::copy(__news, __beg, __beglen);
+      _Traits::copy(__news + __beglen, __end, 
+                         __newlen - __beglen - __mod);
     }
 
   // Used by both numeric and monetary facets.
@@ -2401,5 +2417,3 @@ namespace std
 } // namespace std
 
 #endif
-
-
index ce90dafa20972ac541e3e86bbd12b247679e67d2..e42eca29192f2ce01e51a567c937db439cc168b5 100644 (file)
@@ -474,7 +474,8 @@ namespace std
              streamsize __len = 1;
              if (__w > __len)
                {
-                 __pad(__out, __out.fill(), __pads, &__c, __w, __len, false);
+                 __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __pads, 
+                                                &__c, __w, __len, false);
                  __len = __w;
                }
              __out.write(__pads, __len);
@@ -509,7 +510,8 @@ namespace std
              streamsize __len = 1;
              if (__w > __len)
                {
-                 __pad(__out, __out.fill(), __pads, &__c, __w, __len, false);
+                 __pad<char, _Traits>::_S_pad(__out, __out.fill(), __pads, 
+                                              &__c, __w, __len, false);
                  __len = __w;
                }
              __out.write(__pads, __len);
@@ -542,7 +544,8 @@ namespace std
              streamsize __len = static_cast<streamsize>(_Traits::length(__s));
              if (__w > __len)
                {
-                 __pad(__out, __out.fill(), __pads, __s, __w, __len, false);
+                 __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __pads, 
+                                                __s, __w, __len, false);
                  __s = __pads;
                  __len = __w;
                }
@@ -590,7 +593,8 @@ namespace std
              
              if (__w > __len)
                {
-                 __pad(__out, __out.fill(), __pads, __ws, __w, __len, false);
+                 __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __pads, 
+                                                __ws, __w, __len, false);
                  __str = __pads;
                  __len = __w;
                }
@@ -628,7 +632,8 @@ namespace std
 
              if (__w > __len)
                {
-                 __pad(__out, __out.fill(), __pads, __s, __w, __len, false);
+                 __pad<char, _Traits>::_S_pad(__out, __out.fill(), __pads, 
+                                                __s, __w, __len, false);
                  __s = __pads;
                  __len = __w;
                }
@@ -668,7 +673,8 @@ namespace std
 #endif
          if (__w > __len)
            {
-             __pad(__out, __out.fill(), __pads, __s, __w, __len, false);
+             __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __pads, __s, 
+                                            __w, __len, false);
              __s = __pads;
              __len = __w;
            }
index fd56347a7a4afa9f21c42d2ad81cfc92d57b66c0..99eb6af125f576a3fc26ce93641ee9383cbb0a3f 100644 (file)
@@ -184,7 +184,7 @@ namespace std
       
       if (_M_buf_size)
        {
-         off_type __pos = __sp._M_position();
+         off_type __pos = __sp; // Use streamoff operator to do conversion.
          char_type* __beg = NULL;
          char_type* __end = NULL;
          bool __testin = (ios_base::in & _M_mode & __mode) != 0;
index 659caecb2aff26ace097e4f8730328a8648e9ce6..152df9c6e4b993ad91272e2cfdaea31d27df423c 100644 (file)
@@ -69,13 +69,13 @@ namespace std
 
     public:
       istreambuf_iterator() throw() 
-      : _M_sbuf(0), _M_c(-2) { }
+      : _M_sbuf(0), _M_c(traits_type::eof()) { }
       
       istreambuf_iterator(istream_type& __s) throw()
-      : _M_sbuf(__s.rdbuf()), _M_c(-2) { }
+      : _M_sbuf(__s.rdbuf()), _M_c(traits_type::eof()) { }
 
       istreambuf_iterator(streambuf_type* __s) throw()
-      : _M_sbuf(__s), _M_c(-2) { }
+      : _M_sbuf(__s), _M_c(traits_type::eof()) { }
        
       // NB: The result of operator*() on an end of stream is undefined.
       char_type 
@@ -85,21 +85,25 @@ namespace std
       istreambuf_iterator& 
       operator++()
       { 
-       if (_M_sbuf && _M_sbuf->sbumpc() == traits_type::eof())
+       const int_type __eof = traits_type::eof();
+       if (_M_sbuf && traits_type::eq_int_type(_M_sbuf->sbumpc(), __eof))
          _M_sbuf = 0;
        else
-         _M_c = -2;
+         _M_c = __eof;
        return *this; 
       }
 
       istreambuf_iterator
       operator++(int)
       {
+       const int_type __eof = traits_type::eof();
        istreambuf_iterator __old = *this;
-       if (_M_sbuf && (__old._M_c = _M_sbuf->sbumpc()) == traits_type::eof())
+       if (_M_sbuf
+           && traits_type::eq_int_type((__old._M_c = _M_sbuf->sbumpc()), 
+                                       __eof))
          _M_sbuf = 0;
        else
-         _M_c = -2;
+         _M_c = __eof;
        return __old; 
       }
 
@@ -110,8 +114,8 @@ namespace std
       equal(const istreambuf_iterator& __b) const
       {
        const int_type __eof = traits_type::eof();
-       bool __thiseof = _M_get() == __eof;
-       bool __beof = __b._M_get() == __eof;
+       bool __thiseof = traits_type::eq_int_type(_M_get(), __eof);
+       bool __beof = traits_type::eq_int_type(__b._M_get(), __eof);
        return (__thiseof && __beof || (!__thiseof && !__beof));
       }
 #endif
@@ -120,13 +124,14 @@ namespace std
       int_type 
       _M_get() const
       { 
-       int_type __ret = traits_type::eof();
+       const int_type __eof = traits_type::eof();
+       int_type __ret = __eof;
        if (_M_sbuf)
          { 
-           if (_M_c != static_cast<int_type>(-2))
+           if (!traits_type::eq_int_type(_M_c, __eof))
              __ret = _M_c;
            else 
-             if ((__ret = _M_sbuf->sgetc()) == traits_type::eof())
+             if (traits_type::eq_int_type((__ret = _M_sbuf->sgetc()), __eof))
                _M_sbuf = 0;
          }
        return __ret;
index fb95965a06af3b5593c3ce262f7973a65bfc9640..c3861051d40b8bff745722521b78c35099559fda 100644 (file)
@@ -286,7 +286,16 @@ namespace std
       }
     };
 
-
+  // Explicit specializations.
+  template<> 
+    basic_filebuf<char>::int_type 
+    basic_filebuf<char>::_M_underflow_common(bool __bump);
+
+ #ifdef _GLIBCPP_USE_WCHAR_T
+  template<> 
+    basic_filebuf<wchar_t>::int_type 
+    basic_filebuf<wchar_t>::_M_underflow_common(bool __bump);
+ #endif
 
   // 27.8.1.5  Template class basic_ifstream
   /**
index 0270c181c126c988519e1fdd7f79f4792afe8e06..491570ec59314c5e1d7996fb7244fa7b1847a76b 100644 (file)
@@ -71,6 +71,7 @@ namespace std
       // Non-standard Types:
       typedef ctype<char_type>                         __ctype_type;
       typedef basic_streambuf<char_type, traits_type>          __streambuf_type;
+      typedef typename traits_type::state_type                 __state_type;
       
       friend class basic_ios<char_type, traits_type>;
       friend class basic_istream<char_type, traits_type>;
@@ -132,6 +133,9 @@ namespace std
       char_type*               _M_pback_end_save;
       bool                     _M_pback_init; 
 
+      // Yet unused.
+      fpos<__state_type>       _M_pos;
+
       // Initializes pback buffers, and moves normal buffers to safety.
       // Assumptions:
       // _M_in_cur has already been moved back
index dd6b774116e1645937f525bb686b28add5296f0c..371b77ef2b8736cd870e1e7925e249ab260f4687 100644 (file)
@@ -1,6 +1,6 @@
 // new abi support -*- C++ -*-
   
-// Copyright (C) 2000 Free Software Foundation, Inc.
+// Copyright (C) 2000, 2002 Free Software Foundation, Inc.
 //
 // This file is part of GNU CC.
 //
@@ -117,7 +117,7 @@ class __pbase_type_info
 {
 /* abi defined member variables */
 public:
-  unsigned int __qualifier_flags; /* qualification of the target object */
+  unsigned int __flags; /* qualification of the target object */
   const std::type_info *__pointee;   /* type of pointed to object */
 
 /* abi defined member functions */
@@ -127,12 +127,12 @@ public:
   explicit __pbase_type_info (const char *__n,
                                 int __quals,
                                 const std::type_info *__type)
-    : std::type_info (__n), __qualifier_flags (__quals), __pointee (__type)
+    : std::type_info (__n), __flags (__quals), __pointee (__type)
     { }
 
 /* implementation defined types */
 public:
-  enum __qualifier_masks {
+  enum __masks {
     __const_mask = 0x1,
     __volatile_mask = 0x2,
     __restrict_mask = 0x4,
@@ -181,7 +181,7 @@ class __pointer_to_member_type_info
 {
 /* abi defined member variables */
 public:
-  __class_type_info *__context_class;   /* class of the member */
+  __class_type_info *__context;   /* class of the member */
 
 /* abi defined member functions */
 public:
@@ -191,7 +191,7 @@ public:
                                           int __quals,
                                           const std::type_info *__type,
                                           __class_type_info *__klass)
-    : __pbase_type_info (__n, __quals, __type), __context_class (__klass)
+    : __pbase_type_info (__n, __quals, __type), __context (__klass)
     { }
 
 /* implementation defined member functions */
@@ -204,11 +204,11 @@ protected:
 class __class_type_info;
 
 /* helper class for __vmi_class_type */
-class __base_class_info
+class __base_class_type_info
 {
 /* abi defined member variables */
 public:
-  const __class_type_info *__base;    /* base class type */
+  const __class_type_info* __base_type;    /* base class type */
   long __offset_flags;            /* offset and info */
 
 /* implementation defined types */
@@ -216,8 +216,8 @@ public:
   enum __offset_flags_masks {
     __virtual_mask = 0x1,
     __public_mask = 0x2,
-    hwm_bit = 2,
-    offset_shift = 8          /* bits to shift offset by */
+    __hwm_bit = 2,
+    __offset_shift = 8          /* bits to shift offset by */
   };
   
 /* implementation defined member functions */
@@ -230,7 +230,7 @@ public:
     { 
       // This shift, being of a signed type, is implementation defined. GCC
       // implements such shifts as arithmetic, which is what we want.
-      return static_cast<__PTRDIFF_TYPE__> (__offset_flags) >> offset_shift;
+      return static_cast<__PTRDIFF_TYPE__> (__offset_flags) >> __offset_shift;
     }
 };
 
@@ -259,9 +259,9 @@ public:
                                 /* publicly) */
     __contained_ambig,          /* contained ambiguously */
     
-    __contained_virtual_mask = __base_class_info::__virtual_mask, /* via a virtual path */
-    __contained_public_mask = __base_class_info::__public_mask,   /* via a public path */
-    __contained_mask = 1 << __base_class_info::hwm_bit,         /* contained within us */
+    __contained_virtual_mask = __base_class_type_info::__virtual_mask, /* via a virtual path */
+    __contained_public_mask = __base_class_type_info::__public_mask,   /* via a public path */
+    __contained_mask = 1 << __base_class_type_info::__hwm_bit,         /* contained within us */
     
     __contained_private = __contained_mask,
     __contained_public = __contained_mask | __contained_public_mask
@@ -365,7 +365,7 @@ class __vmi_class_type_info : public __class_type_info {
 public:
   unsigned int __flags;         /* details about the class hierarchy */
   unsigned int __base_count;    /* number of direct bases */
-  __base_class_info const __base_info[1]; /* array of bases */
+  __base_class_type_info __base_info[1]; /* array of bases */
   /* The array of bases uses the trailing array struct hack
      so this class is not constructable with a normal constructor. It is
      internally generated by the compiler. */
index 1eecdeb41a15feab2437883c2e8df5703e6026ad..be041048a602bf971f217b7718e596881eed3b6a 100644 (file)
@@ -295,7 +295,7 @@ __do_find_public_src (ptrdiff_t src2dst,
         }
       base = convert_to_base (base, is_virtual, offset);
       
-      __sub_kind base_kind = __base_info[i].__base->__do_find_public_src
+      __sub_kind base_kind = __base_info[i].__base_type->__do_find_public_src
                               (src2dst, base, src_type, src_ptr);
       if (contained_p (base_kind))
         {
@@ -432,7 +432,7 @@ __do_dyncast (ptrdiff_t src2dst,
         }
       
       bool result2_ambig
-          = __base_info[i].__base->__do_dyncast (src2dst, base_access,
+          = __base_info[i].__base_type->__do_dyncast (src2dst, base_access,
                                              dst_type, base,
                                              src_type, src_ptr, result2);
       result.whole2src = __sub_kind (result.whole2src | result2.whole2src);
@@ -616,10 +616,10 @@ __do_upcast (const __class_type_info *dst, const void *obj_ptr,
       if (base)
         base = convert_to_base (base, is_virtual, offset);
       
-      if (__base_info[i].__base->__do_upcast (dst, base, result2))
+      if (__base_info[i].__base_type->__do_upcast (dst, base, result2))
         {
           if (result2.base_type == nonvirtual_base_type && is_virtual)
-            result2.base_type = __base_info[i].__base;
+            result2.base_type = __base_info[i].__base_type;
           if (contained_p (result2.part2dst) && !is_public)
             result2.part2dst = __sub_kind (result2.part2dst & ~__contained_public_mask);
           
index 8f3d6319c3826c530cf7ca3fc360369cdca9fb68..600cdf6ae4400322adee7b18c4f586df3053b83d 100644 (file)
@@ -1,6 +1,6 @@
 // Methods for type_info for -*- C++ -*- Run Time Type Identification.
 
-// Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001 
+// Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001, 2002
 // Free Software Foundation
 //
 // This file is part of GNU CC.
@@ -116,11 +116,11 @@ __do_catch (const type_info *thr_type,
   const __pbase_type_info *thrown_type =
     static_cast <const __pbase_type_info *> (thr_type);
   
-  if (thrown_type->__qualifier_flags & ~__qualifier_flags)
+  if (thrown_type->__flags & ~__flags)
     // We're less qualified.
     return false;
   
-  if (!(__qualifier_flags & __const_mask))
+  if (!(__flags & __const_mask))
     outer &= ~1;
   
   return __pointer_catch (thrown_type, thr_obj, outer);
@@ -158,7 +158,7 @@ __pointer_catch (const __pbase_type_info *thr_type,
   const __pointer_to_member_type_info *thrown_type =
     static_cast <const __pointer_to_member_type_info *> (thr_type);
   
-  if (*__context_class != *thrown_type->__context_class)
+  if (*__context != *thrown_type->__context)
     return false;     // not pointers to member of same class
   
   return __pbase_type_info::__pointer_catch (thrown_type, thr_obj, outer);
index e8fca80a517451be0d7878af27a014e2816eac7c..4e2404173dd771bc9c7b0811ee0c09db828c9901 100644 (file)
@@ -69,8 +69,8 @@ sources = \
        collate.cc ctype.cc messages.cc monetary.cc numeric.cc time.cc \
        concept-inst.cc locale-inst.cc misc-inst.cc stl-inst.cc \
        string-inst.cc wstring-inst.cc valarray-inst.cc  ext-inst.cc \
-       fstream-inst.cc io-inst.cc istream-inst.cc ostream-inst.cc \
-       streambuf-inst.cc sstream-inst.cc
+       fstream.cc fstream-inst.cc io-inst.cc istream-inst.cc \
+       ostream-inst.cc streambuf-inst.cc sstream-inst.cc
 
 VPATH = $(top_srcdir)/src:$(top_srcdir)
 
index 0d849679067d89f80d947bc8a9a2cf2c96d93d8d..46fffcbd165eb60ff4936235cd9537191c9e348d 100644 (file)
@@ -174,8 +174,8 @@ sources = \
        collate.cc ctype.cc messages.cc monetary.cc numeric.cc time.cc \
        concept-inst.cc locale-inst.cc misc-inst.cc stl-inst.cc \
        string-inst.cc wstring-inst.cc valarray-inst.cc  ext-inst.cc \
-       fstream-inst.cc io-inst.cc istream-inst.cc ostream-inst.cc \
-       streambuf-inst.cc sstream-inst.cc
+       fstream.cc fstream-inst.cc io-inst.cc istream-inst.cc \
+       ostream-inst.cc streambuf-inst.cc sstream-inst.cc
 
 
 VPATH = $(top_srcdir)/src:$(top_srcdir)
@@ -258,8 +258,8 @@ ios.lo strstream.lo bitset.lo functexcept.lo stdexcept.lo vterminate.lo \
 c++locale.lo locale.lo localename.lo codecvt.lo collate.lo ctype.lo \
 messages.lo monetary.lo numeric.lo time.lo concept-inst.lo \
 locale-inst.lo misc-inst.lo stl-inst.lo string-inst.lo wstring-inst.lo \
-valarray-inst.lo ext-inst.lo fstream-inst.lo io-inst.lo istream-inst.lo \
-ostream-inst.lo streambuf-inst.lo sstream-inst.lo
+valarray-inst.lo ext-inst.lo fstream.lo fstream-inst.lo io-inst.lo \
+istream-inst.lo ostream-inst.lo streambuf-inst.lo sstream-inst.lo
 CXXFLAGS = @CXXFLAGS@
 CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
 CXXLD = $(CXX)
index 10f45eca0a0709efde5016b397e68408d1e9afb1..5e6c6751bc449bbd86fafd65197da72308552583 100644 (file)
@@ -420,15 +420,7 @@ namespace std
     bool
     __verify_grouping<char>(const basic_string<char>&, basic_string<char>&);
 
-  template
-    void 
-    __pad<char>(ios_base&, char, char*, const char *, streamsize, 
-               streamsize, const bool);
-
-  template
-    void 
-    __pad<char, char_traits<char> >(ios_base&, char, char*, const char *, 
-                                   streamsize, streamsize, const bool);
+  template class __pad<char, char_traits<char> >;
 
 #ifdef _GLIBCPP_USE_WCHAR_T
   template
@@ -440,29 +432,23 @@ namespace std
     __verify_grouping<wchar_t>(const basic_string<wchar_t>&, 
                               basic_string<wchar_t>&);
 
-  template
-    void 
-    __pad<wchar_t>(ios_base&, wchar_t, wchar_t*, const wchar_t*, 
-                  streamsize, streamsize, const bool);
-
-  template
-    void 
-    __pad<wchar_t, char_traits<wchar_t> >(ios_base&, wchar_t, wchar_t*, 
-                                         const wchar_t*, streamsize, 
-                                         streamsize, const bool);
-#endif // _GLIBCPP_USE_WCHAR_T
+  template class __pad<wchar_t, char_traits<wchar_t> >;
+#endif 
 
   template
     int
-    __convert_from_v(char*, const int, const char*, double, const __c_locale&, int);
+    __convert_from_v(char*, const int, const char*, double, 
+                    const __c_locale&, int);
 
   template
     int
-    __convert_from_v(char*, const int, const char*, long double, const __c_locale&, int);
+    __convert_from_v(char*, const int, const char*, long double, 
+                    const __c_locale&, int);
 
   template
     int
-    __convert_from_v(char*, const int, const char*, long, const __c_locale&, int);
+    __convert_from_v(char*, const int, const char*, long, 
+                    const __c_locale&, int);
 
   template
     int
@@ -471,7 +457,8 @@ namespace std
 
   template
     int
-    __convert_from_v(char*, const int, const char*, long long, const __c_locale&, int);
+    __convert_from_v(char*, const int, const char*, long long, 
+                    const __c_locale&, int);
 
   template
     int
index 3cb9d1b4cbfd1f569b700add610f38263c66b364..3c755bbcba4dbdd5eba3618798e33a7389782841 100644 (file)
@@ -284,11 +284,11 @@ namespace std
   const locale&
   locale::classic()
   {
-    static _STL_mutex_lock __lock __STL_MUTEX_INITIALIZER;
-    _STL_auto_lock __auto(__lock);
-
     if (!_S_classic)
       {
+       static _STL_mutex_lock __lock __STL_MUTEX_INITIALIZER;
+       _STL_auto_lock __auto(__lock);
+
        try 
          {
            // 26 Standard facets, 2 references.
index 85aed1d0ae25d40d81e2c23dc874c81bf367e297..6ffaa06f9e44343118d70c61abb02976a695a1cb 100644 (file)
@@ -36,6 +36,93 @@ template<typename T>
 
 struct B { };
 
+// char_traits specialization
+namespace std
+{
+  template<>
+    struct char_traits<A<B> >
+    {
+      typedef A<B>             char_type;
+      // Unsigned as wint_t in unsigned.
+      typedef unsigned long    int_type;
+      typedef streampos        pos_type;
+      typedef streamoff        off_type;
+      typedef mbstate_t        state_type;
+      
+      static void 
+      assign(char_type& __c1, const char_type& __c2)
+      { __c1 = __c2; }
+
+      static bool 
+      eq(const char_type& __c1, const char_type& __c2)
+      { return __c1 == __c2; }
+
+      static bool 
+      lt(const char_type& __c1, const char_type& __c2)
+      { return __c1 < __c2; }
+
+      static int 
+      compare(const char_type* __s1, const char_type* __s2, size_t __n)
+      { 
+       for (size_t __i = 0; __i < __n; ++__i)
+         if (!eq(__s1[__i], __s2[__i]))
+           return lt(__s1[__i], __s2[__i]) ? -1 : 1;
+       return 0; 
+      }
+
+      static size_t
+      length(const char_type* __s)
+      { 
+       const char_type* __p = __s; 
+       while (__p) 
+         ++__p; 
+       return (__p - __s); 
+      }
+
+      static const char_type* 
+      find(const char_type* __s, size_t __n, const char_type& __a)
+      { 
+       for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p)
+         if (*__p == __a) return __p;
+       return 0;
+      }
+
+      static char_type* 
+      move(char_type* __s1, const char_type* __s2, size_t __n)
+      { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); }
+
+      static char_type* 
+      copy(char_type* __s1, const char_type* __s2, size_t __n)
+      { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); }
+
+      static char_type* 
+      assign(char_type* __s, size_t __n, char_type __a)
+      { 
+       for (char_type* __p = __s; __p < __s + __n; ++__p) 
+         assign(*__p, __a);
+        return __s; 
+      }
+
+      static char_type 
+      to_char_type(const int_type& __c)
+      { return char_type(); }
+
+      static int_type 
+      to_int_type(const char_type& __c) { return int_type(); }
+
+      static bool 
+      eq_int_type(const int_type& __c1, const int_type& __c2)
+      { return __c1 == __c2; }
+
+      static int_type 
+      eof() { return static_cast<int_type>(-1); }
+
+      static int_type 
+      not_eof(const int_type& __c)
+      { return eq_int_type(__c, eof()) ? int_type(0) : __c; }
+    };
+} // namespace std
+
 void test01()
 {
   // 1 POD types : resize, capacity, reserve
index 0d0d1d5bcade7484771d74822c1fc6f54916a047..51bf9b9600ad4107c36c4ce497d4e9f1f3cea62b 100644 (file)
 #include <locale>
 #include <testsuite_hooks.h>
 
-using namespace std;
+
 
 #ifdef _GLIBCPP_USE___ENC_TRAITS
 
+// Need some char_traits specializations for this to work.
+typedef unsigned short                 unicode_t;
+
+namespace std
+{
+  template<>
+    struct char_traits<unicode_t>
+    {
+      typedef unicode_t        char_type;
+      // Unsigned as wint_t is unsigned.
+      typedef unsigned long    int_type;
+      typedef streampos        pos_type;
+      typedef streamoff        off_type;
+      typedef mbstate_t        state_type;
+      
+      static void 
+      assign(char_type& __c1, const char_type& __c2);
+
+      static bool 
+      eq(const char_type& __c1, const char_type& __c2);
+
+      static bool 
+      lt(const char_type& __c1, const char_type& __c2);
+
+      static int 
+      compare(const char_type* __s1, const char_type* __s2, size_t __n)
+      { return memcmp(__s1, __s2, __n); }
+
+      static size_t
+      length(const char_type* __s);
+
+      static const char_type* 
+      find(const char_type* __s, size_t __n, const char_type& __a);
+
+      static char_type* 
+      move(char_type* __s1, const char_type* __s2, size_t __n);
+
+      static char_type* 
+      copy(char_type* __s1, const char_type* __s2, size_t __n)
+      {  return static_cast<char_type*>(memcpy(__s1, __s2, __n)); }
+
+      static char_type* 
+      assign(char_type* __s, size_t __n, char_type __a);
+
+      static char_type 
+      to_char_type(const int_type& __c);
+
+      static int_type 
+      to_int_type(const char_type& __c);
+
+      static bool 
+      eq_int_type(const int_type& __c1, const int_type& __c2);
+
+      static int_type 
+      eof(); 
+
+      static int_type 
+      not_eof(const int_type& __c);
+    };
+}
+
 /*
 > how do I check that these conversions are correct? 
 Very easy.  Since all the characters are from ASCII you simply
@@ -51,7 +112,7 @@ it shows that the other byte-order is used (25856 == 0x6500).
 
 
 void
-initialize_state(__enc_traits& state)
+initialize_state(std::__enc_traits& state)
 { state._M_init(); }
 
 // Partial specialization using __enc_traits.
@@ -59,8 +120,8 @@ initialize_state(__enc_traits& state)
 // UNICODE - UCS2 (big endian)
 void test01()
 {
+  using namespace std;
   typedef codecvt_base::result                 result;
-  typedef unsigned short                       unicode_t;
   typedef unicode_t                            int_type;
   typedef char                                 ext_type;
   typedef __enc_traits                         enc_type;
@@ -146,6 +207,7 @@ void test01()
 // UNICODE - UCS2 (little endian)
 void test02()
 {
+  using namespace std;
   typedef codecvt_base::result                 result;
   typedef unsigned short                       unicode_t;
   typedef unicode_t                            int_type;
index 87a2f05bf6c3fb3b031e56f3678825c7080bc91a..c944865b08fd7e7c2c697a57d212f3fe5411fdae 100644 (file)
@@ -1,6 +1,6 @@
 // 2000-08-23 Benjamin Kosnik <bkoz@cygnus.com>
 
-// Copyright (C) 2000, 2001 Free Software Foundation
+// Copyright (C) 2000, 2001, 2002 Free Software Foundation
 //
 // 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
 #include <locale>
 #include <testsuite_hooks.h>
 
-using namespace std;
-
 #ifdef _GLIBCPP_USE___ENC_TRAITS
 #ifdef _GLIBCPP_USE_WCHAR_T
 
+// Need some char_traits specializations for this to work.
+typedef unsigned short                 unicode_t;
+
+namespace std
+{
+  template<>
+    struct char_traits<unicode_t>
+    {
+      typedef unicode_t        char_type;
+      // Unsigned as wint_t is unsigned.
+      typedef unsigned long    int_type;
+      typedef streampos        pos_type;
+      typedef streamoff        off_type;
+      typedef mbstate_t        state_type;
+      
+      static void 
+      assign(char_type& __c1, const char_type& __c2);
+
+      static bool 
+      eq(const char_type& __c1, const char_type& __c2);
+
+      static bool 
+      lt(const char_type& __c1, const char_type& __c2);
+
+      static int 
+      compare(const char_type* __s1, const char_type* __s2, size_t __n)
+      { return memcmp(__s1, __s2, __n); }
+
+      static size_t
+      length(const char_type* __s);
+
+      static const char_type* 
+      find(const char_type* __s, size_t __n, const char_type& __a);
+
+      static char_type* 
+      move(char_type* __s1, const char_type* __s2, size_t __n);
+
+      static char_type* 
+      copy(char_type* __s1, const char_type* __s2, size_t __n)
+      {  return static_cast<char_type*>(memcpy(__s1, __s2, __n)); }
+
+      static char_type* 
+      assign(char_type* __s, size_t __n, char_type __a);
+
+      static char_type 
+      to_char_type(const int_type& __c);
+
+      static int_type 
+      to_int_type(const char_type& __c);
+
+      static bool 
+      eq_int_type(const int_type& __c1, const int_type& __c2);
+
+      static int_type 
+      eof(); 
+
+      static int_type 
+      not_eof(const int_type& __c);
+    };
+}
+
 void
-initialize_state(__enc_traits& state)
+initialize_state(std::__enc_traits& state)
 { state._M_init(); }
 
 // Partial specialization using __enc_traits.
 // codecvt<unicode_t, wchar_t, __enc_traits>
 void test01()
 {
+  using namespace std;
   typedef codecvt_base::result                 result;
-  typedef unsigned short                       unicode_t;
   typedef unicode_t                            int_type;
   typedef wchar_t                              ext_type;
   typedef __enc_traits                         enc_type;
index 732ec1714aa23b6ae6dc638ce4f1a775b1835ffe..94db3bcc139675406e0e73376b6743f2f762e839 100644 (file)
@@ -48,11 +48,70 @@ public:
 
 std::locale::id gnu_facet::id;
 
+// Need some char_traits specializations for this to work.
+typedef unsigned short                 unicode_t;
+
+namespace std
+{
+  template<>
+    struct char_traits<unicode_t>
+    {
+      typedef unicode_t        char_type;
+      // Unsigned as wint_t is unsigned.
+      typedef unsigned long    int_type;
+      typedef streampos        pos_type;
+      typedef streamoff        off_type;
+      typedef mbstate_t        state_type;
+      
+      static void 
+      assign(char_type& __c1, const char_type& __c2);
+
+      static bool 
+      eq(const char_type& __c1, const char_type& __c2);
+
+      static bool 
+      lt(const char_type& __c1, const char_type& __c2);
+
+      static int 
+      compare(const char_type* __s1, const char_type* __s2, size_t __n)
+      { return memcmp(__s1, __s2, __n); }
+
+      static size_t
+      length(const char_type* __s);
+
+      static const char_type* 
+      find(const char_type* __s, size_t __n, const char_type& __a);
+
+      static char_type* 
+      move(char_type* __s1, const char_type* __s2, size_t __n);
+
+      static char_type* 
+      copy(char_type* __s1, const char_type* __s2, size_t __n)
+      {  return static_cast<char_type*>(memcpy(__s1, __s2, __n)); }
+
+      static char_type* 
+      assign(char_type* __s, size_t __n, char_type __a);
+
+      static char_type 
+      to_char_type(const int_type& __c);
+
+      static int_type 
+      to_int_type(const char_type& __c);
+
+      static bool 
+      eq_int_type(const int_type& __c1, const int_type& __c2);
+
+      static int_type 
+      eof(); 
+
+      static int_type 
+      not_eof(const int_type& __c);
+    };
+}
+
 void test01()
 {
   using namespace std;
-
-  typedef unsigned short                       unicode_t;
   typedef unicode_t                            int_type;
   typedef char                                 ext_type;
   typedef __enc_traits                         enc_type;
index 9919365a552b3d3f37cedf00d3fdde6a068811aa..e72f2ca8f6f78493b15081b682469fc215b65cb0 100644 (file)
@@ -42,11 +42,67 @@ void test01()
 // test05
 // libstdc++/1886
 // should be able to instantiate basic_filebuf for non-standard types.
-template class std::basic_filebuf<short, std::char_traits<short> >;
+namespace test 
+{
+  using namespace std;
+  typedef short type_t;
+  template class basic_filebuf<type_t, char_traits<type_t> >;
+  template class basic_filebuf<gnu_char, char_traits<gnu_char> >;
+} // test
+
+
+// test07
+// libstdc++/2020
+// should be able to use custom char_type
+class gnu_char_type
+{
+  unsigned long character;
+public:
+  // operator ==
+  bool
+  operator==(const gnu_char_type& __lhs) 
+  { return character == __lhs.character; }
+
+  // operator <
+  bool
+  operator<(const gnu_char_type& __lhs) 
+  { return character < __lhs.character; }
+
+  // default ctor
+  gnu_char_type() { }
+
+  // to_char_type
+  gnu_char_type(const unsigned long& __l) : character(__l) { } 
+
+  // to_int_type
+  operator unsigned long() const { return character; }
+};
+
+void test07()
+{
+  bool test = true;
+  typedef std::basic_filebuf<gnu_char_type> gnu_filebuf;
+  
+  try
+    { gnu_filebuf obj; }
+  catch(std::exception& obj)
+    { 
+      test = false; 
+      VERIFY( test );
+    }
+}
+
+#if !__GXX_WEAK__
+// Explicitly instantiate for systems with no COMDAT or weak support.
+template 
+  std::basic_streambuf<gnu_char_type>::int_type
+  std::basic_streambuf<gnu_char_type>::_S_pback_size;
+#endif
 
 int main() 
 {
   test01();
+  test07();
   return 0;
 }
 
index fb370c36e50ea787567d96908b4522a15d02ea4d..0a92788296a5b0e50e0fe7dcef0015a3f683959b 100644 (file)
@@ -514,54 +514,6 @@ void test06()
   VERIFY( buffer[0] == 'a' );
 }
 
-// test06
-// libstdc++/2020
-// should be able to use custom char_type
-class gnu_char_type
-{
-  unsigned long character;
-public:
-  // operator ==
-  bool
-  operator==(const gnu_char_type& __lhs) 
-  { return character == __lhs.character; }
-
-  // operator <
-  bool
-  operator<(const gnu_char_type& __lhs) 
-  { return character < __lhs.character; }
-
-  // default ctor
-  gnu_char_type() { }
-
-  // to_char_type
-  gnu_char_type(const unsigned long& __l) : character(__l) { } 
-
-  // to_int_type
-  operator unsigned long() const { return character; }
-};
-
-void test07()
-{
-  bool test = true;
-  typedef std::basic_filebuf<gnu_char_type> gnu_filebuf;
-  
-  try
-    { gnu_filebuf obj; }
-  catch(std::exception& obj)
-    { 
-      test = false; 
-      VERIFY( test );
-    }
-}
-
-#if !__GXX_WEAK__
-// Explicitly instantiate for systems with no COMDAT or weak support.
-template 
-  std::basic_streambuf<gnu_char_type>::int_type
-  std::basic_streambuf<gnu_char_type>::_S_pback_size;
-#endif
-
 main() 
 {
   test01();
@@ -571,7 +523,6 @@ main()
   test04();
   test05();
   test06();
-  test07();
 
   return 0;
 }
index 2ecd0778700f698d36530e748093b6ac84cc0787..276294d9c9d4c2c6b424cb370153657ae380e0b6 100644 (file)
@@ -31,6 +31,7 @@
 // NB: This file is for testing basic_fstream with NO OTHER INCLUDES.
 
 #include <fstream>
+#include <testsuite_hooks.h>
 
 // { dg-do compile }
 
@@ -51,6 +52,7 @@ namespace test
   using namespace std;
   typedef short type_t;
   template class basic_fstream<type_t, char_traits<type_t> >;
+  template class basic_fstream<gnu_char, char_traits<gnu_char> >;
 } // test
 
 int main() 
index 1905aa64ac8d326ada401553454f78c355a98cf9..33a52de9470e43f098f80bd75d920e5fb16997c1 100644 (file)
 #include <iostream>
 #include <testsuite_hooks.h>
 
+// char_traits specialization
+namespace std
+{
+  template<>
+    struct char_traits<unsigned short>
+    {
+      typedef unsigned short   char_type;
+      // Unsigned as wint_t in unsigned.
+      typedef unsigned long    int_type;
+      typedef streampos        pos_type;
+      typedef streamoff        off_type;
+      typedef mbstate_t        state_type;
+      
+      static void 
+      assign(char_type& __c1, const char_type& __c2)
+      { __c1 = __c2; }
+
+      static bool 
+      eq(const char_type& __c1, const char_type& __c2)
+      { return __c1 == __c2; }
+
+      static bool 
+      lt(const char_type& __c1, const char_type& __c2)
+      { return __c1 < __c2; }
+
+      static int 
+      compare(const char_type* __s1, const char_type* __s2, size_t __n)
+      { 
+       for (size_t __i = 0; __i < __n; ++__i)
+         if (!eq(__s1[__i], __s2[__i]))
+           return lt(__s1[__i], __s2[__i]) ? -1 : 1;
+       return 0; 
+      }
+
+      static size_t
+      length(const char_type* __s)
+      { 
+       const char_type* __p = __s; 
+       while (__p) 
+         ++__p; 
+       return (__p - __s); 
+      }
+
+      static const char_type* 
+      find(const char_type* __s, size_t __n, const char_type& __a)
+      { 
+       for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p)
+         if (*__p == __a) return __p;
+       return 0;
+      }
+
+      static char_type* 
+      move(char_type* __s1, const char_type* __s2, size_t __n)
+      { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); }
+
+      static char_type* 
+      copy(char_type* __s1, const char_type* __s2, size_t __n)
+      { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); }
+
+      static char_type* 
+      assign(char_type* __s, size_t __n, char_type __a)
+      { 
+       for (char_type* __p = __s; __p < __s + __n; ++__p) 
+         assign(*__p, __a);
+        return __s; 
+      }
+
+      static char_type 
+      to_char_type(const int_type& __c)
+      { return char_type(); }
+
+      static int_type 
+      to_int_type(const char_type& __c) { return int_type(); }
+
+      static bool 
+      eq_int_type(const int_type& __c1, const int_type& __c2)
+      { return __c1 == __c2; }
+
+      static int_type 
+      eof() { return static_cast<int_type>(-1); }
+
+      static int_type 
+      not_eof(const int_type& __c)
+      { return eq_int_type(__c, eof()) ? int_type(0) : __c; }
+    };
+
+  template<>
+    struct char_traits<unsigned char>
+    {
+      typedef unsigned char    char_type;
+      // Unsigned as wint_t in unsigned.
+      typedef unsigned long    int_type;
+      typedef streampos        pos_type;
+      typedef streamoff        off_type;
+      typedef mbstate_t        state_type;
+      
+      static void 
+      assign(char_type& __c1, const char_type& __c2)
+      { __c1 = __c2; }
+
+      static bool 
+      eq(const char_type& __c1, const char_type& __c2)
+      { return __c1 == __c2; }
+
+      static bool 
+      lt(const char_type& __c1, const char_type& __c2)
+      { return __c1 < __c2; }
+
+      static int 
+      compare(const char_type* __s1, const char_type* __s2, size_t __n)
+      { 
+       for (size_t __i = 0; __i < __n; ++__i)
+         if (!eq(__s1[__i], __s2[__i]))
+           return lt(__s1[__i], __s2[__i]) ? -1 : 1;
+       return 0; 
+      }
+
+      static size_t
+      length(const char_type* __s)
+      { 
+       const char_type* __p = __s; 
+       while (__p && *__p) 
+         ++__p; 
+       return (__p - __s); 
+      }
+
+      static const char_type* 
+      find(const char_type* __s, size_t __n, const char_type& __a)
+      { 
+       for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p)
+         if (*__p == __a) return __p;
+       return 0;
+      }
+
+      static char_type* 
+      move(char_type* __s1, const char_type* __s2, size_t __n)
+      { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); }
+
+      static char_type* 
+      copy(char_type* __s1, const char_type* __s2, size_t __n)
+      { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); }
+
+      static char_type* 
+      assign(char_type* __s, size_t __n, char_type __a)
+      { 
+       for (char_type* __p = __s; __p < __s + __n; ++__p) 
+         assign(*__p, __a);
+        return __s; 
+      }
+
+      static char_type 
+      to_char_type(const int_type& __c)
+      { return char_type(); }
+
+      static int_type 
+      to_int_type(const char_type& __c) { return int_type(); }
+
+      static bool 
+      eq_int_type(const int_type& __c1, const int_type& __c2)
+      { return __c1 == __c2; }
+
+      static int_type 
+      eof() { return static_cast<int_type>(-1); }
+
+      static int_type 
+      not_eof(const int_type& __c)
+      { return eq_int_type(__c, eof()) ? int_type(0) : __c; }
+    };
+} // namespace std
+
 class gnu_filebuf: public std::filebuf
 {
   int i;
index 05db50ed461f627ebc366b4a03b671e492a9235b..6cec904eb67a50009d4365fe2467166767b79c3b 100644 (file)
@@ -31,6 +31,7 @@
 // NB: This file is for testing istream with NO OTHER INCLUDES.
 
 #include <istream>
+#include <testsuite_hooks.h>
 
 // { dg-do compile }
 
@@ -51,6 +52,7 @@ namespace test
   using namespace std;
   typedef short type_t;
   template class basic_istream<type_t, char_traits<type_t> >;
+  template class basic_istream<gnu_char, char_traits<gnu_char> >;
 } // test
 
 int main() 
index ae524ec61f29eb32efcaee96806ef569f75b2758..ee764f9d69769624c6224c02c7a00c889dd73d4b 100644 (file)
@@ -31,6 +31,7 @@
 // NB: This file is for testing ostream with NO OTHER INCLUDES.
 
 #include <ostream>
+#include <testsuite_hooks.h>
 
 // { dg-do compile }
 
@@ -51,6 +52,7 @@ namespace test
   using namespace std;
   typedef short type_t;
   template class basic_ostream<type_t, char_traits<type_t> >;
+  template class basic_ostream<gnu_char, char_traits<gnu_char> >;
 } // test
 
 int main() 
index 905dee089de81cac8c2892af5d7c2d2fd81791a9..102ff60c260acd54c92a55ffd754f008f1a30532 100644 (file)
@@ -31,6 +31,7 @@
 // NB: This file is for testing basic_streambuf with NO OTHER INCLUDES.
 
 #include <streambuf>
+#include <testsuite_hooks.h>
 
 // { dg-do compile }
 
@@ -51,6 +52,7 @@ namespace test
   using namespace std;
   typedef short type_t;
   template class basic_streambuf<type_t, char_traits<type_t> >;
+  template class basic_streambuf<gnu_char, char_traits<gnu_char> >;
 } // test
 
 int main() 
index 00825b6b69c7130b20babc83ea34895f4a958ec5..3cfd5af605c2ccc892aa6d307f53489f66a7fcfb 100644 (file)
@@ -31,6 +31,7 @@
 // NB: This file is for testing basic_stringbuf with NO OTHER INCLUDES.
 
 #include <sstream>
+#include <testsuite_hooks.h>
 
 // { dg-do compile }
 
@@ -51,6 +52,7 @@ namespace test
   using namespace std;
   typedef short type_t;
   template class basic_stringbuf<type_t, char_traits<type_t> >;
+  template class basic_stringbuf<gnu_char, char_traits<gnu_char> >;
 } // test
 
 int main() 
index 1a1b017807418e67330de5663ffa57a7e03b0b67..cb9e39d9588df9c02d684f31e8571408691b7bd0 100644 (file)
@@ -31,6 +31,7 @@
 // NB: This file is for testing basic_stringstream with NO OTHER INCLUDES.
 
 #include <sstream>
+#include <testsuite_hooks.h>
 
 // { dg-do compile }
 
@@ -51,6 +52,7 @@ namespace test
   using namespace std;
   typedef short type_t;
   template class basic_stringstream<type_t, char_traits<type_t> >;
+  template class basic_stringstream<gnu_char, char_traits<gnu_char> >;
 } // test
 
 int main() 
index eb87d51f2973b4fea0e986858939990abca1dd4a..b307fd8d51dc6a0f05eecc551e064df883d706b5 100644 (file)
 //   which starts at zero, increments on instance construction, and decrements
 //   on instance destruction.  "assert_count(n)" can be called to VERIFY()
 //   that the count equals N.
+//
+// 4) gnu_char, gnu_char_traits, abstract character classes and
+// char_traits specializations for testing instantiations.
 
 #ifndef _GLIBCPP_TESTSUITE_HOOKS_H
 #define _GLIBCPP_TESTSUITE_HOOKS_H
 
+#include <bits/c++config.h>
+#include <cstddef>
+
 #ifdef DEBUG_ASSERT
 # include <cassert>
 # define VERIFY(fn) assert(fn)
@@ -57,8 +63,6 @@
 # define VERIFY(fn) test &= (fn)
 #endif
 
-#include <bits/c++config.h>
-
 // Defined in GLIBCPP_CONFIGURE_TESTSUITE.
 #ifndef _GLIBCPP_MEM_LIMITS
 
@@ -130,6 +134,80 @@ struct gnu_counting_struct
 
 gnu_counting_struct::size_type  gnu_counting_struct::count = 0;
 
+struct gnu_char
+{
+  unsigned long c;
+};
+
+struct gnu_int
+{
+  unsigned long i;
+};
+
+struct gnu_state
+{
+  unsigned long l;
+  unsigned long l2;
+};
+
+// char_traits specialization
+namespace std
+{
+  template<class _CharT>
+    struct char_traits;
+
+  template<>
+    struct char_traits<gnu_char>
+    {
+      typedef gnu_char                 char_type;
+      typedef gnu_int                  int_type;
+      typedef long             pos_type;
+      typedef unsigned long    off_type;
+      typedef gnu_state        state_type;
+      
+      static void 
+      assign(char_type& __c1, const char_type& __c2);
+
+      static bool 
+      eq(const char_type& __c1, const char_type& __c2);
+
+      static bool 
+      lt(const char_type& __c1, const char_type& __c2);
+
+      static int 
+      compare(const char_type* __s1, const char_type* __s2, size_t __n);
+
+      static size_t
+      length(const char_type* __s);
+
+      static const char_type* 
+      find(const char_type* __s, size_t __n, const char_type& __a);
+
+      static char_type* 
+      move(char_type* __s1, const char_type* __s2, size_t __n);
+
+      static char_type* 
+      copy(char_type* __s1, const char_type* __s2, size_t __n);
+
+      static char_type* 
+      assign(char_type* __s, size_t __n, char_type __a);
+
+      static char_type 
+      to_char_type(const int_type& __c);
+
+      static int_type 
+      to_int_type(const char_type& __c);
+
+      static bool 
+      eq_int_type(const int_type& __c1, const int_type& __c2);
+
+      static int_type 
+      eof();
+
+      static int_type 
+      not_eof(const int_type& __c);
+    };
+} // namespace std
 
 #endif // _GLIBCPP_TESTSUITE_HOOKS_H