From: Zeev Suraski Date: Fri, 30 Apr 1999 10:46:48 +0000 (+0000) Subject: * Fix a problem with constant quoted strings, that was causing Thies's problem X-Git-Tag: BEFORE_PHP4_APACHE_MODULE_CHANGE~122 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bc3686c14ad33e0f1479315fadd5e0bcc178ffb4;p=php * Fix a problem with constant quoted strings, that was causing Thies's problem * Remove a development-time printf --- diff --git a/Zend/zend-scanner.l b/Zend/zend-scanner.l index 35f6f50f40..28f8182bf3 100644 --- a/Zend/zend-scanner.l +++ b/Zend/zend-scanner.l @@ -1019,7 +1019,7 @@ ESCAPED_AND_WHITESPACE [\n\t\r #'.:;,()|^&+-/*=%!~<>?@]+ } -(["]([^"$\\]|([\\]+[^\\$]))*["])|([']([^'\\]|([\\]+['\\]))*[']) { +(["]([^$"\\]|("\\".))*["]) { register char *s, *t; char *end; @@ -1051,9 +1051,6 @@ ESCAPED_AND_WHITESPACE [\n\t\r #'.:;,()|^&+-/*=%!~<>?@]+ zendlval->value.str.len--; break; case '\\': - *t++ = '\\'; - zendlval->value.str.len--; - break; case '$': case '"': *t++ = *s; @@ -1075,6 +1072,46 @@ ESCAPED_AND_WHITESPACE [\n\t\r #'.:;,()|^&+-/*=%!~<>?@]+ } +([']([^'\\]|("\\".))*[']) { + register char *s, *t; + char *end; + + zendlval->value.str.val = estrndup(yytext+1, yyleng-2); + zendlval->value.str.len = yyleng-2; + zendlval->type = IS_STRING; + HANDLE_NEWLINES(yytext,yyleng); + + /* convert escape sequences */ + s = t = zendlval->value.str.val; + end = s+zendlval->value.str.len; + while (s=end) { + continue; + } + switch(*s) { + case '\\': + case '\'': + *t++ = *s; + zendlval->value.str.len--; + break; + default: + *t++ = '\\'; + *t++ = *s; + break; + } + s++; + } else { + *t++ = *s++; + } + } + *t = 0; + + return T_CONSTANT_ENCAPSED_STRING; +} + + ["] { BEGIN(DOUBLE_QUOTES); return '\"'; @@ -1298,8 +1335,6 @@ ESCAPED_AND_WHITESPACE [\n\t\r #'.:;,()|^&+-/*=%!~<>?@]+ } - - . { zend_error(E_COMPILE_WARNING,"Unexpected character in input: '%c' (ASCII=%d) state=%d",yytext[0],yytext[0],YYSTATE); } diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index f47cff1a51..64a6b3926e 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1249,7 +1249,6 @@ void do_fetch_constant(znode *result, znode *constant_name, int mode CLS_DC) case ZEND_CT: *result = *constant_name; result->u.constant.type = IS_CONSTANT; - printf("Fetching compiletime constant: '%s'\n", result->u.constant.value.str.val); break; case ZEND_RT: { zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);