delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/05/08/04:36:40

Date: Tue, 8 May 2001 10:20:30 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Andris Pavenis <pavenis AT lanet DOT lv>
cc: djgpp-workers AT delorie DOT com
Subject: Re: libstdc++-v3: bug in handling text files for DJGPP
In-Reply-To: <Pine.A41.4.05.10105080939260.38822-100000@ieva06.lanet.lv>
Message-ID: <Pine.SUN.3.91.1010508101745.3965G-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Tue, 8 May 2001, Andris Pavenis wrote:

> > DO I understand correctly that libstdc++ uses its own buffering (as
> > opposed to the buffering code implemented in libc.a for stdio)?
> > 
> > If so, it should use code similar to what the DJGPP library does for
> > buffered I/O functions.
> 
> Here is source of basic_filebuf::sync()
> 
> virtual int 
>       sync(void)
>       {
> 	bool __testput = _M_out_cur && _M_out_beg < _M_out_end;
> 	if (__testput)
> 	  {
>             // Make sure that libio resyncs its idea of the file position
>             // with the external file.
>             _M_file->sync();
> 
> 	    // Need to restore current position. This interpreted as
> 	    // the position of the external byte sequence (_M_file)
> 	    // plus the offset in the current internal buffer
> 	    // (_M_out_beg - _M_out_cur)
> 	    streamoff __cur = _M_file->seekoff(0, ios_base::cur);
> 	    off_type __off = _M_out_cur - _M_out_beg;
> 	    _M_really_overflow();
> 	    _M_file->seekpos(__cur + __off);
> 	  }
> 	_M_last_overflowed = false;	
> 	return 0;
>       }
>       
> _M_file->sync() is simply fflush(_M_file._M_cfile)

Thanks.  But the real problem seems to be inside seekoff, or maybe 
seekpos.

In general, as we know from the libc experience, the way to solve these 
problems is to read the file in binary mode and remove the CR characters 
when delivering the data to applications.  The buffered data should 
retain the CRs.  Then seeking will DTRT, as it does on GNU/Linux.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019