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]

libstdc++-v3: bug in handling text files for DJGPP



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


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