summaryrefslogtreecommitdiff
path: root/Zend/zend_language_scanner.l
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2000-11-14 17:54:11 +0000
committerStanislav Malyshev <stas@php.net>2000-11-14 17:54:11 +0000
commit0b6a8d0458d37d39f6416935c9e4526f31d7a8bd (patch)
treeab9ebc45f89c20a79c0c359f7c19ec29df750d4a /Zend/zend_language_scanner.l
parentd4f9f8336310b7f49274ebb39ec7372b9f915476 (diff)
downloadphp-git-0b6a8d0458d37d39f6416935c9e4526f31d7a8bd.tar.gz
Better 0x handling - not change non-0x number behaviour
Diffstat (limited to 'Zend/zend_language_scanner.l')
-rw-r--r--Zend/zend_language_scanner.l29
1 files changed, 18 insertions, 11 deletions
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index 1e02fc4818..b537c08141 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -1001,19 +1001,12 @@ ANY_CHAR (.|[\n])
}
-<ST_IN_SCRIPTING>{LNUM}|{HNUM} {
+<ST_IN_SCRIPTING>{LNUM} {
errno = 0;
- zendlval->value.lval = strtoul(yytext, NULL, 0);
+ zendlval->value.lval = strtol(yytext, NULL, 0);
if (errno == ERANGE) { /* overflow */
- if(yytext[0] == 0 && (yytext[1] == 'x' || yytext[1] == 'X') ) {
- /* strtod for 0x'es returns trash */
- zendlval->value.lval = LONG_MAX; /* maximal long */
- zendlval->type = IS_LONG;
- zend_error(E_NOTICE,"Hex number is too big: %s",yytext);
- } else {
- zendlval->value.dval = strtod(yytext,NULL);
- zendlval->type = IS_DOUBLE;
- }
+ zendlval->value.dval = strtod(yytext,NULL);
+ zendlval->type = IS_DOUBLE;
return T_DNUMBER;
} else {
zendlval->type = IS_LONG;
@@ -1021,6 +1014,20 @@ ANY_CHAR (.|[\n])
}
}
+<ST_IN_SCRIPTING>{HNUM} {
+ errno = 0;
+ zendlval->value.lval = strtoul(yytext, NULL, 16);
+ if (errno == ERANGE) { /* overflow */
+ /* not trying strtod - it returns trans on 0x-es */
+ zendlval->value.lval = LONG_MAX; /* maximal long */
+ zend_error(E_NOTICE,"Hex number is too big: %s",yytext);
+ } else {
+ zendlval->type = IS_LONG;
+ }
+ zendlval->type = IS_LONG;
+ return T_LNUMBER;
+}
+
<ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>{LNUM}|{HNUM} { /* treat numbers (almost) as strings inside encapsulated strings */
zendlval->value.str.val = (char *)estrndup(yytext, yyleng);
zendlval->value.str.len = yyleng;