aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@redhat.com>2002-04-21 04:15:29 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2002-04-21 04:15:29 +0000
commit9a4b4cfc1a49c1537a852f6e40d2f3e0c4d3e0b2 (patch)
treeadd173ebc2da118f90306d3c05822088573b6ac6
parent20764052b9fb43469efe0314dd611c9dfb91a80e (diff)
downloadgcc-9a4b4cfc1a49c1537a852f6e40d2f3e0c4d3e0b2.zip
gcc-9a4b4cfc1a49c1537a852f6e40d2f3e0c4d3e0b2.tar.gz
gcc-9a4b4cfc1a49c1537a852f6e40d2f3e0c4d3e0b2.tar.bz2
re PR libstdc++/6360 (Wrong workaround in char_traits.h - ignore stops on \0xff)
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. From-SVN: r52563
-rw-r--r--libstdc++-v3/ChangeLog8
-rw-r--r--libstdc++-v3/include/bits/istream.tcc22
-rw-r--r--libstdc++-v3/include/bits/streambuf.tcc2
-rw-r--r--libstdc++-v3/testsuite/27_io/istream_unformatted.cc25
4 files changed, 40 insertions, 17 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 42ac416..6550006 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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,
diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc
index 6b2e4ca..a55e906 100644
--- a/libstdc++-v3/include/bits/istream.tcc
+++ b/libstdc++-v3/include/bits/istream.tcc
@@ -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)
{
diff --git a/libstdc++-v3/include/bits/streambuf.tcc b/libstdc++-v3/include/bits/streambuf.tcc
index 607800e..292999c 100644
--- a/libstdc++-v3/include/bits/streambuf.tcc
+++ b/libstdc++-v3/include/bits/streambuf.tcc
@@ -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);
}
diff --git a/libstdc++-v3/testsuite/27_io/istream_unformatted.cc b/libstdc++-v3/testsuite/27_io/istream_unformatted.cc
index 19c2c92..bf25be8 100644
--- a/libstdc++-v3/testsuite/27_io/istream_unformatted.cc
+++ b/libstdc++-v3/testsuite/27_io/istream_unformatted.cc
@@ -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;
}