Index: libstdc++-v3/config/linker-map.gnu
===================================================================
RCS file: /home/petur/cvsroot/gcc/libstdc++-v3/config/linker-map.gnu,v
retrieving revision 1.1.1.4
diff -c -3 -p -r1.1.1.4 linker-map.gnu
*** libstdc++-v3/config/linker-map.gnu	24 Apr 2003 19:58:29 -0000	1.1.1.4
--- libstdc++-v3/config/linker-map.gnu	30 Apr 2003 22:26:07 -0000
*************** GLIBCPP_3.4 {
*** 56,61 ****
--- 56,62 ----
        std::__num_base::_S_format_int*;
        std::__num_base::_S_atoms_in;
        std::__num_base::_S_atoms_out;
+       std::__showmanyc_helper*;
        
        # Needed only when generic cpu's atomicity.h is in use.
        __gnu_cxx::_Atomic_add_mutex;
Index: libstdc++-v3/config/io/basic_file_stdio.cc
===================================================================
RCS file: /home/petur/cvsroot/gcc/libstdc++-v3/config/io/basic_file_stdio.cc,v
retrieving revision 1.1.1.3
diff -c -3 -p -r1.1.1.3 basic_file_stdio.cc
*** libstdc++-v3/config/io/basic_file_stdio.cc	24 Apr 2003 19:58:34 -0000	1.1.1.3
--- libstdc++-v3/config/io/basic_file_stdio.cc	30 Apr 2003 22:07:29 -0000
***************
*** 61,66 ****
--- 61,69 ----
  
  namespace std 
  {
+   streamsize
+   __showmanyc_helper(FILE* __file, bool __stdio);
+ 
    // Definitions for __basic_file<char>.
    __basic_file<char>::__basic_file(__c_lock* /*__lock*/) 
    : _M_cfile(NULL), _M_cfile_created(false) { }
*************** namespace std 
*** 276,286 ****
  
    streamsize
    __basic_file<char>::showmanyc_helper(bool __stdio)
    {
  #ifdef FIONREAD
      // Pipes and sockets.    
      int __num = 0;
!     int __r = ioctl(this->fd(), FIONREAD, &__num);
      if (!__r && __num >= 0)
        return __num; 
  #endif    
--- 279,293 ----
  
    streamsize
    __basic_file<char>::showmanyc_helper(bool __stdio)
+   { return __showmanyc_helper(_M_cfile, __stdio); }
+ 
+   streamsize
+   __showmanyc_helper(FILE* __file, bool __stdio)
    {
  #ifdef FIONREAD
      // Pipes and sockets.    
      int __num = 0;
!     int __r = ioctl(fileno(__file), FIONREAD, &__num);
      if (!__r && __num >= 0)
        return __num; 
  #endif    
*************** namespace std 
*** 288,294 ****
  #ifdef _GLIBCPP_HAVE_POLL
      // Cheap test.
      struct pollfd __pfd[1];
!     __pfd[0].fd = this->fd();
      __pfd[0].events = POLLIN;
      if (poll(__pfd, 1, 0) <= 0)
        return 0;
--- 295,301 ----
  #ifdef _GLIBCPP_HAVE_POLL
      // Cheap test.
      struct pollfd __pfd[1];
!     __pfd[0].fd = fileno(__file);
      __pfd[0].events = POLLIN;
      if (poll(__pfd, 1, 0) <= 0)
        return 0;
*************** namespace std 
*** 297,308 ****
  #if defined(_GLIBCPP_HAVE_S_ISREG) || defined(_GLIBCPP_HAVE_S_IFREG)
      // Regular files.
      struct stat __buffer;
!     int __ret = fstat(this->fd(), &__buffer);
      if (!__ret && _GLIBCPP_ISREG(__buffer.st_mode))
        if (__stdio)
! 	return __buffer.st_size - ftell(_M_cfile);
        else
! 	return __buffer.st_size - lseek(this->fd(), 0, ios_base::cur);
  #endif
      return 0;
    }
--- 304,315 ----
  #if defined(_GLIBCPP_HAVE_S_ISREG) || defined(_GLIBCPP_HAVE_S_IFREG)
      // Regular files.
      struct stat __buffer;
!     int __ret = fstat(fileno(__file), &__buffer);
      if (!__ret && _GLIBCPP_ISREG(__buffer.st_mode))
        if (__stdio)
! 	return __buffer.st_size - ftell(__file);
        else
! 	return __buffer.st_size - lseek(fileno(__file), 0, ios_base::cur);
  #endif
      return 0;
    }
Index: libstdc++-v3/include/Makefile.am
===================================================================
RCS file: /home/petur/cvsroot/gcc/libstdc++-v3/include/Makefile.am,v
retrieving revision 1.1.1.4
diff -c -3 -p -r1.1.1.4 Makefile.am
*** libstdc++-v3/include/Makefile.am	24 Apr 2003 19:58:41 -0000	1.1.1.4
--- libstdc++-v3/include/Makefile.am	30 Apr 2003 08:30:32 -0000
*************** ext_headers = \
*** 217,222 ****
--- 217,223 ----
  	${ext_srcdir}/algorithm \
  	${ext_srcdir}/enc_filebuf.h \
  	${ext_srcdir}/stdio_filebuf.h \
+ 	${ext_srcdir}/stdiostream.h \
  	${ext_srcdir}/functional \
  	${ext_srcdir}/hash_map \
  	${ext_srcdir}/hash_set \
Index: libstdc++-v3/include/bits/ios_base.h
===================================================================
RCS file: /home/petur/cvsroot/gcc/libstdc++-v3/include/bits/ios_base.h,v
retrieving revision 1.1.1.4
diff -c -3 -p -r1.1.1.4 ios_base.h
*** libstdc++-v3/include/bits/ios_base.h	28 Apr 2003 21:16:27 -0000	1.1.1.4
--- libstdc++-v3/include/bits/ios_base.h	1 May 2003 22:46:21 -0000
*************** namespace std
*** 452,463 ****
        Init();
        ~Init();
        
-       static void
-       _S_create_buffers(bool __sync);
-       
-       static void
-       _S_destroy_buffers();
- 
        // NB: Allows debugger applications use of the standard streams
        // from operator new. _S_ios_base_init must be incremented in
        // _S_ios_create _after_ initialization is completed.
--- 452,457 ----
Index: libstdc++-v3/include/ext/stdiostream.h
===================================================================
RCS file: libstdc++-v3/include/ext/stdiostream.h
diff -N libstdc++-v3/include/ext/stdiostream.h
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/include/ext/stdiostream.h	1 May 2003 23:06:05 -0000
***************
*** 0 ****
--- 1,317 ----
+ // Iostreams wrapper for stdio FILE* -*- C++ -*-
+ 
+ // Copyright (C) 2003 Free Software Foundation, Inc.
+ //
+ // This file is part of the GNU ISO C++ Library.  This library is free
+ // software; you can redistribute it and/or modify it under the
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+ 
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ // GNU General Public License for more details.
+ 
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING.  If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+ 
+ // As a special exception, you may use this file as part of a free software
+ // library without restriction.  Specifically, if other files instantiate
+ // templates or use macros or inline functions from this file, or you compile
+ // this file and link it with other files to produce an executable, this
+ // file does not by itself cause the resulting executable to be covered by
+ // the GNU General Public License.  This exception does not however
+ // invalidate any other reasons why the executable file might be covered by
+ // the GNU General Public License.
+ 
+ /** @file ext/stdiostream.h
+  *  This file is a GNU extension to the Standard C++ Library.
+  */
+ 
+ #ifndef _EXT_STDIOSTREAM_H
+ #define _EXT_STDIOSTREAM_H
+ 
+ #pragma GCC system_header
+ #include <streambuf>
+ #include <istream>
+ #include <ostream>
+ #include <cstdio>
+ #ifdef _GLIBCPP_USE_WCHAR_T
+ #include <cwchar>
+ #endif
+ 
+ #pragma GCC system_header
+ 
+ namespace std
+ {
+   // Needed by showmanyc
+   streamsize
+   __showmanyc_helper(FILE* __file, bool __stdio);
+ } // namespace std
+ 
+ namespace __gnu_cxx
+ {
+   // NB: Only the specializatons for char and wchar_t are defined.
+   // The primary template is undefined. 
+   template<typename _CharT>
+     class basic_stdiobuf;
+   typedef basic_stdiobuf<char> stdiobuf;
+ #ifdef _GLIBCPP_USE_WCHAR_T
+   typedef basic_stdiobuf<wchar_t> wstdiobuf;
+ #endif
+ 
+   template<typename _CharT>
+     class basic_istdiostream;
+   typedef basic_istdiostream<char> istdiostream;
+ #ifdef _GLIBCPP_USE_WCHAR_T
+   typedef basic_istdiostream<wchar_t> wistdiostream;
+ #endif
+ 
+   template<typename _CharT>
+     class basic_ostdiostream;
+   typedef basic_ostdiostream<char> ostdiostream;
+ #ifdef _GLIBCPP_USE_WCHAR_T
+   typedef basic_ostdiostream<wchar_t> wostdiostream;
+ #endif
+ 
+   template<typename _CharT>
+     class basic_stdiostream;
+   typedef basic_stdiostream<char> stdiostream;
+ #ifdef _GLIBCPP_USE_WCHAR_T
+   typedef basic_stdiostream<wchar_t> wstdiostream;
+ #endif
+ 
+   // basic_stdiobuf
+   // Minimal wrapper around FILE*
+   template<>
+     class basic_stdiobuf<char> : public std::basic_streambuf<char>
+     {
+     private:
+       std::FILE* const _M_file;
+ 
+     public:
+       explicit basic_stdiobuf(std::FILE* __file)
+       : _M_file(__file)
+       { }
+ 
+       std::FILE*
+       stdiofile() const
+       { return _M_file; }
+ 
+     protected:
+       virtual int_type
+       underflow()
+       {
+ 	int_type __c = std::getc(_M_file);
+ 	return std::ungetc(__c, _M_file);
+       }
+ 
+       virtual int_type
+       uflow()
+       { return std::getc(_M_file); }
+ 
+       virtual int_type
+       pbackfail(int_type __c = traits_type::eof())
+       { return std::ungetc(__c, _M_file); }
+ 
+       virtual std::streamsize
+       xsgetn(char_type* __s, std::streamsize __n)
+       { return std::fread(__s, 1, __n, _M_file); }
+ 
+       virtual std::streamsize
+       showmanyc()
+       { return std::__showmanyc_helper(_M_file, true); }
+ 
+       virtual int_type
+       overflow(int_type __c = traits_type::eof())
+       {
+ 	int_type __ret;
+ 	if (traits_type::eq_int_type(__c, traits_type::eof()))
+ 	  {
+ 	    if (std::fflush(_M_file))
+ 	      __ret = traits_type::eof();
+ 	    else
+ 	      __ret = traits_type::not_eof(__c);
+ 	  }
+ 	else
+ 	  __ret = std::putc(__c, _M_file);
+ 	return __ret;
+       }
+ 
+       virtual std::streamsize
+       xsputn(const char_type* __s, std::streamsize __n)
+       { return std::fwrite(__s, 1, __n, _M_file); }
+ 
+       virtual int
+       sync()
+       { return std::fflush(_M_file); }
+ 
+       virtual std::streampos
+       seekoff(std::streamoff __off, std::ios_base::seekdir __dir,
+ 	      std::ios_base::openmode = std::ios_base::in | std::ios_base::out)
+       {
+ 	std::streampos __ret(std::streamoff(-1));
+ 	int __whence;
+ 	if (__dir == std::ios_base::beg)
+ 	  __whence = SEEK_SET;
+ 	else if (__dir == std::ios_base::cur)
+ 	  __whence = SEEK_CUR;
+ 	else
+ 	  __whence = SEEK_END;
+ 	
+ 	if (!fseek(_M_file, __off, __whence))
+ 	  __ret = std::streampos(std::ftell(_M_file));
+ 	return __ret;
+       }
+ 
+       virtual std::streampos
+       seekpos(std::streampos __pos,
+ 	      std::ios_base::openmode __mode =
+ 	      std::ios_base::in | std::ios_base::out)
+       { return seekoff(std::streamoff(__pos), std::ios_base::beg, __mode); }
+     };
+ 
+ #ifdef _GLIBCPP_USE_WCHAR_T
+   template<>
+     class basic_stdiobuf<wchar_t> : public std::basic_streambuf<wchar_t>
+     {
+     private:
+       std::FILE* const _M_file;
+ 
+     public:
+       explicit basic_stdiobuf(std::FILE* __file)
+       : _M_file(__file)
+       { }
+ 
+       std::FILE*
+       stdiofile() const
+       { return _M_file; }
+ 
+     protected:
+       virtual int_type
+       underflow()
+       {
+ 	int_type __c = std::getwc(_M_file);
+ 	return std::ungetwc(__c, _M_file);
+       }
+ 
+       virtual int_type
+       uflow()
+       { return std::getwc(_M_file); }
+ 
+       virtual int_type
+       pbackfail(int_type __c = traits_type::eof())
+       { return std::ungetwc(__c, _M_file); }
+ 
+       virtual std::streamsize
+       xsgetn(char_type* __s, std::streamsize __n)
+       {
+ 	std::streamsize __ret = 0;
+ 	while (__n--)
+ 	  {
+ 	    int_type __c = std::getwc(_M_file);
+ 	    if (__c == WEOF)
+ 	      break;
+ 	    *__s++ = __c;
+ 	    ++__ret;
+ 	  }
+ 	return __ret;
+       }
+ 
+       virtual int_type
+       overflow(int_type __c = traits_type::eof())
+       {
+ 	int_type __ret;
+ 	if (traits_type::eq_int_type(__c, traits_type::eof()))
+ 	  {
+ 	    if (std::fflush(_M_file))
+ 	      __ret = traits_type::eof();
+ 	    else
+ 	      __ret = traits_type::not_eof(__c);
+ 	  }
+ 	else
+ 	  __ret = std::putwc(__c, _M_file);
+ 	return __ret;
+       }
+ 
+       virtual std::streamsize
+       xsputn(const char_type* __s, std::streamsize __n)
+       {
+ 	std::streamsize __ret = 0;
+ 	while (__n--)
+ 	  {
+ 	    if (std::putwc(*__s++, _M_file) == WEOF)
+ 	      break;
+ 	    ++__ret;
+ 	  }
+ 	return __ret;
+       }
+ 
+       virtual int
+       sync()
+       { return std::fflush(_M_file); }
+     };
+ #endif
+ 
+   template<typename _CharT>
+     class basic_istdiostream : public std::basic_istream<_CharT>
+     {
+     private:
+       typedef std::basic_istream<_CharT> __istream_type;
+       typedef basic_stdiobuf<_CharT> __stdiobuf_type;
+ 
+       basic_stdiobuf<_CharT> _M_buf;
+ 
+     public:
+       explicit basic_istdiostream(std::FILE* __file)
+       : __istream_type(&_M_buf), _M_buf(__file)
+       { }
+ 
+       __stdiobuf_type*
+       rdbuf() const
+       { return const_cast<__stdiobuf_type*>(&_M_buf); }
+     };
+ 
+   template<typename _CharT>
+     class basic_ostdiostream : public std::basic_ostream<_CharT>
+     {
+     private:
+       typedef std::basic_ostream<_CharT> __ostream_type;
+       typedef basic_stdiobuf<_CharT> __stdiobuf_type;
+ 
+       basic_stdiobuf<_CharT> _M_buf;
+ 
+     public:
+       explicit basic_ostdiostream(std::FILE* __file)
+       : __ostream_type(&_M_buf), _M_buf(__file)
+       { }
+ 
+       __stdiobuf_type*
+       rdbuf() const
+       { return const_cast<__stdiobuf_type*>(&_M_buf); }      
+     };
+ 
+   template<typename _CharT>
+     class basic_stdiostream : public std::basic_iostream<_CharT>
+     {
+     private:
+       typedef std::basic_iostream<_CharT> __iostream_type;
+       typedef basic_stdiobuf<_CharT> __stdiobuf_type;
+ 
+       basic_stdiobuf<_CharT> _M_buf;
+ 
+     public:
+       explicit basic_stdiostream(std::FILE* __file)
+       : __iostream_type(&_M_buf), _M_buf(__file)
+       { }
+ 
+       __stdiobuf_type*
+       rdbuf() const
+       { return const_cast<__stdiobuf_type*>(&_M_buf); }
+     };
+ } // namespace __gnu_cxx
+ 
+ #endif /* _EXT_STDIOSTREAM_H */
Index: libstdc++-v3/src/globals.cc
===================================================================
RCS file: /home/petur/cvsroot/gcc/libstdc++-v3/src/globals.cc,v
retrieving revision 1.1.1.3
diff -c -3 -p -r1.1.1.3 globals.cc
*** libstdc++-v3/src/globals.cc	28 Apr 2003 21:16:34 -0000	1.1.1.3
--- libstdc++-v3/src/globals.cc	1 May 2003 22:36:30 -0000
***************
*** 32,37 ****
--- 32,38 ----
  #include <ostream>
  #include <locale>
  #include <ext/stdio_filebuf.h>
+ #include <ext/stdiostream.h>
  
  // On AIX, and perhaps other systems, library initialization order is
  // not guaranteed.  For example, the static initializers for the main
*************** namespace __gnu_cxx
*** 78,98 ****
  {
    using namespace std;
  
!   // Because <iostream> declares the standard streams to be [io]stream
!   // types instead of say [io]fstream types, it is also necessary to
!   // allocate the actual file buffers in this file.
    typedef char fake_filebuf[sizeof(stdio_filebuf<char>)]
    __attribute__ ((aligned(__alignof__(stdio_filebuf<char>))));
!   fake_filebuf buf_cout;
!   fake_filebuf buf_cin;
!   fake_filebuf buf_cerr;
  
  #ifdef _GLIBCPP_USE_WCHAR_T
    typedef char fake_wfilebuf[sizeof(stdio_filebuf<wchar_t>)]
    __attribute__ ((aligned(__alignof__(stdio_filebuf<wchar_t>))));
!   fake_wfilebuf buf_wcout;
!   fake_wfilebuf buf_wcin;
!   fake_wfilebuf buf_wcerr;
  #endif
  
    typedef char fake_locale_Impl[sizeof(locale::_Impl)]
--- 79,110 ----
  {
    using namespace std;
  
!   // We use different stream buffer types depending on whether
!   // ios_base::sync_with_stdio(false) has been called.
!   typedef char fake_stdiobuf[sizeof(stdiobuf)]
!   __attribute__ ((aligned(__alignof__(stdiobuf))));
!   fake_stdiobuf buf_cout_sync;
!   fake_stdiobuf buf_cin_sync;
!   fake_stdiobuf buf_cerr_sync;
! 
    typedef char fake_filebuf[sizeof(stdio_filebuf<char>)]
    __attribute__ ((aligned(__alignof__(stdio_filebuf<char>))));
!   fake_filebuf buf_cout_unsync;
!   fake_filebuf buf_cin_unsync;
!   fake_filebuf buf_cerr_unsync;
  
  #ifdef _GLIBCPP_USE_WCHAR_T
+   typedef char fake_wstdiobuf[sizeof(wstdiobuf)]
+   __attribute__ ((aligned(__alignof__(wstdiobuf))));
+   fake_wstdiobuf buf_wcout_sync;
+   fake_wstdiobuf buf_wcin_sync;
+   fake_wstdiobuf buf_wcerr_sync;
+ 
    typedef char fake_wfilebuf[sizeof(stdio_filebuf<wchar_t>)]
    __attribute__ ((aligned(__alignof__(stdio_filebuf<wchar_t>))));
!   fake_wfilebuf buf_wcout_unsync;
!   fake_wfilebuf buf_wcin_unsync;
!   fake_wfilebuf buf_wcerr_unsync;
  #endif
  
    typedef char fake_locale_Impl[sizeof(locale::_Impl)]
Index: libstdc++-v3/src/ios.cc
===================================================================
RCS file: /home/petur/cvsroot/gcc/libstdc++-v3/src/ios.cc,v
retrieving revision 1.1.1.5
diff -c -3 -p -r1.1.1.5 ios.cc
*** libstdc++-v3/src/ios.cc	28 Apr 2003 21:16:34 -0000	1.1.1.5
--- libstdc++-v3/src/ios.cc	1 May 2003 22:36:30 -0000
***************
*** 38,55 ****
  #include <fstream>
  #include <bits/atomicity.h>
  #include <ext/stdio_filebuf.h>
  
  namespace __gnu_cxx
  {
    // Extern declarations for global objects in src/globals.cc.
!   extern stdio_filebuf<char> buf_cout;
!   extern stdio_filebuf<char> buf_cin;
!   extern stdio_filebuf<char> buf_cerr;
  
  #ifdef _GLIBCPP_USE_WCHAR_T
!   extern stdio_filebuf<wchar_t> buf_wcout;
!   extern stdio_filebuf<wchar_t> buf_wcin;
!   extern stdio_filebuf<wchar_t> buf_wcerr;
  #endif
  } // namespace __gnu_cxx
  
--- 38,64 ----
  #include <fstream>
  #include <bits/atomicity.h>
  #include <ext/stdio_filebuf.h>
+ #include <ext/stdiostream.h>
  
  namespace __gnu_cxx
  {
    // Extern declarations for global objects in src/globals.cc.
!   extern stdiobuf buf_cout_sync;
!   extern stdiobuf buf_cin_sync;
!   extern stdiobuf buf_cerr_sync;
! 
!   extern stdio_filebuf<char> buf_cout_unsync;
!   extern stdio_filebuf<char> buf_cin_unsync;
!   extern stdio_filebuf<char> buf_cerr_unsync;
  
  #ifdef _GLIBCPP_USE_WCHAR_T
!   extern wstdiobuf buf_wcout_sync;
!   extern wstdiobuf buf_wcin_sync;
!   extern wstdiobuf buf_wcerr_sync;
! 
!   extern stdio_filebuf<wchar_t> buf_wcout_unsync;
!   extern stdio_filebuf<wchar_t> buf_wcin_unsync;
!   extern stdio_filebuf<wchar_t> buf_wcerr_unsync;
  #endif
  } // namespace __gnu_cxx
  
*************** namespace std 
*** 153,202 ****
    ios_base::failure::what() const throw()
    { return _M_name; }
  
-   void
-   ios_base::Init::_S_create_buffers(bool __sync)
-   {
-     size_t __out_size = __sync ? 0 : static_cast<size_t>(BUFSIZ);
-     size_t __in_size = __sync ? 1 : static_cast<size_t>(BUFSIZ);
- 
-     // Create stream buffers for the standard streams and use those
-     // buffers without destroying and recreating the streams.
-     new (&buf_cout) stdio_filebuf<char>(stdout, ios_base::out, __out_size);
-     new (&buf_cin) stdio_filebuf<char>(stdin, ios_base::in, __in_size);
-     new (&buf_cerr) stdio_filebuf<char>(stderr, ios_base::out, __out_size);
-     cout.rdbuf(&buf_cout);
-     cin.rdbuf(&buf_cin);
-     cerr.rdbuf(&buf_cerr);
-     clog.rdbuf(&buf_cerr);
-     
- #ifdef _GLIBCPP_USE_WCHAR_T
-     new (&buf_wcout) stdio_filebuf<wchar_t>(stdout, ios_base::out, __out_size);
-     new (&buf_wcin) stdio_filebuf<wchar_t>(stdin, ios_base::in, __in_size);
-     new (&buf_wcerr) stdio_filebuf<wchar_t>(stderr, ios_base::out, __out_size);
-     wcout.rdbuf(&buf_wcout);
-     wcin.rdbuf(&buf_wcin);
-     wcerr.rdbuf(&buf_wcerr);
-     wclog.rdbuf(&buf_wcerr);
- #endif
-   }
- 
-   void
-   ios_base::Init::_S_destroy_buffers()
-   {
-     // Explicitly call dtors to free any memory that is dynamically
-     // allocated by filebuf ctor or member functions, but don't
-     // deallocate all memory by calling operator delete.
-     buf_cout.~stdio_filebuf();
-     buf_cin.~stdio_filebuf();
-     buf_cerr.~stdio_filebuf();
- 
- #ifdef _GLIBCPP_USE_WCHAR_T
-     buf_wcout.~stdio_filebuf();
-     buf_wcin.~stdio_filebuf();
-     buf_wcerr.~stdio_filebuf();
- #endif
-   }
- 
    ios_base::Init::Init()
    {
      if (_S_ios_base_init == 0)
--- 162,167 ----
*************** namespace std 
*** 204,228 ****
  	// Standard streams default to synced with "C" operations.
  	ios_base::Init::_S_synced_with_stdio = true;
  
  	// The standard streams are constructed once only and never destroyed.
! 	// The stream buffers are set in _S_create_buffers below.
! 	new (&cout) ostream(NULL);
! 	new (&cin) istream(NULL);
! 	new (&cerr) ostream(NULL);
! 	new (&clog) ostream(NULL);
  	cin.tie(&cout);
  	cerr.flags(ios_base::unitbuf);
  	
  #ifdef _GLIBCPP_USE_WCHAR_T
! 	new (&wcout) wostream(NULL);
! 	new (&wcin) wistream(NULL);
! 	new (&wcerr) wostream(NULL);
! 	new (&wclog) wostream(NULL);
  	wcin.tie(&wcout);
  	wcerr.flags(ios_base::unitbuf);
  #endif
  
- 	_S_create_buffers(ios_base::Init::_S_synced_with_stdio);
  	_S_ios_base_init = 1;
        }
      ++_S_ios_base_init;
--- 169,199 ----
  	// Standard streams default to synced with "C" operations.
  	ios_base::Init::_S_synced_with_stdio = true;
  
+ 	new (&buf_cout_sync) stdiobuf(stdout);
+ 	new (&buf_cin_sync) stdiobuf(stdin);
+ 	new (&buf_cerr_sync) stdiobuf(stderr);
+ 
  	// The standard streams are constructed once only and never destroyed.
! 	new (&cout) ostream(&buf_cout_sync);
! 	new (&cin) istream(&buf_cin_sync);
! 	new (&cerr) ostream(&buf_cerr_sync);
! 	new (&clog) ostream(&buf_cerr_sync);
  	cin.tie(&cout);
  	cerr.flags(ios_base::unitbuf);
  	
  #ifdef _GLIBCPP_USE_WCHAR_T
! 	new (&buf_wcout_sync) wstdiobuf(stdout);
! 	new (&buf_wcin_sync) wstdiobuf(stdin);
! 	new (&buf_wcerr_sync) wstdiobuf(stderr);
! 
! 	new (&wcout) wostream(&buf_wcout_sync);
! 	new (&wcin) wistream(&buf_wcin_sync);
! 	new (&wcerr) wostream(&buf_wcerr_sync);
! 	new (&wclog) wostream(&buf_wcerr_sync);
  	wcin.tie(&wcout);
  	wcerr.flags(ios_base::unitbuf);
  #endif
  
  	_S_ios_base_init = 1;
        }
      ++_S_ios_base_init;
*************** namespace std 
*** 388,395 ****
      if (!__sync && __ret)
        {
  	ios_base::Init::_S_synced_with_stdio = __sync;
! 	ios_base::Init::_S_destroy_buffers();
! 	ios_base::Init::_S_create_buffers(__sync);
        }
      return __ret; 
    }
--- 359,397 ----
      if (!__sync && __ret)
        {
  	ios_base::Init::_S_synced_with_stdio = __sync;
! 
! 	// Explicitly call dtors to free any memory that is dynamically
! 	// allocated by filebuf ctor or member functions, but don't
! 	// deallocate all memory by calling operator delete.
! 	buf_cout_sync.~stdiobuf();
! 	buf_cin_sync.~stdiobuf();
! 	buf_cerr_sync.~stdiobuf();
! 
! #ifdef _GLIBCPP_USE_WCHAR_T
! 	buf_wcout_sync.~wstdiobuf();
! 	buf_wcin_sync.~wstdiobuf();
! 	buf_wcerr_sync.~wstdiobuf();
! #endif
! 
! 	// Create stream buffers for the standard streams and use those
! 	// buffers without destroying and recreating the streams.
! 	new (&buf_cout_unsync) stdio_filebuf<char>(stdout, ios_base::out);
! 	new (&buf_cin_unsync) stdio_filebuf<char>(stdin, ios_base::in);
! 	new (&buf_cerr_unsync) stdio_filebuf<char>(stderr, ios_base::out);
! 	cout.rdbuf(&buf_cout_unsync);
! 	cin.rdbuf(&buf_cin_unsync);
! 	cerr.rdbuf(&buf_cerr_unsync);
! 	clog.rdbuf(&buf_cerr_unsync);
!     
! #ifdef _GLIBCPP_USE_WCHAR_T
! 	new (&buf_wcout_unsync) stdio_filebuf<wchar_t>(stdout, ios_base::out);
! 	new (&buf_wcin_unsync) stdio_filebuf<wchar_t>(stdin, ios_base::in);
! 	new (&buf_wcerr_unsync) stdio_filebuf<wchar_t>(stderr, ios_base::out);
! 	wcout.rdbuf(&buf_wcout_unsync);
! 	wcin.rdbuf(&buf_wcin_unsync);
! 	wcerr.rdbuf(&buf_wcerr_unsync);
! 	wclog.rdbuf(&buf_wcerr_unsync);
! #endif
        }
      return __ret; 
    }
Index: libstdc++-v3/testsuite/27_io/objects/char/10.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/char/10.cc
diff -N libstdc++-v3/testsuite/27_io/objects/char/10.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/char/10.cc	1 May 2003 22:14:51 -0000
***************
*** 0 ****
--- 1,73 ----
+ // 2003-05-01  Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2003 Free Software Foundation, Inc.
+ //
+ // This file is part of the GNU ISO C++ Library.  This library is free
+ // software; you can redistribute it and/or modify it under the
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+ 
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ // GNU General Public License for more details.
+ 
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING.  If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+  
+ #include <iostream>
+ #include <cstdio>
+ #include <testsuite_hooks.h>
+ 
+ void test10()
+ {
+   using namespace std;
+ 
+   bool test = true;
+   const char* name = "filebuf_virtuals-1.txt";
+ 
+   FILE* ret = freopen(name, "r", stdin);
+   VERIFY( ret != NULL );
+ 
+   streampos p1 = cin.tellg();
+   VERIFY( p1 != streampos(-1) );
+   VERIFY( streamoff(p1) == 0 );
+ 
+   cin.seekg(0, ios::end);
+   VERIFY( cin.good() );
+ 
+   streampos p2 = cin.tellg();
+   VERIFY( p2 != streampos(-1) );
+   VERIFY( p2 != p1 );
+   VERIFY( streamoff(p2) == ftell(stdin) );
+ 
+   cin.seekg(p1);
+   VERIFY( cin.good() );
+ 
+   streamoff n = p2 - p1;
+   VERIFY( n > 0 );
+ 	
+   for (streamoff i = 0; i < n; ++i)
+     {
+       streampos p3 = cin.tellg();
+       VERIFY( streamoff(p3) == i );
+       VERIFY( ftell(stdin) == i );
+       cin.get();
+       VERIFY( cin.good() );
+     }
+ 
+   streampos p4 = cin.tellg();
+   VERIFY( streamoff(p4) == n );
+   VERIFY( ftell(stdin) == n );
+   cin.get();
+   VERIFY( cin.eof() );
+ }
+ 
+ int main()
+ {
+   test10();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/char/9.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/char/9.cc
diff -N libstdc++-v3/testsuite/27_io/objects/char/9.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/char/9.cc	1 May 2003 21:51:46 -0000
***************
*** 0 ****
--- 1,47 ----
+ // 2003-05-01  Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2003 Free Software Foundation, Inc.
+ //
+ // This file is part of the GNU ISO C++ Library.  This library is free
+ // software; you can redistribute it and/or modify it under the
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+ 
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ // GNU General Public License for more details.
+ 
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING.  If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+  
+ #include <iostream>
+ #include <cstdio>
+ #include <testsuite_hooks.h>
+ 
+ void test09()
+ {
+   using namespace std;
+ 
+   bool test = true;
+   const char* name = "tmp_09";
+ 
+   FILE* fout = fopen(name, "w");
+   fputs("abc\n", fout);
+   fclose(fout);
+ 
+   freopen(name, "r", stdin);
+  
+   // The number of unread characters should be 4 (a, b, c, \\n)
+   VERIFY( 4 == std::cin.rdbuf()->in_avail() );
+ }
+ 
+ int 
+ main()
+ {
+   test09();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/char/9661-1.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/char/9661-1.cc
diff -N libstdc++-v3/testsuite/27_io/objects/char/9661-1.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/char/9661-1.cc	30 Apr 2003 07:03:47 -0000
***************
*** 0 ****
--- 1,85 ----
+ // 2003-04-30  Petur Runolfsson <peturr02@ru.is>
+ 
+ // Copyright (C) 2003 Free Software Foundation, Inc.
+ //
+ // This file is part of the GNU ISO C++ Library.  This library is free
+ // software; you can redistribute it and/or modify it under the
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+ 
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ // GNU General Public License for more details.
+ 
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING.  If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+ 
+ #include <testsuite_hooks.h>
+ #include <cstdio>
+ #include <iostream>
+ #include <unistd.h>
+ #include <signal.h>
+ #include <fcntl.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ 
+ // Check that cin.rdbuf()->sputbackc() puts characters back to stdin.
+ // If cin.rdbuf() is a filebuf, this succeeds when stdin is a regular
+ // file, but fails otherwise, hence the named fifo.
+ void test01()
+ {
+   using namespace std;
+ 
+   bool test = true;
+ 
+   const char* name = "tmp_fifo5";
+ 
+   signal(SIGPIPE, SIG_IGN);
+ 
+   unlink(name);  
+   mkfifo(name, S_IRWXU);
+   
+   int child = fork();
+   VERIFY( child != -1 );
+ 
+   if (child == 0)
+     {
+       sleep(1);
+       FILE* file = fopen(name, "w");
+       fputs("Whatever\n", file);
+       fflush(file);
+       sleep(2);
+       fclose(file);
+       exit(0);
+     }
+   
+   freopen(name, "r", stdin);
+   sleep(2);
+ 
+   int c1 = fgetc(stdin);
+   VERIFY( c1 != EOF );
+   int c2 = cin.rdbuf()->sputbackc('a');
+   VERIFY( c2 != EOF );
+   VERIFY( c2 == 'a' );
+   
+   int c3 = fgetc(stdin);
+   VERIFY( c3 != EOF );
+   VERIFY( c3 == c2 );
+   int c4 = ungetc('b', stdin);
+   VERIFY( c4 != EOF );
+   VERIFY( c4 == 'b' );
+   
+   int c5 = cin.rdbuf()->sgetc();
+   VERIFY( c5 != EOF );
+   VERIFY( c5 == c4 );
+ }
+ 
+ int main()
+ {
+   test01();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.cc
diff -N libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.cc	30 Apr 2003 20:17:39 -0000
***************
*** 0 ****
--- 1,47 ----
+ // 2003-04-30  Petur Runolfsson <peturr02@ru.is>
+ 
+ // Copyright (C) 2003 Free Software Foundation, Inc.
+ //
+ // This file is part of the GNU ISO C++ Library.  This library is free
+ // software; you can redistribute it and/or modify it under the
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+ 
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ // GNU General Public License for more details.
+ 
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING.  If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+ 
+ #include <testsuite_hooks.h>
+ #include <cstdio>
+ #include <iostream>
+ 
+ void test02()
+ {
+   using namespace std;
+ 
+   bool test = true;
+ 
+   int c1 = fgetc(stdin);
+   int c2 = cin.rdbuf()->sputbackc(c1);
+   VERIFY( c2 == c1 );
+   
+   int c3 = fgetc(stdin);
+   VERIFY( c3 == c1 );
+   ungetc(c3, stdin);
+   
+   int c4 = cin.rdbuf()->sgetc();
+   VERIFY( c4 == c3 );
+ }
+ 
+ int main()
+ {
+   test02();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.in
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.in
diff -N libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.in
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/char/9661-2_xin.in	30 Apr 2003 07:42:22 -0000
***************
*** 0 ****
--- 1 ----
+ For what you dream of
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/1.cc
===================================================================
RCS file: /home/petur/cvsroot/gcc/libstdc++-v3/testsuite/27_io/objects/wchar_t/1.cc,v
retrieving revision 1.1.1.1
diff -c -3 -p -r1.1.1.1 1.cc
*** libstdc++-v3/testsuite/27_io/objects/wchar_t/1.cc	24 Apr 2003 19:59:14 -0000	1.1.1.1
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/1.cc	1 May 2003 08:29:51 -0000
***************
*** 1,4 ****
! // 2000-08-02 bkoz
  
  // Copyright (C) 2000, 2003 Free Software Foundation, Inc.
  //
--- 1,4 ----
! // 2003-05-01 Petur Runolfsson  <peturr02@ru.is>
  
  // Copyright (C) 2000, 2003 Free Software Foundation, Inc.
  //
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/10.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/10.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/10.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/10.cc	2 May 2003 07:33:10 -0000
***************
*** 0 ****
--- 1,121 ----
+ // 2003-05-01  Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2003 Free Software Foundation, Inc.
+ //
+ // This file is part of the GNU ISO C++ Library.  This library is free
+ // software; you can redistribute it and/or modify it under the
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+ 
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ // GNU General Public License for more details.
+ 
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING.  If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+ 
+ #include <iostream>
+ #include <cstdio>
+ #include <testsuite_hooks.h>
+ 
+ // Test handling of UTF-8 in wcin and wcout
+ void test10()
+ {
+   using namespace std;
+   
+   bool test = true;
+   const char* name = "tmp_10";
+ 
+   locale loc(__gnu_cxx_test::try_named_locale("se_NO.UTF-8"));
+   locale::global(loc);
+   wcin.imbue(loc);
+   wcout.imbue(loc);
+ 
+   const char* e_lit =
+     "\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf\x10\x11\x12\x13"
+     "\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20!\"#$%&"
+     "'()*+,-./0123456789:;<=>?@}~\x7f\xc2\x80\xc2\x81\xc2\x82\xc2"
+     "\x83\xc2\x84\xc2\x85\xc2\x86\xc2\x87\xc2\x88\xc2\x89\xc2\x8a"
+     "\xc2\x8b\xc2\x8c\xc2\x8d\xc2\x8e\xc2\x8f\xc2\x90\xc2\x91\xc2"
+     "\x92\xc2\x93\xc2\x94\xc2\x95\xc2\x96\xc2\x97\xc2\x98\xc2\x99"
+     "\xc2\x9a\xc2\x9b\xc2\x9c\xc3\xba\xc3\xbb\xc3\xbc\xc3\xbd\xc3"
+     "\xbe\xc3\xbf\xc4\x80\xc4\x81\xc4\x82\xc4\x83\xc4\x84\xc4\x85"
+     "\xc4\x86\xc4\x87\xc4\x88\xc4\x89\xc4\x8a\xc4\x8b\xc4\x8c\xc4"
+     "\x8d\xc4\x8e\xc4\x8f\xc4\x90\xc4\x91\xc4\x92\xc4\x93\xc4\x94"
+     "\xc4\x95\xc4\x96\xc4\x97\xc4\x98\xc4\x99\xdf\xb8\xdf\xb9\xdf"
+     "\xba\xdf\xbb\xdf\xbc\xdf\xbd\xdf\xbe\xdf\xbf\xe0\xa0\x80\xe0"
+     "\xa0\x81\xe0\xa0\x82\xe0\xa0\x83\xe0\xa0\x84\xe0\xa0\x85\xe0"
+     "\xa0\x86\xe0\xa0\x87\xe0\xa0\x88\xe0\xa0\x89\xe0\xa0\x8a\xe0"
+     "\xa0\x8b\xe0\xa0\x8c\xe0\xa0\x8d\xe0\xa0\x8e\xe0\xa0\x8f\xe0"
+     "\xa0\x90\xe0\xa0\x91\xe0\xa0\x92\xe0\xa0\x93\xe0\xa0\x94\xe0"
+     "\xa0\x95\xe0\xa0\x96\xe0\xa0\x97\x1\x2\x4\x8\x10\x20@\xc2\x80"
+     "\xc4\x80\xc8\x80\xd0\x80\xe0\xa0\x80\xe1\x80\x80\xe2\x80\x80"
+     "\xe4\x80\x80\xe8\x80\x80\xf0\x90\x80\x80\xf0\xa0\x80\x80\xf1"
+     "\x80\x80\x80\xf2\x80\x80\x80\xf4\x80\x80\x80\xf8\x88\x80\x80"
+     "\x80\xf8\x90\x80\x80\x80\xf8\xa0\x80\x80\x80\xf9\x80\x80\x80"
+     "\x80\xfa\x80\x80\x80\x80\xfc\x84\x80\x80\x80\x80\xfc\x88\x80"
+     "\x80\x80\x80\xfc\x90\x80\x80\x80\x80\xfc\xa0\x80\x80\x80\x80"
+     "\xfd\x80\x80\x80\x80\x80";
+   size_t e_size = strlen(e_lit);
+ 
+   const wchar_t i_lit[] = {
+     0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc,
+     0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+     0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, L'!',
+     L'"', L'#', L'$', L'%', L'&', L'\'', L'(', L')', L'*', L'+',
+     L',', L'-', L'.', L'/', L'0', L'1', L'2', L'3', L'4', L'5',
+     L'6', L'7', L'8', L'9', L':', L';', L'<', L'=', L'>', L'?',
+     L'@', L'}', L'~', 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85,
+     0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+     0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
+     0x9a, 0x9b, 0x9c, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x100,
+     0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 0x108, 0x109,
+     0x10a, 0x10b, 0x10c, 0x10d, 0x10e, 0x10f, 0x110, 0x111, 0x112,
+     0x113, 0x114, 0x115, 0x116, 0x117, 0x118, 0x119, 0x7f8, 0x7f9,
+     0x7fa, 0x7fb, 0x7fc, 0x7fd, 0x7fe, 0x7ff, 0x800, 0x801, 0x802,
+     0x803, 0x804, 0x805, 0x806, 0x807, 0x808, 0x809, 0x80a, 0x80b,
+     0x80c, 0x80d, 0x80e, 0x80f, 0x810, 0x811, 0x812, 0x813, 0x814,
+     0x815, 0x816, 0x817, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, L'@',
+     0x80, 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000, 0x8000,
+     0x10000, 0x20000, 0x40000, 0x80000, 0x100000, 0x200000, 0x400000,
+     0x800000, 0x1000000, 0x2000000, 0x4000000, 0x8000000, 0x10000000,
+     0x20000000, 0x40000000, 0x0
+   };
+   size_t i_size = wcslen(i_lit);
+ 
+   freopen(name, "w", stdout);
+   
+   wcout.write(i_lit, i_size);
+   wcout.flush();
+   VERIFY( wcout.good() );
+ 
+   FILE* file = fopen(name, "r");
+   char* buf = new char[e_size + 10];
+   size_t n = fread(buf, 1, e_size + 10, file);
+   VERIFY( n == e_size );
+   VERIFY( !memcmp(buf, e_lit, e_size) );
+   delete[] buf;
+   fclose(file);
+ 
+   freopen(name, "r", stdin);
+   
+   wchar_t* wbuf = new wchar_t[i_size + 10];
+   wcin.read(wbuf, i_size + 10);
+   n = wcin.gcount();
+   VERIFY( n == i_size );
+   VERIFY( !wmemcmp(wbuf, i_lit, i_size) );
+   VERIFY( wcin.eof() );
+   VERIFY( wcin.fail() );
+   VERIFY( !wcin.bad() );
+   delete[] wbuf;
+ }
+ 
+ int main()
+ {
+   test10();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/2.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/2.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/2.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/2.cc	1 May 2003 08:30:29 -0000
***************
*** 0 ****
--- 1,47 ----
+ // 2003-05-01 Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2000, 2001, 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
+ // 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 <iostream>
+ 
+ // Interactive test, to be exercised as follows:
+ // assign stderr to stdout in shell command line,
+ // pipe stdout to cat process and/or redirect stdout to file.
+ // a.out >& output
+ // "hello fine world\n" should be written to stdout, and output, in
+ // proper order.  This is a version of the scott snyder test taken
+ // from: http://gcc.gnu.org/ml/libstdc++/1999-q4/msg00108.html
+ void test04()
+ {
+   using namespace std;
+ 
+   wcout << L"hello ";
+   wcout.flush();
+   wcerr << L"fine ";
+   wcerr.flush();
+   wcout << L"world" << endl;
+   wcout.flush();
+ }
+ 
+ int 
+ main()
+ {
+   test04();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-1_xin.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-1_xin.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-1_xin.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-1_xin.cc	1 May 2003 08:39:04 -0000
***************
*** 0 ****
--- 1,89 ----
+ // 2003-05-01 Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2000, 2001, 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
+ // 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 all the headers except for iostream.
+ #include <algorithm>
+ #include <bitset>
+ #include <complex>
+ #include <deque>
+ #include <exception>
+ #include <fstream>
+ #include <functional>
+ #include <iomanip>
+ #include <ios>
+ #include <iosfwd>
+ #include <istream>
+ #include <iterator>
+ #include <limits>
+ #include <list>
+ #include <locale>
+ #include <map>
+ #include <memory>
+ #include <new>
+ #include <numeric>
+ #include <ostream>
+ #include <queue>
+ #include <set>
+ #include <sstream>
+ #include <stack>
+ #include <stdexcept>
+ #include <streambuf>
+ #include <string>
+ #include <typeinfo>
+ #include <utility>
+ #include <valarray>
+ #include <vector>
+ #include <cassert>
+ #include <cctype>
+ #include <cerrno>
+ #include <cfloat>
+ #include <ciso646>
+ #include <climits>
+ #include <clocale>
+ #include <cmath>
+ #include <csetjmp>
+ #include <csignal>
+ #include <cstdarg>
+ #include <cstddef>
+ #include <cstdio>
+ #include <cstdlib>
+ #include <cstring>
+ #include <ctime>
+ #include <testsuite_hooks.h>
+ 
+ // Include iostream last, just to make is as difficult as possible to
+ // properly initialize the standard iostream objects.
+ #include <iostream>
+ 
+ // libstdc++/2523
+ void test02()
+ {
+   using namespace std;
+   int i;
+   wcin >> i;
+   wcout << "i == " << i << endl;
+ }
+ 
+ int 
+ main()
+ {
+   test02();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-1_xin.in
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-1_xin.in
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-1_xin.in
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-1_xin.in	1 May 2003 08:34:21 -0000
***************
*** 0 ****
--- 1 ----
+ 5588885 
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-2_xin.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-2_xin.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-2_xin.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-2_xin.cc	1 May 2003 08:38:28 -0000
***************
*** 0 ****
--- 1,39 ----
+ // 2003-05-01 Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2000, 2001, 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
+ // 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 <iostream>
+ 
+ // libstdc++/2523
+ void test03()
+ {
+   using namespace std;
+   ios_base::sync_with_stdio(false);
+ 
+   int i;
+   wcin >> i;
+   wcout << "i == " << i << endl;
+ }
+ 
+ int 
+ main()
+ {
+   test03();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-2_xin.in
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-2_xin.in
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-2_xin.in
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/2523-2_xin.in	1 May 2003 08:34:21 -0000
***************
*** 0 ****
--- 1 ----
+ 33332
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/3045.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/3045.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/3045.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/3045.cc	1 May 2003 08:38:33 -0000
***************
*** 0 ****
--- 1,86 ----
+ // 2003-05-01 Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2001, 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
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+ 
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ // GNU General Public License for more details.
+ 
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING.  If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+ 
+ // As a special exception, you may use this file as part of a free software
+ // library without restriction.  Specifically, if other files instantiate
+ // templates or use macros or inline functions from this file, or you compile
+ // this file and link it with other files to produce an executable, this
+ // file does not by itself cause the resulting executable to be covered by
+ // the GNU General Public License.  This exception does not however
+ // invalidate any other reasons why the executable file might be covered by
+ // the GNU General Public License.
+ 
+ #include <fstream>
+ #include <iostream>
+ #include <testsuite_hooks.h>
+ 
+ class gnu_filebuf: public std::wfilebuf
+ {
+   int i;
+ public:
+   gnu_filebuf(int j = 1): i(j) { }
+   ~gnu_filebuf() { --i; }
+   int get_i() { return i;}
+ };
+ 
+ const int initial = 4;
+ gnu_filebuf buf(initial);
+ 
+ // libstdc++/3045, in a vague way.
+ void test01()
+ {
+   bool test = true;
+   int k1;
+ 
+   // 1 normal
+   k1 = buf.get_i();
+   VERIFY( k1 == initial );
+   {
+     std::wcout.rdbuf(&buf);
+   }
+   k1 = buf.get_i();
+   VERIFY( k1 == initial );
+ 
+   // 2 syncd off
+   k1 = buf.get_i();
+   VERIFY( k1 == initial );
+   {
+     std::wcout.rdbuf(&buf);
+     std::ios_base::sync_with_stdio(false); // make sure doesn't clobber buf
+   }
+   k1 = buf.get_i();
+   VERIFY( k1 == initial );
+ 
+   // 3 callling init
+   k1 = buf.get_i();
+   VERIFY( k1 == initial );
+   {
+     std::wcout.rdbuf(&buf);
+     std::ios_base::Init make_sure_initialized;
+   }
+   k1 = buf.get_i();
+   VERIFY( k1 == initial );
+ }
+ 
+ int main()
+ {
+   test01();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/3647.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/3647.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/3647.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/3647.cc	1 May 2003 08:38:40 -0000
***************
*** 0 ****
--- 1,46 ----
+ // 2003-05-01 Petur Runolfsson  <peturr02@ru.is>
+ 
+ // 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
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+ 
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ // GNU General Public License for more details.
+ 
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING.  If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+ 
+ // As a special exception, you may use this file as part of a free software
+ // library without restriction.  Specifically, if other files instantiate
+ // templates or use macros or inline functions from this file, or you compile
+ // this file and link it with other files to produce an executable, this
+ // file does not by itself cause the resulting executable to be covered by
+ // the GNU General Public License.  This exception does not however
+ // invalidate any other reasons why the executable file might be covered by
+ // the GNU General Public License.
+ 
+ // 27.6.1.5 - Template class basic_iostream
+ // NB: This file is for testing iostream with NO OTHER INCLUDES.
+ 
+ #include <iostream>
+ 
+ // libstdc++/3647
+ void test07()
+ {
+   // Should not block.
+   std::wcout << std::wcin.rdbuf()->in_avail() << std::endl;
+ }
+ 
+ int main() 
+ {
+   test07();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/3_xin.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/3_xin.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/3_xin.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/3_xin.cc	1 May 2003 08:38:48 -0000
***************
*** 0 ****
--- 1,42 ----
+ // 2003-05-01 Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2000, 2001, 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
+ // 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 <iostream>
+ 
+ // Interactive test, to be exercised as follows:
+ // run test under truss(1) or strace(1).  Look at
+ // size and pattern of write system calls.
+ // Should be 2 or 3 write(1,[...]) calls when run interactively
+ // depending upon buffering mode enforced.
+ void test05()
+ {
+   std::wcout << L"hello" << L' ' << L"world" << std::endl;
+   std::wcout << L"Enter your name: ";
+   std::wstring s;
+   std::wcin >> s;
+   std::wcout << L"hello " << s << std::endl;
+ }
+ 
+ int 
+ main()
+ {
+   test05();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/3_xin.in
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/3_xin.in
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/3_xin.in
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/3_xin.in	1 May 2003 08:34:21 -0000
***************
*** 0 ****
--- 1 ----
+ JOHN HUME and DAVID TRIMBLE
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/4_xin.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/4_xin.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/4_xin.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/4_xin.cc	1 May 2003 08:38:56 -0000
***************
*** 0 ****
--- 1,39 ----
+ // 2003-05-01 Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2000, 2001, 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
+ // 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 <iostream>
+ 
+ // http://gcc.gnu.org/ml/libstdc++/2002-08/msg00060.html
+ // Should only have to hit enter once.
+ void
+ test10()
+ {
+   using namespace std;
+   wcout << L"Press ENTER once\n";
+   wcin.ignore(1);
+   wcout << L"_M_gcount: " << wcin.gcount() << endl;
+ }
+ 
+ int 
+ main()
+ {
+   test10();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/4_xin.in
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/4_xin.in
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/4_xin.in
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/4_xin.in	1 May 2003 08:34:21 -0000
***************
*** 0 ****
--- 1 ----
+ 
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/5.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/5.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/5.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/5.cc	1 May 2003 08:31:20 -0000
***************
*** 0 ****
--- 1,85 ----
+ // 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.
+ 
+ // 27.3 Standard iostream objects
+ 
+ // Check that standard streams can be used from constructors and
+ // destructors of static objects, provided that an instance of 
+ // ios_base::Init has been constructed.
+ 
+ void init_standard_streams();
+ int use_standard_streams();
+ 
+ struct Strange
+ {
+   int i;
+ 
+   Strange()
+   {
+     init_standard_streams();
+     i = use_standard_streams();
+   }
+ 
+   ~Strange()
+   {
+     use_standard_streams();
+     init_standard_streams();
+   }
+ };
+ 
+ static Strange static_ob;
+ 
+ #include <testsuite_hooks.h>
+ #include <iostream>
+ 
+ void init_standard_streams()
+ {
+   std::ios_base::Init init;
+ }
+ 
+ int use_standard_streams()
+ {
+   std::wcout << L"Hello, world!" << std::endl;
+   std::wcerr << L"World, hello!" << std::endl;
+ 
+   int ret = std::ios_base::xalloc();
+   std::wcin.iword(ret) = ret + 1;
+   std::wcout.iword(ret) = ret + 2;
+   std::wcerr.iword(ret) = ret + 3;
+   std::wclog.iword(ret) = ret + 4;
+   return ret;
+ }
+ 
+ void test05()
+ {
+   bool test = true;
+   int i = static_ob.i;
+ 
+   VERIFY( std::wcin.iword(i) == i + 1 );
+   VERIFY( std::wcout.iword(i) == i + 2 );
+   VERIFY( std::wcerr.iword(i) == i + 3 );
+   VERIFY( std::wclog.iword(i) == i + 4 );
+ }
+ 
+ int main()
+ {
+   test05();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/5268.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/5268.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/5268.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/5268.cc	1 May 2003 08:32:01 -0000
***************
*** 0 ****
--- 1,46 ----
+ // 2003-05-01 Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2001, 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
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+ 
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ // GNU General Public License for more details.
+ 
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING.  If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+ 
+ // As a special exception, you may use this file as part of a free software
+ // library without restriction.  Specifically, if other files instantiate
+ // templates or use macros or inline functions from this file, or you compile
+ // this file and link it with other files to produce an executable, this
+ // file does not by itself cause the resulting executable to be covered by
+ // the GNU General Public License.  This exception does not however
+ // invalidate any other reasons why the executable file might be covered by
+ // the GNU General Public License.
+ 
+ #include <sstream>
+ #include <iostream>
+ 
+ // libstdc++/5268
+ void test04()
+ {
+   std::wstringbuf b1;
+   std::wcout.rdbuf( &b1 );
+   std::wcout << L"hello\n";
+   std::wcout.rdbuf(NULL);
+ }
+ 
+ int main()
+ {
+   test04();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/5280_xin.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/5280_xin.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/5280_xin.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/5280_xin.cc	1 May 2003 08:31:42 -0000
***************
*** 0 ****
--- 1,48 ----
+ // 2003-05-01 Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2000, 2001, 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
+ // 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 <iostream>
+ 
+ // libstdc++/5280
+ // Interactive test: input "1234^D^D" for i should terminate for EOF.
+ void test06()
+ {
+   using namespace std;
+   int i;
+   wcin >> i;
+   if (!wcin.good()) 
+     {
+       wcerr << endl;
+       wcerr << L"i == " << i << endl;
+       wcerr << L"wcin.rdstate() == " << wcin.rdstate() << endl;
+       wcerr << L"wcin.bad() == " << wcin.bad() << endl;      
+       wcerr << L"wcin.fail() == " << wcin.fail() << endl;      
+       wcerr << L"wcin.eof() == " << wcin.eof() << endl;
+     }   
+   else
+     wcerr << L"i == " << i << endl;
+ }
+ 
+ int 
+ main()
+ {
+   test06();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/5280_xin.in
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/5280_xin.in
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/5280_xin.in
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/5280_xin.in	1 May 2003 08:34:21 -0000
***************
*** 0 ****
--- 1 ----
+ 1234
\ No newline at end of file
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/6.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/6.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/6.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/6.cc	1 May 2003 08:28:17 -0000
***************
*** 0 ****
--- 1,50 ----
+ // 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.
+ 
+ // 27.3 Standard iostream objects
+ 
+ // ios_base::Init::~Init() calls wcout.flush(), which may call
+ // wcout.setstate(badbit), which may throw an exception. Check that
+ // the exception doesn't escape from the destructor.
+ 
+ #include <iostream>
+ #include <streambuf>
+ 
+ class Badbuf : public std::wstreambuf
+ {
+ protected:
+   virtual int sync()
+   {
+     return -1;
+   }
+ };
+ 
+ void test06()
+ {
+   std::ios_base::Init init;
+   std::wcout.rdbuf(new Badbuf);
+   std::wcout.exceptions(std::ios_base::badbit);
+ }
+ 
+ int main()
+ {
+   test06();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/6548_xin.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/6548_xin.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/6548_xin.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/6548_xin.cc	1 May 2003 09:05:43 -0000
***************
*** 0 ****
--- 1,39 ----
+ // 2003-05-01 Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2000, 2001, 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
+ // 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 <iostream>
+ #include <testsuite_hooks.h>
+ 
+ // libstdc++/6548
+ void test07()
+ {
+   bool test = true;
+   std::wcout << L"Enter 'test':";
+   std::wstring s;
+   std::getline(std::wcin, s, L'\n');
+   VERIFY( s == L"test" );
+ }
+ 
+ int 
+ main()
+ {
+   test07();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/6548_xin.in
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/6548_xin.in
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/6548_xin.in
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/6548_xin.in	1 May 2003 08:34:21 -0000
***************
*** 0 ****
--- 1 ----
+ test
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-1_xin.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-1_xin.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-1_xin.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-1_xin.cc	1 May 2003 09:04:16 -0000
***************
*** 0 ****
--- 1,38 ----
+ // 2003-05-01 Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2000, 2001, 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
+ // 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 <iostream>
+ 
+ // libstdc++/6648
+ // Interactive tests: each one (run alone) must terminate upon a single '\n'.
+ void test08()
+ {
+   bool test = true;
+   wchar_t buff[2048];
+   std::wcout << "Enter name: ";
+   std::wcin.getline(buff, 2048);
+ }
+ 
+ int 
+ main()
+ {
+   test08();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-1_xin.in
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-1_xin.in
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-1_xin.in
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-1_xin.in	1 May 2003 08:34:21 -0000
***************
*** 0 ****
--- 1 ----
+ Kofi A. Annan
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-2_xin.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-2_xin.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-2_xin.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-2_xin.cc	1 May 2003 09:04:29 -0000
***************
*** 0 ****
--- 1,35 ----
+ // 2003-05-01  Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2000, 2001, 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
+ // 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 <iostream>
+ 
+ void test09()
+ {
+   bool test = true;
+   std::wcout << L"Enter favorite beach: ";
+   std::wcin.ignore(2048, '\n');
+ }
+ 
+ int 
+ main()
+ {
+   test09();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-2_xin.in
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-2_xin.in
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-2_xin.in
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/6648-2_xin.in	1 May 2003 08:34:21 -0000
***************
*** 0 ****
--- 1 ----
+ Oak St. Beach, Chicago
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/7.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/7.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/7.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/7.cc	1 May 2003 08:29:12 -0000
***************
*** 0 ****
--- 1,75 ----
+ // 2003-05-01 Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2003 Free Software Foundation, Inc.
+ //
+ // This file is part of the GNU ISO C++ Library.  This library is free
+ // software; you can redistribute it and/or modify it under the
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+ 
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ // GNU General Public License for more details.
+ 
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING.  If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+ 
+ // 27.3 Standard iostream objects
+ 
+ #include <fstream>
+ #include <iostream>
+ #include <unistd.h>
+ #include <signal.h>
+ #include <fcntl.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <testsuite_hooks.h>
+ 
+ // Check that wcout.flush() is called when last ios_base::Init is destroyed.
+ void test07()
+ {
+   using namespace std;
+   bool test = true;
+ 
+   const char* name = "tmp_fifo4";
+ 
+   signal(SIGPIPE, SIG_IGN);
+ 
+   unlink(name);  
+   mkfifo(name, S_IRWXU);
+   
+   int child = fork();
+   VERIFY( child != -1 );
+ 
+   if (child == 0)
+     {
+       wfilebuf fbout;
+       sleep(1);
+       fbout.open(name, ios_base::out);
+       wcout.rdbuf(&fbout);
+       fbout.sputc(L'a');
+       sleep(2);
+       // NB: fbout is *not* destroyed here!
+       exit(0);
+     }
+   
+   wfilebuf fbin;
+   fbin.open(name, ios_base::in);
+   sleep(2);
+   wfilebuf::int_type c = fbin.sbumpc();
+   VERIFY( c != wfilebuf::traits_type::eof() );
+   VERIFY( c == wfilebuf::traits_type::to_int_type(L'a') );
+ 
+   fbin.close();
+ }
+ 
+ int
+ main()
+ {
+   test07();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/7744_xin.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/7744_xin.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/7744_xin.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/7744_xin.cc	1 May 2003 08:28:56 -0000
***************
*** 0 ****
--- 1,42 ----
+ // 2003-05-01  Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2000, 2001, 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
+ // 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 <iostream>
+ #include <testsuite_hooks.h>
+ 
+ // libstdc++/7744
+ void test11()
+ {
+   bool test = true;
+   std::ios::sync_with_stdio(false);
+ 
+   std::wcout << "Type in the characters 'abc' and press <ENTER>: ";
+   std::wcin.peek();
+  
+   // The number of unread characters should be 4 (a, b, c, \\n)
+   VERIFY( 4 == std::wcin.rdbuf()->in_avail() );
+ }
+ 
+ int 
+ main()
+ {
+   test11();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/7744_xin.in
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/7744_xin.in
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/7744_xin.in
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/7744_xin.in	1 May 2003 08:34:21 -0000
***************
*** 0 ****
--- 1 ----
+ abc
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/8.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/8.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/8.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/8.cc	1 May 2003 08:29:32 -0000
***************
*** 0 ****
--- 1,51 ----
+ // 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.
+ 
+   // 27.3 - Standard iostream objects p 2
+ 
+ #include <iostream>
+ #include <testsuite_hooks.h>
+ 
+ void test02() 
+ {
+   bool test = true;
+   
+   // 27.3 - Standard iostream objects p 2
+   // The objects are not destroyed during program execution.
+   void* p1 = &std::wcout;
+   void* p2 = &std::wcin;
+   void* p3 = &std::wcerr;
+   void* p4 = &std::wclog;
+   std::ios_base::sync_with_stdio(false); 
+   void* p1s = &std::wcout;
+   void* p2s = &std::wcin;
+   void* p3s = &std::wcerr;
+   void* p4s = &std::wclog;
+   VERIFY( p1 == p1s );
+   VERIFY( p2 == p2s );
+   VERIFY( p3 == p3s );
+   VERIFY( p4 == p4s );
+ }
+ 
+ int main(void)
+ {
+   test02();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/9520.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/9520.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/9520.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/9520.cc	30 Apr 2003 21:52:35 -0000
***************
*** 0 ****
--- 1,57 ----
+ // 2003-04-30  Petur Runolfsson <peturr02@ru.is>
+ 
+ // Copyright (C) 2003 Free Software Foundation, Inc.
+ //
+ // This file is part of the GNU ISO C++ Library.  This library is free
+ // software; you can redistribute it and/or modify it under the
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+ 
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ // GNU General Public License for more details.
+ 
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING.  If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+ 
+ #include <testsuite_hooks.h>
+ #include <iostream>
+ #include <cstdio>
+ 
+ void test01()
+ {
+   using namespace std;
+ 
+   bool test = true;
+   const char* name = "tmp_9520";
+ 
+   FILE* file = fopen(name, "w");
+   for (int i = 1; i < 256; ++i)
+     putc(static_cast<unsigned char>(i), file);
+   fclose(file);
+ 
+   locale loc (__gnu_cxx_test::try_named_locale("de_DE.ISO-8859-15@euro"));
+   locale::global(loc); // Set locale for stdin
+ 
+   freopen(name, "r", stdin);
+ 
+   wcin.imbue(loc);
+ 
+   for (int j = 1; j < 256; ++j)
+     {
+       wint_t c1 = wcin.rdbuf()->sgetc();
+       VERIFY( c1 != WEOF );
+       wint_t c2 = wcin.rdbuf()->sbumpc();
+       VERIFY( c1 == c2 );
+     }
+ }
+ 
+ int main()
+ {
+   test01();  
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-1.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-1.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-1.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-1.cc	30 Apr 2003 08:11:34 -0000
***************
*** 0 ****
--- 1,85 ----
+ // 2003-04-30  Petur Runolfsson <peturr02@ru.is>
+ 
+ // Copyright (C) 2003 Free Software Foundation, Inc.
+ //
+ // This file is part of the GNU ISO C++ Library.  This library is free
+ // software; you can redistribute it and/or modify it under the
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+ 
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ // GNU General Public License for more details.
+ 
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING.  If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+ 
+ #include <testsuite_hooks.h>
+ #include <cstdio>
+ #include <iostream>
+ #include <unistd.h>
+ #include <signal.h>
+ #include <fcntl.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ 
+ // Check that wcin.rdbuf()->sputbackc() puts characters back to stdin.
+ // If wcin.rdbuf() is a filebuf, this succeeds when stdin is a regular
+ // file, but fails otherwise, hence the named fifo.
+ void test01()
+ {
+   using namespace std;
+ 
+   bool test = true;
+ 
+   const char* name = "tmp_fifo5";
+ 
+   signal(SIGPIPE, SIG_IGN);
+ 
+   unlink(name);  
+   mkfifo(name, S_IRWXU);
+   
+   int child = fork();
+   VERIFY( child != -1 );
+ 
+   if (child == 0)
+     {
+       sleep(1);
+       FILE* file = fopen(name, "w");
+       fputs("Whatever\n", file);
+       fflush(file);
+       sleep(2);
+       fclose(file);
+       exit(0);
+     }
+   
+   freopen(name, "r", stdin);
+   sleep(2);
+ 
+   wint_t c1 = fgetwc(stdin);
+   VERIFY( c1 != WEOF );
+   wint_t c2 = wcin.rdbuf()->sputbackc(L'a');
+   VERIFY( c2 != WEOF );
+   VERIFY( c2 == L'a' );
+   
+   wint_t c3 = fgetwc(stdin);
+   VERIFY( c3 != WEOF );
+   VERIFY( c3 == c2 );
+   wint_t c4 = ungetwc(L'b', stdin);
+   VERIFY( c4 != WEOF );
+   VERIFY( c4 == L'b' );
+   
+   wint_t c5 = wcin.rdbuf()->sgetc();
+   VERIFY( c5 != WEOF );
+   VERIFY( c5 == c4 );
+ }
+ 
+ int main()
+ {
+   test01();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-2_xin.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-2_xin.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-2_xin.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-2_xin.cc	1 May 2003 09:07:01 -0000
***************
*** 0 ****
--- 1,48 ----
+ // 2003-04-30  Petur Runolfsson <peturr02@ru.is>
+ 
+ // Copyright (C) 2003 Free Software Foundation, Inc.
+ //
+ // This file is part of the GNU ISO C++ Library.  This library is free
+ // software; you can redistribute it and/or modify it under the
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+ 
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ // GNU General Public License for more details.
+ 
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING.  If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+ 
+ #include <testsuite_hooks.h>
+ #include <cstdio>
+ #include <iostream>
+ #include <cwchar>
+ 
+ void test02()
+ {
+   using namespace std;
+ 
+   bool test = true;
+ 
+   wint_t c1 = fgetwc(stdin);
+   wint_t c2 = wcin.rdbuf()->sputbackc(c1);
+   VERIFY( c2 == c1 );
+   
+   wint_t c3 = fgetwc(stdin);
+   VERIFY( c3 == c1 );
+   ungetwc(c3, stdin);
+   
+   wint_t c4 = wcin.rdbuf()->sgetc();
+   VERIFY( c4 == c3 );
+ }
+ 
+ int main()
+ {
+   test02();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-2_xin.in
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-2_xin.in
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-2_xin.in
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/9661-2_xin.in	30 Apr 2003 08:08:15 -0000
***************
*** 0 ****
--- 1 ----
+ For what you dream of
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/9662.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/9662.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/9662.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/9662.cc	30 Apr 2003 07:02:59 -0000
***************
*** 0 ****
--- 1,42 ----
+ // 2003-04-30  Petur Runolfsson <peturr02@ru.is>
+ 
+ // Copyright (C) 2003 Free Software Foundation, Inc.
+ //
+ // This file is part of the GNU ISO C++ Library.  This library is free
+ // software; you can redistribute it and/or modify it under the
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+ 
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ // GNU General Public License for more details.
+ 
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING.  If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+ 
+ #include <testsuite_hooks.h>
+ #include <iostream>
+ #include <cstdio>
+ #include <cwchar>
+ 
+ // Check that operations on wcout can be mixed with wide operations
+ // on stdout.
+ void test01()
+ {
+   bool test = true;
+ 
+   std::wcout << L"Hello, ";
+   VERIFY( std::fwide(stdout, 0) >= 0 );
+   int ret = std::fputws(L"world!\n", stdout);
+   VERIFY( ret >= 0 );
+ }
+ 
+ int main()
+ {
+   test01();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/9_xin.cc
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/9_xin.cc
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/9_xin.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/9_xin.cc	1 May 2003 22:46:21 -0000
***************
*** 0 ****
--- 1,65 ----
+ // 2003-05-01  Petur Runolfsson  <peturr02@ru.is>
+ 
+ // Copyright (C) 2003 Free Software Foundation, Inc.
+ //
+ // This file is part of the GNU ISO C++ Library.  This library is free
+ // software; you can redistribute it and/or modify it under the
+ // terms of the GNU General Public License as published by the
+ // Free Software Foundation; either version 2, or (at your option)
+ // any later version.
+ 
+ // This library is distributed in the hope that it will be useful,
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ // GNU General Public License for more details.
+ 
+ // You should have received a copy of the GNU General Public License along
+ // with this library; see the file COPYING.  If not, write to the Free
+ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ // USA.
+ 
+ #include <iostream>
+ #include <locale>
+ #include <string>
+ #include <cwchar>
+ #include <cwctype>
+ #include <iterator>
+ #include <algorithm>
+ #include <testsuite_hooks.h>
+ 
+ // This tests the handling of multibyte characters by wcin and wcout.
+ void test09()
+ {
+   using namespace std;
+ 
+   locale loc("");
+   locale::global(loc);
+ 	
+   wcout.imbue(loc);
+   wcin.imbue(loc);
+ 
+   wcout << L"Current locale is: \'" << loc.name().c_str() << L"\'\n";
+   wcout << L"Please enter your name: ";
+ 
+   wstring str;
+   getline(wcin, str);
+ 
+   wcout << str << endl;
+   wcout << str.size() << endl;
+ 
+   transform(str.begin(), str.end(),
+ 	    ostream_iterator<wchar_t, wchar_t>(wcout), towupper);
+   wcout << endl;
+   transform(str.begin(), str.end(),
+ 	    ostream_iterator<wchar_t, wchar_t>(wcout), towlower);
+   wcout << endl << hex << showbase;
+   copy(str.begin(), str.end(),
+        ostream_iterator<wint_t, wchar_t>(wcout, L" "));
+   wcout << endl;
+ }
+ 
+ int main()
+ {
+   test09();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/27_io/objects/wchar_t/9_xin.in
===================================================================
RCS file: libstdc++-v3/testsuite/27_io/objects/wchar_t/9_xin.in
diff -N libstdc++-v3/testsuite/27_io/objects/wchar_t/9_xin.in
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/27_io/objects/wchar_t/9_xin.in	1 May 2003 21:50:30 -0000
***************
*** 0 ****
--- 1 ----
+ JOHN HUME and DAVID TRIMBLE
Index: libstdc++-v3/testsuite/ext/stdiobuf_char.cc
===================================================================
RCS file: libstdc++-v3/testsuite/ext/stdiobuf_char.cc
diff -N libstdc++-v3/testsuite/ext/stdiobuf_char.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/ext/stdiobuf_char.cc	1 May 2003 09:23:10 -0000
***************
*** 0 ****
--- 1,78 ----
+ // 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/stdiostream.h>
+ #include <testsuite_hooks.h>
+ 
+ void test01()
+ {
+   using namespace std;
+ 
+   bool test = true;
+   const char* c_lit = "black pearl jasmine tea";
+   int size = strlen(c_lit);
+   const char* name = "stdiobuf-1.txt";
+ 
+   FILE* fout = fopen(name, "w");
+   fwrite(c_lit, 1, size, fout);
+   fclose(fout);
+ 
+   FILE* fin = fopen(name, "r");
+   __gnu_cxx::stdiobuf sbuf(fin);
+ 
+   VERIFY( sbuf.sgetc() == c_lit[0] );
+   VERIFY( getc(fin) == c_lit[0] );
+   VERIFY( sbuf.sgetc() == c_lit[1] );
+   VERIFY( sbuf.sbumpc() == c_lit[1] );
+   VERIFY( ungetc('Z', fin) == 'Z' );
+   VERIFY( sbuf.sbumpc() == 'Z' );
+   VERIFY( getc(fin) == c_lit[2] );
+   VERIFY( sbuf.sputbackc('X') == 'X' );
+   VERIFY( getc(fin) == 'X' );
+ 
+   char buf[5];
+   memset(buf, 'x', 5);
+   VERIFY( sbuf.sgetn(buf, 5) == 5 );
+   VERIFY( !memcmp(buf, c_lit + 3, 5) );
+   VERIFY( getc(fin) == c_lit[8] );
+   VERIFY( sbuf.sungetc() == EOF );
+ 
+   fclose(fin);
+ }
+ 
+ void test02()
+ {
+   using namespace __gnu_cxx;
+   bool test = true;
+ 
+   istdiostream is (stdin);
+   VERIFY( is.rdbuf()->stdiofile() == stdin );
+   ostdiostream os (stdout);
+   VERIFY( os.rdbuf()->stdiofile() == stdout );
+   stdiostream ss (stderr);
+   VERIFY( ss.rdbuf()->stdiofile() == stderr );
+ }
+ 
+ int main ()
+ {
+   test01();
+   test02();
+   return 0;
+ }
Index: libstdc++-v3/testsuite/ext/stdiobuf_wchar_t.cc
===================================================================
RCS file: libstdc++-v3/testsuite/ext/stdiobuf_wchar_t.cc
diff -N libstdc++-v3/testsuite/ext/stdiobuf_wchar_t.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- libstdc++-v3/testsuite/ext/stdiobuf_wchar_t.cc	1 May 2003 09:23:10 -0000
***************
*** 0 ****
--- 1,79 ----
+ // 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/stdiostream.h>
+ #include <testsuite_hooks.h>
+ 
+ void test01()
+ {
+   using namespace std;
+ 
+   bool test = true;
+   const char* c_lit = "black pearl jasmine tea";
+   const wchar_t* w_lit = L"black pearl jasmine tea";
+   int size = strlen(c_lit);
+   const char* name = "stdiobuf-1.txt";
+ 
+   FILE* fout = fopen(name, "w");
+   fwrite(c_lit, 1, size, fout);
+   fclose(fout);
+ 
+   FILE* fin = fopen(name, "r");
+   __gnu_cxx::wstdiobuf wsbuf(fin);
+ 
+   VERIFY( wsbuf.sgetc() == w_lit[0] );
+   VERIFY( getwc(fin) == w_lit[0] );
+   VERIFY( wsbuf.sgetc() == w_lit[1] );
+   VERIFY( wsbuf.sbumpc() == w_lit[1] );
+   VERIFY( ungetwc(L'Z', fin) == L'Z' );
+   VERIFY( wsbuf.sbumpc() == L'Z' );
+   VERIFY( getwc(fin) == w_lit[2] );
+   VERIFY( wsbuf.sputbackc(L'X') == L'X' );
+   VERIFY( getwc(fin) == L'X' );
+ 
+   wchar_t buf[5];
+   wmemset(buf, 0xdeadbeef, 5);
+   VERIFY( wsbuf.sgetn(buf, 5) == 5 );
+   VERIFY( !wmemcmp(buf, w_lit + 3, 5) );
+   VERIFY( getwc(fin) == w_lit[8] );
+   VERIFY( wsbuf.sungetc() == WEOF );
+ 
+   fclose(fin);
+ }
+ 
+ void test02()
+ {
+   using namespace __gnu_cxx;
+   bool test = true;
+ 
+   wistdiostream is (stdin);
+   VERIFY( is.rdbuf()->stdiofile() == stdin );
+   wostdiostream os (stdout);
+   VERIFY( os.rdbuf()->stdiofile() == stdout );
+   wstdiostream ss (stderr);
+   VERIFY( ss.rdbuf()->stdiofile() == stderr );
+ }
+ 
+ int main ()
+ {
+   test01();
+   test02();
+   return 0;
+ }
