pollita Fri Dec 8 01:02:49 2006 UTC Modified files: /php-src/ext/standard file.c Log: More BC bodges for fgets/fgetss http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.474&r2=1.475&diff_format=u Index: php-src/ext/standard/file.c diff -u php-src/ext/standard/file.c:1.474 php-src/ext/standard/file.c:1.475 --- php-src/ext/standard/file.c:1.474 Thu Dec 7 23:00:45 2006 +++ php-src/ext/standard/file.c Fri Dec 8 01:02:49 2006 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.474 2006/12/07 23:00:45 tony2001 Exp $ */ +/* $Id: file.c,v 1.475 2006/12/08 01:02:49 pollita Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -1129,13 +1129,15 @@ RETURN_NULL(); } - php_stream_from_zval(stream, &zstream); - - if (length > 0) { + if (length == 1) { /* For BC reasons, fgets() should only return length-1 bytes. */ + RETURN_FALSE; + } else if (length > 1) { length--; } + php_stream_from_zval(stream, &zstream); + buf.v = php_stream_get_line_ex(stream, stream->readbuf_type, NULL_ZSTR, 0, length, &retlen); if (!buf.v) { RETURN_FALSE; @@ -1180,7 +1182,7 @@ } /* }}} */ -/* {{{ proto string fgetss(resource fp [, int length, string allowable_tags]) U +/* {{{ proto string fgetss(resource fp [, int lengthish, string allowable_tags]) U Get a line from file pointer and strip HTML tags */ PHPAPI PHP_FUNCTION(fgetss) { @@ -1194,6 +1196,13 @@ return; } + if (length == 1) { + /* For BC reasons, fgetss() should only return length-1 bytes. */ + RETURN_FALSE; + } else if (length > 1) { + length--; + } + php_stream_from_zval(stream, &zstream); if (length > 0) {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php