compile-time warnings and replay them on the next include, even if it is
served from cache.
+- Standard:
+ . printf() and friends how support the %h and %H format specifiers. These
+ are the same as %g and %G, but always use "." as the decimal separator,
+ rather than determining it through the LC_NUMERIC locale.
+
- Zip:
. Extension updated to version 1.19.0
. New ZipArchive::lastId property to get index value of last added entry.
case 'g':
case 'G':
+ case 'h':
+ case 'H':
+ {
if (precision == 0)
precision = 1;
- /*
- * * We use &num_buf[ 1 ], so that we have room for the sign
- */
+
+ char decimal_point = '.';
+ if (fmt == 'g' || fmt == 'G') {
#ifdef ZTS
- localeconv_r(&lconv);
+ localeconv_r(&lconv);
#else
- lconv = localeconv();
+ lconv = localeconv();
#endif
- s = php_gcvt(number, precision, LCONV_DECIMAL_POINT, (fmt == 'G')?'E':'e', &num_buf[1]);
+ decimal_point = LCONV_DECIMAL_POINT;
+ }
+
+ char exp_char = fmt == 'G' || fmt == 'H' ? 'E' : 'e';
+ /* We use &num_buf[ 1 ], so that we have room for the sign. */
+ s = php_gcvt(number, precision, decimal_point, exp_char, &num_buf[1]);
is_negative = 0;
if (*s == '-') {
is_negative = 1;
s_len = strlen(s);
break;
+ }
}
php_sprintf_appendstring(buffer, pos, s, width, 0, padding,
width, padding, alignment);
break;
- case 'g':
- case 'G':
case 'e':
case 'E':
case 'f':
case 'F':
+ case 'g':
+ case 'G':
+ case 'h':
+ case 'H':
php_sprintf_appenddouble(&result, &outpos,
zval_get_double(tmp),
width, padding, alignment,
--- /dev/null
+--TEST--
+sprintf() %h and %H specifiers
+--SKIPIF--
+<?php
+if (!setlocale(LC_ALL, "de_DE.utf8")) die("skip de_DE.utf8 locale not available");
+?>
+--FILE--
+<?php
+
+setlocale(LC_ALL, "de_DE.utf8");
+$f = 1.25;
+printf("%g %G %h %H\n", $f, $f, $f, $f);
+$f = 0.00000125;
+printf("%g %G %h %H\n", $f, $f, $f, $f);
+
+?>
+--EXPECT--
+1,25 1,25 1.25 1.25
+1,25e-6 1,25E-6 1.25e-6 1.25E-6