This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
libstdc++-v3: bug in handling text files for DJGPP
- To: djgpp-workers at delorie dot com
- Subject: libstdc++-v3: bug in handling text files for DJGPP
- From: pavenis at lanet dot lv
- Date: Mon, 7 May 2001 19:45:18 +0300
- Cc: libstdc++ at gcc dot gnu dot org
basic_filebuf::sync() always advances file pointer by number of bytes
stored in buffer for output (see seekoff at end of this procedure).
It's OK for example for Linux when there is no special format for text
files. For DOS (and perhaps also Windows) we're getting problems as
adding CR before LF is done by fwrite() and as result sync()
incorrectly moves current pointer back.
See following simple example:
#include <iostream>
using std::cout;
int main (void)
{
cout << "\n\n\n\n\n\nfoo"; cout.flush();
cout << "bar"; cout.flush();
return 0;
}
I used gcc-3.0 20010506 built for target i586-pc-msdosdjgpp.
After running executable I got and redirecting
output to file, Im getting the following:
-----------------------------------------------------------------
barfoo
------------------------------------------------------------------
Or in hexadecimal form:
0D 0A 0D 0A 0D 0A 0D 0A 0D 62 61 72 66 6F 6F
Andris