diff options
author | George Peter Banyard <girgias@php.net> | 2020-07-29 02:51:09 +0100 |
---|---|---|
committer | George Peter Banyard <girgias@php.net> | 2020-07-29 02:51:09 +0100 |
commit | b2248789ed21300aaf356336bf43b6b065183fcb (patch) | |
tree | c61dba0a43f72d27904e956318f911c7dc719dda /Zend/zend_operators.h | |
parent | f759936591c08d9bff6ab707f2f8c192f61b5bf1 (diff) | |
download | php-git-b2248789ed21300aaf356336bf43b6b065183fcb.tar.gz |
Implement 'Saner Numeric Strings' RFC:
RFC: https://wiki.php.net/rfc/saner-numeric-strings
This removes the -1 allow_error mode from is_numeric_string functions and replaces it by
a trailing boolean out argument to preserve BC in a couple of places.
Most of the changes can be resumed to "numeric" strings which emitted a E_NOTICE now emit
a E_WARNING and "numeric" strings which emitted a E_WARNING now throw a TypeError.
This mostly affects:
- String offsets
- Arithmetic operations
- Bitwise operations
Closes GH-5762
Diffstat (limited to 'Zend/zend_operators.h')
-rw-r--r-- | Zend/zend_operators.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 2664514709..9eb064b125 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -86,7 +86,8 @@ static zend_always_inline zend_bool instanceof_function( * could not be represented as such due to overflow. It writes 1 to oflow_info * if the integer is larger than ZEND_LONG_MAX and -1 if it's smaller than ZEND_LONG_MIN. */ -ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t length, zend_long *lval, double *dval, int allow_errors, int *oflow_info); +ZEND_API zend_uchar ZEND_FASTCALL _is_numeric_string_ex(const char *str, size_t length, zend_long *lval, + double *dval, bool allow_errors, int *oflow_info, bool *trailing_data); ZEND_API const char* ZEND_FASTCALL zend_memnstr_ex(const char *haystack, const char *needle, size_t needle_len, const char *end); ZEND_API const char* ZEND_FASTCALL zend_memnrstr_ex(const char *haystack, const char *needle, size_t needle_len, const char *end); @@ -135,16 +136,17 @@ static zend_always_inline zend_long zend_dval_to_lval_cap(double d) #define ZEND_IS_DIGIT(c) ((c) >= '0' && (c) <= '9') #define ZEND_IS_XDIGIT(c) (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f')) -static zend_always_inline zend_uchar is_numeric_string_ex(const char *str, size_t length, zend_long *lval, double *dval, int allow_errors, int *oflow_info) +static zend_always_inline zend_uchar is_numeric_string_ex(const char *str, size_t length, zend_long *lval, + double *dval, bool allow_errors, int *oflow_info, bool *trailing_data) { if (*str > '9') { return 0; } - return _is_numeric_string_ex(str, length, lval, dval, allow_errors, oflow_info); + return _is_numeric_string_ex(str, length, lval, dval, allow_errors, oflow_info, trailing_data); } -static zend_always_inline zend_uchar is_numeric_string(const char *str, size_t length, zend_long *lval, double *dval, int allow_errors) { - return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL); +static zend_always_inline zend_uchar is_numeric_string(const char *str, size_t length, zend_long *lval, double *dval, bool allow_errors) { + return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL, NULL); } ZEND_API zend_uchar ZEND_FASTCALL is_numeric_str_function(const zend_string *str, zend_long *lval, double *dval); |