[v3] libstdc++/6648

Paolo Carlini pcarlini@unitus.it
Wed May 15 04:51:00 GMT 2002


Hi,

the following patch fixes this interactive bug affecting 
istream::getline and istream::ignore. Tested i686-pc-linux-gnu, approved 
by Loren J. Rittle and Benjamin Kosnik, committed trunk and soon branch 
too (after the unfreeze, that is).

Ciao,
Paolo.

//////////////////

2002-05-15  Paolo Carlini  <pcarlini@unitus.it>

        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.

===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/istream.tcc,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- gcc/libstdc++-v3/include/bits/istream.tcc	2002/04/22 19:10:01	1.29
+++ gcc/libstdc++-v3/include/bits/istream.tcc	2002/05/15 10:27:28	1.30
@@ -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;
 		}
 	    }

===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- gcc/libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc	2002/05/03 18:22:58	1.9
+++ gcc/libstdc++-v3/testsuite/27_io/narrow_stream_objects.cc	2002/05/15 10:27:29	1.10
@@ -175,6 +175,23 @@
   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 @@
   // test05();
   // test06();
   // test07();
+  // test08();
+  // test09();
   return 0;
 }











More information about the Gcc-patches mailing list