diff options
| author | Gustavo André dos Santos Lopes <cataphract@php.net> | 2012-03-19 16:28:10 +0000 |
|---|---|---|
| committer | Gustavo André dos Santos Lopes <cataphract@php.net> | 2012-03-19 16:34:31 +0000 |
| commit | 9a460497da3cc2b755f4628350756427fc0a1051 (patch) | |
| tree | 03d3031a78763be85b261a90ee6a68673300642b /ext/standard/tests/streams | |
| parent | 53e3467ff233af4a40626f86ea8a61880722beb8 (diff) | |
| download | php-git-9a460497da3cc2b755f4628350756427fc0a1051.tar.gz | |
MFH: 45a6f8d for 5.4.
- Further fix for bug #60455 (stream_get_line misbehaves if EOF is not detected
together with the last read).
- Fixed bug #60817 (stream_get_line() reads from stream even when there is
already sufficient data buffered). stream_get_line() now behaves more like
fgets(), as is documented.
Diffstat (limited to 'ext/standard/tests/streams')
| -rw-r--r-- | ext/standard/tests/streams/bug60455_02.phpt | 1 | ||||
| -rw-r--r-- | ext/standard/tests/streams/bug60455_03.phpt | 2 | ||||
| -rw-r--r-- | ext/standard/tests/streams/bug60455_04.phpt | 32 | ||||
| -rw-r--r-- | ext/standard/tests/streams/bug60817.phpt | 36 |
4 files changed, 71 insertions, 0 deletions
diff --git a/ext/standard/tests/streams/bug60455_02.phpt b/ext/standard/tests/streams/bug60455_02.phpt index 6e06e9fa3f..0ddf346eba 100644 --- a/ext/standard/tests/streams/bug60455_02.phpt +++ b/ext/standard/tests/streams/bug60455_02.phpt @@ -28,3 +28,4 @@ while (!feof($f)) { } --EXPECT-- string(1) "a" +bool(false) diff --git a/ext/standard/tests/streams/bug60455_03.phpt b/ext/standard/tests/streams/bug60455_03.phpt index 5d7ba1f248..2429d31008 100644 --- a/ext/standard/tests/streams/bug60455_03.phpt +++ b/ext/standard/tests/streams/bug60455_03.phpt @@ -47,7 +47,9 @@ while (!feof($f)) { --EXPECT-- string(1) "a" string(1) "b" +bool(false) string(1) "a" string(0) "" +bool(false) string(1) "a" string(0) "" diff --git a/ext/standard/tests/streams/bug60455_04.phpt b/ext/standard/tests/streams/bug60455_04.phpt new file mode 100644 index 0000000000..3a82298dbc --- /dev/null +++ b/ext/standard/tests/streams/bug60455_04.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #60455: stream_get_line and 1-line with maxlen size followed by 0-length +read with EOL indication +--FILE-- +<?php +class TestStream { + private $s = 0; + function stream_open($path, $mode, $options, &$opened_path) { + return true; + } + function stream_read($count) { + if ($this->s++ == 0) + return "a\n"; + + return ""; + } + function stream_eof() { + return $this->s >= 2; + } + +} + +stream_wrapper_register("test", "TestStream"); + +$f = fopen("test://", "r"); +while (!feof($f)) { + $line = stream_get_line($f, 2, "\n"); + var_dump($line); +} +--EXPECT-- +string(1) "a" +bool(false) diff --git a/ext/standard/tests/streams/bug60817.phpt b/ext/standard/tests/streams/bug60817.phpt new file mode 100644 index 0000000000..2d4cf2682b --- /dev/null +++ b/ext/standard/tests/streams/bug60817.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #60817: stream_get_line() reads from stream even when there is already sufficient data buffered +--FILE-- +<?php +class TestStream { //data, empty data, empty data + eof + private $s = 0; + function stream_open($path, $mode, $options, &$opened_path) { + return true; + } + function stream_read($count) { + echo "Read done\n"; + if ($this->s++ == 0) + return "a\nbb\ncc"; + + return ""; + } + function stream_eof() { + return $this->s >= 2; + } + +} + +stream_wrapper_register("test", "TestStream"); + +$f = fopen("test://", "r"); +while (!feof($f)) { + $line = stream_get_line($f, 99, "\n"); + var_dump($line); +} + +--EXPECT-- +Read done +string(1) "a" +string(2) "bb" +Read done +string(2) "cc" |
