iliaa Sun, 05 Jun 2011 21:57:01 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=311849
Log: Fixed bug #51997 (SEEK_CUR with 0 value, returns a warning). Bug: http://bugs.php.net/51997 (Assigned) fseek($fp, 0, SEEK_CUR) generates needless warning when seeking isn't supported Changed paths: U php/php-src/branches/PHP_5_3/NEWS A php/php-src/branches/PHP_5_3/ext/bz2/tests/bug51997.phpt U php/php-src/branches/PHP_5_3/main/streams/streams.c A php/php-src/branches/PHP_5_4/ext/bz2/tests/bug51997.phpt U php/php-src/branches/PHP_5_4/main/streams/streams.c A php/php-src/trunk/ext/bz2/tests/bug51997.phpt U php/php-src/trunk/main/streams/streams.c Modified: php/php-src/branches/PHP_5_3/NEWS =================================================================== --- php/php-src/branches/PHP_5_3/NEWS 2011-06-05 21:44:34 UTC (rev 311848) +++ php/php-src/branches/PHP_5_3/NEWS 2011-06-05 21:57:01 UTC (rev 311849) @@ -47,6 +47,7 @@ . Fixed bug #54721 (Different Hashes on Windows, BSD and Linux on wrong Salt size) (Pierre, os at irj dot ru) . Fixed bug #53848 (fgetcsv() ignores spaces at beginnings of fields). (Ilia) + . Fixed bug #51997 (SEEK_CUR with 0 value, returns a warning). (Ilia) . Fixed bug #50363 (Invalid parsing in convert.quoted-printable-decode filter). (slusarz at curecanti dot org) . Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using Added: php/php-src/branches/PHP_5_3/ext/bz2/tests/bug51997.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/bz2/tests/bug51997.phpt (rev 0) +++ php/php-src/branches/PHP_5_3/ext/bz2/tests/bug51997.phpt 2011-06-05 21:57:01 UTC (rev 311849) @@ -0,0 +1,24 @@ +--TEST-- +Bug #51997 (SEEK_CUR with 0 value, returns a warning) +--SKIPIF-- +<?php if (!extension_loaded("bz2")) print "skip"; ?> +--FILE-- +<?php + +error_reporting(E_ALL); + +$filename = "testfile.bz2"; +$str = "This is a test string.\n"; +$bz = bzopen($filename, "w"); +bzwrite($bz, $str); +bzclose($bz); + +$bz = bzopen($filename, "r"); +fseek($bz, 0, SEEK_CUR); +print bzread($bz, 10); +print bzread($bz); +bzclose($bz); +unlink($filename); + +--EXPECT-- +This is a test string. Modified: php/php-src/branches/PHP_5_3/main/streams/streams.c =================================================================== --- php/php-src/branches/PHP_5_3/main/streams/streams.c 2011-06-05 21:44:34 UTC (rev 311848) +++ php/php-src/branches/PHP_5_3/main/streams/streams.c 2011-06-05 21:57:01 UTC (rev 311849) @@ -1184,7 +1184,7 @@ } /* emulate forward moving seeks with reads */ - if (whence == SEEK_CUR && offset > 0) { + if (whence == SEEK_CUR && offset >= 0) { char tmp[1024]; size_t didread; while(offset > 0) { Added: php/php-src/branches/PHP_5_4/ext/bz2/tests/bug51997.phpt =================================================================== --- php/php-src/branches/PHP_5_4/ext/bz2/tests/bug51997.phpt (rev 0) +++ php/php-src/branches/PHP_5_4/ext/bz2/tests/bug51997.phpt 2011-06-05 21:57:01 UTC (rev 311849) @@ -0,0 +1,24 @@ +--TEST-- +Bug #51997 (SEEK_CUR with 0 value, returns a warning) +--SKIPIF-- +<?php if (!extension_loaded("bz2")) print "skip"; ?> +--FILE-- +<?php + +error_reporting(E_ALL); + +$filename = "testfile.bz2"; +$str = "This is a test string.\n"; +$bz = bzopen($filename, "w"); +bzwrite($bz, $str); +bzclose($bz); + +$bz = bzopen($filename, "r"); +fseek($bz, 0, SEEK_CUR); +print bzread($bz, 10); +print bzread($bz); +bzclose($bz); +unlink($filename); + +--EXPECT-- +This is a test string. Modified: php/php-src/branches/PHP_5_4/main/streams/streams.c =================================================================== --- php/php-src/branches/PHP_5_4/main/streams/streams.c 2011-06-05 21:44:34 UTC (rev 311848) +++ php/php-src/branches/PHP_5_4/main/streams/streams.c 2011-06-05 21:57:01 UTC (rev 311849) @@ -1255,7 +1255,7 @@ } /* emulate forward moving seeks with reads */ - if (whence == SEEK_CUR && offset > 0) { + if (whence == SEEK_CUR && offset >= 0) { char tmp[1024]; size_t didread; while(offset > 0) { Added: php/php-src/trunk/ext/bz2/tests/bug51997.phpt =================================================================== --- php/php-src/trunk/ext/bz2/tests/bug51997.phpt (rev 0) +++ php/php-src/trunk/ext/bz2/tests/bug51997.phpt 2011-06-05 21:57:01 UTC (rev 311849) @@ -0,0 +1,24 @@ +--TEST-- +Bug #51997 (SEEK_CUR with 0 value, returns a warning) +--SKIPIF-- +<?php if (!extension_loaded("bz2")) print "skip"; ?> +--FILE-- +<?php + +error_reporting(E_ALL); + +$filename = "testfile.bz2"; +$str = "This is a test string.\n"; +$bz = bzopen($filename, "w"); +bzwrite($bz, $str); +bzclose($bz); + +$bz = bzopen($filename, "r"); +fseek($bz, 0, SEEK_CUR); +print bzread($bz, 10); +print bzread($bz); +bzclose($bz); +unlink($filename); + +--EXPECT-- +This is a test string. Modified: php/php-src/trunk/main/streams/streams.c =================================================================== --- php/php-src/trunk/main/streams/streams.c 2011-06-05 21:44:34 UTC (rev 311848) +++ php/php-src/trunk/main/streams/streams.c 2011-06-05 21:57:01 UTC (rev 311849) @@ -1255,7 +1255,7 @@ } /* emulate forward moving seeks with reads */ - if (whence == SEEK_CUR && offset > 0) { + if (whence == SEEK_CUR && offset >= 0) { char tmp[1024]; size_t didread; while(offset > 0) {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php