]> granicus.if.org Git - php/commitdiff
- MFH: Fixed bug #30630: Added a BSD based strtod function that is
authorDerick Rethans <derick@php.net>
Wed, 3 Nov 2004 23:14:32 +0000 (23:14 +0000)
committerDerick Rethans <derick@php.net>
Wed, 3 Nov 2004 23:14:32 +0000 (23:14 +0000)
  locale-independent.

Zend/zend_execute_API.c
Zend/zend_globals.h
Zend/zend_ini.c
Zend/zend_language_scanner.l
Zend/zend_operators.c
Zend/zend_operators.h

index 73404e29fc1bfd9a9e13bf13fc07d8d840b2a715..f150479c71cf2a59530a92234f78cde246641523 100644 (file)
@@ -183,8 +183,6 @@ void init_executor(TSRMLS_D)
        EG(scope) = NULL;
 
        EG(This) = NULL;
-
-       EG(float_separator)[0] = '.';
 }
 
 void shutdown_executor(TSRMLS_D)
index 1ce4c39295b951906605aa9db4dd0ffbe0e9fb64..41063f4330712bbf15e89176efc026f1eb150ebf 100644 (file)
@@ -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];
 };
 
index 45ff7d9b9c9c64f8a11b798cd45abf6f964b98b4..e43ecbb83369313b78ac8b581d6dd82a86471b2b 100644 (file)
@@ -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;
 }
 
index e6efbcc8270ef5b566526525c7eba7b0d1834f9f..1b96504652faf7ef98cb1e4e7b964b6322f3a04b 100644 (file)
@@ -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 <stdarg.h>
@@ -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")
 }
 
 <ST_IN_SCRIPTING>{DNUM}|{EXPONENT_DNUM} {
-       zendlval->value.dval = strtod(yytext, NULL);
+       zendlval->value.dval = zend_strtod(yytext, NULL);
        zendlval->type = IS_DOUBLE;
        return T_DNUMBER;
 }
index 76c21878ec5d89e089c8e24eba4157bab3ed08fa..d628073c953d3f2edb4120e9e9661f503562c3de 100644 (file)
@@ -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];
-               }       
-       }
 }
 
 /*
index 11f00acb0a797b91bfecf482d6810a086675c22b..8349eba363d736f31bd0c2d7a397ecc5dc3912bb 100644 (file)
@@ -29,6 +29,7 @@
 #include <ieeefp.h>
 #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)) {