mirror of
https://github.com/php/php-src.git
synced 2025-08-17 22:48:57 +02:00
- Fix the fix
- Improved test
This commit is contained in:
parent
b51214fce7
commit
1eb552a712
2 changed files with 16 additions and 4 deletions
|
@ -411,7 +411,7 @@ PHP_FUNCTION(stream_get_contents)
|
||||||
|
|
||||||
php_stream_from_zval(stream, &zsrc);
|
php_stream_from_zval(stream, &zsrc);
|
||||||
|
|
||||||
if (pos >= 0 && php_stream_seek(stream, pos, SEEK_SET) < 0) {
|
if ((pos > 0 || (pos == 0 && ZEND_NUM_ARGS() > 2)) && php_stream_seek(stream, pos, SEEK_SET) < 0) {
|
||||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", pos);
|
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", pos);
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,16 +7,28 @@ $tmp = tmpfile();
|
||||||
|
|
||||||
fwrite($tmp, "12345");
|
fwrite($tmp, "12345");
|
||||||
|
|
||||||
|
echo stream_get_contents($tmp, 2, 1);
|
||||||
|
echo "\n";
|
||||||
|
echo stream_get_contents($tmp, -1);
|
||||||
|
echo "\n";
|
||||||
echo stream_get_contents($tmp, -1, 0);
|
echo stream_get_contents($tmp, -1, 0);
|
||||||
echo "\n";
|
echo "\n";
|
||||||
echo stream_get_contents($tmp, -1, 1);
|
|
||||||
echo "\n";
|
|
||||||
echo stream_get_contents($tmp, -1, 2);
|
echo stream_get_contents($tmp, -1, 2);
|
||||||
|
echo "\n";
|
||||||
|
echo stream_get_contents($tmp, 0, 0);
|
||||||
|
echo "\n";
|
||||||
|
echo stream_get_contents($tmp, 1, 0);
|
||||||
|
echo "\n";
|
||||||
|
echo stream_get_contents($tmp, -1);
|
||||||
|
|
||||||
@unlink($tmp);
|
@unlink($tmp);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
23
|
||||||
|
45
|
||||||
12345
|
12345
|
||||||
2345
|
|
||||||
345
|
345
|
||||||
|
|
||||||
|
1
|
||||||
|
2345
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue