Re: PHP 4.0 Bug #8247: one line comment ending in ??> vs ???>
| From: | Chris Newbill | Date: | Thu, 14 Dec 2000 05:38:09 +0000 |
| Subject: | Re: PHP 4.0 Bug #8247: one line comment ending in ??> vs ???> | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-41293@lists.php.net to get a copy of this message | ||
This is not a bug the behavior is expected. The extra ? do not mean
anything, the reason it is failing is just the single ?>, which the scanner
will interpret as the end of the php code block.
http://www.php.net/manual/language.basic-syntax.comments.php
Chris
----- Original Message -----
From: <boian@bonev.com>
To: <php-dev@lists.php.net>
Sent: Wednesday, December 13, 2000 10:29 PM
Subject: [PHP-DEV] PHP 4.0 Bug #8247: one line comment ending in ??> vs ???>
> From: boian@bonev.com
> Operating system: Linux glibc 2.1
> PHP version: 4.0.3pl1
> PHP Bug Type: Scripting Engine problem
> Bug description: one line comment ending in ??> vs ???>
>
> case one:
> <?
> // case 1 ??>
> ?>
> case two:
> <?
> // simple case ???>
> ?>
> case three:
> <?
> // stoopid_foo("?>");
> ?>
>
> to resolve the problem(s) i have patched Zend/zend-scanner.l
>
> --- /usr/src/php-4.0.3pl1/Zend/zend-scanner.l Thu Oct 5 20:58:46 2000
> +++ zend-scanner.l Thu Dec 14 07:16:13 2000
> @@ -29,6 +29,10 @@
> %x ST_LOOKING_FOR_PROPERTY
> %x ST_LOOKING_FOR_VARNAME
> %x ST_COMMENT
> +%x ST_ONELINECOMMENT
> +%x ST_ONELINECOMMENT_SQ
> +%x ST_ONELINECOMMENT_DQ
> +%x ST_ONELINECOMMENT_BQ
> %option stack
>
> %{
> @@ -1154,8 +1158,68 @@
> }
>
>
>
> -<ST_IN_SCRIPTING>([#]|"//")([^\n\r?]|"?"[^>\n\r])*("?\n"|"?\r\n")?
> { /*
eat one line comments */
>
> +<ST_IN_SCRIPTING>([#]|"//")([^\n\r?'"
]|("?"+[^?>\n\r'"]))*
> { /* begin
eating one line comments */
> + BEGIN(ST_ONELINECOMMENT);
> + yymore();
> +}
> +
> +<ST_ONELINECOMMENT>([']|("?"+['])) { /* eat single quoted comments
> */
> + BEGIN(ST_ONELINECOMMENT_SQ);
> + yymore();
> +}
> +
> +<ST_ONELINECOMMENT>(["]|("?"+["])) { /* eat double quoted comments
> */
> + BEGIN(ST_ONELINECOMMENT_DQ);
> + yymore();
> +}
> +
> +<ST_ONELINECOMMENT>([]|("?"+[])) { /* eat back
> quoted comments */
> + BEGIN(ST_ONELINECOMMENT_BQ);
> + yymore();
> +}
> +
>
> +<ST_ONELINECOMMENT>("\n"|"\r\n"|("?"+"\n")|("?"+"\r\n"))?
> { /* unexpected
end of line or end of comment */
> + HANDLE_NEWLINE(yytext[yyleng-1]);
> + BEGIN(ST_IN_SCRIPTING);
> + return T_COMMENT;
> +}
> +
> +<ST_ONELINECOMMENT>"?"+">" {
> + yyless(yyleng-2);
> + BEGIN(ST_IN_SCRIPTING);
> + return T_COMMENT;
> +}
> +
> +<ST_ONELINECOMMENT_SQ>([^'\n\r\\]|[\\][^\n\r])* { /* eat quoted content
*/
> + yymore();
> +}
> +
> +<ST_ONELINECOMMENT_DQ>([^"\n\r\\]|[\\][^\n\r])*
> + yymore();
> +}
> +
> +<ST_ONELINECOMMENT_BQ>([^`\n\r\\]|[\\][^\n\r])* {
> + yymore();
> +}
> +
>
> +<ST_ONELINECOMMENT_SQ>[']([^\n\r?'"]|"?"+[^?>\n\r"'])*
> { /* end of
quoted content */
> + BEGIN(ST_ONELINECOMMENT);
> + yymore();
> +}
> +
>
> +<ST_ONELINECOMMENT_DQ>["]([^\n\r?'"]|"?"+[^?>\n\r"'])*
> + BEGIN(ST_ONELINECOMMENT);
> + yymore();
> +}
> +
>
> +<ST_ONELINECOMMENT_BQ>[]([^\n\r?'"]|("?"+[^?>\n\r"'`]))*
> {
> + BEGIN(ST_ONELINECOMMENT);
> + yymore();
> +}
> +
>
+<ST_ONELINECOMMENT_SQ,ST_ONELINECOMMENT_DQ,ST_ONELINECOMMENT_BQ>"\n"|"\r\n"
{ /* unexpected end of line */
> HANDLE_NEWLINE(yytext[yyleng-1]);
> + BEGIN(ST_IN_SCRIPTING);
> return T_COMMENT;
> }
>
>
>
>
> --
> Edit Bug report at: http://bugs.php.net/?id=8247&edit=1
>
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net
> For additional commands, e-mail: php-dev-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>