#44607 [Fbk->Opn]: stream_get_line not working as expected
| From: | amoo_miki at yahoo dot com | Date: | Wed, 02 Apr 2008 12:14:33 +0000 |
| Subject: | #44607 [Fbk->Opn]: stream_get_line not working as expected | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-123866@lists.php.net to get a copy of this message | ||
ID: 44607
User updated by: amoo_miki at yahoo dot com
Reported By: amoo_miki at yahoo dot com
-Status: Feedback
+Status: Open
Bug Type: Streams related
Operating System: Win32
PHP Version: 5.2.5
New Comment:
Using:
PHP 5.2.6RC4-dev (cli) (built: Apr 2 2008 08:04:44)
Still i get the faulty output:
Found in source at 9295
Location in stream: 15000
Rewinding...
Location in stream: 15000
Attempting fix...
Location in stream: 9307
Rewinding...
Location in stream: 9307
Previous Comments:
------------------------------------------------------------------------
[2008-04-02 12:03:55] felipe@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows (zip):
http://snaps.php.net/win32/php5.2-win32-latest.zip
For Windows (installer):
http://snaps.php.net/win32/php5.2-win32-installer-latest.msi
Already was fixed a similar bug, try a snapshot.
------------------------------------------------------------------------
[2008-04-02 11:56:25] amoo_miki at yahoo dot com
Description:
------------
On some occasions stream_get_line acts weired by attempting the first
seek without considering the "end of line" string.
Below is the sample code that shows the problem with a workaround to
temporarily solve the issue (that might ring some bells for the person
who plans on fixing this).
The code uses a small binary JPX file that can be fetched from
http://barahmand.com/streambug/sample.txt
Reproduce code:
---------------
<?php
$filename = 'sample.txt';
$arr = explode('<EndOfFrame>', file_get_contents($filename));
echo "Found in source at ".strlen($arr[0])."\n\n";
$fp = fopen($filename, "rb");
stream_get_line($fp, 15000, "<EndOfFrame>");
echo "Location in stream: ".ftell($fp)."\n";
echo "Rewinding...\n"; rewind($fp);
stream_get_line($fp, 15000, "<EndOfFrame>");
echo "Location in stream: ".ftell($fp)."\n";
rewind($fp);
echo "\nAttempting fix...\n";
stream_get_line($fp, 1, "<EndOfFrame>");
stream_get_line($fp, 15000, "<EndOfFrame>");
echo "Location in stream: ".ftell($fp)."\n";
echo "Rewinding...\n"; rewind($fp);
stream_get_line($fp, 15000, "<EndOfFrame>");
echo "Location in stream: ".ftell($fp)."\n";
fclose($fp);
?>
Expected result:
----------------
Found in source at 9295
Location in stream: 9307
Rewinding...
Location in stream: 9307
Attempting fix...
Location in stream: 9307
Rewinding...
Location in stream: 9307
Actual result:
--------------
Found in source at 9295
Location in stream: 15000
Rewinding...
Location in stream: 15000
Attempting fix...
Location in stream: 9307
Rewinding...
Location in stream: 9307
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44607&edit=1