This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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";
  cin.ignore(1);
  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).

Changelog

2002-08-08  Danny Smith  dannysmith@users.sourceforge.net

	* 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 1.24.2.6.2.2
diff -u -3 -p -r1.24.2.6.2.2 istream.tcc
--- istream.tcc	1 Aug 2002 21:29:17 -0000	1.24.2.6.2.2
+++ 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();
 		  ++_M_gcount;
 		}
 	      if (traits_type::eq_int_type(__c, __eof))


http://digital.yahoo.com.au - 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]