delorie.com/archives/browse.cgi | search |
From: | pavenis AT lanet DOT lv |
To: | djgpp-workers AT delorie DOT com |
Date: | Mon, 7 May 2001 19:45:18 +0300 |
MIME-Version: | 1.0 |
Subject: | libstdc++-v3: bug in handling text files for DJGPP |
Cc: | libstdc++@gcc.gnu.org |
Message-ID: | <3AF6FB4E.3915.208439A@localhost> |
X-mailer: | Pegasus Mail for Win32 (v3.12c) |
Reply-To: | djgpp-workers AT delorie DOT com |
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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |