This is the mail archive of the libstdc++@gcc.gnu.org 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]

Re: bug in istream.get(b,c,d)? (No.)


On 2002-09-18 at 16:43:41, Mark J. Reed wrote:
> If a get(buffer, count, delim) call reads 0 characters
> (because the next character on the stream is a delimiter),
> then a subsequent call to get(void) returns EOF even though
> there are more characters on the stream to be read.  
Okay, so it's not a bug.  From Stroustrop (special edition), 
section 21.3.4:

        "If a get() or getline() function doesn't read and remove
         at least one character from the stream, setstate(failbit)
         is called, so that subsequent reads from the stream will fail".

It still seems like this is a poor design for the three-argument
get(), which can quite legitimately not read and remove anything
without anything being wrong with the stream.  I guess a solution
is to use getline(), although detecting whether or not getline()
read and removed a '\n' in the case where it reads exactly the
specified number of characters seems less than straightforward.

Anyway, sorry to have bothered you with a non-bug.

-- 
Mark REED 		     | CNN Internet Technology
1 CNN Center Rm SW0831G      | mark.reed@cnn.com
Atlanta, GA 30348      USA   | +1 404 827 4754 
--
Thirty white horses on a red hill,
First they champ,
Then they stamp,
Then they stand still.
		-- Tolkien


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