jani Thu Jul 26 15:24:06 2007 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/standard/tests/strings bug42107.phpt
Modified files:
/php-src NEWS
/php-src/ext/standard scanf.c
Log:
MFH: - Fixed bug #42107 (sscanf broken when using %2$s type format parameters)
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.861&r2=1.2027.2.547.2.862&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.861 php-src/NEWS:1.2027.2.547.2.862
--- php-src/NEWS:1.2027.2.547.2.861 Thu Jul 26 08:26:47 2007
+++ php-src/NEWS Thu Jul 26 15:24:05 2007
@@ -70,6 +70,7 @@
- Fixed PECL bug #11216 (crash in ZipArchive::addEmptyDir when a directory
already exists). (Pierre)
+- Fixed Bug #42107 (sscanf broken when using %2$s format parameters). (Jani)
- Fixed bug #42090 (json_decode causes segmentation fault). (Hannes)
- Fixed bug #42072 (No warning message for clearstatcache() with arguments).
(Ilia)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/scanf.c?r1=1.31.2.2.2.4&r2=1.31.2.2.2.5&diff_format=u
Index: php-src/ext/standard/scanf.c
diff -u php-src/ext/standard/scanf.c:1.31.2.2.2.4
php-src/ext/standard/scanf.c:1.31.2.2.2.5
--- php-src/ext/standard/scanf.c:1.31.2.2.2.4 Thu Jul 26 14:30:22 2007
+++ php-src/ext/standard/scanf.c Thu Jul 26 15:24:06 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: scanf.c,v 1.31.2.2.2.4 2007/07/26 14:30:22 jani Exp $ */
+/* $Id: scanf.c,v 1.31.2.2.2.5 2007/07/26 15:24:06 jani Exp $ */
/*
scanf.c --
@@ -649,6 +649,7 @@
return FAILURE;
}
}
+ varStart = 0; /* Array index starts from 0 */
}
baseString = string;
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug42107.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/strings/bug42107.phpt
+++ php-src/ext/standard/tests/strings/bug42107.phpt
--TEST--
Bug #42107 (sscanf() broken when using %2$s type format parameters)
--FILE--
<?php
var_dump(sscanf('one two', '%1$s %2$s'));
var_dump(sscanf('one two', '%2$s %1$s'));
echo "--\n";
sscanf('one two', '%1$s %2$s', $foo, $bar);
var_dump($foo, $bar);
sscanf('one two', '%2$s %1$s', $foo, $bar);
var_dump($foo, $bar);
echo "--\n";
var_dump(sscanf('one two', '%1$d %2$d'));
var_dump(sscanf('one two', '%1$d'));
echo "Done\n";
?>
--EXPECTF--
array(2) {
[0]=>
string(3) "one"
[1]=>
string(3) "two"
}
array(2) {
[0]=>
string(3) "two"
[1]=>
string(3) "one"
}
--
string(3) "one"
string(3) "two"
string(3) "two"
string(3) "one"
--
array(2) {
[0]=>
NULL
[1]=>
NULL
}
array(1) {
[0]=>
NULL
}
Done
--UEXPECTF--
array(2) {
[0]=>
unicode(3) "one"
[1]=>
unicode(3) "two"
}
array(2) {
[0]=>
unicode(3) "two"
[1]=>
unicode(3) "one"
}
--
unicode(3) "one"
unicode(3) "two"
unicode(3) "two"
unicode(3) "one"
--
array(2) {
[0]=>
NULL
[1]=>
NULL
}
array(1) {
[0]=>
NULL
}
Done
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php