]> granicus.if.org Git - php/commitdiff
- MFH: Fixed bug #47322 (sscanf %d does't work)
authorFelipe Pena <felipe@php.net>
Fri, 6 Feb 2009 10:20:09 +0000 (10:20 +0000)
committerFelipe Pena <felipe@php.net>
Fri, 6 Feb 2009 10:20:09 +0000 (10:20 +0000)
ext/standard/scanf.c
ext/standard/tests/strings/bug47322.phpt [new file with mode: 0644]

index bb7e477ee5ae6a40821f9f1e257e9e08801bc3e0..73541fbb5a54fac0a1fdd97a74b08380fde78427 100644 (file)
@@ -1078,7 +1078,7 @@ addToInt:
                                                } else if (numVars) {
                                                        current = args[objIndex++];
                                                        zval_dtor(*current);
-                                                       Z_LVAL(**current) = value;
+                                                       ZVAL_LONG(*current, value);
                                                } else {
                                                        add_index_long(*return_value, objIndex++, value);
                                                }
@@ -1183,7 +1183,7 @@ addToFloat:
                                        } else if (numVars) {
                                                current = args[objIndex++];
                                                zval_dtor(*current);
-                                               Z_DVAL_PP( current ) = dvalue;
+                                               ZVAL_DOUBLE(*current, dvalue);
                                        } else {
                                                add_index_double( *return_value, objIndex++, dvalue );
                                        }
diff --git a/ext/standard/tests/strings/bug47322.phpt b/ext/standard/tests/strings/bug47322.phpt
new file mode 100644 (file)
index 0000000..4ca78ee
--- /dev/null
@@ -0,0 +1,19 @@
+--TEST--
+Bug #47322 (sscanf %d does't work)
+--FILE--
+<?php
+
+sscanf("15:59:58.2","%d:%d:%f", $a, $b, $c);
+echo "[$a][$b][$c]\n";
+
+sscanf("15:59:58.2","%d:%d:%f", $a, $b, $c);
+echo "[$a][$b][$c]\n";
+
+sscanf("15:59:foo","%d:%d:%s", $a, $b, $c);
+echo "[$a][$b][$c]\n";
+
+?>
+--EXPECT--
+[15][59][58.2]
+[15][59][58.2]
+[15][59][foo]