This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

[v3] libstdc++/2523



Fixed this mess. Tempted to clean up istream extractors and commonize code.

2001-05-07  Benjamin Kosnik  <bkoz@redhat.com>

	libstdc++/2523
	* include/bits/std_fstream.h (basic_filebuf): Change signature.
	* include/bits/fstream.tcc (basic_filebuf): Change bool argument
	to int_type, pass in buffer size info.
	* include/bits/std_streambuf.h (_M_is_indeterminate): Check for
	unbuffered situation.
	(underflow): Remove codecvt bits for the time being.
	* include/bits/istream.tcc (istream::sentry): Avoid sputbackc call.
	* include/bits/locale_facets.tcc (_M_extract): Cache dereference
	values from iterators, clean.
	* src/locale.cc: Ditto.
	* include/bits/sbuf_iter.h: Format.
	* src/ios.cc: Explicitly pass in buffer sizes at creation time.
	* testsuite/27_io/narrow_stream_objects.cc: Add tests.
	* testsuite/27_io/filebuf.cc: Tweaks.
	* testsuite/27_io/filebuf_members.cc: Tweaks.
	
Index: include/bits/fstream.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/fstream.tcc,v
retrieving revision 1.12
diff -c -p -r1.12 fstream.tcc
*** fstream.tcc	2001/04/04 01:02:25	1.12
--- fstream.tcc	2001/05/08 02:56:44
*************** namespace std
*** 90,96 ****
  
    template<typename _CharT, typename _Traits>
      basic_filebuf<_CharT, _Traits>::
