]> granicus.if.org Git - php/commitdiff
MFB51: Allow zend_parse_parameters to handle non-well formed integers, but
authorIlia Alshanetsky <iliaa@php.net>
Thu, 17 Nov 2005 00:20:31 +0000 (00:20 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 17 Nov 2005 00:20:31 +0000 (00:20 +0000)
raise E_NOTICE in the process.

Zend/zend_API.c
Zend/zend_operators.h

index 941a2b4b0a7fc709a91c6c5d7102672a0e15b14f..c96f456757097085f43f484163a6d3611ef89627 100644 (file)
@@ -316,7 +316,7 @@ static char *zend_parse_arg_impl(int arg_num, zval **arg, va_list *va, char **sp
                                                        double d;
                                                        int type;
 
-                                                       if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), p, &d, 0)) == 0) {
+                                                       if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), p, &d, -1)) == 0) {
                                                                return "long";
                                                        } else if (type == IS_DOUBLE) {
                                                                *p = (long) d;
@@ -363,7 +363,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_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &l, p, 0)) == 0) {
+                                                       if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &l, p, -1)) == 0) {
                                                                return "double";
                                                        } else if (type == IS_LONG) {
                                                                *p = (double) l;
index 4984117b9122176bfcfb998bd9eadbb037a1570e..29d12a1e1ed2ed34188fa499e386799cae4e95e1 100644 (file)
@@ -68,7 +68,7 @@ ZEND_API long zend_u_strtol(const UChar *nptr, UChar **endptr, int base);
 ZEND_API double zend_u_strtod(const UChar *nptr, UChar **endptr);
 END_EXTERN_C()
 
-static inline zend_uchar is_numeric_string(char *str, int length, long *lval, double *dval, zend_bool allow_errors)
+static inline zend_uchar is_numeric_string(char *str, int length, long *lval, double *dval, int allow_errors)
 {
        long local_lval;
        double local_dval;
@@ -119,16 +119,21 @@ static inline zend_uchar is_numeric_string(char *str, int length, long *lval, do
        } else {
                end_ptr_double=NULL;
        }
-       if (allow_errors) {
-               if (end_ptr_double>end_ptr_long && dval) {
-                       *dval = local_dval;
-                       return IS_DOUBLE;
-               } else if (end_ptr_long && lval) {
-                       *lval = local_lval;
-                       return IS_LONG;
-               }
+
+       if (!allow_errors) {
+               return 0;
+       }
+       if (allow_errors == -1) {
+               zend_error(E_NOTICE, "A non well formed numeric value encountered");
+       }
+
+       if (end_ptr_double>end_ptr_long && dval) {
+               *dval = local_dval;
+               return IS_DOUBLE;
+       } else if (end_ptr_long && lval) {
+               *lval = local_lval;
+               return IS_LONG;
        }
-       return 0;
 }
 
 static inline zend_uchar is_numeric_unicode(UChar *str, int32_t length, long *lval, double *dval, zend_bool allow_errors)