This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

char_traits patch, round two


..still pending. There are some issues left to resolve: hopefully
these will fall into place after a good nights sleep...

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

	XXX char_traits vs. other _traits
	XXX money_ bits
	XXX num_get/num_put bits
	XXX testsuites
	* include/bits/char_traits.h: Remove generic definitions.
	* include/bits/streambuf_iterator.h (istreambuf_iterator): Use
	eof, not -2.
	* include/bits/istream.tcc (istream::readsome): Don't check
	against eof, instead use constants.
	(istream::sync): Same.
	(istream::sentry::sentry): Use eq_int_type.
	(istream::get): Same.
	* include/bits/ostream.tcc: Change __pad to 
	__pad<_CharT, _Traits>::_S_pad. 
	* include/bits/locale_facets.h: Add __pad_traits generic and
	ostreambuf_iterator specialization.
	* include/bits/locale_facets.tcc: Change __pad into struct __pad
	with a _CharT and _Traits template parameter and _S_pad static
	member function.
	* src/locale-inst.cc: Update __pad instantiations.
	
	* include/std/std_fstream.h: Declare _M_underflow_common
	specializations.
	* src/fstream.cc: New. Add _M_underflow_common specializations.
	* include/bits/fstream.tcc (filebuf::close): Use traits_type.
	(filebuf::_M_underflow_common(bool)): Remove generic version, as
	sys_ungetc and custom int_types don't get along.
	* src/Makefile.am (sources): Add fstream.cc.
	* src/Makefile.in: Regenerate.

Index: include/bits/char_traits.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/char_traits.h,v
retrieving revision 1.13
diff -c -p -r1.13 char_traits.h
*** include/bits/char_traits.h	20 Jul 2002 06:26:26 -0000	1.13
--- include/bits/char_traits.h	29 Jul 2002 07:34:29 -0000
***************
*** 1,6 ****
  // Character Traits for use by standard string and iostream -*- C++ -*-
  
! // Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
  //
  // This file is part of the GNU ISO C++ Library.  This library is free
  // software; you can redistribute it and/or modify it under the
--- 1,7 ----
  // Character Traits for use by standard string and iostream -*- C++ -*-
  
! // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
! // Free Software Foundation, Inc.
  //
  // This file is part of the GNU ISO C++ Library.  This library is free
  // software; you can redistribute it and/or modify it under the
*************** namespace std 
*** 57,138 ****
      struct char_traits
      {
        typedef _CharT 		char_type;
!       // Unsigned as wint_t in unsigned.
        typedef unsigned long  	int_type;
        typedef streampos 	pos_type;
        typedef streamoff 	off_type;
        typedef mbstate_t 	state_type;
        
        static void 
!       assign(char_type& __c1, const char_type& __c2)
!       { __c1 = __c2; }
  
        static bool 
!       eq(const char_type& __c1, const char_type& __c2)
!       { return __c1 == __c2; }
  
        static bool 
!       lt(const char_type& __c1, const char_type& __c2)
!       { return __c1 < __c2; }
  
        static int 
!       compare(const char_type* __s1, const char_type* __s2, size_t __n)
!       { 
! 	for (size_t __i = 0; __i < __n; ++__i)
! 	  if (!eq(__s1[__i], __s2[__i]))
! 	    return lt(__s1[__i], __s2[__i]) ? -1 : 1;
! 	return 0; 
!       }
  
        static size_t
!       length(const char_type* __s)
!       { 
! 	const char_type* __p = __s; 
! 	while (*__p) ++__p; 
! 	return (__p - __s); 
!       }
  
        static const char_type* 
!       find(const char_type* __s, size_t __n, const char_type& __a)
!       { 
! 	for (const char_type* __p = __s; size_t(__p - __s) < __n; ++__p)
! 	  if (*__p == __a) return __p;
! 	return 0;
!       }
  
        static char_type* 
!       move(char_type* __s1, const char_type* __s2, size_t __n)
!       { return (char_type*) memmove(__s1, __s2, __n * sizeof(char_type)); }
  
        static char_type* 
!       copy(char_type* __s1, const char_type* __s2, size_t __n)
!       { return (char_type*) memcpy(__s1, __s2, __n * sizeof(char_type)); }
  
        static char_type* 
!       assign(char_type* __s, size_t __n, char_type __a)
!       { 
! 	for (char_type* __p = __s; __p < __s + __n; ++__p) 
! 	  assign(*__p, __a);
!         return __s; 
!       }
  
        static char_type 
!       to_char_type(const int_type& __c)
!       { return char_type(__c); }
  
        static int_type 
!       to_int_type(const char_type& __c) { return int_type(__c); }
  
        static bool 
!       eq_int_type(const int_type& __c1, const int_type& __c2)
!       { return __c1 == __c2; }
  
        static int_type 
!       eof() { return static_cast<int_type>(-1); }
  
        static int_type 
!       not_eof(const int_type& __c)
!       { return eq_int_type(__c, eof()) ? int_type(0) : __c; }
      };
  
  
--- 58,110 ----
      struct char_traits
      {
        typedef _CharT 		char_type;
!       // Unsigned as wint_t is unsigned.
        typedef unsigned long  	int_type;
        typedef streampos 	pos_type;
        typedef streamoff 	off_type;
        typedef mbstate_t 	state_type;
        
        static void 
!       assign(char_type& __c1, const char_type& __c2);
  
        static bool 
!       eq(const char_type& __c1, const char_type& __c2);
  
        static bool 
!       lt(const char_type& __c1, const char_type& __c2);
  
        static int 
!       compare(const char_type* __s1, const char_type* __s2, size_t __n);
  
        static size_t
!       length(const char_type* __s);
  
        static const char_type* 
!       find(const char_type* __s, size_t __n, const char_type& __a);
  
        static char_type* 
!       move(char_type* __s1, const char_type* __s2, size_t __n);
  
        static char_type* 
!       copy(char_type* __s1, const char_type* __s2, size_t __n);
  
        static char_type* 
!       assign(char_type* __s, size_t __n, char_type __a);
  
        static char_type 
!       to_char_type(const int_type& __c);
  
        static int_type 
!       to_int_type(const char_type& __c);
  
        static bool 
!       eq_int_type(const int_type& __c1, const int_type& __c2);
  
        static int_type 
!       eof(); 
  
        static int_type 
!       not_eof(const int_type& __c);
      };
  
  
