cvs: php4(PHP_4_3) /main streams.c

From: Date: Thu, 13 Feb 2003 21:03:25 +0000
Subject: cvs: php4(PHP_4_3) /main streams.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-18807@lists.php.net to get a copy of this message
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; }

« previous php.cvs (#18807) next »