[v3] libstdc++/6360

Benjamin Kosnik bkoz@redhat.com
Sat Apr 20 21:14:00 GMT 2002


tested x86/linux
gcc
gcc-3_1-branch

2002-04-20  Benjamin Kosnik  <bkoz@redhat.com>

	PR libstdc++/6360
	* include/bits/istream.tcc (istream::ignore): Streamline, use
	delimiter as is.
	* include/bits/streambuf.tcc: Use this->gptr.
	* testsuite/27_io/istream_unformatted.cc (test08): Add test.

Index: include/bits/istream.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/istream.tcc,v
retrieving revision 1.27
diff -c -p -r1.27 istream.tcc
*** include/bits/istream.tcc	18 Apr 2002 23:47:46 -0000	1.27
--- include/bits/istream.tcc	21 Apr 2002 04:12:02 -0000
*************** namespace std 
*** 708,736 ****
      {
        _M_gcount = 0;
        sentry __cerb(*this, true);
!       if (__cerb && __n > 0) 
  	{
  	  try 
  	    {
- 	      const int_type __idelim = traits_type::to_int_type(__delim);
  	      const int_type __eof = traits_type::eof();
  	      __streambuf_type* __sb = this->rdbuf();
! 	      int_type __c = __sb->sbumpc();	
! 	      bool __testdelim = __c == __idelim;
! 	      bool __testeof =  __c == __eof;
  	      
  	      __n = min(__n, numeric_limits<streamsize>::max());
! 	      while (_M_gcount < __n - 1 && !__testeof && !__testdelim)
  		{
  		  ++_M_gcount;
- 		  __c = __sb->sbumpc();
- 		  __testeof = __c == __eof;
- 		  __testdelim = __c == __idelim;
  		}
! 	      if ((_M_gcount == __n - 1 && !__testeof) || __testdelim)
! 		++_M_gcount;
! 	      if (__testeof)
  		this->setstate(ios_base::eofbit);
  	    }
  	  catch(exception& __fail)
  	    {
--- 708,734 ----
      {
        _M_gcount = 0;
        sentry __cerb(*this, true);
!       if (__cerb) 
  	{
  	  try 
  	    {
  	      const int_type __eof = traits_type::eof();
  	      __streambuf_type* __sb = this->rdbuf();
! 	      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->snextc();
+ 		  ++_M_gcount;
+ 		}
  	    }
  	  catch(exception& __fail)
  	    {
Index: include/bits/streambuf.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/streambuf.tcc,v
retrieving revision 1.13
diff -c -p -r1.13 streambuf.tcc
*** include/bits/streambuf.tcc	16 Apr 2002 00:45:25 -0000	1.13
--- include/bits/streambuf.tcc	21 Apr 2002 04:12:02 -0000
*************** namespace std 
*** 51,57 ****
        int_type __ret;
        if (_M_in_cur && _M_in_cur < _M_in_end)
  	{
! 	  char_type __c = *gptr();
  	  _M_in_cur_move(1);
  	  __ret = traits_type::to_int_type(__c);
  	}
--- 51,57 ----
        int_type __ret;
        if (_M_in_cur && _M_in_cur < _M_in_end)
  	{
! 	  char_type __c = *(this->gptr());
  	  _M_in_cur_move(1);
  	  __ret = traits_type::to_int_type(__c);
  	}
Index: testsuite/27_io/istream_unformatted.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/istream_unformatted.cc,v
retrieving revision 1.15
diff -c -p -r1.15 istream_unformatted.cc
*** testsuite/27_io/istream_unformatted.cc	7 Aug 2001 03:38:33 -0000	1.15
--- testsuite/27_io/istream_unformatted.cc	21 Apr 2002 04:12:02 -0000
***************
*** 1,6 ****
  // 1999-08-11 bkoz
  
! // Copyright (C) 1999, 2000, 2001 Free Software Foundation
  //
  // This file is part of the GNU ISO C++ Library.  This library is free
  // software; you can redistribute it and/or modify it under the
--- 1,6 ----
  // 1999-08-11 bkoz
  
! // Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation
  //
  // This file is part of the GNU ISO C++ Library.  This library is free
  // software; you can redistribute it and/or modify it under the
*************** test06()
*** 463,469 ****
  
  // bug reported by bgarcia@laurelnetworks.com
  // http://gcc.gnu.org/ml/libstdc++-prs/2000-q3/msg00041.html
! int
  test07()
  {
    bool test = true;
--- 463,469 ----
  
  // bug reported by bgarcia@laurelnetworks.com
  // http://gcc.gnu.org/ml/libstdc++-prs/2000-q3/msg00041.html
! void
  test07()
  {
    bool test = true;
*************** test07()
*** 481,489 ****
        line = line_ss.str();
        VERIFY( line == "1234567890" || line == "" );
      }
-   return 0;
  }
!  
  int 
  main()
  {
--- 481,505 ----
        line = line_ss.str();
        VERIFY( line == "1234567890" || line == "" );
      }
  }
! 
! // 2002-04-19 PR libstdc++ 6360
! void
! test08()
! {
!   using namespace std;
!   bool test = true;
! 
!   stringstream ss("abcd" "\xFF" "1234ina donna coolbrith");  
!   char c;
!   ss >> c;
!   VERIFY( c == 'a' );
!   ss.ignore(8);
!   ss >> c;
!   VERIFY( c == 'i' );
! }
!     
! 
  int 
  main()
  {
*************** main()
*** 494,499 ****
--- 510,516 ----
    test05();
    test06();
    test07();
+   test08();
  
    return 0;
  }



More information about the Gcc-patches mailing list