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: r52564
This commit is contained in:
Benjamin Kosnik 2002-04-21 04:18:41 +00:00 committed by Benjamin Kosnik
parent 20c6d62eb2
commit 43367d3b1d
4 changed files with 40 additions and 17 deletions

View 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-19 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/localefwd.h (locale::id::_M_id): Do this correctly,

View 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)
{

View 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);
}

View 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;
}