From: Derick Rethans Date: Wed, 3 Nov 2004 23:14:32 +0000 (+0000) Subject: - MFH: Fixed bug #30630: Added a BSD based strtod function that is X-Git-Tag: php-5.0.3RC1~93 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=90546a871fe6d80e5ed3189ef952a371fc925c6a;p=php - MFH: Fixed bug #30630: Added a BSD based strtod function that is locale-independent. --- diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 73404e29fc..f150479c71 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -183,8 +183,6 @@ void init_executor(TSRMLS_D) EG(scope) = NULL; EG(This) = NULL; - - EG(float_separator)[0] = '.'; } void shutdown_executor(TSRMLS_D) diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h index 1ce4c39295..41063f4330 100644 --- a/Zend/zend_globals.h +++ b/Zend/zend_globals.h @@ -237,9 +237,6 @@ struct _zend_executor_globals { zend_property_info std_property_info; - /* locale stuff */ - char float_separator[1]; - void *reserved[ZEND_MAX_RESERVED_RESOURCES]; }; diff --git a/Zend/zend_ini.c b/Zend/zend_ini.c index 45ff7d9b9c..e43ecbb833 100644 --- a/Zend/zend_ini.c +++ b/Zend/zend_ini.c @@ -24,6 +24,7 @@ #include "zend_ini.h" #include "zend_alloc.h" #include "zend_operators.h" +#include "zend_strtod.h" static HashTable *registered_zend_ini_directives; @@ -298,9 +299,9 @@ ZEND_API double zend_ini_double(char *name, uint name_length, int orig) if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry)==SUCCESS) { if (orig && ini_entry->modified) { - return (double) (ini_entry->orig_value ? strtod(ini_entry->orig_value, NULL) : 0.0); + return (double) (ini_entry->orig_value ? zend_strtod(ini_entry->orig_value, NULL) : 0.0); } else if (ini_entry->value) { - return (double) strtod(ini_entry->value, NULL); + return (double) zend_strtod(ini_entry->value, NULL); } } @@ -486,7 +487,7 @@ ZEND_API ZEND_INI_MH(OnUpdateReal) p = (double *) (base+(size_t) mh_arg1); - *p = strtod(new_value, NULL); + *p = zend_strtod(new_value, NULL); return SUCCESS; } diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index e6efbcc827..1b96504652 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -57,6 +57,7 @@ #include "zend_constants.h" #include "zend_variables.h" #include "zend_operators.h" +#include "zend_strtod.h" #ifdef HAVE_STDARG_H # include @@ -1188,7 +1189,7 @@ NEWLINE ("\r"|"\n"|"\r\n") errno = 0; zendlval->value.lval = strtol(yytext, NULL, 0); if (errno == ERANGE) { /* overflow */ - zendlval->value.dval = strtod(yytext, NULL); + zendlval->value.dval = zend_strtod(yytext, NULL); zendlval->type = IS_DOUBLE; return T_DNUMBER; } else { @@ -1225,7 +1226,7 @@ NEWLINE ("\r"|"\n"|"\r\n") } {DNUM}|{EXPONENT_DNUM} { - zendlval->value.dval = strtod(yytext, NULL); + zendlval->value.dval = zend_strtod(yytext, NULL); zendlval->type = IS_DOUBLE; return T_DNUMBER; } diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 76c21878ec..d628073c95 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -29,6 +29,7 @@ #include "zend_fast_cache.h" #include "zend_API.h" #include "zend_multiply.h" +#include "zend_strtod.h" #define LONG_SIGN_MASK (1L << (8*sizeof(long)-1)) @@ -384,7 +385,7 @@ ZEND_API void convert_to_double(zval *op) case IS_STRING: strval = op->value.str.val; - op->value.dval = strtod(strval, NULL); + op->value.dval = zend_strtod(strval, NULL); STR_FREE(strval); break; case IS_ARRAY: @@ -1904,9 +1905,9 @@ ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2) (ret2=is_numeric_string(s2->value.str.val, s2->value.str.len, &lval2, &dval2, 0))) { if ((ret1==IS_DOUBLE) || (ret2==IS_DOUBLE)) { if (ret1!=IS_DOUBLE) { - dval1 = strtod(s1->value.str.val, NULL); + dval1 = zend_strtod(s1->value.str.val, NULL); } else if (ret2!=IS_DOUBLE) { - dval2 = strtod(s2->value.str.val, NULL); + dval2 = zend_strtod(s2->value.str.val, NULL); } result->value.dval = dval1 - dval2; result->value.lval = ZEND_NORMALIZE_BOOL(result->value.dval); @@ -1980,13 +1981,6 @@ ZEND_API void zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC) op->value.str.val = (char *) emalloc_rel(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1); sprintf(op->value.str.val, "%.*G", (int) EG(precision), dval); op->value.str.len = strlen(op->value.str.val); - - if (EG(float_separator)[0] != '.') { - char *p = op->value.str.val; - if ((p = strchr(p, '.'))) { - *p = EG(float_separator)[0]; - } - } } /* diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 11f00acb0a..8349eba363 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -29,6 +29,7 @@ #include #endif +#include "zend_strtod.h" #if 0&&HAVE_BCMATH #include "ext/bcmath/libbcmath/src/bcmath.h" @@ -99,7 +100,7 @@ static inline zend_bool is_numeric_string(char *str, int length, long *lval, dou } errno=0; - local_dval = strtod(str, &end_ptr_double); + local_dval = zend_strtod(str, &end_ptr_double); if (errno != ERANGE) { if (end_ptr_double == str+length) { /* floating point string */ if (!zend_finite(local_dval)) {