[PATCH] libstdc++/6648
Paolo Carlini
pcarlini@unitus.it
Mon May 13 15:51:00 GMT 2002
> 2002-05-13 Paolo Carlini <pcarlini@unitus.it>
>
> PR libstdc++/6648
> * include/bits/istream.tcc (getline, ignore):
> Upon __idelim (__delim) call sbumpc() not snextc().
> * testsuite/27_io/narrow_stream_object.cc: Add test08.
On second thought, I'm not quite happy with the testcase.
Please consider the following instead.
Ciao again,
Paolo.
/////////////////////
diff -urN libstdc++-v3-orig/include/bits/istream.tcc
libstdc++-v3/include/bits/istream.tcc
--- libstdc++-v3-orig/include/bits/istream.tcc 2002-04-22
21:10:01.000000000 +0200
+++ libstdc++-v3/include/bits/istream.tcc 2002-05-13
22:32:43.000000000 +0200
@@ -679,7 +679,7 @@
{
if (__c == __idelim)
{
- __sb->snextc();
+ __sb->sbumpc();
++_M_gcount;
}
else
@@ -726,7 +726,7 @@
this->setstate(ios_base::eofbit);
else if (__c == __delim)
{
- __sb->snextc();
+ __sb->sbumpc();
++_M_gcount;
}
}
diff -urN libstdc++-v3-orig/testsuite/27_io/narrow_stream_objects.cc
libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc
--- libstdc++-v3-orig/testsuite/27_io/narrow_stream_objects.cc
2002-05-03 20:22:58.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc 2002-05-14
00:20:42.000000000 +0200
@@ -175,6 +175,18 @@
VERIFY( s == "test" );
}
+// libstdc++/6648
+// Interactive test: each input must terminate upon a single '\n'.
+void test08()
+{
+ bool test = true;
+ char buff[2048];
+ std::cout << "Enter name: ";
+ std::cin.getline(buff, 2048);
+ std::cout << "Enter second name: ";
+ std::cin.ignore(2048, '\n');
+}
+
int
main()
{
@@ -186,5 +198,6 @@
// test05();
// test06();
// test07();
+ // test08();
return 0;
}
More information about the Libstdc++
mailing list