Index: include/bits/fstream.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/fstream.tcc,v
retrieving revision 1.38
diff -c -p -r1.38 fstream.tcc
*** include/bits/fstream.tcc	13 May 2002 13:57:54 -0000	1.38
--- include/bits/fstream.tcc	29 Jul 2002 07:34:29 -0000
*************** namespace std
*** 112,118 ****
  	{
  	  const int_type __eof = traits_type::eof();
  	  bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
! 	  if (__testput && _M_really_overflow(__eof) == __eof)
  	    return __ret;
  
  	  // NB: Do this here so that re-opened filebufs will be cool...
--- 112,119 ----
  	{
  	  const int_type __eof = traits_type::eof();
  	  bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
! 	  if (__testput 
! 	      && traits_type::eq_int_type(_M_really_overflow(__eof), __eof))
  	    return __ret;
  
  	  // NB: Do this here so that re-opened filebufs will be cool...
*************** namespace std
*** 151,246 ****
  	    __ret = _M_in_end - _M_in_cur;
  	  else
  	    __ret = 0;
- 	}
-       _M_last_overflowed = false;	
-       return __ret;
-     }
- 
-   template<typename _CharT, typename _Traits>
-     typename basic_filebuf<_CharT, _Traits>::int_type 
-     basic_filebuf<_CharT, _Traits>::
-     _M_underflow_common(bool __bump)
-     {
-       int_type __ret = traits_type::eof();
-       bool __testin = _M_mode & ios_base::in;
-       bool __testout = _M_mode & ios_base::out;
- 
-       if (__testin)
- 	{
- 	  // Check for pback madness, and if so swich back to the
- 	  // normal buffers and jet outta here before expensive
- 	  // fileops happen...
- 	  if (_M_pback_init)
- 	    {
- 	      _M_pback_destroy();
- 	      if (_M_in_cur < _M_in_end)
- 		return traits_type::to_int_type(*_M_in_cur);
- 	    }
- 
- 	  // Sync internal and external buffers.
- 	  // NB: __testget -> __testput as _M_buf_unified here.
- 	  bool __testget = _M_in_cur && _M_in_beg < _M_in_cur;
- 	  bool __testinit = _M_is_indeterminate();
- 	  if (__testget)
- 	    {
- 	      if (__testout)
- 		_M_really_overflow();
- 	      else if (_M_in_cur != _M_filepos)
- 		_M_file.seekoff(_M_in_cur - _M_filepos,
- 				ios_base::cur, ios_base::in);
- 	    }
- 
- 	  if (__testinit || __testget)
- 	    {
- 	      const locale __loc = this->getloc();
- 	      const __codecvt_type& __cvt = use_facet<__codecvt_type>(__loc); 
- 
- 	      streamsize __elen = 0;
- 	      streamsize __ilen = 0;
- 	      if (__cvt.always_noconv())
- 		{
- 		  __elen = _M_file.xsgetn(reinterpret_cast<char*>(_M_in_beg), 
- 					  _M_buf_size);
- 		  __ilen = __elen;
- 		}
- 	      else
- 		{
- 		  char* __buf = static_cast<char*>(__builtin_alloca(_M_buf_size));
- 		  __elen = _M_file.xsgetn(__buf, _M_buf_size);
- 
- 		  const char* __eend;
- 		  char_type* __iend;
- 		  __res_type __r = __cvt.in(_M_state_cur, __buf, 
- 					    __buf + __elen, __eend, _M_in_beg, 
- 					    _M_in_beg + _M_buf_size, __iend);
- 		  if (__r == codecvt_base::ok)
- 		    __ilen = __iend - _M_in_beg;
- 		  else 
- 		    {
- 		      // Unwind.
- 		      __ilen = 0;
- 		      _M_file.seekoff(-__elen, ios_base::cur, ios_base::in);
- 		    }
- 		}
- 
- 	      if (0 < __ilen)
- 		{
- 		  _M_set_determinate(__ilen);
- 		  if (__testout)
- 		    _M_out_cur = _M_in_cur;
- 		  __ret = traits_type::to_int_type(*_M_in_cur);
- 		  if (__bump)
- 		    _M_in_cur_move(1);
- 		  else if (_M_buf_size == 1)
- 		    {
- 		      // If we are synced with stdio, we have to unget the
- 		      // character we just read so that the file pointer
- 		      // doesn't move.
- 		      _M_file.sys_ungetc(*_M_in_cur);
- 		      _M_set_indeterminate();
- 		    }
- 		}	   
- 	    }
  	}
        _M_last_overflowed = false;	
        return __ret;
--- 152,157 ----
Index: include/bits/istream.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/istream.tcc,v
retrieving revision 1.32
diff -c -p -r1.32 istream.tcc
*** include/bits/istream.tcc	25 Jul 2002 23:20:49 -0000	1.32
--- include/bits/istream.tcc	29 Jul 2002 07:34:32 -0000
*************** namespace std 
*** 54,66 ****
  	      __int_type __c = __sb->sgetc();
  
  	      if (__in._M_check_facet(__in._M_fctype))
! 		while (__c != __eof
! 		       && __in._M_fctype->is(ctype_base::space, __c))
  		  __c = __sb->snextc();
  
  #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
  //195.  Should basic_istream::sentry's constructor ever set eofbit? 
! 	      if (__c == __eof)
  		__in.setstate(ios_base::eofbit);
  #endif
  	    }
--- 54,67 ----
  	      __int_type __c = __sb->sgetc();
  
  	      if (__in._M_check_facet(__in._M_fctype))
! 		while (!traits_type::eq_int_type(__c, __eof)
! 		       && __in._M_fctype->is(ctype_base::space, 
! 					     traits_type::to_char_type(__c)))
  		  __c = __sb->snextc();
  
  #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
  //195.  Should basic_istream::sentry's constructor ever set eofbit? 
! 	      if (traits_type::eq_int_type(__c, __eof))
  		__in.setstate(ios_base::eofbit);
  #endif
  	    }
*************** namespace std 
*** 521,527 ****
  	    {
  	      __c = this->rdbuf()->sbumpc();
  	      // 27.6.1.1 paragraph 3
! 	      if (__c != __eof)
  		_M_gcount = 1;
  	      else
  		this->setstate(ios_base::eofbit | ios_base::failbit);
--- 522,528 ----
  	    {
  	      __c = this->rdbuf()->sbumpc();
  	      // 27.6.1.1 paragraph 3
! 	      if (!traits_type::eq_int_type(__c, __eof))
  		_M_gcount = 1;
  	      else
  		this->setstate(ios_base::eofbit | ios_base::failbit);
*************** namespace std 
*** 552,558 ****
  	      const int_type __eof = traits_type::eof();
  	      int_type __bufval = this->rdbuf()->sbumpc();
  	      // 27.6.1.1 paragraph 3
! 	      if (__bufval != __eof)
  		{
  		  _M_gcount = 1;
  		  __c = traits_type::to_char_type(__bufval);
--- 553,559 ----
  	      const int_type __eof = traits_type::eof();
  	      int_type __bufval = this->rdbuf()->sbumpc();
  	      // 27.6.1.1 paragraph 3
! 	      if (!traits_type::eq_int_type(__bufval, __eof))
  		{
  		  _M_gcount = 1;
  		  __c = traits_type::to_char_type(__bufval);
*************** namespace std 
*** 588,600 ****
  	      __streambuf_type* __sb = this->rdbuf();
  	      int_type __c = __sb->sgetc();	
  	      
! 	      while (_M_gcount + 1 < __n && __c != __eof && __c != __idelim)
  		{
  		  *__s++ = traits_type::to_char_type(__c);
  		  __c = __sb->snextc();
  		  ++_M_gcount;
  		}
! 	      if (__c == __eof)
  		this->setstate(ios_base::eofbit);
  	    }
  	  catch(exception& __fail)
--- 589,603 ----
  	      __streambuf_type* __sb = this->rdbuf();
  	      int_type __c = __sb->sgetc();	
  	      
! 	      while (_M_gcount + 1 < __n 
! 		     && !traits_type::eq_int_type(__c, __eof)
! 		     && !traits_type::eq_int_type(__c, __idelim))
  		{
  		  *__s++ = traits_type::to_char_type(__c);
  		  __c = __sb->snextc();
  		  ++_M_gcount;
  		}
! 	      if (traits_type::eq_int_type(__c, __eof))
  		this->setstate(ios_base::eofbit);
  	    }
  	  catch(exception& __fail)
*************** namespace std 
*** 627,640 ****
  	      const int_type __eof = traits_type::eof();	      
  	      __streambuf_type* __this_sb = this->rdbuf();
  	      int_type __c = __this_sb->sgetc();
  	      
! 	      while (__c != __eof && __c != __idelim 
! 		     && (__sb.sputc(traits_type::to_char_type(__c)) != __eof))
  		{
  		  ++_M_gcount;
  		  __c = __this_sb->snextc();
  		}
! 	      if (__c == __eof)
  		this->setstate(ios_base::eofbit);
  	    }
  	  catch(exception& __fail)
--- 630,646 ----
  	      const int_type __eof = traits_type::eof();	      
  	      __streambuf_type* __this_sb = this->rdbuf();
  	      int_type __c = __this_sb->sgetc();
+ 	      char_type __c2 = traits_type::to_char_type(__c);
  	      
! 	      while (!traits_type::eq_int_type(__c, __eof) 
! 		     && !traits_type::eq_int_type(__c, __idelim) 
! 		     && !traits_type::eq_int_type(__sb.sputc(__c2), __eof))
  		{
  		  ++_M_gcount;
  		  __c = __this_sb->snextc();
+ 		  __c2 = traits_type::to_char_type(__c);
  		}
! 	      if (traits_type::eq_int_type(__c, __eof))
  		this->setstate(ios_base::eofbit);
  	    }
  	  catch(exception& __fail)
*************** namespace std 
*** 667,683 ****
  	      __streambuf_type* __sb = this->rdbuf();
  	      int_type __c = __sb->sgetc();
  	    
! 	      while (_M_gcount + 1 < __n && __c != __eof && __c != __idelim)
  		{
  		  *__s++ = traits_type::to_char_type(__c);
  		  __c = __sb->snextc();
  		  ++_M_gcount;
  		}
