Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_language_parser.y zend_language_scanner.l
[email protected] ("Matt Wilmas") Thu, 26 Mar 2009 15:38:14 -0500
| Newsgroups | php.internals,php.zend-engine.cvs |
|---|---|
| Message-ID | <FD714740EF424384BE4AA3207FAA147A@pc1> |
Hi Dmitry,
I had looked at this Bug and wondering whether it should be fixed (I guess
the answer is yes :-)) and how to do so. I was only thinking along the
lines of adding a stack to keep track of multiple heredocs in the scanner.
Then I saw your fix and thought it was a cool method and better than
whatever came to my mind...
However, it seems there's nothing to handle nested heredocs in
zend_highlight/strip, tokenizer, etc., so they will break there (I think
only the "inner" heredoc's ending label will be found). Plus memory leak
too I guess -- though that would have happened before as well if someone
tried to nest heredocs...
- Matt
----- Original Message -----
From: "Dmitry Stogov"
Sent: Thursday, March 26, 2009
> dmitry Thu Mar 26 12:38:10 2009 UTC
>
> Modified files:
> /ZendEngine2 zend_language_parser.y zend_language_scanner.l
> Log:
> Fixed bug #47516 (nowdoc can not be embed in heredoc but can be embed in
> double quote)
>
>
> http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_language_parser.y?r1=1.214&r2=1.215&diff_format=u
> Index: ZendEngine2/zend_language_parser.y
> diff -u ZendEngine2/zend_language_parser.y:1.214
> ZendEngine2/zend_language_parser.y:1.215
> --- ZendEngine2/zend_language_parser.y:1.214 Wed Dec 31 11:09:46 2008
> +++ ZendEngine2/zend_language_parser.y Thu Mar 26 12:38:10 2009
> @@ -18,7 +18,7 @@
>
> +----------------------------------------------------------------------+
> */
>
> -/* $Id: zend_language_parser.y,v 1.214 2008/12/31 11:09:46 sebastian Exp
> $ */
> +/* $Id: zend_language_parser.y,v 1.215 2009/03/26 12:38:10 dmitry Exp $
> */
>
> /*
> * LALR shift/reduce conflicts and how they are resolved:
> @@ -768,13 +768,13 @@
> | T_METHOD_C { $$ = $1; }
> | T_FUNC_C { $$ = $1; }
> | T_NS_C { $$ = $1; }
> - | start_heredoc T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC { $$ = $2; }
> - | start_heredoc T_END_HEREDOC { if (CG(literal_type) == IS_UNICODE) {
> ZVAL_EMPTY_UNICODE(&$$.u.constant); } else {
> ZVAL_EMPTY_STRING(&$$.u.constant); } INIT_PZVAL(&$$.u.constant);
> $$.op_type = IS_CONST; }
> + | start_heredoc T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC { $$ = $2;
> CG(heredoc) = Z_STRVAL($1.u.constant); CG(heredoc_len) =
> Z_STRLEN($1.u.constant); }
> + | start_heredoc T_END_HEREDOC { if (CG(literal_type) == IS_UNICODE) {
> ZVAL_EMPTY_UNICODE(&$$.u.constant); } else {
> ZVAL_EMPTY_STRING(&$$.u.constant); } INIT_PZVAL(&$$.u.constant);
> $$.op_type = IS_CONST; CG(heredoc) = Z_STRVAL($1.u.constant);
> CG(heredoc_len) = Z_STRLEN($1.u.constant); }
> ;
>
> start_heredoc:
> - T_START_HEREDOC { CG(literal_type) =
> UG(unicode)?IS_UNICODE:IS_STRING; }
> - | T_BINARY_HEREDOC { CG(literal_type) = IS_STRING; }
> + T_START_HEREDOC { CG(literal_type) = UG(unicode)?IS_UNICODE:IS_STRING;
> $$ = $1; }
> + | T_BINARY_HEREDOC { CG(literal_type) = IS_STRING; $$ = $1; }
> ;
>
>
> @@ -802,7 +802,7 @@
> | common_scalar { $$ = $1; }
> | '"' { CG(literal_type) = UG(unicode)?IS_UNICODE:IS_STRING; }
> encaps_list '"' { $$ = $3; }
> | T_BINARY_DOUBLE { CG(literal_type) = IS_STRING; } encaps_list '"' { $$
> = $3; }
> - | start_heredoc encaps_list T_END_HEREDOC { $$ = $2; }
> + | start_heredoc encaps_list T_END_HEREDOC { $$ = $2; CG(heredoc) =
> Z_STRVAL($1.u.constant); CG(heredoc_len) = Z_STRLEN($1.u.constant); }
> ;
>
>
> http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_language_scanner.l?r1=1.203&r2=1.204&diff_format=u
> Index: ZendEngine2/zend_language_scanner.l
> diff -u ZendEngine2/zend_language_scanner.l:1.203
> ZendEngine2/zend_language_scanner.l:1.204
> --- ZendEngine2/zend_language_scanner.l:1.203 Wed Mar 25 15:24:27 2009
> +++ ZendEngine2/zend_language_scanner.l Thu Mar 26 12:38:10 2009
> @@ -21,7 +21,7 @@
>
> +----------------------------------------------------------------------+
> */
>
> -/* $Id: zend_language_scanner.l,v 1.203 2009/03/25 15:24:27 dmitry Exp $
> */
> +/* $Id: zend_language_scanner.l,v 1.204 2009/03/26 12:38:10 dmitry Exp $
> */
>
> #if 0
> # define YYDEBUG(s, c) printf("state: %d char: %c\n", s, c)
> @@ -2402,6 +2402,10 @@
> char *s;
> int bprefix = (yytext[0] != '<') ? 1 : 0;
>
> + /* save old heredoc label */
> + Z_STRVAL_P(zendlval) = CG(heredoc);
> + Z_STRLEN_P(zendlval) = CG(heredoc_len);
> +
> CG(zend_lineno)++;
> CG(heredoc_len) = yyleng-bprefix-3-1-(yytext[yyleng-2]=='\r'?1:0);
> s = yytext+bprefix+3;
>
>