libstdc++-v3: bug in handling text files for DJGPP
pavenis@lanet.lv
pavenis@lanet.lv
Mon May 7 09:45:00 GMT 2001
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
More information about the Libstdc++
mailing list