From: Paolo Carlini Date: Fri, 17 May 2002 11:43:43 +0000 (+0200) Subject: re PR libstdc++/6648 (Problems with cin.getline (interactive)) X-Git-Tag: releases/gcc-3.1.1~340 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb12158798a3b26974551db7bcae7e3172bfccd2;p=thirdparty%2Fgcc.git re PR libstdc++/6648 (Problems with cin.getline (interactive)) 2002-05-15 Paolo Carlini PR libstdc++/6648 * include/bits/istream.tcc (istream::getline, ignore): Upon __idelim (__delim) call sbumpc() not snextc(). * testsuite/27_io/narrow_stream_objects.cc: Add test08 and test09. From-SVN: r53557 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 6727390f3efb..8c9169457d64 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -3,6 +3,14 @@ * docs/html/faq/index.html: Update not-a-bug list with basic_file.h. * docs/html/faq/index.txt: Regenerate. +2002-05-15 Paolo Carlini + + PR libstdc++/6648 + * include/bits/istream.tcc (istream::getline, ignore): + Upon __idelim (__delim) call sbumpc() not snextc(). + * testsuite/27_io/narrow_stream_objects.cc: + Add test08 and test09. + 2002-05-14 Release Manager * GCC 3.1 Released. diff --git a/libstdc++-v3/include/bits/istream.tcc b/libstdc++-v3/include/bits/istream.tcc index 636a73863598..f7f8d6977891 100644 --- a/libstdc++-v3/include/bits/istream.tcc +++ b/libstdc++-v3/include/bits/istream.tcc @@ -679,7 +679,7 @@ namespace std { if (__c == __idelim) { - __sb->snextc(); + __sb->sbumpc(); ++_M_gcount; } else @@ -726,7 +726,7 @@ namespace std this->setstate(ios_base::eofbit); else if (__c == __delim) { - __sb->snextc(); + __sb->sbumpc(); ++_M_gcount; } } diff --git a/libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc b/libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc index 016a982c8efc..f767b7248713 100644 --- a/libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc +++ b/libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc @@ -175,6 +175,23 @@ void test07() VERIFY( s == "test" ); } +// libstdc++/6648 +// Interactive tests: each one (run alone) must terminate upon a single '\n'. +void test08() +{ + bool test = true; + char buff[2048]; + std::cout << "Enter name: "; + std::cin.getline(buff, 2048); +} + +void test09() +{ + bool test = true; + std::cout << "Enter name: "; + std::cin.ignore(2048, '\n'); +} + int main() { @@ -186,5 +203,7 @@ main() // test05(); // test06(); // test07(); + // test08(); + // test09(); return 0; }