!     basic_filebuf(__c_file_type* __f, bool __s, ios_base::openmode __mode)
      : __streambuf_type(),  _M_file(NULL), _M_state_cur(__state_type()), 
      _M_state_beg(__state_type()), _M_last_overflowed(false)
      {
--- 90,96 ----
  
    template<typename _CharT, typename _Traits>
      basic_filebuf<_CharT, _Traits>::
!     basic_filebuf(__c_file_type* __f, ios_base::openmode __mode, int_type __s)
      : __streambuf_type(),  _M_file(NULL), _M_state_cur(__state_type()), 
      _M_state_beg(__state_type()), _M_last_overflowed(false)
      {
*************** namespace std
*** 99,106 ****
        if (this->is_open())
  	{
  	  _M_mode = __mode;
! 	  if (!__s)
  	    {
  	      _M_allocate_buffers();
  	      _M_set_indeterminate();
  	    }
--- 99,107 ----
        if (this->is_open())
  	{
  	  _M_mode = __mode;
! 	  if (__s)
  	    {
+ 	      _M_buf_size_opt = __s;
  	      _M_allocate_buffers();
  	      _M_set_indeterminate();
  	    }
*************** namespace std
*** 208,214 ****
      {
        int_type __ret = traits_type::eof();
        bool __testin = _M_mode & ios_base::in;
!       
        if (__testin)
  	{
  	  // Check for pback madness, and if so swich back to the
--- 209,217 ----
      {
        int_type __ret = traits_type::eof();
        bool __testin = _M_mode & ios_base::in;
!       bool __testout = _M_mode & ios_base::out;
! 
!       // XXX Should re-enable codecvt bits disabled after 2.90.8.
        if (__testin)
  	{
  	  // Check for pback madness, and if so swich back to the
*************** namespace std
*** 223,230 ****
  
  	  bool __testget = _M_in_cur && _M_in_beg < _M_in_cur;
  	  bool __testinit = _M_is_indeterminate();
- 	  bool __testout = _M_mode & ios_base::out;
- 
  	  // Sync internal and external buffers.
  	  // NB: __testget -> __testput as _M_buf_unified here.
  	  if (__testget)
--- 226,231 ----
*************** namespace std
*** 238,244 ****
  
  	  if (__testinit || __testget)
  	    {
! #if 1
  	      streamsize __size = _M_file->xsgetn(_M_in_beg, _M_buf_size);
  	      if (0 < __size)
  		{
--- 239,245 ----
  
  	  if (__testinit || __testget)
  	    {
! 	      // Assume buffered case, need to refill internal buffers.
  	      streamsize __size = _M_file->xsgetn(_M_in_beg, _M_buf_size);
  	      if (0 < __size)
  		{
*************** namespace std
*** 251,304 ****
  		  if (__p == -1)
  		    {
  		      // XXX Something is wrong, do error checking.
- 		    }
- 		}
- #else
- 	      // 2000-08-04 bkoz disable
- 	      // Part one: (Re)fill external buf (_M_file->_IO_*) from
- 	      // external byte sequence (whatever physical byte sink or
- 	      // FILE actually is.)
- 	      char_type* __conv_buf = static_cast<char_type*>(__builtin_alloca(sizeof(char_type) * _M_buf_size));
- 	      streamsize __size = _M_file->xsgetn(__conv_buf, _M_buf_size);
- 	      
- 	      // Part two: (Re)fill internal buf contents from external buf.
- 	      if (0 < __size)
- 		{
- 		  _M_set_determinate(__size);
- 		  
- 		  char* __conv_cur = __conv_buf;
- 		  _M_state_beg = _M_state_cur;
- 		  __res_type __r = _M_fcvt->in(_M_state_cur, 
- 					       __conv_buf,
- 					       __conv_buf + __size,
- 					 const_cast<const char*&>(__conv_cur), 
- 					      _M_in_beg, _M_in_end, _M_in_cur);
- 	      
- 		  if (__r == codecvt_base::partial)
- 		    {
- 		      // XXX Retry with larger _M_buf size.
- 		    }
- 		  
- 		  // Set pointers to internal and external buffers
- 		  // correctly. . .
- 		  if (__r != codecvt_base::error)
- 		    {
- 		      if (__testout)
- 			_M_out_cur = _M_in_cur;
- 		      __ret = traits_type::to_int_type(*_M_in_cur);
- 		    }
- 
- 		  // Part three: Sync the current internal buffer
- 		  // position with the (now overshot) external buffer
- 		  // position.  
- 		  streamoff __p = _M_file->seekoff(0 - __size, ios_base::cur, 
- 						  ios_base::in);
- 		  if (__p == -1)
- 		    {
- 		      // XXX Something is wrong, do error checking.
  		    }
! 		}
! #endif	      
  	    }
  	}
        _M_last_overflowed = false;	
--- 252,259 ----
  		  if (__p == -1)
  		    {
  		      // XXX Something is wrong, do error checking.
  		    }
! 		}	   
  	    }
  	}
        _M_last_overflowed = false;	
Index: include/bits/istream.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/istream.tcc,v
retrieving revision 1.12
diff -c -p -r1.12 istream.tcc
*** istream.tcc	2001/03/12 18:30:29	1.12
--- istream.tcc	2001/05/08 02:56:47
*************** namespace std {
*** 44,67 ****
  	  if (!__noskipws && (__in.flags() & ios_base::skipws))
  	    {	  
  	      const __int_type __eof = traits_type::eof();
- 	      __int_type __c = __int_type(0);
- 	      __streambuf_type* __sb = __in.rdbuf();
  	      const __ctype_type* __ctype = __in._M_get_fctype_ios();
! 	      bool __testsp = true;
! 	      bool __testeof = false;
! 	      
! 	      while (!__testeof && __testsp)
! 		{
! 		  __c = __sb->sbumpc();
! 		  __testeof = __c == __eof;
! 		  __testsp = __ctype->is(ctype_base::space, __c);
! 		}
  	      
! 	      if (!__testeof && !__testsp)
! 		__sb->sputbackc(__c);
  #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
  //195.  Should basic_istream::sentry's constructor ever set eofbit? 
! 	      else
  		__in.setstate(ios_base::eofbit);
  #endif
  	    }
--- 44,59 ----
  	  if (!__noskipws && (__in.flags() & ios_base::skipws))
  	    {	  
  	      const __int_type __eof = traits_type::eof();
  	      const __ctype_type* __ctype = __in._M_get_fctype_ios();
! 	      __streambuf_type* __sb = __in.rdbuf();
! 	      __int_type __c = __sb->sgetc();
  	      
! 	      while (__c != __eof && __ctype->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
  	    }
Index: include/bits/locale_facets.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/locale_facets.tcc,v
retrieving revision 1.12
diff -c -p -r1.12 locale_facets.tcc
*** locale_facets.tcc	2001/03/14 20:46:33	1.12
--- locale_facets.tcc	2001/05/08 02:56:50
*************** namespace std
*** 189,203 ****
        switch (__ev)
          {
          case ios_base::erase_event:
!           delete static_cast<_Format_cache<_CharT>*> (__p); __p = 0;
            break;
          case ios_base::copyfmt_event:
            // If just stored zero, the callback would get registered again.
!           try {
!             __p = new _Format_cache<_CharT>;
!           }
!           catch(...) {
!           }
            break;
          case ios_base::imbue_event:
            static_cast<_Format_cache<_CharT>*>(__p)->_M_valid = false;
--- 189,203 ----
        switch (__ev)
          {
          case ios_base::erase_event:
!           delete static_cast<_Format_cache<_CharT>*>(__p);
! 	  __p = 0;
            break;
          case ios_base::copyfmt_event:
            // If just stored zero, the callback would get registered again.
!           try 
! 	    { __p = new _Format_cache<_CharT>; }
!           catch(...) 
! 	    { }
            break;
          case ios_base::imbue_event:
            static_cast<_Format_cache<_CharT>*>(__p)->_M_valid = false;
Index: include/bits/sbuf_iter.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/sbuf_iter.h,v
retrieving revision 1.6
diff -c -p -r1.6 sbuf_iter.h
*** sbuf_iter.h	2001/05/02 05:50:19	1.6
--- sbuf_iter.h	2001/05/08 02:56:50
*************** namespace std
*** 46,52 ****
        typedef _Traits                          traits_type;
        typedef basic_streambuf<_CharT, _Traits> streambuf_type;
        typedef basic_ostream<_CharT, _Traits>   ostream_type;
!       
        inline 
        ostreambuf_iterator(ostream_type& __s) throw ()
        : _M_sbuf(__s.rdbuf()), _M_failed(!_M_sbuf) { }
--- 46,57 ----
        typedef _Traits                          traits_type;
        typedef basic_streambuf<_CharT, _Traits> streambuf_type;
        typedef basic_ostream<_CharT, _Traits>   ostream_type;
! 
!     private:
!       streambuf_type* 	_M_sbuf;
!       bool 		_M_failed;
! 
!     public:
        inline 
        ostreambuf_iterator(ostream_type& __s) throw ()
        : _M_sbuf(__s.rdbuf()), _M_failed(!_M_sbuf) { }
*************** namespace std
*** 72,81 ****
        bool 
        failed() const throw()
        { return _M_failed; }
- 
-     private:
-       streambuf_type* 	_M_sbuf;
-       bool 		_M_failed;
      };
  
    template<typename _CharT, typename _Traits>
--- 77,82 ----
*************** namespace std
*** 90,102 ****
  
  
    // 24.5.3 Template class istreambuf_iterator
!   template<class _CharT, class _Traits>
      class istreambuf_iterator
      : public iterator<input_iterator_tag, _CharT, typename _Traits::off_type,
      		      _CharT*, _CharT&>
      {
      public:
- 
        // Types:
        typedef _CharT                         		char_type;
        typedef _Traits                        		traits_type;
--- 91,102 ----
  
  
    // 24.5.3 Template class istreambuf_iterator
!   template<typename _CharT, typename _Traits>
      class istreambuf_iterator
      : public iterator<input_iterator_tag, _CharT, typename _Traits::off_type,
      		      _CharT*, _CharT&>
      {
      public:
        // Types:
        typedef _CharT                         		char_type;
        typedef _Traits                        		traits_type;
*************** namespace std
*** 106,111 ****
--- 106,123 ----
        // Non-standard Types:
        typedef istreambuf_iterator<_CharT, _Traits>	__istreambufiter_type;
  
+     private:
+       // 24.5.3 istreambuf_iterator 
+       // p 1 
+       // If the end of stream is reached (streambuf_type::sgetc()
+       // returns traits_type::eof()), the iterator becomes equal to
+       // the "end of stream" iterator value.
+       // NB: This implementation assumes the "end of stream" value
+       // is EOF, or -1.
+       streambuf_type* 		_M_sbuf;  
+       int_type 			_M_c;
+ 
+     public:
        istreambuf_iterator() throw() 
        : _M_sbuf(NULL), _M_c(-2) { }
        
*************** namespace std
*** 174,190 ****
  	return (__thiseof && __beof || (!__thiseof && !__beof));
        }
  #endif
- 
-     private:
-       // 24.5.3 istreambuf_iterator 
-       // p 1 
-       // If the end of stream is reached (streambuf_type::sgetc()
-       // returns traits_type::eof()), the iterator becomes equal to
-       // the "end of stream" iterator value.
-       // NB: This implementation assumes the "end of stream" value
-       // is EOF, or -1.
-       streambuf_type* 		_M_sbuf;  
-       int_type 			_M_c;
      };
  
    template<typename _CharT, typename _Traits>
--- 186,191 ----
*************** namespace std
*** 198,207 ****
      operator!=(const istreambuf_iterator<_CharT, _Traits>& __a,
  	       const istreambuf_iterator<_CharT, _Traits>& __b)
      { return !__a.equal(__b); }
- 
  } // namespace std
- 
  #endif
- 
- 
- 
--- 199,203 ----
Index: include/bits/std_fstream.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/std_fstream.h,v
retrieving revision 1.7
diff -c -p -r1.7 std_fstream.h
*** std_fstream.h	2001/04/04 01:02:25	1.7
--- std_fstream.h	2001/05/08 02:56:50
*************** namespace std 
*** 86,92 ****
        basic_filebuf();
  
        // Non-standard ctor:
!       basic_filebuf(__c_file_type* __f, bool __s, ios_base::openmode __mode);
   
        virtual 
        ~basic_filebuf() 
--- 86,93 ----
        basic_filebuf();
  
        // Non-standard ctor:
!       basic_filebuf(__c_file_type* __f, ios_base::openmode __mode, 
! 		    int_type __s = static_cast<int_type>(BUFSIZ));
   
        virtual 
        ~basic_filebuf() 
Index: include/bits/std_streambuf.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/std_streambuf.h,v
retrieving revision 1.8
diff -c -p -r1.8 std_streambuf.h
*** std_streambuf.h	2001/03/14 20:46:34	1.8
--- std_streambuf.h	2001/05/08 02:56:52
*************** namespace std
*** 251,267 ****
  	  this->setg(_M_buf, _M_buf, _M_buf + __off);
  	if (__testout)
  	  this->setp(_M_buf, _M_buf + __off);
- 
        }
  
        bool
        _M_is_indeterminate(void)
        { 
  	bool __ret = false;
! 	if (_M_mode & ios_base::in)
! 	  __ret = _M_in_beg == _M_in_cur && _M_in_cur == _M_in_end;
! 	if (_M_mode & ios_base::out)
! 	  __ret = _M_out_beg == _M_out_cur && _M_out_cur == _M_out_end;
  	return __ret;
        }
  
--- 251,270 ----
  	  this->setg(_M_buf, _M_buf, _M_buf + __off);
  	if (__testout)
  	  this->setp(_M_buf, _M_buf + __off);
        }
  
        bool
        _M_is_indeterminate(void)
        { 
  	bool __ret = false;
! 	// Don't return true if unbuffered.
! 	if (_M_buf)
! 	  {
! 	    if (_M_mode & ios_base::in)
! 	      __ret = _M_in_beg == _M_in_cur && _M_in_cur == _M_in_end;
! 	    if (_M_mode & ios_base::out)
! 	      __ret = _M_out_beg == _M_out_cur && _M_out_cur == _M_out_end;
! 	  }
  	return __ret;
        }
  
*************** namespace std
*** 350,356 ****
        {
  	int_type __ret;
  	if (_M_in_cur && _M_in_cur < _M_in_end)
! 	  __ret = traits_type::to_int_type(*gptr());
  	else 
  	  __ret = this->underflow();
  	return __ret;
--- 353,359 ----
        {
  	int_type __ret;
  	if (_M_in_cur && _M_in_cur < _M_in_end)
! 	  __ret = traits_type::to_int_type(*(this->gptr()));
  	else 
  	  __ret = this->underflow();
  	return __ret;
Index: src/ios.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/ios.cc,v
retrieving revision 1.17
diff -c -p -r1.17 ios.cc
*** ios.cc	2001/04/04 01:02:25	1.17
--- ios.cc	2001/05/08 02:56:54
*************** namespace std 
*** 136,154 ****
    void
    ios_base::Init::_S_ios_create(bool __sync)
    {
      // NB: The file std_iostream.h creates the four standard files
!     // with NULL buffers. At this point, we swap out these
!     new (&cout) ostream(new filebuf(stdout, __sync, ios_base::out));
!     new (&cin) istream(new filebuf(stdin, __sync, ios_base::in));
!     new (&cerr) ostream(new filebuf(stderr, __sync, ios_base::out));
      new (&clog) ostream(cerr.rdbuf());
      cin.tie(&cout);
      cerr.flags(ios_base::unitbuf);
      
  #ifdef _GLIBCPP_USE_WCHAR_T
!     new (&wcout) wostream( new wfilebuf(stdout, __sync, ios_base::out));
!     new (&wcin) wistream(new wfilebuf(stdin, __sync, ios_base::in));
!     new (&wcerr) wostream(new wfilebuf(stderr, __sync, ios_base::out));
      new (&wclog) wostream(wcerr.rdbuf());
      wcin.tie(&wcout);
      wcerr.flags(ios_base::unitbuf);
--- 136,156 ----
    void
    ios_base::Init::_S_ios_create(bool __sync)
    {
+     int __bufsize = __sync ? 0 : static_cast<int>(BUFSIZ);
      // NB: The file std_iostream.h creates the four standard files
!     // with NULL buffers. At this point, we swap out the dummy NULL
!     // buffers with the real deal.
!     new (&cout) ostream(new filebuf(stdout, ios_base::out, __bufsize));
!     new (&cin) istream(new filebuf(stdin, ios_base::in, 1));
!     new (&cerr) ostream(new filebuf(stderr, ios_base::out, __bufsize));
      new (&clog) ostream(cerr.rdbuf());
      cin.tie(&cout);
      cerr.flags(ios_base::unitbuf);
      
  #ifdef _GLIBCPP_USE_WCHAR_T
!     new (&wcout) wostream( new wfilebuf(stdout, ios_base::out, __bufsize));
!     new (&wcin) wistream(new wfilebuf(stdin, ios_base::in, 1));
!     new (&wcerr) wostream(new wfilebuf(stderr, ios_base::out, __bufsize));
      new (&wclog) wostream(wcerr.rdbuf());
      wcin.tie(&wcout);
      wcerr.flags(ios_base::unitbuf);
Index: src/locale.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/locale.cc,v
retrieving revision 1.31
diff -c -p -r1.31 locale.cc
*** locale.cc	2001/03/04 21:34:02	1.31
--- locale.cc	2001/05/08 02:56:56
*************** namespace std 
*** 676,684 ****
  
        // Stage 2: extract characters.
        __cache_type const* __fmt = __cache_type::_S_get(__io);
!       bool __valid = __beg != __end;
        // Fail quickly if !__valid
!       if (!__valid)
          {
            __err |= (ios_base::eofbit | ios_base::failbit);
            return;
--- 676,684 ----
  
        // Stage 2: extract characters.
        __cache_type const* __fmt = __cache_type::_S_get(__io);
! 
        // Fail quickly if !__valid
!       if (__beg == __end)
          {
            __err |= (ios_base::eofbit | ios_base::failbit);
            return;
*************** namespace std 
*** 694,707 ****
        // Check first for sign
        bool __testsign = false;
        if ((__c == __lits[__cache_type::_S_minus])
!           || (__c == __lits[__cache_type::_S_plus]))
          {
            __xtrc[__pos++] = __c;
            ++__beg;
!           __testsign = true;
!           // whitespace may follow a sign
!           while ((__beg != __end) && (isspace(*__beg)))
!             ++__beg;
  
            // There had better be more to come...
            if (__beg == __end)
--- 694,712 ----
        // Check first for sign
        bool __testsign = false;
        if ((__c == __lits[__cache_type::_S_minus])
! 	  || (__c == __lits[__cache_type::_S_plus]))
          {
+           __testsign = true;
            __xtrc[__pos++] = __c;
            ++__beg;
! 	  __c = * __beg;
! 
!           // Whitespace may follow a sign
!           while ((__beg != __end) && (isspace(__c)))
! 	    {
! 	      ++__beg;
! 	      __c = *__beg;
! 	    }
  
            // There had better be more to come...
            if (__beg == __end)
*************** namespace std 
*** 712,731 ****
              }
          }
  
!       bool __testzero = false;    // Has there been a leading zero?
! 
!       // Now check if first character is a zero
!       __c = *__beg;
        if (__c == __lits[__cache_type::_S_digits])
          {
             __testzero = true;
             ++__beg;
  
             // We have to check for __beg == __end here. If so,
             // a plain '0' (possibly with a sign) can be got rid of now
             if (__beg == __end)
               {
!                __xtrc[__pos++] = __c;
                 __xtrc[__pos] = '\0';
                 __err |= ios_base::eofbit;
                 return;
--- 717,735 ----
              }
          }
  
!       // Now check if first character is a zero.
!       bool __testzero = false;    
        if (__c == __lits[__cache_type::_S_digits])
          {
             __testzero = true;
             ++__beg;
+ 	   __c = *__beg;
  
             // We have to check for __beg == __end here. If so,
             // a plain '0' (possibly with a sign) can be got rid of now
             if (__beg == __end)
               {
!                __xtrc[__pos++] = __lits[__cache_type::_S_digits];
                 __xtrc[__pos] = '\0';
                 __err |= ios_base::eofbit;
                 return;
*************** namespace std 
*** 736,746 ****
            if (!__fp && __base != 10 && __base != 8)
              {
                // Here, __base == 0 or 16
-               __c = *__beg;
                if ((__c == __lits[__cache_type::_S_x])
                   || (__c == __lits[__cache_type::_S_X]))
                  {
                    ++__beg;
                    __base = 16;
                    __testzero = false; // "0x" is not a leading zero
                  }
--- 740,750 ----
            if (!__fp && __base != 10 && __base != 8)
              {
                // Here, __base == 0 or 16
                if ((__c == __lits[__cache_type::_S_x])
                   || (__c == __lits[__cache_type::_S_X]))
                  {
                    ++__beg;
+ 		  __c = *__beg;
                    __base = 16;
                    __testzero = false; // "0x" is not a leading zero
                  }
*************** namespace std 
*** 751,759 ****
            // Remove any more leading zeros
            while (__beg != __end)
              {
!               if (*__beg == __lits[__cache_type::_S_digits])
                  {
                    ++__beg;
                    __testzero = true;
                  }
                else
--- 755,764 ----
            // Remove any more leading zeros
            while (__beg != __end)
              {
!               if (__c == __lits[__cache_type::_S_digits])
                  {
                    ++__beg;
+ 		  __c = *__beg;
                    __testzero = true;
                  }
                else
*************** namespace std 
*** 767,810 ****
        // We may need to know if anything is found here. A leading zero
        // (removed by now) would count.
        bool __testunits = __testzero;
!       while (__valid && __beg != __end)
          {
!           __valid = false;
!           __c = *__beg;
!           const char* __p = strchr(__fmt->_S_literals, __c);
  
            // NB: strchr returns true for __c == 0x0
!           if (__p && __c)
!             {
!               // Try first for acceptable digit; record it if found
!               if ((__p >= &__lits[__cache_type::_S_digits]
!                     && __p < &__lits[__cache_type::_S_digits + __base])
!                    || (__p >= &__lits[__cache_type::_S_udigits]
!                        && __p < &__lits[__cache_type::_S_udigits + __base]))
!                 {
!                   __xtrc[__pos++] = __c;
!                   ++__sep_pos;
!                   __valid = true;
!                   __testunits = true;
!                 }
!             }
!           else if (__c == __fmt->_M_thousands_sep
!                    && __fmt->_M_use_grouping)
!             {
                // NB: Thousands separator at the beginning of a string
                // is a no-no, as is two consecutive thousands
!               // separators
                if (__sep_pos)
                  {
                    __grp += static_cast<char>(__sep_pos);
                    __sep_pos = 0;
!                   __valid = true;
                  }
                else
!                 __err |= ios_base::failbit;
              }
!           if (__valid)
!             ++__beg;
          }
  
        // Digit grouping is checked. If _M_groupings() doesn't
--- 772,816 ----
        // We may need to know if anything is found here. A leading zero
        // (removed by now) would count.
        bool __testunits = __testzero;
!       while (__beg != __end)
          {
!           const char* __p = strchr(__lits, __c);
  
            // NB: strchr returns true for __c == 0x0
!           if (__p && __c
! 	      &&((__p >= &__lits[__cache_type::_S_digits]
! 		  && __p < &__lits[__cache_type::_S_digits + __base])
! 		 || (__p >= &__lits[__cache_type::_S_udigits]
! 		     && __p < &__lits[__cache_type::_S_udigits + __base])))
! 	    {
! 	      // Try first for acceptable digit; record it if found.
! 	      __xtrc[__pos++] = __c;
! 	      ++__sep_pos;
! 	      __testunits = true;
! 	      ++__beg;
! 	      __c = *__beg;
! 	    }
!           else if (__c == __fmt->_M_thousands_sep && __fmt->_M_use_grouping)
! 	    {
                // NB: Thousands separator at the beginning of a string
                // is a no-no, as is two consecutive thousands
!               // separators.
                if (__sep_pos)
                  {
                    __grp += static_cast<char>(__sep_pos);
                    __sep_pos = 0;
! 		  ++__beg;
! 		  __c = *__beg;
                  }
                else
! 		{
! 		  __err |= ios_base::failbit;
! 		  break;
! 		}
              }
! 	  else
! 	    // Not a valid input item.
! 	    break;
          }
  
        // Digit grouping is checked. If _M_groupings() doesn't
*************** namespace std 
*** 852,858 ****
        // That's it for integer types. Remaining code is for floating point
        if (__fp && __beg != __end)
          {
-           __c = *__beg;
            // Check first for decimal point. There MUST be one if
            // __testunits is false.
            bool __testdec = false;    // Is there a decimal point
--- 858,863 ----
*************** namespace std 
*** 861,872 ****
              {
                __xtrc[__pos++] = '.';
                ++__beg;
                // Now we get any digits after the decimal point
                // There MUST be some if __testunits is false.
                while (__beg != __end)
                  {
!                   __c = *__beg;
!                   const char* __p = strchr(__fmt->_S_literals, __c);
                    if ((__p >= &__lits[__cache_type::_S_digits]
                          && __p < &__lits[__cache_type::_S_digits + __base])
                         || (__p >= &__lits[__cache_type::_S_udigits]
--- 866,878 ----
              {
                __xtrc[__pos++] = '.';
                ++__beg;
+ 	      __c = *__beg;
+ 
                // Now we get any digits after the decimal point
                // There MUST be some if __testunits is false.
                while (__beg != __end)
                  {
!                   const char* __p = strchr(__lits, __c);
                    if ((__p >= &__lits[__cache_type::_S_digits]
                          && __p < &__lits[__cache_type::_S_digits + __base])
                         || (__p >= &__lits[__cache_type::_S_udigits]
*************** namespace std 
*** 874,879 ****
--- 880,886 ----
                      {
                        __xtrc[__pos++] = __c;
                        ++__beg;
+ 		      __c = *__beg;
                        __testdec = true;
                      }
                    else
*************** namespace std 
*** 892,916 ****
            // Now we may find an exponent
            if (__beg != __end)
              {
-               __c = *__beg;
                if ((__c == __lits[__cache_type::_S_ee])
                     || (__c == __lits[__cache_type::_S_Ee]))
                  {
                    __xtrc[__pos++] = __c;
                    ++__beg;
                    // Now there may be a sign
                    if (__beg != __end)
                      {
-                       __c = *__beg;
                        if ((__c == __lits[__cache_type::_S_minus])
                            || (__c == __lits[__cache_type::_S_plus]))
                          {
                            __xtrc[__pos++] = __c;
                            ++__beg;
                            // whitespace may follow a sign
!                           while ((__beg != __end) && (isspace(*__beg)))
!                             ++__beg;
! 
                          }
                      }
                    // And now there must be some digits
--- 899,926 ----
            // Now we may find an exponent
            if (__beg != __end)
              {
                if ((__c == __lits[__cache_type::_S_ee])
                     || (__c == __lits[__cache_type::_S_Ee]))
                  {
                    __xtrc[__pos++] = __c;
                    ++__beg;
+ 		  __c = *__beg;
+ 
                    // Now there may be a sign
                    if (__beg != __end)
                      {
                        if ((__c == __lits[__cache_type::_S_minus])
                            || (__c == __lits[__cache_type::_S_plus]))
                          {
                            __xtrc[__pos++] = __c;
                            ++__beg;
+ 			  __c = *__beg;
                            // whitespace may follow a sign
!                           while ((__beg != __end) && (isspace(__c)))
! 			    {
! 			      ++__beg;
! 			      __c = *__beg;
! 			    }
                          }
                      }
                    // And now there must be some digits
*************** namespace std 
*** 922,929 ****
                      }
                    while (__beg != __end)
                      {
!                       __c = *__beg;
!                       const char* __p = strchr(__fmt->_S_literals, __c);
                        if ((__p >= &__lits[__cache_type::_S_digits]
                              && __p < &__lits[__cache_type::_S_digits + __base])
                             || (__p >= &__lits[__cache_type::_S_udigits]
--- 932,938 ----
                      }
                    while (__beg != __end)
                      {
!                       const char* __p = strchr(__lits, __c);
                        if ((__p >= &__lits[__cache_type::_S_digits]
                              && __p < &__lits[__cache_type::_S_digits + __base])
                             || (__p >= &__lits[__cache_type::_S_udigits]
*************** namespace std 
*** 931,936 ****
--- 940,946 ----
                          {
                            __xtrc[__pos++] = __c;
                            ++__beg;
+ 			  __c = *__beg;
                          }
                        else
                          break;
Index: testsuite/27_io/filebuf.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/filebuf.cc,v
retrieving revision 1.10
diff -c -p -r1.10 filebuf.cc
*** filebuf.cc	2001/03/14 20:46:34	1.10
--- filebuf.cc	2001/05/08 02:56:58
*************** public:
*** 546,551 ****
--- 546,554 ----
    operator<(const gnu_char_type& __lhs) 
    { return character < __lhs.character; }
  
+   // default ctor
+   gnu_char_type() { }
+ 
    // to_char_type
    gnu_char_type(const unsigned long& __l) : character(__l) { } 
  
Index: testsuite/27_io/filebuf_members.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/filebuf_members.cc,v
retrieving revision 1.7
diff -c -p -r1.7 filebuf_members.cc
*** filebuf_members.cc	2001/04/04 01:02:26	1.7
--- filebuf_members.cc	2001/05/08 02:56:58
*************** test_01()
*** 52,58 ****
    FILE* f2 = fopen(name_01, "r");
    VERIFY( f2 != NULL );
    {
!     std::filebuf fb(f2, false, std::ios_base::in);
    }
    close_num = fclose(f2);
    VERIFY( close_num == 0 );
--- 52,58 ----
    FILE* f2 = fopen(name_01, "r");
    VERIFY( f2 != NULL );
    {
!     std::filebuf fb(f2, std::ios_base::in, 512);
    }
    close_num = fclose(f2);
    VERIFY( close_num == 0 );
Index: testsuite/27_io/narrow_stream_objects.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc,v
retrieving revision 1.2
diff -c -p -r1.2 narrow_stream_objects.cc
*** narrow_stream_objects.cc	2000/08/14 19:59:25	1.2
--- narrow_stream_objects.cc	2001/05/08 02:56:58
***************
*** 1,6 ****
  // 2000-08-02 bkoz
  
! // Copyright (C) 2000 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,6 ----
  // 2000-08-02 bkoz
  
! // Copyright (C) 2000, 2001 Free Software Foundation, Inc.
  //
  // This file is part of the GNU ISO C++ Library.  This library is free
  // software; you can redistribute it and/or modify it under the
*************** test01()
*** 93,103 ****
--- 93,123 ----
    return 0;
  }
  
+ // libstdc++/2523
+ void test02()
+ {
+   int i;
+   cin >> i;
+   cout << "i == " << i << endl;
+ }
+ 
+ // libstdc++/2523
+ void test03()
+ {
+   ios_base::sync_with_stdio(false);
  
+   int i;
+   cin >> i;
+   cout << "i == " << i << endl;
+ }
+ 
  int 
  main()
  {
    test01();
+ 
+   // test02();
+   // test03();
    return 0;
  }
  


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