version 1.1.1.2, 2012/05/29 12:34:36
|
version 1.1.1.3, 2013/07/22 01:32:16
|
Line 2
|
Line 2
|
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Zend Engine | |
| Zend Engine | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) | | | Copyright (c) 1998-2013 Zend Technologies Ltd. (http://www.zend.com) | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| This source file is subject to version 2.00 of the Zend license, | |
| This source file is subject to version 2.00 of the Zend license, | |
| that is bundled with this package in the file LICENSE, and is | |
| that is bundled with this package in the file LICENSE, and is | |
Line 79 static zend_always_inline long zend_dval_to_lval(doubl
|
Line 79 static zend_always_inline long zend_dval_to_lval(doubl
|
#else |
#else |
static zend_always_inline long zend_dval_to_lval(double d) |
static zend_always_inline long zend_dval_to_lval(double d) |
{ |
{ |
if (d > LONG_MAX) { | /* >= as (double)LONG_MAX is outside signed range */ |
| if (d >= LONG_MAX) { |
return (long)(unsigned long) d; |
return (long)(unsigned long) d; |
} |
} |
return (long) d; |
return (long) d; |
Line 100 static zend_always_inline long zend_dval_to_lval(doubl
|
Line 101 static zend_always_inline long zend_dval_to_lval(doubl
|
* if the number was out of long range or contained a decimal point/exponent. |
* if the number was out of long range or contained a decimal point/exponent. |
* The number's value is returned into the respective pointer, *lval or *dval, |
* The number's value is returned into the respective pointer, *lval or *dval, |
* if that pointer is not NULL. |
* if that pointer is not NULL. |
|
* |
|
* This variant also gives information if a string that represents an integer |
|
* could not be represented as such due to overflow. It writes 1 to oflow_info |
|
* if the integer is larger than LONG_MAX and -1 if it's smaller than LONG_MIN. |
*/ |
*/ |
| static inline zend_uchar is_numeric_string_ex(const char *str, int length, long *lval, double *dval, int allow_errors, int *oflow_info) |
static inline zend_uchar is_numeric_string(const char *str, int length, long *lval, double *dval, int allow_errors) | |
{ |
{ |
const char *ptr; |
const char *ptr; |
int base = 10, digits = 0, dp_or_e = 0; |
int base = 10, digits = 0, dp_or_e = 0; |
Line 113 static inline zend_uchar is_numeric_string(const char
|
Line 117 static inline zend_uchar is_numeric_string(const char
|
return 0; |
return 0; |
} |
} |
|
|
|
if (oflow_info != NULL) { |
|
*oflow_info = 0; |
|
} |
|
|
/* Skip any whitespace |
/* Skip any whitespace |
* This is much faster than the isspace() function */ |
* This is much faster than the isspace() function */ |
while (*str == ' ' || *str == '\t' || *str == '\n' || *str == '\r' || *str == '\v' || *str == '\f') { |
while (*str == ' ' || *str == '\t' || *str == '\n' || *str == '\r' || *str == '\v' || *str == '\f') { |
Line 165 check_digits:
|
Line 173 check_digits:
|
|
|
if (base == 10) { |
if (base == 10) { |
if (digits >= MAX_LENGTH_OF_LONG) { |
if (digits >= MAX_LENGTH_OF_LONG) { |
|
if (oflow_info != NULL) { |
|
*oflow_info = *str == '-' ? -1 : 1; |
|
} |
dp_or_e = -1; |
dp_or_e = -1; |
goto process_double; |
goto process_double; |
} |
} |
Line 172 check_digits:
|
Line 183 check_digits:
|
if (dval) { |
if (dval) { |
local_dval = zend_hex_strtod(str, &ptr); |
local_dval = zend_hex_strtod(str, &ptr); |
} |
} |
|
if (oflow_info != NULL) { |
|
*oflow_info = 1; |
|
} |
type = IS_DOUBLE; |
type = IS_DOUBLE; |
} |
} |
} else if (*ptr == '.' && ZEND_IS_DIGIT(ptr[1])) { |
} else if (*ptr == '.' && ZEND_IS_DIGIT(ptr[1])) { |
Line 207 process_double:
|
Line 221 process_double:
|
if (dval) { |
if (dval) { |
*dval = zend_strtod(str, NULL); |
*dval = zend_strtod(str, NULL); |
} |
} |
|
if (oflow_info != NULL) { |
|
*oflow_info = *str == '-' ? -1 : 1; |
|
} |
|
|
return IS_DOUBLE; |
return IS_DOUBLE; |
} |
} |
Line 224 process_double:
|
Line 241 process_double:
|
|
|
return IS_DOUBLE; |
return IS_DOUBLE; |
} |
} |
|
} |
|
|
|
static inline zend_uchar is_numeric_string(const char *str, int length, long *lval, double *dval, int allow_errors) { |
|
return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL); |
} |
} |
|
|
static inline char * |
static inline char * |