Re: Fix for 49148 (combination of stream_get_line and fseek does not work correctly)

From: Date: Fri, 18 Dec 2009 23:55:33 +0000
Subject: Re: Fix for 49148 (combination of stream_get_line and fseek does not work correctly)
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-46469@lists.php.net to get a copy of this message
Hi!
I've updated my patch to return null on EOF.
Unfortunately, on Linux this patch fails test stream_get_line_nb.phpt - looks like it changes the stream behavior in the non-blocking case.
Index: streams/streams.c =================================================================== --- streams/streams.c (revision 289073) +++ streams/streams.c (working copy) @@ -890,6 +890,9 @@
                 size_t seek_len;
                 seek_len = stream->writepos - stream->readpos;
+               if(!seek_len)
+                       return FALSE;
+
                 if (seek_len>  maxlen) {
                         seek_len = maxlen;
                 }
@@ -901,10 +904,7 @@
                 }
                 if (!e) {
-                       if (seek_len<  maxlen&&  !stream->eof) {
-                               return NULL;
-                       }
-                       toread = maxlen;
+                       toread = (seek_len<  maxlen) ? seek_len : maxlen;
                 } else {
                         toread = e - (char *) stream->readbuf - stream->readpos;
                         skip = 1;
-- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com


« previous php.internals (#46469) next »