help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Behavior of ifstream::read()


From: Alex Vinokur
Subject: Re: Behavior of ifstream::read()
Date: Mon, 16 Oct 2006 20:19:45 +0200

"Ulrich Eckhardt" <doomster@knuut.de> wrote in message 
4phf8cFiocekU1@uni-berlin.de">news:4phf8cFiocekU1@uni-berlin.de...
> Alex Vinokur wrote:
> > char cbuffer[BUFFER_SIZE];
> > ifstream fs (INPUT_FILE_NAME);
> >
> >   fs.clear();
> >   fs.seekg (0, ios::beg);
> >
> >   while (!fs.eof())
> >   {
> >     fs.read (cbuffer, sizeof(cbuffer));
> >     cout << "rdstate() = 0x" << hex << fs.rdstate() << dec << "; gcount()
> = " << fs.gcount() << endl;
> >   }
>
> [...]
> > Output for g++ (Cygwin)
> > --------------------
> > rdstate() = 0x6; gcount() = 1499
> > rdstate() = 0x6
> > -------------------
> > It seems that behavior of g++ is wrong here.
>
> There are several stupid things in the code you gave, I won't go into
> those. Now, while opening the file, you request that external CR/LF pairs
> be converted to an internal '\n'. However, in your file there are LFs that
> are not preceeded by CRs, so in fact your file is invalid. At least I
> wouldn't be too sure about this being an error, I think Cygwin itself can
> also be configured whether its lineendings behaviour should match that of
> DOS or of Unix. Disclaimer: I'd have to trace the code myself to see
> what's wrong, but take these things into account.
>

It is bug in g++ 3.4.4. It is fixed in 4.x.
http://cygwin.com/ml/cygwin/2006-10/msg00568.html

-- 
 Alex Vinokur
     email: alex DOT vinokur AT gmail DOT com
     http://mathforum.org/library/view/10978.html
     http://sourceforge.net/users/alexvn








reply via email to

[Prev in Thread] Current Thread [Next in Thread]