wez             Thu Feb 13 16:03:25 2003 EDT

  Modified files:              (Branch: PHP_4_3)
    /php4/main  streams.c 
  Log:
  Fix for Bug #22199 (fputs() + fgets() destroys readbuffer for non-seekable streams).
  
  
Index: php4/main/streams.c
diff -u php4/main/streams.c:1.125.2.29 php4/main/streams.c:1.125.2.30
--- php4/main/streams.c:1.125.2.29      Thu Feb 13 12:32:41 2003
+++ php4/main/streams.c Thu Feb 13 16:03:25 2003
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: streams.c,v 1.125.2.29 2003/02/13 17:32:41 wez Exp $ */
+/* $Id: streams.c,v 1.125.2.30 2003/02/13 21:03:25 wez Exp $ */
 
 #define _GNU_SOURCE
 #include "php.h"
@@ -863,14 +863,17 @@
                        justwrote = stream->ops->write(stream, buf, towrite TSRMLS_CC);
                }
                if (justwrote > 0) {
-                       stream->position += justwrote;
                        buf += justwrote;
                        count -= justwrote;
                        didwrite += justwrote;
                        
-                       /* FIXME: invalidate the whole readbuffer */
-                       stream->writepos = 0;
-                       stream->readpos = 0;
+                       /* Only screw with the buffer if we can seek, otherwise we 
+lose data
+                        * buffered from fifos and sockets */
+                       if (stream->ops->seek && (stream->flags & 
+PHP_STREAM_FLAG_NO_SEEK) == 0) {
+                               stream->position += justwrote;
+                               stream->writepos = 0;
+                               stream->readpos = 0;
+                       }
                } else {
                        break;
                }



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to