cataphract Thu, 14 Oct 2010 02:39:21 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=304382
Log: - Ooops. Fixed tests for rev #304380 (stream_get_contents() related) and a small error. Bug: http://bugs.php.net/304380 (error getting bug information) Changed paths: U php/php-src/trunk/ext/standard/streamsfuncs.c U php/php-src/trunk/ext/standard/tests/streams/bug46426.phpt U php/php-src/trunk/ext/standard/tests/streams/stream_get_contents_001.phpt Modified: php/php-src/trunk/ext/standard/streamsfuncs.c =================================================================== --- php/php-src/trunk/ext/standard/streamsfuncs.c 2010-10-14 02:38:23 UTC (rev 304381) +++ php/php-src/trunk/ext/standard/streamsfuncs.c 2010-10-14 02:39:21 UTC (rev 304382) @@ -425,7 +425,7 @@ php_stream_from_zval(stream, &zsrc); - if ((pos != 0L) && php_stream_seek(stream, pos, SEEK_CUR) < 0) { + if ((pos > 0L) && php_stream_seek(stream, pos, SEEK_CUR) < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek %ld bytes from current position in the stream", pos); RETURN_FALSE; } else if (pos < 0L) { Modified: php/php-src/trunk/ext/standard/tests/streams/bug46426.phpt =================================================================== --- php/php-src/trunk/ext/standard/tests/streams/bug46426.phpt 2010-10-14 02:38:23 UTC (rev 304381) +++ php/php-src/trunk/ext/standard/tests/streams/bug46426.phpt 2010-10-14 02:39:21 UTC (rev 304382) @@ -7,19 +7,23 @@ fwrite($tmp, b"12345"); -echo stream_get_contents($tmp, 2, 1); +fseek($tmp, 0); +echo stream_get_contents($tmp, 2, 1); //23 echo "\n"; -echo stream_get_contents($tmp, -1); +echo stream_get_contents($tmp, -1); //45 echo "\n"; -echo stream_get_contents($tmp, -1, 0); +fseek($tmp, -1, SEEK_CUR); +echo stream_get_contents($tmp, -1, 0); //5 echo "\n"; -echo stream_get_contents($tmp, -1, 2); +fseek($tmp, 0); +echo stream_get_contents($tmp, -1, 2); //345 echo "\n"; -echo stream_get_contents($tmp, 0, 0); +fseek($tmp, 0); +echo stream_get_contents($tmp, 0, 0); //"" echo "\n"; -echo stream_get_contents($tmp, 1, 0); +echo stream_get_contents($tmp, 1, 0); //1 echo "\n"; -echo stream_get_contents($tmp, -1); +echo stream_get_contents($tmp, -1); //2345 @unlink($tmp); @@ -27,7 +31,7 @@ --EXPECT-- 23 45 -12345 +5 345 1 Modified: php/php-src/trunk/ext/standard/tests/streams/stream_get_contents_001.phpt =================================================================== --- php/php-src/trunk/ext/standard/tests/streams/stream_get_contents_001.phpt 2010-10-14 02:38:23 UTC (rev 304381) +++ php/php-src/trunk/ext/standard/tests/streams/stream_get_contents_001.phpt 2010-10-14 02:39:21 UTC (rev 304382) @@ -9,14 +9,17 @@ echo stream_get_contents($tmp, 2, 5), "--\n"; echo stream_get_contents($tmp, 2), "--\n"; +fseek($tmp, 0); echo stream_get_contents($tmp, 2, 3), "--\n"; echo stream_get_contents($tmp, 2, -1), "--\n"; @unlink($tmp); ?> ---EXPECT-- +--EXPECTF-- -- -- 45-- + +Warning: stream_get_contents(): Number of bytes to seek must be non-negative, given -1 in %s on line %d --
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php