[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard streamsfuncs.c /ext/standard/tests/streams bug46426.phpt

2008-10-30 Thread Felipe Pena
felipe  Thu Oct 30 10:09:22 2008 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/standard/tests/streams bug46426.phpt 

  Modified files:  
/php-src/ext/standard   streamsfuncs.c 
  Log:
  - MFH: Fixed bug #46426 (3rd parameter offset of stream_get_contents not 
works for 0)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.58.2.6.2.15.2.24r2=1.58.2.6.2.15.2.25diff_format=u
Index: php-src/ext/standard/streamsfuncs.c
diff -u php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.24 
php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.25
--- php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.24  Sun Oct 26 
13:25:06 2008
+++ php-src/ext/standard/streamsfuncs.c Thu Oct 30 10:09:20 2008
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: streamsfuncs.c,v 1.58.2.6.2.15.2.24 2008/10/26 13:25:06 felipe Exp $ */
+/* $Id: streamsfuncs.c,v 1.58.2.6.2.15.2.25 2008/10/30 10:09:20 felipe Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -411,7 +411,7 @@
 
php_stream_from_zval(stream, zsrc);
 
-   if (pos  0  php_stream_seek(stream, pos, SEEK_SET)  0) {
+   if (pos = 0  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);
RETURN_FALSE;
}

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/streams/bug46426.phpt?view=markuprev=1.1
Index: php-src/ext/standard/tests/streams/bug46426.phpt
+++ php-src/ext/standard/tests/streams/bug46426.phpt
--TEST--
Bug #46426 (3rd parameter offset of stream_get_contents not works for 0)
--FILE--
?php

$tmp = tmpfile();

fwrite($tmp, 12345);

echo stream_get_contents($tmp, -1, 0);
echo \n;
echo stream_get_contents($tmp, -1, 1);
echo \n;
echo stream_get_contents($tmp, -1, 2);

@unlink($tmp);

?
--EXPECT--
12345
2345
345



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard streamsfuncs.c /ext/standard/tests/streams bug46426.phpt

2008-10-30 Thread Hannes Magnusson
On Thu, Oct 30, 2008 at 11:09, Felipe Pena [EMAIL PROTECTED] wrote:
 felipe  Thu Oct 30 10:09:22 2008 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/standard/tests/streams bug46426.phpt

  Modified files:
/php-src/ext/standard   streamsfuncs.c
  Log:
  - MFH: Fixed bug #46426 (3rd parameter offset of stream_get_contents not 
 works for 0)


 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.58.2.6.2.15.2.24r2=1.58.2.6.2.15.2.25diff_format=u
 Index: php-src/ext/standard/streamsfuncs.c
 diff -u php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.24 
 php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.25
 --- php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.24  Sun Oct 26 
 13:25:06 2008
 +++ php-src/ext/standard/streamsfuncs.c Thu Oct 30 10:09:20 2008
 @@ -17,7 +17,7 @@
   +--+
  */

 -/* $Id: streamsfuncs.c,v 1.58.2.6.2.15.2.24 2008/10/26 13:25:06 felipe Exp $ 
 */
 +/* $Id: streamsfuncs.c,v 1.58.2.6.2.15.2.25 2008/10/30 10:09:20 felipe Exp $ 
 */

  #include php.h
  #include php_globals.h
 @@ -411,7 +411,7 @@

