php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | |
Patch inconsistent-bin-hex-handling.patch for Strings related Bug #66399Patch version 2014-01-03 14:15 UTC Return to Bug #66399 | Download this patchThis patch is obsolete Obsoleted by patches: This patch renders other patches obsolete Obsolete patches: Patch Revisions: 2014-01-03 14:25 UTC | 2014-01-03 14:15 UTC | 2014-01-03 14:13 UTC | 2014-01-03 13:39 UTCDeveloper: krakjoe@php.netdiff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index e862929..f0fdbdc 100644 index e862929..98d34de 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -79,6 +79,22 @@ static const unsigned char tolower_map[256] = { @@ -79,6 +79,24 @@ static const unsigned char tolower_map[256] = { zend_binary_strncasecmp */ +static inline long zendi_strtol(const char *str, int base) { + long converted = 0L; + + if (str[0] == '0') { + if (str[1] == 'x' || str[1] == 'X') { + return strtol(&str[2], NULL, 8); + } else { + if (str[1] == 'b') { + return strtol(&str[2], NULL, 2); + if (str[1] != '\0' && str[1] != '\0') { + if (str[1] == 'x' || str[1] == 'X') { + return strtol(&str[2], NULL, 8); + } else { + if (str[1] == 'b' || str[1] == 'B') { + return strtol(&str[2], NULL, 2); + } + } + } + } + + ZEND_API int zend_atoi(const char *str, int str_len) /* {{{ */ { int retval; @@ -86,7 +102,7 @@ ZEND_API int zend_atoi(const char *str, int str_len) /* {{{ */ @@ -86,7 +104,7 @@ ZEND_API int zend_atoi(const char *str, int str_len) /* {{{ */ if (!str_len) { str_len = strlen(str); } - retval = strtol(str, NULL, 0); + retval = zendi_strtol(str, 0); if (str_len>0) { switch (str[str_len-1]) { case 'g': @@ -114,7 +130,7 @@ ZEND_API long zend_atol(const char *str, int str_len) /* {{{ */ @@ -114,7 +132,7 @@ ZEND_API long zend_atol(const char *str, int str_len) /* {{{ */ if (!str_len) { str_len = strlen(str); } - retval = strtol(str, NULL, 0); + retval = zendi_strtol(str, 0); if (str_len>0) { switch (str[str_len-1]) { case 'g': @@ -263,7 +279,7 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC) /* {{{ */ @@ -263,7 +281,7 @@ ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC) /* {{{ */ Z_LVAL(holder) = zend_dval_to_lval(Z_DVAL_P(op)); \ break; \ case IS_STRING: \ - Z_LVAL(holder) = strtol(Z_STRVAL_P(op), NULL, 10); \ + Z_LVAL(holder) = zendi_strtol(Z_STRVAL_P(op), 10); \ break; \ case IS_ARRAY: \ Z_LVAL(holder) = (zend_hash_num_elements(Z_ARRVAL_P(op))?1:0); \ @@ -390,7 +406,7 @@ ZEND_API void convert_to_long_base(zval *op, int base) /* {{{ */ @@ -390,7 +408,7 @@ ZEND_API void convert_to_long_base(zval *op, int base) /* {{{ */ { char *strval = Z_STRVAL_P(op); - Z_LVAL_P(op) = strtol(strval, NULL, base); } /* Skip any leading 0s */ diff --git a/Zend/zend_strtod.c b/Zend/zend_strtod.c index 4546614..d22d646 100644 index 4546614..0348778 100644 --- a/Zend/zend_strtod.c +++ b/Zend/zend_strtod.c @@ -2063,7 +2063,7 @@ ZEND_API double zend_strtod (CONST char *s00, CONST char **se) } else if (*s == '+') { + if (*s == '\0') { s = s00; goto ret; @@ -2074,7 +2074,14 @@ ZEND_API double zend_strtod (CONST char *s00, CONST char **se) @@ -2074,7 +2074,16 @@ ZEND_API double zend_strtod (CONST char *s00, CONST char **se) while(*++s == '0') ; if (!*s) goto ret; + + if (*s == 'x' || *s == 'X') { + return zend_hex_strtod(&s[1], se); + if (s[1] != '\0') + return zend_hex_strtod(&s[1], se); + } else if (*s == 'b' || *s == 'B') { + return zend_bin_strtod(&s[1], se); + if (s[1] != '\0') + return zend_bin_strtod(&s[1], se); + } } + s0 = s; |
Copyright © 2001-2024 The PHP Group All rights reserved. |
Last updated: Wed Apr 24 08:01:29 2024 UTC |