case '\0':
if (!format_len) {
- goto exit;
+ zend_value_error("Missing format specifier at end of string");
+ goto fail;
}
- break;
+ /* break missing intentionally */
default:
zend_value_error("Unknown format specifier '%c'", *format);
goto fail;
}
-exit:
/* possibly, we have to make sure we have room for the terminating null? */
ZSTR_VAL(result)[outpos]=0;
ZSTR_LEN(result) = outpos;
echo $e->getMessage(), "\n";
}
+try {
+ var_dump(sprintf("foo %", 42));
+} catch (ValueError $e) {
+ echo $e->getMessage(), "\n";
+}
+
echo "Done";
?>
--EXPECTF--
4 parameters are required, 2 given
4 parameters are required, 1 given
101 parameters are required, 1 given
+Missing format specifier at end of string
Done
"%10.4o %-10.4o %04o %04.4o",
"%'#2o %'2o %'$2o %'_2o",
"%o %o %o %o",
- "%% %%o %10",
+ "%% %%o",
'%3$o %4$o %1$o %2$o'
);
array(0123456, 01234567, -01234567, 01234567),
array(0111, 02222, -0333333, -044444444),
array(0x123b, 0xfAb, 0123, 012),
- array(01234, 0567, -01234),
+ array(01234, 0567),
array(03, 04, 01, 02)
);
int(17)
-- Iteration 7 --
-% %o
-int(5)
+% %o
+int(4)
-- Iteration 8 --
1 2 3 4
"%10.4o %-10.4o %04o %04.4o",
"%'#2o %'2o %'$2o %'_2o",
"%o %o %o %o",
- "%% %%o %10",
+ "%% %%o",
'%3$o %4$o %1$o %2$o'
);
array(0123456, 01234567, -01234567, 01234567),
array(0111, 02222, -0333333, -044444444),
array(0x123b, 0xfAb, 0123, 012),
- array(01234, 0567, -01234),
+ array(01234, 0567),
array(03, 04, 01, 02)
);
int(17)
-- Iteration 7 --
-% %o
-int(5)
+% %o
+int(4)
-- Iteration 8 --
1 2 3 4
"%10.4x %-10.4x %04x %04.4x",
"%'#2x %'2x %'$2x %'_2x",
"%x %x %x %x",
- "% %%x x%",
+ "% %%x",
'%3$x %4$x %1$x %2$x'
);
}
?>
---EXPECTF--
+--EXPECT--
*** Testing vprintf() : hexa formats with hexa values ***
-- Iteration 1 --
int(12)
-- Iteration 7 --
-%34 x
-int(5)
+%34
+int(3)
-- Iteration 8 --
1 2 3 4
"%10.4x %-10.4x %04x %04.4x",
"%'#2x %'2x %'$2x %'_2x",
"%x %x %x %x",
- "% %%x x%",
+ "% %%x",
'%3$x %4$x %1$x %2$x'
);
array(123456, 12345678, -1234567, 1234567),
array(1, 0x2222, 0333333, -0x44444444),
array(0x123b, 0xfAb, "0xaxz", 012),
- array(0x1234, 0x34, 0x2ff),
+ array(0x1234, 0x34),
array(0x3, 0x4, 0x1, 0x2)
);
}
?>
---EXPECTF--
+--EXPECT--
*** Testing vprintf() : hexa formats with hexa values ***
-- Iteration 1 --
int(12)
-- Iteration 7 --
-%34 x
-int(5)
+%34
+int(3)
-- Iteration 8 --
1 2 3 4
"%10.4d %-10.4d %04d %04.4d",
"%'#2d %'2d %'$2d %'_2d",
"%d %d %d %d",
- "% %%d d%",
+ "% %%d",
'%3$d %4$d %1$d %2$d'
);
array(123456, 12345678, -1234567, 1234567),
array(111, 2222, 333333, 44444444),
array(0x123b, 0xfAb, 0123, 012),
- array(1234, -5678, 2345),
+ array(1234, -5678),
array(3, 4, 1, 2)
);
int(15)
-- Iteration 7 --
-%-5678 d
-int(8)
+%-5678
+int(6)
-- Iteration 8 --
1 2 3 4
"%10.4f %-10.4F %04f %04.4f",
"%'#2f %'2f %'$2f %'_2f",
"%f %f %f %f",
- "% %%f f%",
+ "% %%f",
'%3$f %4$f %1$f %2$f'
);
array(2e5, 2e-5, -2e5, -2e-5),
array(0.2E5, -0.2e40, 0.2E-20, 0.2E+20),
array(0x123b, 0xfAb, 0123, 012),
- array(1234.1234, -5678.5678, 2345.2345),
+ array(1234.1234, -5678.5678),
array(3.33, 4.44, 1.11, 2.22)
);
int(43)
-- Iteration 7 --
-%-5678.567800 f
-int(15)
+%-5678.567800
+int(13)
-- Iteration 8 --
1.110000 2.220000 3.330000 4.440000