Well, that's a really good question.

Pre-patch, at the end of the stream (when you don't explicitly seek), you get 
empty strings:

--example.php--
$tmp = tmpfile();
fwrite($tmp, "line1\r\n");
fseek($tmp, 0);

var_dump(stream_get_line($tmp, null, "\r\n"));
var_dump(stream_get_line($tmp, null, "\r\n"));
var_dump(stream_get_line($tmp, null, "\r\n"));
var_dump(stream_get_line($tmp, null, "\r\n"));
var_dump(stream_get_line($tmp, null, "\r\n"));

fclose($tmp);
-----------------

--results--
string(5) "line1"
string(0) ""
string(0) ""
string(0) ""
string(0) ""
-----------------


Do you want to change the behavior so that it does return false? It's trivial 
to do (and I'd agree that it would be correct), but it does change the behavior 
from the current behavior.

G

-----Original Message-----
From: Stanislav Malyshev [mailto:s...@zend.com] 
Sent: Thursday, September 03, 2009 5:31 PM
To: Garrett Serack
Cc: 'PHP Internals'
Subject: Re: [PHP-DEV] Fix for 49148 (combination of stream_get_line and fseek 
does not work correctly)

Hi!

> it happens on Linux and Windows. I've repro'd it in both places.
> 
> The bug submitter hadn't tested elsewhere.

You are right. However, I notice something strange with your patch - if 
I call stream_get_line again with the same parameters I get "". 
Shouldn't I get false instead, as it's at EOF? fgets() returns false.
-- 
Stanislav Malyshev, Zend Software Architect
s...@zend.com   http://www.zend.com/
(408)253-8829   MSN: s...@zend.com


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to