]> granicus.if.org Git - php/commitdiff
fix #41517 (different behaviour of floatval() in Unicode mode)
authorAntony Dovgal <tony2001@php.net>
Mon, 28 May 2007 20:26:52 +0000 (20:26 +0000)
committerAntony Dovgal <tony2001@php.net>
Mon, 28 May 2007 20:26:52 +0000 (20:26 +0000)
Zend/zend_API.c
Zend/zend_operators.h

index ba9a774480513ca1aa5060c42aba23cea9263663..0ebdce2d7ba34a1f5017b1558b1d0fa9a6ab097d 100644 (file)
@@ -412,7 +412,7 @@ static char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, char **sp
                                                        long l;
                                                        int type;
 
-                                                       if ((type = is_numeric_unicode(Z_USTRVAL_PP(arg), Z_USTRLEN_PP(arg), &l, p, 0)) == 0) {
+                                                       if ((type = is_numeric_unicode(Z_USTRVAL_PP(arg), Z_USTRLEN_PP(arg), &l, p, -1)) == 0) {
                                                                return "double";
                                                        } else if (type == IS_LONG) {
                                                                *p = (double) l;
index 44c4b6a8506214ec5124657af6bf49e9ad440d34..6bc46ecc2e4008273dfce725ded96bb05745ab81 100644 (file)
@@ -147,7 +147,7 @@ static inline zend_uchar is_numeric_string(char *str, int length, long *lval, do
        return 0;
 }
 
-static inline zend_uchar is_numeric_unicode(UChar *str, int length, long *lval, double *dval, zend_bool allow_errors)
+static inline zend_uchar is_numeric_unicode(UChar *str, int length, long *lval, double *dval, int allow_errors)
 {
        long local_lval;
        double local_dval;
@@ -200,6 +200,13 @@ static inline zend_uchar is_numeric_unicode(UChar *str, int length, long *lval,
                }
        }
 
+       if (!allow_errors) {
+               return 0;
+       }
+       if (allow_errors == -1) {
+               zend_error(E_NOTICE, "A non well formed numeric value encountered");
+       }
+
        if (allow_errors) {
                if (end_ptr_double > end_ptr_long && dval) {
                        *dval = local_dval;