#22682 [NEW]: Proplems with fread(), ftell() and fseek() and CRLF newlines
From: fbeyer at clickhand dot de
Operating system: Windows XP
PHP version: 4CVS-2003-03-13 (stable)
PHP Bug Type: Filesystem function related
Bug description: Proplems with fread(), ftell() and fseek() and CRLF newlines
I have found this bug in 4.3.0, searched matching bug reports and they said
the bug is fixed in the latest stable CVS snap. I have downloaded and
installed today's latest version, the fix is mentioned in the news.txt,
but the bug is still there.
Here are my test files for a short reproducing script:
file test.txt:
(saved in dos format, ie. newlines are CRLF/\r\n):
------------------------------
This is a test file
in win32 / dos format
ie. lines end with CRLF
resp. \r\n
------------------------------
file test.php
------------------------------
<?php
$fp = fopen('test.txt', 'r');
$contents = fread($fp, 30);
fseek($fp, ftell($fp));
$contents .= fread($fp, 30);
echo $contents;
echo "\n\n";
var_dump(strpos($contents, "\r"));
?>
------------------------------
Output:
------------------------------
This is a test file
in win32 // dos format
ie. lines end wit
bool(false)
------------------------------
It can be seen that fseek() or ftell() don't work as expected: the '/'
character is read twice.
Furthermore, fread() doesn't return \r characters. I also have tested this
for fgetc() - \r is not read.
A strange thing is that this bug doesn't occurr in the newest php5/ze2
snapshot.
--
Edit bug report at http://bugs.php.net/?id=22682&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=22682&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=22682&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=22682&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=22682&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=22682&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=22682&r=support
Expected behavior: http://bugs.php.net/fix.php?id=22682&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=22682&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=22682&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=22682&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=22682&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=22682&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=22682&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=22682&r=gnused
Thread (14 messages)
- fbeyer at clickhand dot de
- sniper@php.net#22682 [Opn->Fbk]: Proplems with fread(), ftell() and fseek() and CRLF newlines
- fbeyer at clickhand dot de#22682 [Fbk->Opn]: Proplems with fread(), ftell() and fseek() and CRLF newlines
- sniper@php.net#22682 [Opn->Fbk]: Proplems with fread(), ftell() and fseek() and CRLF newlines
- fbeyer at clickhand dot de#22682 [Fbk->Opn]: Proplems with fread(), ftell() and fseek() and CRLF newlines
- wez@php.net#22682 [Opn]: Proplems with fread(), ftell() and fseek() and CRLF newlines
- moriyoshi@php.net#22682 [Opn->Ver]: Proplems with fread(), ftell() and fseek() and CRLF newlines
- moriyoshi@php.net#22682 [Ver->Ana]: Proplems with fread(), ftell() and fseek() and CRLF newlines
- henrik dot gebauer at web dot de#22682 [Com]: Proplems with fread(), ftell() and fseek() and CRLF newlines
- sniper@php.net#22682 [Ana->Fbk]: Proplems with fread(), ftell() and fseek() and CRLF newlines
- sniper@php.net#22682 [Fbk->NoF]: Proplems with fread(), ftell() and fseek() and CRLF newlines
- alexey at ozerov dot de#22682 [Com]: Proplems with fread(), ftell() and fseek() and CRLF newlines
- frank at heuveltop dot nl#22682 [Com]: Proplems with fread(), ftell() and fseek() and CRLF newlines
- nicolas dot castagne at imag dot fr#22682 [Com]: Proplems with fread(), ftell() and fseek() and CRLF newlines