jani Thu Jul 26 15:23:31 2007 UTC
Added files:
/php-src/ext/standard/tests/strings bug42107.phpt
Modified files:
/php-src/ext/standard scanf.c
Log:
- Fixed bug #42107 (sscanf broken when using %2$s type format parameters)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/scanf.c?r1=1.39&r2=1.40&diff_format=u
Index: php-src/ext/standard/scanf.c
diff -u php-src/ext/standard/scanf.c:1.39 php-src/ext/standard/scanf.c:1.40
--- php-src/ext/standard/scanf.c:1.39 Thu Jul 26 14:30:08 2007
+++ php-src/ext/standard/scanf.c Thu Jul 26 15:23:31 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: scanf.c,v 1.39 2007/07/26 14:30:08 jani Exp $ */
+/* $Id: scanf.c,v 1.40 2007/07/26 15:23:31 jani Exp $ */
/*
scanf.c --
@@ -1105,6 +1105,7 @@
return FAILURE;
}
}
+ varStart = 0; /* Array index starts from 0 */
}
baseString = string;
@@ -1750,6 +1751,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