re PR libstdc++/13189 (<ext/enc_filebuf.h> fails to compile)
authorBenjamin Kosnik <bkoz@redhat.com>
Fri, 5 Dec 2003 06:54:24 +0000 (06:54 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Fri, 5 Dec 2003 06:54:24 +0000 (06:54 +0000)
2003-12-05  Benjamin Kosnik  <bkoz@redhat.com>

PR libstdc++/13189
* include/ext/enc_filebuf.h: Fix.
* include/bits/fstream.tcc: Tweak formatting.
* include/bits/postypes.h: Same.
* include/bits/sstream.tcc: Same.
* include/bits/streambuf.tcc: Same.
* testsuite/ext/stdio_filebuf.cc: Split.
* testsuite/ext/stdio_filebuf_2.cc: Split.
* testsuite/ext/stdio_sync_filebuf_char.cc: Split.
* testsuite/ext/stdio_sync_filebuf_wchar_t.cc: Split.
* testsuite/ext/enc_filebuf/char/13189.cc: New.
* testsuite/ext/enc_filebuf/wchar_t/13189.cc: New.
* testsuite/ext/stdio_filebuf/char/1.cc: New.
* testsuite/ext/stdio_filebuf/char/2.cc: New.
* testsuite/ext/stdio_sync_filebuf/char/1.cc: New.
* testsuite/ext/stdio_sync_filebuf/char/12048-1.cc: New.
* testsuite/ext/stdio_sync_filebuf/char/12048-2.cc: New.
* testsuite/ext/stdio_sync_filebuf/char/12048-3.cc: New.
* testsuite/ext/stdio_sync_filebuf/char/12048-4.cc: New.
* testsuite/ext/stdio_sync_filebuf/wchar_t/1.cc: New.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc: New.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc: New.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc: New.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc: New.

From-SVN: r74313

20 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fstream.tcc
libstdc++-v3/include/bits/postypes.h
libstdc++-v3/include/bits/sstream.tcc
libstdc++-v3/include/bits/streambuf.tcc
libstdc++-v3/include/ext/enc_filebuf.h
libstdc++-v3/testsuite/ext/enc_filebuf/char/13189.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/enc_filebuf/wchar_t/13189.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/stdio_filebuf/char/1.cc [moved from libstdc++-v3/testsuite/ext/stdio_filebuf.cc with 100% similarity]
libstdc++-v3/testsuite/ext/stdio_filebuf/char/2.cc [moved from libstdc++-v3/testsuite/ext/stdio_filebuf_2.cc with 100% similarity]
libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/1.cc [moved from libstdc++-v3/testsuite/ext/stdio_sync_filebuf_char.cc with 52% similarity]
libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-3.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-4.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/1.cc [moved from libstdc++-v3/testsuite/ext/stdio_sync_filebuf_wchar_t.cc with 54% similarity]
libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc [new file with mode: 0644]

index f2936ed..8a78125 100644 (file)
@@ -1,3 +1,30 @@
+2003-12-05  Benjamin Kosnik  <bkoz@redhat.com>
+
+       PR libstdc++/13189
+       * include/ext/enc_filebuf.h: Fix.
+       * include/bits/fstream.tcc: Tweak formatting.
+       * include/bits/postypes.h: Same.
+       * include/bits/sstream.tcc: Same.
+       * include/bits/streambuf.tcc: Same.
+       * testsuite/ext/stdio_filebuf.cc: Split.
+       * testsuite/ext/stdio_filebuf_2.cc: Split.
+       * testsuite/ext/stdio_sync_filebuf_char.cc: Split.
+       * testsuite/ext/stdio_sync_filebuf_wchar_t.cc: Split.
+       * testsuite/ext/enc_filebuf/char/13189.cc: New.
+       * testsuite/ext/enc_filebuf/wchar_t/13189.cc: New.
+       * testsuite/ext/stdio_filebuf/char/1.cc: New.
+       * testsuite/ext/stdio_filebuf/char/2.cc: New.
+       * testsuite/ext/stdio_sync_filebuf/char/1.cc: New.
+       * testsuite/ext/stdio_sync_filebuf/char/12048-1.cc: New.
+       * testsuite/ext/stdio_sync_filebuf/char/12048-2.cc: New.
+       * testsuite/ext/stdio_sync_filebuf/char/12048-3.cc: New.
+       * testsuite/ext/stdio_sync_filebuf/char/12048-4.cc: New.
+       * testsuite/ext/stdio_sync_filebuf/wchar_t/1.cc: New.
+       * testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc: New.
+       * testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc: New.
+       * testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc: New.
+       * testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc: New.
+
 2003-12-05  Carlo Wood  <carlo@alinoe.com>
 
        PR libstdc++/13045
index ef4260b..595d8bd 100644 (file)
@@ -161,7 +161,6 @@ namespace std
     {
       streamsize __ret = -1;
       const bool __testin = this->_M_mode & ios_base::in;
-
       if (__testin && this->is_open())
        {
          // For a stateful encoding (-1) the pending sequence might be just
@@ -170,7 +169,6 @@ namespace std
          if (__check_facet(_M_codecvt).encoding() >= 0)
            __ret += _M_file.showmanyc() / _M_codecvt->max_length();
        }
-
       return __ret;
     }
   
@@ -182,7 +180,6 @@ namespace std
       int_type __ret = traits_type::eof();
       const bool __testin = this->_M_mode & ios_base::in;
       const bool __testout = this->_M_mode & ios_base::out;
-
       if (__testin && !_M_writing)
        {
          // Check for pback madness, and if so swich back to the
@@ -323,14 +320,12 @@ namespace std
     {
       int_type __ret = traits_type::eof();
       const bool __testin = this->_M_mode & ios_base::in;
-
       if (__testin && !_M_writing)
        {
          // Remember whether the pback buffer is active, otherwise below
          // we may try to store in it a second char (libstdc++/9761).
          const bool __testpb = this->_M_pback_init;       
          const bool __testeof = traits_type::eq_int_type(__i, __ret);
-         
          int_type __tmp;
          if (this->eback() < this->gptr())
            {
@@ -378,7 +373,6 @@ namespace std
       int_type __ret = traits_type::eof();
       const bool __testeof = traits_type::eq_int_type(__c, __ret);
       const bool __testout = this->_M_mode & ios_base::out;
-      
       if (__testout && !_M_reading)
        {
          if (this->pbase() < this->pptr())
@@ -391,7 +385,7 @@ namespace std
                }
              
              // Convert pending sequence to external representation,
-             // output.
+             // and output.
              if (_M_convert_to_external(this->pbase(),
                                         this->pptr() - this->pbase())
                  && (!__testeof || (__testeof && !_M_file.sync())))
@@ -436,7 +430,6 @@ namespace std
       // Sizes of external and pending output.
       streamsize __elen = 0;
       streamsize __plen = 0;
-
       if (__check_facet(_M_codecvt).always_noconv())
        {
          __elen += _M_file.xsputn(reinterpret_cast<char*>(__ibuf), __ilen);
@@ -499,11 +492,10 @@ namespace std
      basic_filebuf<_CharT, _Traits>::
      xsputn(const _CharT* __s, streamsize __n)
      { 
-       streamsize __ret = 0;
-      
        // Optimization in the always_noconv() case, to be generalized in the
        // future: when __n is sufficiently large we write directly instead of
        // using the buffer.
+       streamsize __ret = 0;
        const bool __testout = this->_M_mode & ios_base::out;
        if (__testout && !_M_reading
           && __check_facet(_M_codecvt).always_noconv())
@@ -538,8 +530,7 @@ namespace std
            __ret = __streambuf_type::xsputn(__s, __n);
        }
        else
-        __ret = __streambuf_type::xsputn(__s, __n);
-      
+        __ret = __streambuf_type::xsputn(__s, __n);      
        return __ret;
     }
 
@@ -575,14 +566,13 @@ namespace std
     basic_filebuf<_CharT, _Traits>::
     seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode)
     {
-      pos_type __ret =  pos_type(off_type(-1)); 
-
       int __width = 0;
       if (_M_codecvt)
        __width = _M_codecvt->encoding();
       if (__width < 0)
        __width = 0;
 
+      pos_type __ret =  pos_type(off_type(-1)); 
       const bool __testfail = __off != 0 && __width <= 0;
       if (this->is_open() && !__testfail) 
        {
@@ -630,12 +620,10 @@ namespace std
     seekpos(pos_type __pos, ios_base::openmode)
     {
       pos_type __ret =  pos_type(off_type(-1)); 
-
       if (this->is_open()) 
        {
          // Ditch any pback buffers to avoid confusion.
          _M_destroy_pback();
-
          __ret = _M_seek(off_type(__pos), ios_base::beg, __pos.state());
        }
       return __ret;
@@ -650,8 +638,7 @@ namespace std
       if (_M_terminate_output())
        {         
          // Returns pos_type(off_type(-1)) in case of failure.
-         __ret = pos_type(_M_file.seekoff(__off, __way));
-         
+         __ret = pos_type(_M_file.seekoff(__off, __way));        
          _M_reading = false;
          _M_writing = false;
          _M_ext_next = _M_ext_end = _M_ext_buf;
@@ -667,9 +654,8 @@ namespace std
     basic_filebuf<_CharT, _Traits>::
     _M_terminate_output()
     {
-      bool __testvalid = true;
-
       // Part one: update the output sequence.
+      bool __testvalid = true;
       if (this->pbase() < this->pptr())
        {
          const int_type __tmp = this->overflow();
@@ -685,7 +671,6 @@ namespace std
          // get the length of the unshift sequence from codecvt,
          // without calling unshift.
          const size_t __blen = 128;
-
          char __buf[__blen];
          codecvt_base::result __r;
          streamsize __ilen = 0;
@@ -700,8 +685,7 @@ namespace std
              else if (__r == codecvt_base::ok ||
                       __r == codecvt_base::partial)
                {
-                 __ilen = __next - __buf;
-                 
+                 __ilen = __next - __buf;                
                  if (__ilen > 0)
                    {
                      const streamsize __elen = _M_file.xsputn(__buf, __ilen);
@@ -731,18 +715,16 @@ namespace std
     basic_filebuf<_CharT, _Traits>::
     sync()
     {
-      int __ret = 0;
-
       // Make sure that the internal buffer resyncs its idea of
       // the file position with the external file.
       // NB: _M_file.sync() will be called within.
+      int __ret = 0;
       if (this->pbase() < this->pptr())
        {
          const int_type __tmp = this->overflow();
          if (traits_type::eq_int_type(__tmp, traits_type::eof()))
            __ret = -1;
-       }
-      
+       }      
       return __ret;
     }
 
@@ -752,7 +734,6 @@ namespace std
     imbue(const locale& __loc)
     {
       bool __testfail = false;
-
       if (this->is_open())
        {
          const pos_type __ret = this->seekoff(0, ios_base::cur,
index 935ba7c..c9b46b1 100644 (file)
@@ -146,8 +146,8 @@ namespace std
     private:
       friend class streamoff;
 
-      __streamoff_base_type _M_off;
-      _StateT _M_state;
+      __streamoff_base_type    _M_off;
+      _StateT                  _M_state;
 
     public:
       // The standard doesn't require that fpos objects can be default
index dfa1d68..07e1392 100644 (file)
@@ -79,8 +79,7 @@ namespace std
       if (__builtin_expect(!__testout, false))
        return traits_type::eof();
 
-      const bool __testeof = traits_type::eq_int_type(__c,
-                                                     traits_type::eof());
+      const bool __testeof = traits_type::eq_int_type(__c, traits_type::eof());
       if (__builtin_expect(__testeof, false))
        return traits_type::not_eof(__c);
 
@@ -106,8 +105,7 @@ namespace std
          __tmp.assign(_M_string.data(), this->epptr() - this->pbase());
          _M_string.swap(__tmp);
          _M_sync(const_cast<char_type*>(_M_string.data()),
-                 this->gptr() - this->eback(), 
-                 this->pptr() - this->pbase());
+                 this->gptr() - this->eback(), this->pptr() - this->pbase());
        }
       return this->sputc(traits_type::to_char_type(__c));
     }
@@ -123,7 +121,6 @@ namespace std
        {
          // Update egptr() to match the actual string end.
          _M_update_egptr();
-
          if (this->gptr() < this->egptr())
            __ret = traits_type::to_int_type(*this->gptr());
        }
@@ -181,8 +178,7 @@ namespace std
     basic_stringbuf<_CharT, _Traits, _Alloc>::
     seekpos(pos_type __sp, ios_base::openmode __mode)
     {
-      pos_type __ret =  pos_type(off_type(-1)); 
-      
+      pos_type __ret =  pos_type(off_type(-1));       
       if (_M_string.capacity())
        {
          off_type __pos (__sp);
index 494b9f0..4cc9bf1 100644 (file)
@@ -149,15 +149,13 @@ namespace std
   extern template class basic_streambuf<char>;
   extern template
     streamsize
-    __copy_streambufs(basic_streambuf<char>*,
-                     basic_streambuf<char>*); 
+    __copy_streambufs(basic_streambuf<char>*, basic_streambuf<char>*); 
 
 #ifdef _GLIBCXX_USE_WCHAR_T
   extern template class basic_streambuf<wchar_t>;
   extern template
     streamsize
-    __copy_streambufs(basic_streambuf<wchar_t>*,
-                     basic_streambuf<wchar_t>*); 
+    __copy_streambufs(basic_streambuf<wchar_t>*, basic_streambuf<wchar_t>*); 
 #endif
 #endif
 } // namespace std
index a2b3d67..81dad12 100644 (file)
@@ -1,6 +1,6 @@
-// __enc_traits layer for filebuf -*- C++ -*-
+// filebuf with __enc_traits state type -*- C++ -*-
 
-// Copyright (C) 2002 Free Software Foundation, Inc.
+// Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
 
 namespace __gnu_cxx
 {
-  // Custom traits type with __enc_traits for state type, all other bits
-  // equivalent to the required char_traits instantiations.
+  // Custom traits type with __enc_traits for the state type, and the
+  // associated fpos<__enc_traits> for the position type, all other
+  // bits equivalent to the required char_traits instantiations.
   template<typename _CharT>
     struct enc_char_traits: public std::char_traits<_CharT>
     {
-      typedef std::__enc_traits        state_type;
+      typedef std::__enc_traits                        state_type;
+      typedef typename std::fpos<state_type>   pos_type;
     };
 
   template<typename _CharT>
@@ -45,17 +47,19 @@ namespace __gnu_cxx
     : public std::basic_filebuf<_CharT, enc_char_traits<_CharT> >
     {
     public:
-      typedef typename enc_char_traits<_CharT>::state_type state_type;
+      typedef enc_char_traits<_CharT>          traits_type;
+      typedef typename traits_type::state_type         state_type;
+      typedef typename traits_type::pos_type   pos_type;
       
       enc_filebuf(state_type& __state)
       : std::basic_filebuf<_CharT, enc_char_traits<_CharT> >()
       { 
        // Set state type to something useful.
        // Something more than copyconstructible is needed here, so
-       // require copyconstructible + assignment operator.
+       // require default and copy constructible + assignment operator.
        __glibcxx_class_requires(state_type, _SGIAssignableConcept);
-       _M_state_cur = __state;
-       _M_state_cur._M_init();
+       this->_M_state_beg = __state;
+       this->_M_state_beg._M_init();
       };
     };
 } // namespace __gnu_cxx
diff --git a/libstdc++-v3/testsuite/ext/enc_filebuf/char/13189.cc b/libstdc++-v3/testsuite/ext/enc_filebuf/char/13189.cc
new file mode 100644 (file)
index 0000000..57c0871
--- /dev/null
@@ -0,0 +1,50 @@
+// Copyright (C) 2003 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+#include <ext/enc_filebuf.h>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  using namespace std;
+
+  typedef __enc_traits state_type;
+  typedef char char_type;
+  typedef __gnu_cxx::enc_filebuf<char_type> filebuf_type;
+  typedef codecvt<char_type, char, state_type> enc_codecvt;
+
+  bool test __attribute__((unused)) = true;
+  ios_base::openmode mode = ios_base::in | ios_base::out | ios_base::trunc;
+  try
+    {
+      state_type st;
+      filebuf_type fbuf(st);
+      locale loc(locale::classic(), new enc_codecvt);
+      fbuf.pubimbue(loc);
+      fbuf.open("tmp_13189c", mode);
+      fbuf.sputc('a');
+      fbuf.pubseekoff(0, ios_base::beg);
+      fbuf.sgetc();
+      fbuf.close();
+    }
+  catch(...)
+    {
+      VERIFY( false );
+    }
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/enc_filebuf/wchar_t/13189.cc b/libstdc++-v3/testsuite/ext/enc_filebuf/wchar_t/13189.cc
new file mode 100644 (file)
index 0000000..7089b67
--- /dev/null
@@ -0,0 +1,50 @@
+// Copyright (C) 2003 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+#include <ext/enc_filebuf.h>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  using namespace std;
+
+  typedef __enc_traits state_type;
+  typedef wchar_t char_type;
+  typedef __gnu_cxx::enc_filebuf<char_type> filebuf_type;
+  typedef codecvt<char_type, char, state_type> enc_codecvt;
+
+  bool test __attribute__((unused)) = true;
+  ios_base::openmode mode = ios_base::in | ios_base::out | ios_base::trunc;
+  try
+    {
+      state_type st;
+      filebuf_type fbuf(st);
+      locale loc(locale::classic(), new enc_codecvt);
+      fbuf.pubimbue(loc);
+      fbuf.open("tmp_13189w", mode);
+      fbuf.sputc(L'a');
+      fbuf.pubseekoff(0, ios_base::beg);
+      fbuf.sgetc();
+      fbuf.close();
+    }
+  catch(...)
+    {
+      VERIFY( false );
+    }
+  return 0;
+}
@@ -56,85 +56,8 @@ void test01()
   fclose(fin);
 }
 
-// libstdc++/12048
-void test02()
-{
-  bool test __attribute__((unused)) = true;
-  const char* name = "cin_unget-1.txt";
-
-  std::FILE* file = std::fopen(name, "r");
-  __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
-  int c1 = sbuf.sbumpc();
-  VERIFY( c1 != EOF );
-  int c2 = sbuf.sungetc();
-  VERIFY( c2 != EOF );
-  int c3 = sbuf.sbumpc();
-  VERIFY( c3 == c1 );
-
-  std::fclose(file);
-}
-
-// libstdc++/12048
-void test03()
-{
-  bool test __attribute__((unused)) = true;
-  const char* name = "cin_unget-1.txt";
-
-  std::FILE* file = std::fopen(name, "r");
-  __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
-  int c1 = sbuf.sbumpc();
-  VERIFY( c1 != EOF );
-  int c2 = sbuf.sungetc();
-  VERIFY( c2 != EOF );
-  int c3 = std::fgetc(file);
-  VERIFY( c3 == c1 );
-
-  std::fclose(file);
-}
-
-// libstdc++/12048
-void test04()
-{
-  bool test __attribute__((unused)) = true;
-  const char* name = "cin_unget-1.txt";
-
-  std::FILE* file = std::fopen(name, "r");
-  __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
-  char buf[2];
-  VERIFY( sbuf.sgetn(buf, 2) == 2 );
-  int c2 = sbuf.sungetc();
-  VERIFY( c2 != EOF );
-  int c3 = sbuf.sbumpc();
-  VERIFY( c3 == std::char_traits<char>::to_int_type(buf[1]) );
-
-  std::fclose(file);
-}
-
-// libstdc++/12048
-void test05()
-{
-  bool test __attribute__((unused)) = true;
-  const char* name = "cin_unget-1.txt";
-
-  std::FILE* file = std::fopen(name, "r");
-  __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
-  char buf[2];
-  VERIFY( sbuf.sgetn(buf, 2) == 2 );
-  int c2 = sbuf.sungetc();
-  VERIFY( c2 != EOF );
-  int c3 = std::fgetc(file);
-  VERIFY( c3 == std::char_traits<char>::to_int_type(buf[1]) );
-
-  std::fclose(file);
-}
-
 int main ()
 {
   test01();
-  test02();
-  test03();
-  test04();
-  test05();
-
   return 0;
 }
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-1.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-1.cc
new file mode 100644 (file)
index 0000000..e35897e
--- /dev/null
@@ -0,0 +1,46 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test02()
+{
+  bool test __attribute__((unused)) = true;
+  const char* name = "cin_unget-1.txt";
+
+  std::FILE* file = std::fopen(name, "r");
+  __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+  int c1 = sbuf.sbumpc();
+  VERIFY( c1 != EOF );
+  int c2 = sbuf.sungetc();
+  VERIFY( c2 != EOF );
+  int c3 = sbuf.sbumpc();
+  VERIFY( c3 == c1 );
+
+  std::fclose(file);
+}
+
+int main ()
+{
+  test02();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-2.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-2.cc
new file mode 100644 (file)
index 0000000..6619254
--- /dev/null
@@ -0,0 +1,46 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test03()
+{
+  bool test __attribute__((unused)) = true;
+  const char* name = "cin_unget-1.txt";
+
+  std::FILE* file = std::fopen(name, "r");
+  __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+  int c1 = sbuf.sbumpc();
+  VERIFY( c1 != EOF );
+  int c2 = sbuf.sungetc();
+  VERIFY( c2 != EOF );
+  int c3 = std::fgetc(file);
+  VERIFY( c3 == c1 );
+
+  std::fclose(file);
+}
+
+int main ()
+{
+  test03();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-3.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-3.cc
new file mode 100644 (file)
index 0000000..6039e15
--- /dev/null
@@ -0,0 +1,46 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test04()
+{
+  bool test __attribute__((unused)) = true;
+  const char* name = "cin_unget-1.txt";
+
+  std::FILE* file = std::fopen(name, "r");
+  __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+  char buf[2];
+  VERIFY( sbuf.sgetn(buf, 2) == 2 );
+  int c2 = sbuf.sungetc();
+  VERIFY( c2 != EOF );
+  int c3 = sbuf.sbumpc();
+  VERIFY( c3 == std::char_traits<char>::to_int_type(buf[1]) );
+
+  std::fclose(file);
+}
+
+int main ()
+{
+  test04();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-4.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/char/12048-4.cc
new file mode 100644 (file)
index 0000000..5372b68
--- /dev/null
@@ -0,0 +1,46 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test05()
+{
+  bool test __attribute__((unused)) = true;
+  const char* name = "cin_unget-1.txt";
+
+  std::FILE* file = std::fopen(name, "r");
+  __gnu_cxx::stdio_sync_filebuf<char> sbuf(file);
+  char buf[2];
+  VERIFY( sbuf.sgetn(buf, 2) == 2 );
+  int c2 = sbuf.sungetc();
+  VERIFY( c2 != EOF );
+  int c3 = std::fgetc(file);
+  VERIFY( c3 == std::char_traits<char>::to_int_type(buf[1]) );
+
+  std::fclose(file);
+}
+
+int main ()
+{
+  test05();
+  return 0;
+}
@@ -58,85 +58,8 @@ void test01()
   fclose(fin);
 }
 
-// libstdc++/12048
-void test02()
-{
-  bool test __attribute__((unused)) = true;
-  const char* name = "cin_unget-1.txt";
-
-  std::FILE* file = std::fopen(name, "r");
-  __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
-  std::wint_t c1 = sbuf.sbumpc();
-  VERIFY( c1 != WEOF );
-  std::wint_t c2 = sbuf.sungetc();
-  VERIFY( c2 != WEOF );
-  std::wint_t c3 = sbuf.sbumpc();
-  VERIFY( c3 == c1 );
-
-  std::fclose(file);
-}
-
-// libstdc++/12048
-void test03()
-{
-  bool test __attribute__((unused)) = true;
-  const char* name = "cin_unget-1.txt";
-
-  std::FILE* file = std::fopen(name, "r");
-  __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
-  std::wint_t c1 = sbuf.sbumpc();
-  VERIFY( c1 != WEOF );
-  std::wint_t c2 = sbuf.sungetc();
-  VERIFY( c2 != WEOF );
-  std::wint_t c3 = std::fgetwc(file);
-  VERIFY( c3 == c1 );
-
-  std::fclose(file);
-}
-
-// libstdc++/12048
-void test04()
-{
-  bool test __attribute__((unused)) = true;
-  const char* name = "cin_unget-1.txt";
-
-  std::FILE* file = std::fopen(name, "r");
-  __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
-  wchar_t buf[2];
-  VERIFY( sbuf.sgetn(buf, 2) == 2 );
-  std::wint_t c2 = sbuf.sungetc();
-  VERIFY( c2 != WEOF );
-  std::wint_t c3 = sbuf.sbumpc();
-  VERIFY( c3 == std::char_traits<wchar_t>::to_int_type(buf[1]) );
-
-  std::fclose(file);
-}
-
-// libstdc++/12048
-void test05()
-{
-  bool test __attribute__((unused)) = true;
-  const char* name = "cin_unget-1.txt";
-
-  std::FILE* file = std::fopen(name, "r");
-  __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
-  wchar_t buf[2];
-  VERIFY( sbuf.sgetn(buf, 2) == 2 );
-  std::wint_t c2 = sbuf.sungetc();
-  VERIFY( c2 != WEOF );
-  std::wint_t c3 = std::fgetwc(file);
-  VERIFY( c3 == std::char_traits<wchar_t>::to_int_type(buf[1]) );
-
-  std::fclose(file);
-}
-
 int main ()
 {
   test01();
-  test02();
-  test03();
-  test04();
-  test05();
-
   return 0;
 }
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc
new file mode 100644 (file)
index 0000000..5329ba8
--- /dev/null
@@ -0,0 +1,46 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test02()
+{
+  bool test __attribute__((unused)) = true;
+  const char* name = "cin_unget-1.txt";
+
+  std::FILE* file = std::fopen(name, "r");
+  __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+  std::wint_t c1 = sbuf.sbumpc();
+  VERIFY( c1 != WEOF );
+  std::wint_t c2 = sbuf.sungetc();
+  VERIFY( c2 != WEOF );
+  std::wint_t c3 = sbuf.sbumpc();
+  VERIFY( c3 == c1 );
+
+  std::fclose(file);
+}
+
+int main ()
+{
+  test02();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc
new file mode 100644 (file)
index 0000000..285969b
--- /dev/null
@@ -0,0 +1,46 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test03()
+{
+  bool test __attribute__((unused)) = true;
+  const char* name = "cin_unget-1.txt";
+
+  std::FILE* file = std::fopen(name, "r");
+  __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+  std::wint_t c1 = sbuf.sbumpc();
+  VERIFY( c1 != WEOF );
+  std::wint_t c2 = sbuf.sungetc();
+  VERIFY( c2 != WEOF );
+  std::wint_t c3 = std::fgetwc(file);
+  VERIFY( c3 == c1 );
+
+  std::fclose(file);
+}
+
+int main ()
+{
+  test03();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc
new file mode 100644 (file)
index 0000000..b006898
--- /dev/null
@@ -0,0 +1,46 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test04()
+{
+  bool test __attribute__((unused)) = true;
+  const char* name = "cin_unget-1.txt";
+
+  std::FILE* file = std::fopen(name, "r");
+  __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+  wchar_t buf[2];
+  VERIFY( sbuf.sgetn(buf, 2) == 2 );
+  std::wint_t c2 = sbuf.sungetc();
+  VERIFY( c2 != WEOF );
+  std::wint_t c3 = sbuf.sbumpc();
+  VERIFY( c3 == std::char_traits<wchar_t>::to_int_type(buf[1]) );
+
+  std::fclose(file);
+}
+
+int main ()
+{
+  test04();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc
new file mode 100644 (file)
index 0000000..704a753
--- /dev/null
@@ -0,0 +1,46 @@
+// 2003-05-01 Petur Runolfsson <peturr02@ru.is>
+
+// Copyright (C) 2003 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+#include <ext/stdio_sync_filebuf.h>
+#include <testsuite_hooks.h>
+
+// libstdc++/12048
+void test05()
+{
+  bool test __attribute__((unused)) = true;
+  const char* name = "cin_unget-1.txt";
+
+  std::FILE* file = std::fopen(name, "r");
+  __gnu_cxx::stdio_sync_filebuf<wchar_t> sbuf(file);
+  wchar_t buf[2];
+  VERIFY( sbuf.sgetn(buf, 2) == 2 );
+  std::wint_t c2 = sbuf.sungetc();
+  VERIFY( c2 != WEOF );
+  std::wint_t c3 = std::fgetwc(file);
+  VERIFY( c3 == std::char_traits<wchar_t>::to_int_type(buf[1]) );
+
+  std::fclose(file);
+}
+
+int main ()
+{
+  test05();
+  return 0;
+}