This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[libstdc++] istream::ignore() bug and fix

The following was reported as bug to mingw users list for GCC 3.1

When this testcase is run and executed, it waits for two ENTERS rather than
just one.

In gcc-2.95 (with libstdc++ and with STLPort iostream library), it waits for
only one ENTER.

// ignore.cpp 
#include <iostream>
using namespace std;
int main()
  cout<<"cin.ignore(1) waits for two ENTERs\n";
  cout<<"Press ENTER\n";
  cout << "_M_gcount: "<< cin.gcount() << endl;
  return 0;

Replacing snextc with sbumpc as per following
patch changes the behaviour to what is expected.

Tested GCC 3.2 20020804 on mingw and cygwin
No new regressions (istream::ignore is exercised in 3 testcases in 27_io).


2002-08-08  Danny Smith

	* include/bits/istream.tcc (basic_istream::ignore): Use sbumpc,
	not snextc.

Index: istream.tcc
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/istream.tcc,v
retrieving revision
diff -u -3 -p -r1. istream.tcc
--- istream.tcc	1 Aug 2002 21:29:17 -0000
+++ istream.tcc	7 Aug 2002 23:01:49 -0000
@@ -729,7 +729,7 @@ namespace std 
 		     && !traits_type::eq_int_type(__c, __eof) 
 		     && !traits_type::eq_int_type(__c, __delim))
-		  __c = __sb->snextc();
+		  __c = __sb->sbumpc();
 	      if (traits_type::eq_int_type(__c, __eof)) - Yahoo! Digital How To
- Get the best out of your PC!

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]