Re: Fix for 49148 (combination of stream_get_line and fseek does not work correctly)
| From: | Stanislav Malyshev | Date: | Wed, 09 Sep 2009 21:58:50 +0000 |
| Subject: | Re: Fix for 49148 (combination of stream_get_line and fseek does not work correctly) | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-45547@lists.php.net to get a copy of this message | ||
Hi!
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:I think it's a bug, docs say it's like fgets and fgets returns false on EOF. Also, "" with this function can mean "delimiter, than another delimititer" if I understand correctly, because it doesn't return the delims - which means returning "" on EOF is even worse bug.
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.I think it's a bug and should be changed to return false on EOF, just as fgets does. Of course, if there's data before EOF it should return it, and then next read should return false. The case where file ends with delim should return data before delim on first read, and false on the next after delim was read. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com