re PR libstdc++/6549 (std::getline(std::cin,s) work wrong at FreeBSD 4.5)

2002-05-03  Benjamin Kosnik  <bkoz@redhat.com>

	PR libstdc++/6549.
	* include/bits/fstream.tcc (filebuf::_M_underflow_common): Revert.
	* testsuite/27_io/narrow_stream_objects.cc (test07): Add.

From-SVN: r53107
This commit is contained in:
Benjamin Kosnik 2002-05-03 18:22:58 +00:00 committed by Benjamin Kosnik
parent 8157303b1e
commit 2fd819efe5
3 changed files with 25 additions and 15 deletions

View File

@ -1,3 +1,9 @@
2002-05-03 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/6549.
* include/bits/fstream.tcc (filebuf::_M_underflow_common): Revert.
* testsuite/27_io/narrow_stream_objects.cc (test07): Add.
2002-05-03 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* config/os/irix/irix5.2/bits/ctype_noninline.h (classic_table):

View File

@ -182,21 +182,6 @@ namespace std
return traits_type::to_int_type(*_M_in_cur);
}
// Check for unbuffered stream.
if (_M_buf_size == 1)
{
int_type __c = _M_file.sys_getc();
if (__c != __ret)
{
__ret = __c;
*_M_in_cur = traits_type::to_char_type(__c);
_M_set_determinate(1);
if (__testout)
_M_out_cur = _M_in_cur;
}
return __ret;
}
// Sync internal and external buffers.
// NB: __testget -> __testput as _M_buf_unified here.
bool __testget = _M_in_cur && _M_in_beg < _M_in_cur;
@ -251,6 +236,14 @@ namespace std
__ret = traits_type::to_int_type(*_M_in_cur);
if (__bump)
_M_in_cur_move(1);
else if (_M_buf_size == 1)
{
// If we are synced with stdio, we have to unget the
// character we just read so that the file pointer
// doesn't move.
_M_file.sys_ungetc(*_M_in_cur);
_M_set_indeterminate();
}
}
}
}

View File

@ -165,6 +165,16 @@ void test06()
cerr << "i == " << i << endl;
}
// libstdc++/6548
void test07()
{
bool test = true;
std::cout << "Please, enter 'test':";
std::string s;
std::getline(std::cin, s, '\n');
VERIFY( s == "test" );
}
int
main()
{
@ -175,5 +185,6 @@ main()
// test04();
// test05();
// test06();
// test07();
return 0;
}