! 	      if (__c == __eof)
  		this->setstate(ios_base::eofbit);
  	      else
  		{
! 		  if (__c == __idelim)
  		    {
  		      __sb->sbumpc();
  		      ++_M_gcount;
--- 673,691 ----
  	      __streambuf_type* __sb = this->rdbuf();
  	      int_type __c = __sb->sgetc();
  	    
! 	      while (_M_gcount + 1 < __n 
! 		     && !traits_type::eq_int_type(__c, __eof)
! 		     && !traits_type::eq_int_type(__c, __idelim))
  		{
  		  *__s++ = traits_type::to_char_type(__c);
  		  __c = __sb->snextc();
  		  ++_M_gcount;
  		}
! 	      if (traits_type::eq_int_type(__c, __eof))
  		this->setstate(ios_base::eofbit);
  	      else
  		{
! 		  if (traits_type::eq_int_type(__c, __idelim))
  		    {
  		      __sb->sbumpc();
  		      ++_M_gcount;
*************** namespace std 
*** 717,730 ****
  	      int_type __c = __sb->sgetc();	
  	      
  	      __n = min(__n, numeric_limits<streamsize>::max());
! 	      while (_M_gcount < __n  && __c !=__eof && __c != __delim)
  		{
  		  __c = __sb->snextc();
  		  ++_M_gcount;
  		}
! 	      if (__c == __eof)
  		this->setstate(ios_base::eofbit);
! 	      else if (__c == __delim)
  		{
  		  __sb->sbumpc();
  		  ++_M_gcount;
--- 725,740 ----
  	      int_type __c = __sb->sgetc();	
  	      
  	      __n = min(__n, numeric_limits<streamsize>::max());
! 	      while (_M_gcount < __n  
! 		     && !traits_type::eq_int_type(__c, __eof) 
! 		     && !traits_type::eq_int_type(__c, __delim))
  		{
  		  __c = __sb->snextc();
  		  ++_M_gcount;
  		}
! 	      if (traits_type::eq_int_type(__c, __eof))
  		this->setstate(ios_base::eofbit);
! 	      else if (traits_type::eq_int_type(__c, __delim))
  		{
  		  __sb->sbumpc();
  		  ++_M_gcount;
*************** namespace std 
*** 806,814 ****
  	{
  	  try 
  	    {
- 	      const int_type __eof = traits_type::eof(); 
  	      streamsize __num = this->rdbuf()->in_avail();
! 	      if (__num != static_cast<streamsize>(__eof))
  		{
  		  __num = min(__num, __n);
  		  if (__num)
--- 816,823 ----
  	{
  	  try 
  	    {
  	      streamsize __num = this->rdbuf()->in_avail();
! 	      if (__num > 0)
  		{
  		  __num = min(__num, __n);
  		  if (__num)
*************** namespace std 
*** 843,849 ****
  	    {
  	      const int_type __eof = traits_type::eof();
  	      __streambuf_type* __sb = this->rdbuf();
! 	      if (!__sb || __sb->sputbackc(__c) == __eof) 
  		this->setstate(ios_base::badbit);		    
  	    }
  	  catch(exception& __fail)
--- 852,859 ----
  	    {
  	      const int_type __eof = traits_type::eof();
  	      __streambuf_type* __sb = this->rdbuf();
! 	      if (!__sb 
! 		  || traits_type::eq_int_type(__sb->sputbackc(__c), __eof))
  		this->setstate(ios_base::badbit);		    
  	    }
  	  catch(exception& __fail)
*************** namespace std 
*** 873,879 ****
  	    {
  	      const int_type __eof = traits_type::eof();
  	      __streambuf_type* __sb = this->rdbuf();
! 	      if (!__sb || __eof == __sb->sungetc())
  		this->setstate(ios_base::badbit);		    
  	    }
  	  catch(exception& __fail)
--- 883,890 ----
  	    {
  	      const int_type __eof = traits_type::eof();
  	      __streambuf_type* __sb = this->rdbuf();
! 	      if (!__sb 
! 		  || traits_type::eq_int_type(__sb->sungetc(), __eof))
  		this->setstate(ios_base::badbit);		    
  	    }
  	  catch(exception& __fail)
*************** namespace std 
*** 895,901 ****
      basic_istream<_CharT, _Traits>::
      sync(void)
      {
!       int __ret = traits_type::eof();
        _M_gcount = 0;
        sentry __cerb(*this, true);
        if (__cerb) 
--- 906,912 ----
      basic_istream<_CharT, _Traits>::
      sync(void)
      {
!       int __ret = -1;
        _M_gcount = 0;
        sentry __cerb(*this, true);
        if (__cerb) 
*************** namespace std 
*** 903,912 ****
  	  try 
  	    {
  	      __streambuf_type* __sb = this->rdbuf();
! 	      if (!__sb || __ret == __sb->pubsync())
! 		this->setstate(ios_base::badbit);		    
! 	      else 
! 		__ret = 0;
  	    }
  	  catch(exception& __fail)
  	    {
--- 914,926 ----
  	  try 
  	    {
  	      __streambuf_type* __sb = this->rdbuf();
! 	      if (__sb)
! 		{
! 		  if (__sb->pubsync() == -1)
! 		    this->setstate(ios_base::badbit);		    
! 		  else 
! 		    __ret = 0;
! 		}
  	    }
  	  catch(exception& __fail)
  	    {
*************** namespace std 
*** 1186,1201 ****
  	  __streambuf_type* __sb = __in.rdbuf();
  	  __int_type __c = __sb->sbumpc();
  	  const __int_type __eof = _Traits::eof();
! 	  __testdelim = __c ==  __idelim;
  
! 	  while (__extracted <= __n && __c != __eof && !__testdelim)
  	    {
  	      __str += _Traits::to_char_type(__c);
  	      ++__extracted;
  	      __c = __sb->sbumpc();
! 	      __testdelim = __c == __idelim;
  	    }
! 	  if (__c == __eof)
  	    __in.setstate(ios_base::eofbit);
  	}
        if (!__extracted && !__testdelim)
--- 1200,1217 ----
  	  __streambuf_type* __sb = __in.rdbuf();
  	  __int_type __c = __sb->sbumpc();
  	  const __int_type __eof = _Traits::eof();
! 	  __testdelim = _Traits::eq_int_type(__c, __idelim);
  
! 	  while (__extracted <= __n 
! 		 && !_Traits::eq_int_type(__c, __eof)
! 		 && !__testdelim)
  	    {
  	      __str += _Traits::to_char_type(__c);
  	      ++__extracted;
  	      __c = __sb->sbumpc();
! 	      __testdelim = _Traits::eq_int_type(__c, __idelim);
  	    }
! 	  if (_Traits::eq_int_type(__c, __eof))
  	    __in.setstate(ios_base::eofbit);
  	}
        if (!__extracted && !__testdelim)
Index: include/bits/locale_facets.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/locale_facets.h,v
retrieving revision 1.44
diff -c -p -r1.44 locale_facets.h
*** include/bits/locale_facets.h	3 Jul 2002 06:29:26 -0000	1.44
--- include/bits/locale_facets.h	29 Jul 2002 07:34:37 -0000
*************** namespace std
*** 55,60 ****
--- 55,78 ----
  # define  _GLIBCPP_NUM_FACETS 14
  #endif
  
+   // Generic implementation uses char_traits<_CharT>.
+   template<typename _CharT, typename _OutIter>
+     struct __pad_traits
+     {
+       typedef char_traits<_CharT> __traits_type;
+     };
+ 
+   // Partial specialization for ostreambuf_iterator. 
+   // Specialization implementation uses ostreambuf_iterator::traits_type.
+   template<typename _CharT>
+     struct __pad_traits<_CharT, ostreambuf_iterator<_CharT> >
+     {
+       typedef typename ostreambuf_iterator<_CharT>::traits_type  __traits_type;
+     };
+ 
+   template<typename _CharT, typename _Traits>
+   struct __pad;
+ 
    // 22.2.1.1  Template class ctype
    // Include host and configuration specific ctype enums for ctype_base.
    #include <bits/ctype_base.h>
*************** namespace std
*** 652,657 ****
--- 670,676 ----
        virtual iter_type 
        do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
  
+ 
        virtual iter_type 
        do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, long&) const;
  
*************** namespace std
*** 696,701 ****
--- 715,737 ----
  
    template<typename _CharT, typename _InIter>
      locale::id num_get<_CharT, _InIter>::id;
+ 
+ #if 0
+   // Partial specialization for istreambuf_iterator, so can use traits_type.
+   template<typename _CharT>
+     class num_get<_CharT, istreambuf_iterator<_CharT> >;
+ 
+       iter_type 
+       _M_extract_float(iter_type, iter_type, ios_base&, ios_base::iostate&, 
+ 		       string& __xtrc) const;
+ 
+       iter_type 
+       _M_extract_int(iter_type, iter_type, ios_base&, ios_base::iostate&, 
+ 		     string& __xtrc, int& __base) const;
+ 
+       virtual iter_type 
+       do_get(iter_type, iter_type, ios_base&, ios_base::iostate&, bool&) const;
+ #endif
  
    template<typename _CharT, typename _OutIter>
      class num_put : public locale::facet, public __num_base
Index: include/bits/locale_facets.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/locale_facets.tcc,v
retrieving revision 1.77
diff -c -p -r1.77 locale_facets.tcc
*** include/bits/locale_facets.tcc	4 May 2002 21:33:17 -0000	1.77
--- include/bits/locale_facets.tcc	29 Jul 2002 07:34:42 -0000
*************** namespace std
*** 94,99 ****
--- 94,100 ----
      _M_extract_float(_InIter __beg, _InIter __end, ios_base& __io,
  		     ios_base::iostate& __err, string& __xtrc) const
      {
+       typedef typename _InIter::traits_type 		__traits_type;
        const locale __loc = __io.getloc();
        const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
        const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
*************** namespace std
*** 103,109 ****
        const char_type __minus = __ctype.widen('-');
        int __pos = 0;
        char_type  __c = *__beg;
!       if ((__c == __plus || __c == __minus) && __beg != __end)
  	{
  	  __xtrc += __ctype.narrow(__c, char());
  	  ++__pos;
--- 104,111 ----
        const char_type __minus = __ctype.widen('-');
        int __pos = 0;
        char_type  __c = *__beg;
!       if ((__traits_type::eq(__c, __plus) || __traits_type::eq(__c, __minus))
! 	  && __beg != __end)
  	{
  	  __xtrc += __ctype.narrow(__c, char());
  	  ++__pos;
*************** namespace std
*** 113,119 ****
        // Next, strip leading zeros.
        const char_type __zero = __ctype.widen(_S_atoms[_M_zero]);
        bool __found_zero = false;
!       while (__c == __zero && __beg != __end)
  	{
  	  __c = *(++__beg);
  	  __found_zero = true;
--- 115,121 ----
        // Next, strip leading zeros.
        const char_type __zero = __ctype.widen(_S_atoms[_M_zero]);
        bool __found_zero = false;
!       while (__traits_type::eq(__c, __zero) && __beg != __end)
  	{
  	  __c = *(++__beg);
  	  __found_zero = true;
*************** namespace std
*** 141,151 ****
        while (__beg != __end)
          {
  	  // Only look in digits.
- 	  typedef char_traits<_CharT> 	__traits_type;
            const char_type* __p = __traits_type::find(__watoms, 10,  __c);
  
            // NB: strchr returns true for __c == 0x0
!           if (__p && __c)
  	    {
  	      // Try first for acceptable digit; record it if found.
  	      ++__pos;
--- 143,152 ----
        while (__beg != __end)
          {
  	  // Only look in digits.
            const char_type* __p = __traits_type::find(__watoms, 10,  __c);
  
            // NB: strchr returns true for __c == 0x0
!           if (__p && !__traits_type::eq(__c, char_type()))
  	    {
  	      // Try first for acceptable digit; record it if found.
  	      ++__pos;
*************** namespace std
*** 153,159 ****
  	      ++__sep_pos;
  	      __c = *(++__beg);
  	    }
!           else if (__c == __sep && __check_grouping && !__found_dec)
  	    {
                // NB: Thousands separator at the beginning of a string
                // is a no-no, as is two consecutive thousands separators.
--- 154,161 ----
  	      ++__sep_pos;
  	      __c = *(++__beg);
  	    }
!           else if (__traits_type::eq(__c, __sep) 
! 		   && __check_grouping && !__found_dec)
  	    {
                // NB: Thousands separator at the beginning of a string
                // is a no-no, as is two consecutive thousands separators.
*************** namespace std
*** 169,175 ****
  		  break;
  		}
              }
! 	  else if (__c == __dec && !__found_dec)
  	    {
  	      // According to the standard, if no grouping chars are seen,
  	      // no grouping check is applied. Therefore __found_grouping
--- 171,177 ----
  		  break;
  		}
              }
! 	  else if (__traits_type::eq(__c, __dec) && !__found_dec)
  	    {
  	      // According to the standard, if no grouping chars are seen,
  	      // no grouping check is applied. Therefore __found_grouping
*************** namespace std
*** 181,187 ****
  	      __c = *(++__beg);
  	      __found_dec = true;
  	    }
! 	  else if ((__c == __watoms[_M_e] || __c == __watoms[_M_E]) 
  		   && !__found_sci && __pos)
  	    {
  	      // Scientific notation.
--- 183,190 ----
  	      __c = *(++__beg);
  	      __found_dec = true;
  	    }
! 	  else if ((__traits_type::eq(__c, __watoms[_M_e]) 
! 		    || __traits_type::eq(__c, __watoms[_M_E])) 
  		   && !__found_sci && __pos)
  	    {
  	      // Scientific notation.
*************** namespace std
*** 190,196 ****
  	      __c = *(++__beg);
  
  	      // Remove optional plus or minus sign, if they exist.
! 	      if (__c == __plus || __c == __minus)
  		{
  		  ++__pos;
  		  __xtrc += __ctype.narrow(__c, char());
--- 193,200 ----
  	      __c = *(++__beg);
  
  	      // Remove optional plus or minus sign, if they exist.
! 	      if (__traits_type::eq(__c, __plus) 
! 		  || __traits_type::eq(__c, __minus))
  		{
  		  ++__pos;
  		  __xtrc += __ctype.narrow(__c, char());
*************** namespace std
*** 228,233 ****
--- 232,238 ----
      _M_extract_int(_InIter __beg, _InIter __end, ios_base& __io,
  		   ios_base::iostate& __err, string& __xtrc, int& __base) const
      {
+       typedef typename _InIter::traits_type 		__traits_type;
        const locale __loc = __io.getloc();
        const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc);
        const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
*************** namespace std
*** 241,250 ****
        else
  	__base = 10;
  
!      // First check for sign.
        int __pos = 0;
        char_type  __c = *__beg;
!       if ((__c == __ctype.widen('+') || __c == __ctype.widen('-'))
  	  && __beg != __end)
  	{
  	  __xtrc += __ctype.narrow(__c, char());
--- 246,258 ----
        else
  	__base = 10;
  
!       // First check for sign.
        int __pos = 0;
        char_type  __c = *__beg;
!       const char_type __plus = __ctype.widen('+');
!       const char_type __minus = __ctype.widen('-');
! 
!       if ((__traits_type::eq(__c, __plus) || __traits_type::eq(__c, __minus))
  	  && __beg != __end)
  	{
  	  __xtrc += __ctype.narrow(__c, char());
*************** namespace std
*** 259,265 ****
        if (__base == 10)
  	{
  	  bool __found_zero = false;
! 	  while (__c == __zero && __beg != __end)
  	    {
  	      __c = *(++__beg);
  	      __found_zero = true;
--- 267,273 ----
        if (__base == 10)
  	{
  	  bool __found_zero = false;
! 	  while (__traits_type::eq(__c, __zero) && __beg != __end)
  	    {
  	      __c = *(++__beg);
  	      __found_zero = true;
*************** namespace std
*** 270,276 ****
  	      ++__pos;
  	      if (__basefield == 0)
  		{	      
! 		  if ((__c == __x || __c == __X) && __beg != __end)
  		    {
  		      __xtrc += __ctype.narrow(__c, char());
  		      ++__pos;
--- 278,286 ----
  	      ++__pos;
  	      if (__basefield == 0)
  		{	      
! 		  if ((__traits_type::eq(__c, __x) 
! 		       || __traits_type::eq(__c, __X))
! 		      && __beg != __end)
  		    {
  		      __xtrc += __ctype.narrow(__c, char());
  		      ++__pos;
*************** namespace std
*** 284,295 ****
  	}
        else if (__base == 16)
  	{
! 	  if (__c == __zero && __beg != __end)
  	    {
  	      __xtrc += _S_atoms[_M_zero];
  	      ++__pos;
  	      __c = *(++__beg); 
! 	      if  ((__c == __x || __c == __X) && __beg != __end)
  		{
  		  __xtrc += __ctype.narrow(__c, char());
  		  ++__pos;
--- 294,306 ----
  	}
        else if (__base == 16)
  	{
! 	  if (__traits_type::eq(__c, __zero) && __beg != __end)
  	    {
  	      __xtrc += _S_atoms[_M_zero];
  	      ++__pos;
  	      __c = *(++__beg); 
! 	      if ((__traits_type::eq(__c, __x) || __traits_type::eq(__c, __X))
! 		  && __beg != __end)
  		{
  		  __xtrc += __ctype.narrow(__c, char());
  		  ++__pos;
*************** namespace std
*** 316,326 ****
        const char_type __sep = __np.thousands_sep();
        while (__beg != __end)
          {
- 	  typedef char_traits<_CharT> 	__traits_type;
            const char_type* __p = __traits_type::find(__watoms, __len,  __c);
  
            // NB: strchr returns true for __c == 0x0
!           if (__p && __c)
  	    {
  	      // Try first for acceptable digit; record it if found.
  	      __xtrc += _S_atoms[__p - __watoms];
--- 327,336 ----
        const char_type __sep = __np.thousands_sep();
        while (__beg != __end)
          {
            const char_type* __p = __traits_type::find(__watoms, __len,  __c);
  
            // NB: strchr returns true for __c == 0x0
!           if (__p && !__traits_type::eq(__c, char_type()))
  	    {
  	      // Try first for acceptable digit; record it if found.
  	      __xtrc += _S_atoms[__p - __watoms];
*************** namespace std
*** 328,334 ****
  	      ++__sep_pos;
  	      __c = *(++__beg);
  	    }
!           else if (__c == __sep && __check_grouping)
  	    {
                // NB: Thousands separator at the beginning of a string
                // is a no-no, as is two consecutive thousands separators.
--- 338,344 ----
  	      ++__sep_pos;
  	      __c = *(++__beg);
  	    }
!           else if (__traits_type::eq(__c, __sep) && __check_grouping)
  	    {
                // NB: Thousands separator at the beginning of a string
                // is a no-no, as is two consecutive thousands separators.
*************** namespace std
*** 394,400 ****
        // Parse bool values as alphanumeric
        else
          {
! 	  typedef basic_string<_CharT> __string_type;
            locale __loc = __io.getloc();
  	  const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc); 
  	  const __string_type __true = __np.truename();
--- 404,412 ----
        // Parse bool values as alphanumeric
        else
          {
!        	  typedef typename _InIter::traits_type 	__traits_type;
! 	  typedef basic_string<_CharT>   		__string_type;
! 
            locale __loc = __io.getloc();
  	  const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc); 
  	  const __string_type __true = __np.truename();
*************** namespace std
*** 407,414 ****
            for (size_t __n = 0; __beg != __end; ++__n)
              {
                char_type __c = *__beg++;
!               bool __testf = __n <= __falsen ? __c == __falses[__n] : false;
!               bool __testt = __n <= __truen ? __c == __trues[__n] : false;
                if (!(__testf || __testt))
                  {
                    __err |= ios_base::failbit;
--- 419,428 ----
            for (size_t __n = 0; __beg != __end; ++__n)
              {
                char_type __c = *__beg++;
!               bool __testf = __n <= __falsen 
! 		             ? __traits_type::eq(__c, __falses[__n]) : false;
!               bool __testt = __n <= __truen 
! 		             ? __traits_type::eq(__c, __trues[__n]) : false;
                if (!(__testf || __testt))
                  {
                    __err |= ios_base::failbit;
*************** namespace std
*** 708,713 ****
--- 722,728 ----
      _M_widen_float(_OutIter __s, ios_base& __io, _CharT __fill, char* __cs, 
  		   int __len) const
      {
+       typedef typename _OutIter::traits_type 		__traits_type;
        // [22.2.2.2.2] Stage 2, convert to char_type, using correct
        // numpunct.decimal_point() values for '.' and adding grouping.
        const locale __loc = __io.getloc();
*************** namespace std
*** 723,729 ****
        // Replace decimal point.
        const _CharT* __p;
        const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
!       if (__p = char_traits<_CharT>::find(__ws, __len, __ctype.widen('.')))
  	__ws[__p - __ws] = __np.decimal_point();
  
  #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
--- 738,744 ----
        // Replace decimal point.
        const _CharT* __p;
        const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
!       if (__p = __traits_type::find(__ws, __len, __ctype.widen('.')))
  	__ws[__p - __ws] = __np.decimal_point();
  
  #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
*************** namespace std
*** 744,750 ****
  	  // Tack on decimal part.
  	  if (__p)
  	    {
! 	      char_traits<_CharT>::copy(__p2, __p, __len - __declen);
  	      __newlen += __len - __declen;
  	    }    
  
--- 759,765 ----
  	  // Tack on decimal part.
  	  if (__p)
  	    {
! 	      __traits_type::copy(__p2, __p, __len - __declen);
  	      __newlen += __len - __declen;
  	    }    
  
*************** namespace std
*** 822,828 ****
  							    * __w));
        if (__w > static_cast<streamsize>(__len))
  	{
! 	  __pad(__io, __fill, __ws2, __ws, __w, __len, true);
  	  __len = static_cast<int>(__w);
  	  // Switch strings.
  	  __ws = __ws2;
--- 837,845 ----
  							    * __w));
        if (__w > static_cast<streamsize>(__len))
  	{
! 	  typedef __pad_traits<_CharT, _OutIter>::__traits_type __traits_type;
! 	  __pad<_CharT, __traits_type>::_S_pad(__io, __fill, __ws2, __ws, 
! 					       __w, __len, true);
  	  __len = static_cast<int>(__w);
  	  // Switch strings.
  	  __ws = __ws2;
*************** namespace std
*** 845,851 ****
        if ((__flags & ios_base::boolalpha) == 0)
          {
            unsigned long __uv = __v;
!           __s = _M_convert_int(__s, __io, __fill, 'u', char_type(), __uv);
          }
        else
          {
--- 862,868 ----
        if ((__flags & ios_base::boolalpha) == 0)
          {
            unsigned long __uv = __v;
!           __s = _M_convert_int(__s, __io, __fill, 'u', char(), __uv);
          }
        else
          {
*************** namespace std
*** 866,879 ****
      _OutIter
      num_put<_CharT, _OutIter>::
      do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
!     { return _M_convert_int(__s, __io, __fill, 'd', char_type(), __v); }
  
    template<typename _CharT, typename _OutIter>
      _OutIter
      num_put<_CharT, _OutIter>::
      do_put(iter_type __s, ios_base& __io, char_type __fill,
             unsigned long __v) const
!     { return _M_convert_int(__s, __io, __fill, 'u', char_type(), __v); }
  
  #ifdef _GLIBCPP_USE_LONG_LONG
    template<typename _CharT, typename _OutIter>
--- 883,896 ----
      _OutIter
      num_put<_CharT, _OutIter>::
      do_put(iter_type __s, ios_base& __io, char_type __fill, long __v) const
!     { return _M_convert_int(__s, __io, __fill, 'd', char(), __v); }
  
    template<typename _CharT, typename _OutIter>
      _OutIter
      num_put<_CharT, _OutIter>::
      do_put(iter_type __s, ios_base& __io, char_type __fill,
             unsigned long __v) const
!     { return _M_convert_int(__s, __io, __fill, 'u', char(), __v); }
  
  #ifdef _GLIBCPP_USE_LONG_LONG
    template<typename _CharT, typename _OutIter>
*************** namespace std
*** 894,900 ****
      _OutIter
      num_put<_CharT, _OutIter>::
      do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
!     { return _M_convert_float(__s, __io, __fill, char_type(), __v); }
  
    template<typename _CharT, typename _OutIter>
      _OutIter
--- 911,917 ----
      _OutIter
      num_put<_CharT, _OutIter>::
      do_put(iter_type __s, ios_base& __io, char_type __fill, double __v) const
!     { return _M_convert_float(__s, __io, __fill, char(), __v); }
  
    template<typename _CharT, typename _OutIter>
      _OutIter
*************** namespace std
*** 915,921 ****
        __io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase));
        try 
  	{
! 	  __s = _M_convert_int(__s, __io, __fill, 'u', char_type(),
  			       reinterpret_cast<unsigned long>(__v));
  	  __io.flags(__flags);
  	}
--- 932,938 ----
        __io.flags(__flags & __fmt | (ios_base::hex | ios_base::showbase));
        try 
  	{
! 	  __s = _M_convert_int(__s, __io, __fill, 'u', char(),
  			       reinterpret_cast<unsigned long>(__v));
  	  __io.flags(__flags);
  	}
*************** namespace std
*** 1996,2017 ****
    // internal-adjusted objects are padded according to the rules below
    // concerning 0[xX] and +-, otherwise, exactly as right-adjusted
    // ones are.
    template<typename _CharT, typename _Traits>
!     void
!     __pad(ios_base& __io, _CharT __fill, _CharT* __news, const _CharT* __olds,
! 	  const streamsize __newlen, const streamsize __oldlen, 
! 	  const bool __num)
!     {
!       typedef _CharT	char_type;
!       typedef _Traits	traits_type;
!       typedef typename traits_type::int_type int_type;
!       
!       int_type __plen = static_cast<size_t>(__newlen - __oldlen); 
!       char_type* __pads = static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * __plen));
!       traits_type::assign(__pads, __plen, __fill); 
  
!       char_type* __beg;
!       char_type* __end;
        size_t __mod = 0;
        size_t __beglen; //either __plen or __oldlen
        ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield;
--- 2013,2043 ----
    // internal-adjusted objects are padded according to the rules below
    // concerning 0[xX] and +-, otherwise, exactly as right-adjusted
    // ones are.
+ 
+   // NB: Of the two parameters, _CharT can be deduced from the
+   // function arguments. The other (_Traits) has to be explicitly specified.
    template<typename _CharT, typename _Traits>
!     struct __pad
!     {
!       static void
!       _S_pad(ios_base& __io, _CharT __fill, _CharT* __news, 
! 	     const _CharT* __olds, const streamsize __newlen, 
! 	     const streamsize __oldlen, const bool __num);
!     };
! 
!   template<typename _CharT, typename _Traits>
!     void 
!     __pad<_CharT, _Traits>::_S_pad(ios_base& __io, _CharT __fill, 
! 				   _CharT* __news, const _CharT* __olds, 
! 				   const streamsize __newlen, 
! 				   const streamsize __oldlen, const bool __num)
!     {
!       size_t __plen = static_cast<size_t>(__newlen - __oldlen);
!       _CharT* __pads = static_cast<_CharT*>(__builtin_alloca(sizeof(_CharT) * __plen));
!       _Traits::assign(__pads, __plen, __fill); 
  
!       _CharT* __beg;
!       _CharT* __end;
        size_t __mod = 0;
        size_t __beglen; //either __plen or __oldlen
        ios_base::fmtflags __adjust = __io.flags() & ios_base::adjustfield;
*************** namespace std
*** 2019,2025 ****
        if (__adjust == ios_base::left)
  	{
  	  // Padding last.
! 	  __beg = const_cast<char_type*>(__olds);
  	  __beglen = __oldlen;
  	  __end = __pads;
  	}
--- 2045,2051 ----
        if (__adjust == ios_base::left)
  	{
  	  // Padding last.
! 	  __beg = const_cast<_CharT*>(__olds);
  	  __beglen = __oldlen;
  	  __end = __pads;
  	}
*************** namespace std
*** 2030,2041 ****
  	  // Who came up with these rules, anyway? Jeeze.
            locale __loc = __io.getloc();
  	  const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); 
! 	  const char_type __minus = __ctype.widen('-');
! 	  const char_type __plus = __ctype.widen('+');
! 	  bool __testsign = __olds[0] == __minus || __olds[0] == __plus;
! 	  bool __testhex = __ctype.widen('0') == __olds[0] 
! 	                   && (__ctype.widen('x') == __olds[1] 
! 			       || __ctype.widen('X') == __olds[1]);
  	  if (__testhex)
  	    {
  	      __news[0] = __olds[0]; 
--- 2056,2069 ----
  	  // Who came up with these rules, anyway? Jeeze.
            locale __loc = __io.getloc();
  	  const ctype<_CharT>& __ctype = use_facet<ctype<_CharT> >(__loc); 
! 	  const _CharT __minus = __ctype.widen('-');
! 	  const _CharT __plus = __ctype.widen('+');
! 	  bool __testsign = _Traits::eq(__olds[0], __minus)
! 	    		    || _Traits::eq(__olds[0], __plus);
! 
! 	  bool __testhex = _Traits::eq(__ctype.widen('0'), __olds[0]) 
! 	    		   && (_Traits::eq(__ctype.widen('x'), __olds[1]) 
! 			       || _Traits::eq(__ctype.widen('X'), __olds[1]));
  	  if (__testhex)
  	    {
  	      __news[0] = __olds[0]; 
*************** namespace std
*** 2044,2066 ****
  	      __news += 2;
  	      __beg = __pads;
  	      __beglen = __plen;
! 	      __end = const_cast<char_type*>(__olds + __mod);
  	    }
  	  else if (__testsign)
  	    {
! 	      __news[0] = __olds[0] == __plus ? __plus : __minus;
  	      ++__mod;
  	      ++__news;
  	      __beg = __pads;
  	      __beglen = __plen;
! 	      __end = const_cast<char_type*>(__olds + __mod);
  	    }
  	  else
  	    {
  	      // Padding first.
  	      __beg = __pads;
  	      __beglen = __plen;
! 	      __end = const_cast<char_type*>(__olds);
  	    }
  	}
        else
--- 2072,2094 ----
  	      __news += 2;
  	      __beg = __pads;
  	      __beglen = __plen;
! 	      __end = const_cast<_CharT*>(__olds + __mod);
  	    }
  	  else if (__testsign)
  	    {
! 	      _Traits::eq((__news[0] = __olds[0]), __plus) ? __plus : __minus;
  	      ++__mod;
  	      ++__news;
  	      __beg = __pads;
  	      __beglen = __plen;
! 	      __end = const_cast<_CharT*>(__olds + __mod);
  	    }
  	  else
  	    {
  	      // Padding first.
  	      __beg = __pads;
  	      __beglen = __plen;
! 	      __end = const_cast<_CharT*>(__olds);
  	    }
  	}
        else
*************** namespace std
*** 2068,2090 ****
  	  // Padding first.
  	  __beg = __pads;
  	  __beglen = __plen;
! 	  __end = const_cast<char_type*>(__olds);
  	}
!       traits_type::copy(__news, __beg, __beglen);
!       traits_type::copy(__news + __beglen, __end, __newlen - __beglen - __mod);
!     }
! 
!   // NB: Can't have default argument on non-member template, and
!   // num_put doesn't have a _Traits template parameter, so this
!   // forwarding template adds in the default template argument.
!   template<typename _CharT>
!     void
!     __pad(ios_base& __io, _CharT __fill, _CharT* __news, const _CharT* __olds,
! 	  const streamsize __newlen, const streamsize __oldlen, 
! 	  const bool __num)
!     { 
!       return __pad<_CharT, char_traits<_CharT> >(__io, __fill, __news, __olds,
! 						 __newlen, __oldlen, __num); 
      }
  
    // Used by both numeric and monetary facets.
--- 2096,2106 ----
  	  // Padding first.
  	  __beg = __pads;
  	  __beglen = __plen;
! 	  __end = const_cast<_CharT*>(__olds);
  	}
!       _Traits::copy(__news, __beg, __beglen);
!       _Traits::copy(__news + __beglen, __end, 
! 			  __newlen - __beglen - __mod);
      }
  
    // Used by both numeric and monetary facets.
*************** namespace std
*** 2401,2405 ****
  } // namespace std
  
  #endif
- 
- 
--- 2417,2419 ----
Index: include/bits/ostream.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/ostream.tcc,v
retrieving revision 1.30
diff -c -p -r1.30 ostream.tcc
*** include/bits/ostream.tcc	7 Jun 2002 22:06:38 -0000	1.30
--- include/bits/ostream.tcc	29 Jul 2002 07:34:45 -0000
*************** namespace std 
*** 474,480 ****
  	      streamsize __len = 1;
  	      if (__w > __len)
  		{
! 		  __pad(__out, __out.fill(), __pads, &__c, __w, __len, false);
  		  __len = __w;
  		}
  	      __out.write(__pads, __len);
--- 474,481 ----
  	      streamsize __len = 1;
  	      if (__w > __len)
  		{
! 		  __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __pads, 
! 						 &__c, __w, __len, false);
  		  __len = __w;
  		}
  	      __out.write(__pads, __len);
*************** namespace std 
*** 509,515 ****
  	      streamsize __len = 1;
  	      if (__w > __len)
  		{
! 		  __pad(__out, __out.fill(), __pads, &__c, __w, __len, false);
  		  __len = __w;
  		}
  	      __out.write(__pads, __len);
--- 510,517 ----
  	      streamsize __len = 1;
  	      if (__w > __len)
  		{
! 		  __pad<char, _Traits>::_S_pad(__out, __out.fill(), __pads, 
! 					       &__c, __w, __len, false);
  		  __len = __w;
  		}
  	      __out.write(__pads, __len);
*************** namespace std 
*** 542,548 ****
  	      streamsize __len = static_cast<streamsize>(_Traits::length(__s));
  	      if (__w > __len)
  		{
! 		  __pad(__out, __out.fill(), __pads, __s, __w, __len, false);
  		  __s = __pads;
  		  __len = __w;
  		}
--- 544,551 ----
  	      streamsize __len = static_cast<streamsize>(_Traits::length(__s));
  	      if (__w > __len)
  		{
! 		  __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __pads, 
! 						 __s, __w, __len, false);
  		  __s = __pads;
  		  __len = __w;
  		}
*************** namespace std 
*** 590,596 ****
  	      
  	      if (__w > __len)
  		{
! 		  __pad(__out, __out.fill(), __pads, __ws, __w, __len, false);
  		  __str = __pads;
  		  __len = __w;
  		}
--- 593,600 ----
  	      
  	      if (__w > __len)
  		{
! 		  __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __pads, 
! 						 __ws, __w, __len, false);
  		  __str = __pads;
  		  __len = __w;
  		}
*************** namespace std 
*** 628,634 ****
  
  	      if (__w > __len)
  		{
! 		  __pad(__out, __out.fill(), __pads, __s, __w, __len, false);
  		  __s = __pads;
  		  __len = __w;
  		}
--- 632,639 ----
  
  	      if (__w > __len)
  		{
! 		  __pad<char, _Traits>::_S_pad(__out, __out.fill(), __pads, 
! 						 __s, __w, __len, false);
  		  __s = __pads;
  		  __len = __w;
  		}
*************** namespace std 
*** 668,674 ****
  #endif
  	  if (__w > __len)
  	    {
! 	      __pad(__out, __out.fill(), __pads, __s, __w, __len, false);
  	      __s = __pads;
  	      __len = __w;
  	    }
--- 673,680 ----
  #endif
  	  if (__w > __len)
  	    {
! 	      __pad<_CharT, _Traits>::_S_pad(__out, __out.fill(), __pads, __s, 
! 					     __w, __len, false);
  	      __s = __pads;
  	      __len = __w;
  	    }
Index: include/bits/streambuf_iterator.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/streambuf_iterator.h,v
retrieving revision 1.7
diff -c -p -r1.7 streambuf_iterator.h
*** include/bits/streambuf_iterator.h	1 May 2002 22:40:27 -0000	1.7
--- include/bits/streambuf_iterator.h	29 Jul 2002 07:34:45 -0000
*************** namespace std
*** 69,81 ****
  
      public:
        istreambuf_iterator() throw() 
!       : _M_sbuf(0), _M_c(-2) { }
        
        istreambuf_iterator(istream_type& __s) throw()
!       : _M_sbuf(__s.rdbuf()), _M_c(-2) { }
  
        istreambuf_iterator(streambuf_type* __s) throw()
!       : _M_sbuf(__s), _M_c(-2) { }
         
        // NB: The result of operator*() on an end of stream is undefined.
        char_type 
--- 69,81 ----
  
      public:
        istreambuf_iterator() throw() 
!       : _M_sbuf(0), _M_c(traits_type::eof()) { }
        
        istreambuf_iterator(istream_type& __s) throw()
!       : _M_sbuf(__s.rdbuf()), _M_c(traits_type::eof()) { }
  
        istreambuf_iterator(streambuf_type* __s) throw()
!       : _M_sbuf(__s), _M_c(traits_type::eof()) { }
         
        // NB: The result of operator*() on an end of stream is undefined.
        char_type 
*************** namespace std
*** 85,105 ****
        istreambuf_iterator& 
        operator++()
        { 
! 	if (_M_sbuf && _M_sbuf->sbumpc() == traits_type::eof())
  	  _M_sbuf = 0;
  	else
! 	  _M_c = -2;
  	return *this; 
        }
  
        istreambuf_iterator
        operator++(int)
        {
  	istreambuf_iterator __old = *this;
! 	if (_M_sbuf && (__old._M_c = _M_sbuf->sbumpc()) == traits_type::eof())
  	  _M_sbuf = 0;
  	else
! 	  _M_c = -2;
  	return __old; 
        }
  
--- 85,109 ----
        istreambuf_iterator& 
        operator++()
        { 
! 	const int_type __eof = traits_type::eof();
! 	if (_M_sbuf && traits_type::eq_int_type(_M_sbuf->sbumpc(), __eof))
  	  _M_sbuf = 0;
  	else
! 	  _M_c = __eof;
  	return *this; 
        }
  
        istreambuf_iterator
        operator++(int)
        {
+ 	const int_type __eof = traits_type::eof();
  	istreambuf_iterator __old = *this;
! 	if (_M_sbuf
! 	    && traits_type::eq_int_type((__old._M_c = _M_sbuf->sbumpc()), 
! 					__eof))
  	  _M_sbuf = 0;
  	else
! 	  _M_c = __eof;
  	return __old; 
        }
  
*************** namespace std
*** 110,117 ****
        equal(const istreambuf_iterator& __b) const
        {
  	const int_type __eof = traits_type::eof();
! 	bool __thiseof = _M_get() == __eof;
! 	bool __beof = __b._M_get() == __eof;
  	return (__thiseof && __beof || (!__thiseof && !__beof));
        }
  #endif
--- 114,121 ----
        equal(const istreambuf_iterator& __b) const
        {
  	const int_type __eof = traits_type::eof();
! 	bool __thiseof = traits_type::eq_int_type(_M_get(), __eof);
! 	bool __beof = traits_type::eq_int_type(__b._M_get(), __eof);
  	return (__thiseof && __beof || (!__thiseof && !__beof));
        }
  #endif
*************** namespace std
*** 120,132 ****
        int_type 
        _M_get() const
        { 
! 	int_type __ret = traits_type::eof();
  	if (_M_sbuf)
  	  { 
! 	    if (_M_c != static_cast<int_type>(-2))
  	      __ret = _M_c;
  	    else 
! 	      if ((__ret = _M_sbuf->sgetc()) == traits_type::eof())
  		_M_sbuf = 0;
  	  }
  	return __ret;
--- 124,137 ----
        int_type 
        _M_get() const
        { 
! 	const int_type __eof = traits_type::eof();
! 	int_type __ret = __eof;
  	if (_M_sbuf)
  	  { 
! 	    if (!traits_type::eq_int_type(_M_c, __eof))
  	      __ret = _M_c;
  	    else 
! 	      if (traits_type::eq_int_type((__ret = _M_sbuf->sgetc()), __eof))
  		_M_sbuf = 0;
  	  }
  	return __ret;
Index: include/std/std_fstream.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/std/std_fstream.h,v
retrieving revision 1.12
diff -c -p -r1.12 std_fstream.h
*** include/std/std_fstream.h	30 Apr 2002 19:04:39 -0000	1.12
--- include/std/std_fstream.h	29 Jul 2002 07:34:48 -0000
*************** namespace std
*** 94,99 ****
--- 94,102 ----
        // pointer.
        char_type*		_M_filepos;
  
+       // Yet unused.
+       fpos<__state_type>	_M_pos;
+ 
      public:
        // Constructors/destructor:
        basic_filebuf();
*************** namespace std
*** 286,292 ****
        }
      };
  
! 
  
    // 27.8.1.5  Template class basic_ifstream
    /**
--- 289,304 ----
        }
      };
  
!   // Explicit specializations.
!   template<> 
!     basic_filebuf<char>::int_type 
!     basic_filebuf<char>::_M_underflow_common(bool __bump);
! 
!  #ifdef _GLIBCPP_USE_WCHAR_T
!   template<> 
!     basic_filebuf<wchar_t>::int_type 
!     basic_filebuf<wchar_t>::_M_underflow_common(bool __bump);
!  #endif
  
    // 27.8.1.5  Template class basic_ifstream
    /**
Index: src/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/Makefile.am,v
retrieving revision 1.110
diff -c -p -r1.110 Makefile.am
*** src/Makefile.am	20 Jun 2002 19:08:38 -0000	1.110
--- src/Makefile.am	29 Jul 2002 07:34:48 -0000
*************** sources = \
*** 70,75 ****
--- 70,76 ----
  	concept-inst.cc \
  	ctype.cc \
  	ext-inst.cc \
+ 	fstream.cc \
  	fstream-inst.cc \
  	functexcept.cc \
  	globals.cc \
Index: src/Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/Makefile.in,v
retrieving revision 1.155
diff -c -p -r1.155 Makefile.in
*** src/Makefile.in	27 Jun 2002 10:16:49 -0000	1.155
--- src/Makefile.in	29 Jul 2002 07:34:48 -0000
*************** sources = \
*** 175,180 ****
--- 175,181 ----
  	concept-inst.cc \
  	ctype.cc \
  	ext-inst.cc \
+ 	fstream.cc \
  	fstream-inst.cc \
  	functexcept.cc \
  	globals.cc \
*************** LDFLAGS = @LDFLAGS@
*** 279,285 ****
  LIBS = @LIBS@
  libstdc___la_OBJECTS =  basic_file.lo bitset.lo c++locale.lo codecvt.lo \
  collate.lo complex_io.lo concept-inst.lo ctype.lo ext-inst.lo \
! fstream-inst.lo functexcept.lo globals.lo io-inst.lo ios.lo \
  istream-inst.lo limits.lo locale-inst.lo locale.lo localename.lo \
  messages.lo misc-inst.lo monetary.lo numeric.lo ostream-inst.lo \
  sstream-inst.lo stdexcept.lo stl-inst.lo streambuf-inst.lo \
--- 280,286 ----
  LIBS = @LIBS@
  libstdc___la_OBJECTS =  basic_file.lo bitset.lo c++locale.lo codecvt.lo \
  collate.lo complex_io.lo concept-inst.lo ctype.lo ext-inst.lo \
! fstream.lo fstream-inst.lo functexcept.lo globals.lo io-inst.lo ios.lo \
  istream-inst.lo limits.lo locale-inst.lo locale.lo localename.lo \
  messages.lo misc-inst.lo monetary.lo numeric.lo ostream-inst.lo \
  sstream-inst.lo stdexcept.lo stl-inst.lo streambuf-inst.lo \
Index: src/fstream.cc
===================================================================
RCS file: src/fstream.cc
diff -N src/fstream.cc
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- src/fstream.cc	29 Jul 2002 07:34:49 -0000
***************
*** 0 ****
--- 1,191 ----
+ // File based streams -*- C++ -*-
+ 
+ // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
+ // Free Software Foundation, Inc.
+ //
+ // This file is part of the GNU ISO C++ Library.  This library is free
+ // software; you can redistribute it and/or modify it under the
+ // 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.
+ 
+ //
+ // ISO C++ 14882: 27.8  File-based streams
+ //
+ 
+ #include <fstream>
+ 
+ namespace std 
+ {
+   template<> 
+     basic_filebuf<char>::int_type 
+     basic_filebuf<char>::_M_underflow_common(bool __bump)
+     {
+       int_type __ret = traits_type::eof();
+       bool __testin = _M_mode & ios_base::in;
+       bool __testout = _M_mode & ios_base::out;
+ 
+       if (__testin)
+ 	{
+ 	  // Check for pback madness, and if so swich back to the
+ 	  // normal buffers and jet outta here before expensive
+ 	  // fileops happen...
+ 	  if (_M_pback_init)
+ 	    {
+ 	      _M_pback_destroy();
+ 	      if (_M_in_cur < _M_in_end)
+ 		return traits_type::to_int_type(*_M_in_cur);
+ 	    }
+ 
+ 	  // Sync internal and external buffers.
+ 	  // NB: __testget -> __testput as _M_buf_unified here.
+ 	  bool __testget = _M_in_cur && _M_in_beg < _M_in_cur;
+ 	  bool __testinit = _M_is_indeterminate();
+ 	  if (__testget)
+ 	    {
+ 	      if (__testout)
+ 		_M_really_overflow();
+ 	      else if (_M_in_cur != _M_filepos)
+ 		_M_file.seekoff(_M_in_cur - _M_filepos,
+ 				ios_base::cur, ios_base::in);
+ 	    }
+ 
+ 	  if (__testinit || __testget)
+ 	    {
+ 	      streamsize __elen = 0;
+ 	      streamsize __ilen = 0;
+ 	      __elen = _M_file.xsgetn(reinterpret_cast<char*>(_M_in_beg), 
+ 				      _M_buf_size);
+ 	      __ilen = __elen;
+ 
+ 	      if (0 < __ilen)
+ 		{
+ 		  _M_set_determinate(__ilen);
+ 		  if (__testout)
+ 		    _M_out_cur = _M_in_cur;
+ 		  __ret = traits_type::to_int_type(*_M_in_cur);
+ 		  if (__bump)
+ 		    _M_in_cur_move(1);
+ 		  else if (_M_buf_size == 1)
+ 		    {
+ 		      // If we are synced with stdio, we have to unget the
+ 		      // character we just read so that the file pointer
+ 		      // doesn't move.
+ 		      _M_file.sys_ungetc(traits_type::to_int_type(*_M_in_cur));
+ 		      _M_set_indeterminate();
+ 		    }
+ 		}	   
+ 	    }
+ 	}
+       _M_last_overflowed = false;	
+       return __ret;
+     }
+ 
+   template<> 
+     basic_filebuf<wchar_t>::int_type 
+     basic_filebuf<wchar_t>::_M_underflow_common(bool __bump)
+     {
+       int_type __ret = traits_type::eof();
+       bool __testin = _M_mode & ios_base::in;
+       bool __testout = _M_mode & ios_base::out;
+ 
+       if (__testin)
+ 	{
+ 	  // Check for pback madness, and if so swich back to the
+ 	  // normal buffers and jet outta here before expensive
+ 	  // fileops happen...
+ 	  if (_M_pback_init)
+ 	    {
+ 	      _M_pback_destroy();
+ 	      if (_M_in_cur < _M_in_end)
+ 		return traits_type::to_int_type(*_M_in_cur);
+ 	    }
+ 
+ 	  // Sync internal and external buffers.
+ 	  // NB: __testget -> __testput as _M_buf_unified here.
+ 	  bool __testget = _M_in_cur && _M_in_beg < _M_in_cur;
+ 	  bool __testinit = _M_is_indeterminate();
+ 	  if (__testget)
+ 	    {
+ 	      if (__testout)
+ 		_M_really_overflow();
+ 	      else if (_M_in_cur != _M_filepos)
+ 		_M_file.seekoff(_M_in_cur - _M_filepos,
+ 				ios_base::cur, ios_base::in);
+ 	    }
+ 
+ 	  if (__testinit || __testget)
+ 	    {
+ 	      const locale __loc = this->getloc();
+ 	      const __codecvt_type& __cvt = use_facet<__codecvt_type>(__loc); 
+ 
+ 	      streamsize __elen = 0;
+ 	      streamsize __ilen = 0;
+ 	      if (__cvt.always_noconv())
+ 		{
+ 		  __elen = _M_file.xsgetn(reinterpret_cast<char*>(_M_in_beg), 
+ 					  _M_buf_size);
+ 		  __ilen = __elen;
+ 		}
+ 	      else
+ 		{
+ 		  char* __buf = static_cast<char*>(__builtin_alloca(_M_buf_size));
+ 		  __elen = _M_file.xsgetn(__buf, _M_buf_size);
+ 
+ 		  const char* __eend;
+ 		  char_type* __iend;
+ 		  __res_type __r = __cvt.in(_M_state_cur, __buf, 
+ 					    __buf + __elen, __eend, _M_in_beg, 
+ 					    _M_in_beg + _M_buf_size, __iend);
+ 		  if (__r == codecvt_base::ok)
+ 		    __ilen = __iend - _M_in_beg;
+ 		  else 
+ 		    {
+ 		      // Unwind.
+ 		      __ilen = 0;
+ 		      _M_file.seekoff(-__elen, ios_base::cur, ios_base::in);
+ 		    }
+ 		}
+ 
+ 	      if (0 < __ilen)
+ 		{
+ 		  _M_set_determinate(__ilen);
+ 		  if (__testout)
+ 		    _M_out_cur = _M_in_cur;
+ 		  __ret = traits_type::to_int_type(*_M_in_cur);
+ 		  if (__bump)
+ 		    _M_in_cur_move(1);
+ 		  else if (_M_buf_size == 1)
+ 		    {
+ 		      // If we are synced with stdio, we have to unget the
+ 		      // character we just read so that the file pointer
+ 		      // doesn't move.
+ 		      _M_file.sys_ungetc(traits_type::to_int_type(*_M_in_cur));
+ 		      _M_set_indeterminate();
+ 		    }
+ 		}	   
+ 	    }
+ 	}
+       _M_last_overflowed = false;	
+       return __ret;
+     }
+ } // namespace std
Index: src/locale-inst.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/locale-inst.cc,v
retrieving revision 1.33
diff -c -p -r1.33 locale-inst.cc
*** src/locale-inst.cc	7 Jun 2002 22:06:38 -0000	1.33
--- src/locale-inst.cc	29 Jul 2002 07:34:50 -0000
*************** namespace std
*** 420,434 ****
      bool
      __verify_grouping<char>(const basic_string<char>&, basic_string<char>&);
  
!   template
!     void 
!     __pad<char>(ios_base&, char, char*, const char *, streamsize, 
! 		streamsize, const bool);
! 
!   template
!     void 
!     __pad<char, char_traits<char> >(ios_base&, char, char*, const char *, 
! 				    streamsize, streamsize, const bool);
  
  #ifdef _GLIBCPP_USE_WCHAR_T
    template
--- 420,426 ----
      bool
      __verify_grouping<char>(const basic_string<char>&, basic_string<char>&);
  
!   template class __pad<char, char_traits<char> >;
  
  #ifdef _GLIBCPP_USE_WCHAR_T
    template
*************** namespace std
*** 440,468 ****
      __verify_grouping<wchar_t>(const basic_string<wchar_t>&, 
  			       basic_string<wchar_t>&);
  
!   template
!     void 
!     __pad<wchar_t>(ios_base&, wchar_t, wchar_t*, const wchar_t*, 
! 		   streamsize, streamsize, const bool);
! 
!   template
!     void 
!     __pad<wchar_t, char_traits<wchar_t> >(ios_base&, wchar_t, wchar_t*, 
! 					  const wchar_t*, streamsize, 
! 					  streamsize, const bool);
! #endif // _GLIBCPP_USE_WCHAR_T
  
    template
      int
!     __convert_from_v(char*, const int, const char*, double, const __c_locale&, int);
  
    template
      int
!     __convert_from_v(char*, const int, const char*, long double, const __c_locale&, int);
  
    template
      int
!     __convert_from_v(char*, const int, const char*, long, const __c_locale&, int);
  
    template
      int
--- 432,454 ----
      __verify_grouping<wchar_t>(const basic_string<wchar_t>&, 
  			       basic_string<wchar_t>&);
  
!   template class __pad<wchar_t, char_traits<wchar_t> >;
! #endif 
  
    template
      int
!     __convert_from_v(char*, const int, const char*, double, 
! 		     const __c_locale&, int);
  
    template
      int
!     __convert_from_v(char*, const int, const char*, long double, 
! 		     const __c_locale&, int);
  
    template
      int
!     __convert_from_v(char*, const int, const char*, long, 
! 		     const __c_locale&, int);
  
    template
      int
*************** namespace std
*** 471,477 ****
  
    template
      int
!     __convert_from_v(char*, const int, const char*, long long, const __c_locale&, int);
  
    template
      int
--- 457,464 ----
  
    template
      int
!     __convert_from_v(char*, const int, const char*, long long, 
! 		     const __c_locale&, int);
  
    template
      int


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]