2002-04-20 Benjamin Kosnik <bkoz@redhat.com>
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 21 Apr 2002 04:15:29 +0000 (04:15 +0000)
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 21 Apr 2002 04:15:29 +0000 (04:15 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@52563 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/istream.tcc
libstdc++-v3/include/bits/streambuf.tcc
libstdc++-v3/testsuite/27_io/istream_unformatted.cc

index 42ac416..6550006 100644 (file)
@@ -1,3 +1,11 @@
+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.
+       
 2002-04-18  Benjamin Kosnik  <bkoz@redhat.com>
 
        * include/bits/localefwd.h (locale::id::_M_id): Do this correctly,
index 6b2e4ca..a55e906 100644 (file)
@@ -708,29 +708,27 @@ namespace std
     {
       _M_gcount = 0;
       sentry __cerb(*this, true);
-      if (__cerb && __n > 0
+      if (__cerb) 
        {
          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;
+             int_type __c = __sb->sgetc();     
              
              __n = min(__n, numeric_limits<streamsize>::max());
-             while (_M_gcount < __n - 1 && !__testeof && !__testdelim)
+             while (_M_gcount < __n  && __c !=__eof && __c != __delim)
                {
+                 __c = __sb->snextc();
                  ++_M_gcount;
-                 __c = __sb->sbumpc();
-                 __testeof = __c == __eof;
-                 __testdelim = __c == __idelim;
                }
-             if ((_M_gcount == __n - 1 && !__testeof) || __testdelim)
-               ++_M_gcount;
-             if (__testeof)
+             if (__c == __eof)
                this->setstate(ios_base::eofbit);
+             else if (__c == __delim)
+               {
+                 __sb->snextc();
+                 ++_M_gcount;
+               }
            }
          catch(exception& __fail)
            {
index 607800e..292999c 100644 (file)
@@ -51,7 +51,7 @@ namespace std
       int_type __ret;
       if (_M_in_cur && _M_in_cur < _M_in_end)
        {
-         char_type __c = *gptr();
+         char_type __c = *(this->gptr());
          _M_in_cur_move(1);
          __ret = traits_type::to_int_type(__c);
        }
index 19c2c92..bf25be8 100644 (file)
@@ -1,6 +1,6 @@
 // 1999-08-11 bkoz
 
-// Copyright (C) 1999, 2000, 2001 Free Software Foundation
+// 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
@@ -463,7 +463,7 @@ test06()
 
 // bug reported by bgarcia@laurelnetworks.com
 // http://gcc.gnu.org/ml/libstdc++-prs/2000-q3/msg00041.html
-int
+void
 test07()
 {
   bool test = true;
@@ -481,9 +481,25 @@ test07()
       line = line_ss.str();
       VERIFY( line == "1234567890" || line == "" );
     }
-  return 0;
 }
+
+// 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()
 {
@@ -494,6 +510,7 @@ main()
   test05();
   test06();
   test07();
+  test08();
 
   return 0;
 }