ID:               28363
 User updated by:  zoltan at frombach dot com
 Reported By:      zoltan at frombach dot com
-Status:           Feedback
+Status:           Closed
 Bug Type:         Filesystem function related
 Operating System: Windows XP
 PHP Version:      4.3.6
 New Comment:

You have fixed the problem. It works with the current (
http://snaps.php.net/win32/php4-win32-STABLE-200405122030.zip ) CVS
snapshot. Thanks!!


Previous Comments:
------------------------------------------------------------------------

[2004-05-12 12:48:27] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

Please test the next snapshot (dated after this report).
I've committed something that should solve this problem.

------------------------------------------------------------------------

[2004-05-12 02:55:09] zoltan at frombach dot com

Description:
------------
In ASCII mode, fwrite under Windows (when the file is opened with the
'wt' flags) will fail. This is a reproducable bug. See my demonstration
program.

When "\n" (new line) characters written out to the file, those
characters are automatically replaced with "\r\n" which is the expected
behaviour in ASCII mode on Windows (when the file is opened with the
't' flag). However, the next fwrite will overwrite the last few
characters that were previously written to the file!! Exactly that many
characters get lost as many "\r" characters were inserted to the file
on the previous fwrite. Seems to me that after the "\n" to "\r\n"
translation, the current file position pointer does not get updated, so
the next fwrite will overwrite the last few characters previously
written to the file.

If there is only one fwrite (if you comment out the second fwrite from
my code) then no characters get lost!! Because if there is no further
writing to the file, no character overwriting occures. That's why I
guess it is a file pointer problem. In other words, it's not the first
fwrite that forgets to write out those few last characters, IMHO it
just forgets to properly update the actual file pointer and that's why
the next fwrite overwrites those last few characters in the file.

Reproduce code:
---------------
<?

$fp=fopen('testfile.txt', 'wt');
fwrite($fp, "This\ntest\nwill\nfail\n");
fwrite($fp, "Under\nWindows\nmost\ndefinitely\n");
fclose($fp);

?>


Expected result:
----------------
This
test
will
fail
Under
Windows
most
definitely


Actual result:
--------------
This
test
will
faUnder
Windows
most
definitely



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=28363&edit=1

Reply via email to