php_stream_from_zval(stream, zsrc);

 -   if (pos  0  php_stream_seek(stream, pos, SEEK_SET)  0) {
 +   if (pos = 0  php_stream_seek(stream, pos, SEEK_SET)  0) {

Isn't this a change of behavior?

Passing no 3rd argument used to mean don't seek anywhere, just keep
the position as it is, but now means seek to the start of the
stream because pos = 0 by default...

-Hannes

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard streamsfuncs.c /ext/standard/tests/streams bug46426.phpt

2008-10-30 Thread Felipe Pena
Em Qui, 2008-10-30 às 14:35 +0100, Hannes Magnusson escreveu:
 On Thu, Oct 30, 2008 at 11:09, Felipe Pena [EMAIL PROTECTED] wrote:
  felipe  Thu Oct 30 10:09:22 2008 UTC
 
   Added files: (Branch: PHP_5_3)
 /php-src/ext/standard/tests/streams bug46426.phpt
 
   Modified files:
 /php-src/ext/standard   streamsfuncs.c
   Log:
   - MFH: Fixed bug #46426 (3rd parameter offset of stream_get_contents not 
  works for 0)
 
 
  http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.58.2.6.2.15.2.24r2=1.58.2.6.2.15.2.25diff_format=u
  Index: php-src/ext/standard/streamsfuncs.c
  diff -u php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.24 
  php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.25
  --- php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.24  Sun Oct 26 
  13:25:06 2008
  +++ php-src/ext/standard/streamsfuncs.c Thu Oct 30 10:09:20 2008
  @@ -17,7 +17,7 @@
+--+
   */
 
  -/* $Id: streamsfuncs.c,v 1.58.2.6.2.15.2.24 2008/10/26 13:25:06 felipe Exp 
  $ */
  +/* $Id: streamsfuncs.c,v 1.58.2.6.2.15.2.25 2008/10/30 10:09:20 felipe Exp 
  $ */
 
   #include php.h
   #include php_globals.h
  @@ -411,7 +411,7 @@
 
 php_stream_from_zval(stream, zsrc);
 
  -   if (pos  0  php_stream_seek(stream, pos, SEEK_SET)  0) {
  +   if (pos = 0  php_stream_seek(stream, pos, SEEK_SET)  0) {
 
 Isn't this a change of behavior?
 
 Passing no 3rd argument used to mean don't seek anywhere, just keep
 the position as it is, but now means seek to the start of the
 stream because pos = 0 by default...
 
 -Hannes
 

Opss, you are right. Thanks for noticing that.

.phpt++

-- 
Regards,
Felipe Pena


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/standard streamsfuncs.c /ext/standard/tests/streams bug46426.phpt

2008-10-30 Thread Felipe Pena
felipe  Thu Oct 30 14:34:25 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   streamsfuncs.c 
/php-src/ext/standard/tests/streams bug46426.phpt 
  Log:
  - Fix the fix
  - Improved test
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.58.2.6.2.15.2.25r2=1.58.2.6.2.15.2.26diff_format=u
Index: php-src/ext/standard/streamsfuncs.c
diff -u php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.25 
php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.26
--- php-src/ext/standard/streamsfuncs.c:1.58.2.6.2.15.2.25  Thu Oct 30 
10:09:20 2008
+++ php-src/ext/standard/streamsfuncs.c Thu Oct 30 14:34:25 2008
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: streamsfuncs.c,v 1.58.2.6.2.15.2.25 2008/10/30 10:09:20 felipe Exp $ */
+/* $Id: streamsfuncs.c,v 1.58.2.6.2.15.2.26 2008/10/30 14:34:25 felipe Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -411,7 +411,7 @@
 
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);
RETURN_FALSE;
}
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/streams/bug46426.phpt?r1=1.1.2.2r2=1.1.2.3diff_format=u
Index: php-src/ext/standard/tests/streams/bug46426.phpt
diff -u php-src/ext/standard/tests/streams/bug46426.phpt:1.1.2.2 
php-src/ext/standard/tests/streams/bug46426.phpt:1.1.2.3
--- php-src/ext/standard/tests/streams/bug46426.phpt:1.1.2.2Thu Oct 30 
10:09:22 2008
+++ php-src/ext/standard/tests/streams/bug46426.phptThu Oct 30 14:34:25 2008
@@ -7,16 +7,28 @@
 
 fwrite($tmp, 12345);
 
-echo stream_get_contents($tmp, -1, 0);
+echo stream_get_contents($tmp, 2, 1);
+echo \n;
+echo stream_get_contents($tmp, -1);
 echo \n;
-echo stream_get_contents($tmp, -1, 1);
+echo stream_get_contents($tmp, -1, 0);
 echo \n;
 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);
 
 ?
 --EXPECT--
+23
+45
 12345
-2345
 345
+
+1
+2345



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php