[PATCH] libstdc++/6648
Paolo Carlini
pcarlini@unitus.it
Mon May 13 15:30:00 GMT 2002
Hi,
the below fixes this PR, which Peter (Schmid) filed a few hours ago. It
is quite serious (too bad for 3.1.0 :-( but seems to me relatively easy
to fix, indeed just two lines, one for istream::getline and another for
a similar problem in istream::ignore. In a nutshell, upon __idelim
(__delim) we consume the current char with sbumpc(), instead of trying
also to return the next one with snextc().
I have tested it by running the testsuite, the various interactive tests
in narrow_stream_objects.cc and the Pooma tests, which, we have learned,
are quite sensitive to getline problems.
Ok for trunk and 3.1.1 ??
Ciao,
Paolo.
///////////////
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.
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-13
22:37:46.000000000 +0200
@@ -175,6 +175,16 @@
VERIFY( s == "test" );
}
+// libstdc++/6648
+// Interactive test: input must terminate upon a single '\n'.
+void test08()
+{
+ bool test = true;
+ char buff[2048];
+ std::cin.getline(buff, 2048);
+ std::cin.ignore(2048, '\n');
+}
+
int
main()
{
@@ -186,5 +196,6 @@
// test05();
// test06();
// test07();
+ // test08();
return 0;
}
More information about the Libstdc++
mailing list