From: Sara Golemon Date: Thu, 7 Dec 2006 09:51:36 +0000 (+0000) Subject: Change fgets() behavior back to BC version X-Git-Tag: RELEASE_1_0_0RC1~778 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=53a4c18c6a03ead0273ca36fb57a57db61fb4f17;p=php Change fgets() behavior back to BC version --- diff --git a/ext/standard/file.c b/ext/standard/file.c index 83c26994e8..457f1f2475 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1114,7 +1114,7 @@ PHPAPI PHP_FUNCTION(feof) } /* }}} */ -/* {{{ proto string fgets(resource fp[, int length]) U +/* {{{ proto string fgets(resource fp[, int lengthish]) U Get a line from file pointer */ PHPAPI PHP_FUNCTION(fgets) { @@ -1131,6 +1131,11 @@ PHPAPI PHP_FUNCTION(fgets) php_stream_from_zval(stream, &zstream); + if (length > 0) { + /* For BC reasons, fgets() should only return length-1 bytes. */ + length--; + } + buf.v = php_stream_get_line_ex(stream, stream->readbuf_type, NULL_ZSTR, 0, length, &retlen); if (!buf.v) { RETURN_FALSE;