- Added the H modifier to create non-locale-aware non-fixed-precision float

representations.
- Fixed var_export() to use the new H modifier so that it can generate
  parsable PHP code for floats again, independent of the locale.
This commit is contained in:
Derick Rethans 2007-06-19 12:19:27 +00:00
parent 60db2300d7
commit ad8eca0b05
4 changed files with 1066 additions and 3 deletions

File diff suppressed because it is too large Load diff

View file

@ -584,7 +584,7 @@ PHPAPI void php_var_export(zval **struc, int level TSRMLS_DC)
php_printf("%ld", Z_LVAL_PP(struc));
break;
case IS_DOUBLE:
php_printf("%.*G", (int) EG(precision), Z_DVAL_PP(struc));
php_printf("%.*H", (int) EG(precision), Z_DVAL_PP(struc));
break;
case IS_STRING:
tmp_str = php_addcslashes(Z_STRVAL_PP(struc), Z_STRLEN_PP(struc), &tmp_len, 0, "'\\\0", 3 TSRMLS_CC);

View file

@ -1043,6 +1043,7 @@ fmt_string:
case 'g':
case 'G':
case 'H':
switch(modifier) {
case LM_LONG_DOUBLE:
fp_num = (double) va_arg(ap, long double);
@ -1081,7 +1082,7 @@ fmt_string:
lconv = localeconv();
}
#endif
s = php_gcvt(fp_num, precision, LCONV_DECIMAL_POINT, (*fmt == 'G')?'E':'e', &num_buf[1]);
s = php_gcvt(fp_num, precision, *fmt=='H' ? '.' : LCONV_DECIMAL_POINT, (*fmt == 'G')?'E':'e', &num_buf[1]);
if (*s == '-')
prefix_char = *s++;
else if (print_sign)

View file

@ -670,6 +670,7 @@ fmt_string:
case 'g':
case 'G':
case 'H':
switch(modifier) {
case LM_LONG_DOUBLE:
fp_num = (double) va_arg(ap, long double);
@ -708,7 +709,7 @@ fmt_string:
lconv = localeconv();
}
#endif
s = php_gcvt(fp_num, precision, LCONV_DECIMAL_POINT, (*fmt == 'G')?'E':'e', &num_buf[1]);
s = php_gcvt(fp_num, precision, *fmt=='H' ? '.' : LCONV_DECIMAL_POINT, (*fmt == 'G')?'E':'e', &num_buf[1]);
if (*s == '-')
prefix_char = *s++;
else if (print_sign)