gcc/libstdc++-v3
Jonathan Wakely b32eea9c0c libstdc++: Fix istream::ignore discarding too many chars (PR 94749)
The current code assumes that if the next character in the stream is
equal to the delimiter then we stopped because we saw that delimiter,
and so discards it.  But in the testcase for the PR we stop because we
reached the maximum number of characters, and it's coincidence that the
next character equals the delimiter. We should not discard the next
character in that case.

The fix is to check that we haven't discarded __n characters already,
instead of checking whether the next character equals __delim. Because
we've already checked for EOF, if we haven't discarded __n yet then we
know we stopped because we saw the delimiter. On the other hand, if the
next character is the delimiter we don't know if that's why we stopped.

	PR libstdc++/94749
	* include/bits/istream.tcc (basic_istream::ignore(streamsize, CharT)):
	Only discard an extra character if we didn't already reach the
	maximum number.
	* src/c++98/istream.cc (istream::ignore(streamsiz, char))
	(wistream::ignore(streamsize, wchar_t)): Likewise.
	* testsuite/27_io/basic_istream/ignore/char/94749.cc: New test.
	* testsuite/27_io/basic_istream/ignore/wchar_t/94749.cc: New test.
2020-06-11 18:41:37 +01:00
..
config
doc
include libstdc++: Fix istream::ignore discarding too many chars (PR 94749) 2020-06-11 18:41:37 +01:00
libsupc++
po
python
scripts
src libstdc++: Fix istream::ignore discarding too many chars (PR 94749) 2020-06-11 18:41:37 +01:00
testsuite libstdc++: Fix istream::ignore discarding too many chars (PR 94749) 2020-06-11 18:41:37 +01:00
acinclude.m4
aclocal.m4
ChangeLog Daily bump. 2020-06-11 00:16:45 +00:00
ChangeLog-1998
ChangeLog-1999
ChangeLog-2000
ChangeLog-2001
ChangeLog-2002
ChangeLog-2003
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-2016
ChangeLog-2017
ChangeLog-2018
ChangeLog-2019
config.h.in
configure
configure.ac
configure.host
crossconfig.m4
fragment.am
linkage.m4
Makefile.am
Makefile.in
README

file: libstdc++-v3/README

New users may wish to point their web browsers to the file
index.html in the 'doc/html' subdirectory.  It contains brief
building instructions and notes on how to configure the library in
interesting ways.