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: *
PHP Version: 5.2.6
New Comment:
Also tried with the latest CVS snapshot of 5.2.7-dev and it still gives
incorrect results.
Previous Comments:
------------------------------------------------------------------------
[2008-07-14 21:38:15] jani@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
------------------------------------------------------------------------
[2008-07-14 21:30:22] amoo_miki at yahoo dot com
Tested this with PHP v5.2.6 on Windows 2008 Server and FreeBSD 7.0 and
it still returns incorrect results.
------------------------------------------------------------------------
[2008-04-02 12:14:33] amoo_miki at yahoo dot com
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
------------------------------------------------------------------------
[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