From: krakjoe Date: Sat, 15 Feb 2014 23:34:35 +0000 (+0000) Subject: Revert "handle strings better" X-Git-Tag: php-5.6.0beta2~1^2~37^2~20^2~47 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5f899346865bba0657015c4552fd5b90ebdb643e;p=php Revert "handle strings better" This reverts commit a32f1b46540fd8add78f53cc8059f7f749ca3ab8. --- diff --git a/phpdbg_lexer.l b/phpdbg_lexer.l index f916a0bc6a..6915ab62e0 100644 --- a/phpdbg_lexer.l +++ b/phpdbg_lexer.l @@ -11,21 +11,9 @@ #include "phpdbg_parser.h" #include #include - -static inline void phpdbg_param_append(phpdbg_param_t *param, const char *next, size_t nlen) { - if (param->len + nlen > param->addr) { - param->str = realloc( - param->str, param->len + 1024); - param->addr += 1024; - } - memcpy(¶m->str[param->len], next, nlen); - param->len += nlen; - param->str[param->len] = 0; -} %} %s RAW -%s STRING %option outfile="phpdbg_lexer.c" header-file="phpdbg_lexer.h" %option warn nodefault @@ -41,7 +29,6 @@ C_FALSE "false" C_NO "no" C_OFF "off" C_DISABLED "disabled" - C_EVAL "eval" C_SHELL "shell" @@ -50,6 +37,7 @@ ID [a-zA-Z][a-zA-Z0-9_]+ METHOD {ID}::{ID} FILE [^ :0-9]{1,}:[0-9]+ OPLINE 0x[a-fA-F0-9]+ +LITERAL \"(\\.|[^\\"])*\" WS [ \r\n\t]+ INPUT [^\n]+ %% @@ -67,11 +55,11 @@ INPUT [^\n]+ } {C_EVAL} { BEGIN(RAW); - return C_EVAL; + return C_EVAL; } {C_SHELL} { BEGIN(RAW); - return C_SHELL; + return C_SHELL; } {DIGITS} { yylval->type = NUMERIC_PARAM; @@ -95,26 +83,17 @@ INPUT [^\n]+ yylval->addr = strtoul(yytext, NULL, 10); return T_OPLINE; } - {ID} { + {LITERAL} { yylval->type = STR_PARAM; yylval->str = strndup(yytext, yyleng); yylval->len = yyleng; - return T_ID; + return T_LITERAL; } - \" { - BEGIN(STRING); + {ID} { yylval->type = STR_PARAM; - yylval->str = (char*) malloc(28); - yylval->len = 0; - yylval->addr = 28; - } - [^\\"\n]* { phpdbg_param_append(yylval, yytext); } - \\n { phpdbg_param_append(yylval, "\n"); } - \\t { phpdbg_param_append(yylval, "\t"); } - \\[\\"] { phpdbg_param_append(yylval, "\\"); } - \" { - BEGIN(INITIAL); - return T_STRING; + yylval->str = strndup(yytext, yyleng); + yylval->len = yyleng; + return T_ID; } } {INPUT} { diff --git a/phpdbg_parser.y b/phpdbg_parser.y index f8fc5a0a7d..9b87847ebc 100644 --- a/phpdbg_parser.y +++ b/phpdbg_parser.y @@ -98,7 +98,7 @@ typedef void* yyscan_t; %token C_SHELL "shell" %token T_DIGITS "digits (numbers)" -%token T_STRING "literal (T_LITERAL)" +%token T_LITERAL "literal (T_LITERAL)" %token T_METHOD "method (T_METHOD)" %token T_OPLINE "opline (T_OPLINE)" %token T_FILE "file (T_FILE)" @@ -135,7 +135,7 @@ parameter | T_METHOD { $$ = $1; } | T_OPLINE { $$ = $1; } | T_ID { $$ = $1; } - | T_STRING { $$ = $1; } + | T_LITERAL { $$ = $1; } | C_TRUTHY { $$ = $1; } | C_FALSY { $$ = $1; } ;