cvs: php4 /main streams.c

From: Date: Tue, 11 Jun 2002 21:22:13 +0000
Subject: cvs: php4 /main streams.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-12319@lists.php.net to get a copy of this message
mfischer Tue Jun 11 17:22:13 2002 EDT Modified files: /php4/main streams.c Log: - Fix builtin gets() emulation (hopefully). Index: php4/main/streams.c diff -u php4/main/streams.c:1.55 php4/main/streams.c:1.56 --- php4/main/streams.c:1.55 Tue Jun 11 14:55:48 2002 +++ php4/main/streams.c Tue Jun 11 17:22:12 2002 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c,v 1.55 2002/06/11 18:55:48 mfischer Exp $ */ +/* $Id: streams.c,v 1.56 2002/06/11 21:22:12 mfischer Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -250,21 +250,13 @@ return NULL; } else { /* unbuffered fgets - poor performance ! */ - size_t n = 1; char *c = buf; /* TODO: look at error returns? */ - while(n < maxlen && stream->ops->read(stream, c, 1 TSRMLS_CC) > 0) { - n++; - if (*c == '\n') { - c++; - break; - } - c++; - } - *c = 0; - return buf; + while (--maxlen > 0 && stream->ops->read(stream, buf, 1 TSRMLS_CC) == 1 && *buf++ != '\n'); + *buf = '\0'; + return c == buf && maxlen > 0 ? NULL : c; } }

« previous php.cvs (#12319) next »