LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: amoo_miki at yahoo dot com Date: Tue Aug 19 09:24:58 2008 Subject: #44607 [Opn]: stream_get_line return incorrect values
ID: 44607
User updated by: amoo_miki at yahoo dot com
Reported By: amoo_miki at yahoo dot com
Status: Open
Bug Type: Streams related
Operating System: *
-PHP Version: 5.2CVS-2008-07-14
+PHP Version: 5.x upto 5.3-alpha2
New Comment:
The bug still persists.
Previous Comments:
------------------------------------------------------------------------
[2008-07-14 21:54:02] amoo_miki at yahoo dot com
I should also add that the workaround (that works for this example
file) does not always work.
------------------------------------------------------------------------
[2008-07-14 21:45:58] amoo_miki at yahoo dot com
Also tried with the latest CVS snapshot of 5.2.7-dev and it still gives
incorrect results.
------------------------------------------------------------------------
[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
| Navigate in group php.bugs at sever news.php.net | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by PHP Developer
Powered By PHP Consultants |