logo       

cvs: ZendEngine2 / zend_highlight.c zend_language_scanner.l /tests bug3541: msg#00040

Subject: cvs: ZendEngine2 / zend_highlight.c zend_language_scanner.l /tests bug35411.phpt bug35655.phpt
iliaa           Tue Dec 13 21:00:33 2005 EDT

  Modified files:              
    /ZendEngine2        zend_highlight.c zend_language_scanner.l 
    /ZendEngine2/tests  bug35411.phpt bug35655.phpt 
  Log:
  MFB51: Fixed bug #35655 (whitespace following end of heredoc is lost).
  
  
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_highlight.c?r1=1.51&r2=1.52&diff_format=u
Index: ZendEngine2/zend_highlight.c
diff -u ZendEngine2/zend_highlight.c:1.51 ZendEngine2/zend_highlight.c:1.52
--- ZendEngine2/zend_highlight.c:1.51   Fri Aug 12 00:01:44 2005
+++ ZendEngine2/zend_highlight.c        Tue Dec 13 21:00:33 2005
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_highlight.c,v 1.51 2005/08/12 00:01:44 sniper Exp $ */
+/* $Id: zend_highlight.c,v 1.52 2005/12/13 21:00:33 iliaa Exp $ */
 
 #include "zend.h"
 #include <zend_language_parser.h>
@@ -78,7 +78,7 @@
        int token_type;
        char *last_color = syntax_highlighter_ini->highlight_html;
        char *next_color;
-       int in_string=0, post_heredoc = 0;
+       int in_string=0;
 
        CG(literal_type) = IS_STRING;
        zend_printf("<code>");
@@ -136,14 +136,9 @@
                switch (token_type) {
                        case T_END_HEREDOC:
                                zend_html_puts(token.value.str.val, 
token.value.str.len TSRMLS_CC);
-                               post_heredoc = 1;
                                break;
                        default:
                                zend_html_puts(LANG_SCNG(yy_text), 
LANG_SCNG(yy_leng) TSRMLS_CC);
-                               if (post_heredoc) {
-                                        zend_html_putc('\n');
-                                        post_heredoc = 0;
-                               }
                                break;
                }
 
@@ -196,19 +191,21 @@
                        case T_DOC_COMMENT:
                                token.type = 0;
                                continue;
-                       
-                       case T_END_HEREDOC: {
-                                       char *ptr = LANG_SCNG(yy_text);
 
-                                       zend_write(ptr, LANG_SCNG(yy_leng) - 1);
-                                       /* The ensure that we only write one ; 
and that it followed by the required newline */
-                                       zend_write("\n", sizeof("\n") - 1);
-                                       if (ptr[LANG_SCNG(yy_leng) - 1] == ';') 
{
-                                               lex_scan(&token TSRMLS_CC);
-                                       }
-                                       efree(Z_UNIVAL(token));
-                               }
-                               break;
+                       case EOF:
+                               return;
+                       
+                       case T_END_HEREDOC:
+                               zend_write(LANG_SCNG(yy_text), 
LANG_SCNG(yy_leng));
+                               efree(token.value.str.val);
+                               /* read the following character, either newline 
or ; */
+                               if (lex_scan(&token TSRMLS_CC) != T_WHITESPACE) 
{
+                                       zend_write(LANG_SCNG(yy_text), 
LANG_SCNG(yy_leng));
+                               }
+                               zend_write("\n", sizeof("\n") - 1);
+                               prev_space = 1;
+                               token.type = 0;
+                               continue;
                        
                        default:
                                zend_write(LANG_SCNG(yy_text), 
LANG_SCNG(yy_leng));
http://cvs.php.net/viewcvs.cgi/ZendEngine2/zend_language_scanner.l?r1=1.140&r2=1.141&diff_format=u
Index: ZendEngine2/zend_language_scanner.l
diff -u ZendEngine2/zend_language_scanner.l:1.140 
ZendEngine2/zend_language_scanner.l:1.141
--- ZendEngine2/zend_language_scanner.l:1.140   Thu Dec  8 03:12:34 2005
+++ ZendEngine2/zend_language_scanner.l Tue Dec 13 21:00:33 2005
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_language_scanner.l,v 1.140 2005/12/08 03:12:34 iliaa Exp $ */
+/* $Id: zend_language_scanner.l,v 1.141 2005/12/13 21:00:33 iliaa Exp $ */
 
 #define yyleng SCNG(yy_leng)
 #define yytext SCNG(yy_text)
@@ -2285,7 +2285,6 @@
 
 <ST_HEREDOC>^{LABEL}(";")?{NEWLINE} {
        int label_len;
-       unsigned char unput_semicolon;
 
        CG(zend_lineno)++;
        if (yytext[yyleng-2]=='\r') {
@@ -2296,17 +2295,12 @@
 
        if (yytext[label_len-1]==';') {
                label_len--;
-               unput_semicolon=1;
-       } else{
-               unput_semicolon=0;
        }
 
        if (label_len==CG(heredoc_len) && !memcmp(yytext, CG(heredoc), 
label_len)) {
                zendlval->value.str.val = estrndup(yytext, label_len); /* unput 
destroys yytext */
                zendlval->value.str.len = label_len;
-               if (unput_semicolon) {
-                       unput(';');
-               }
+               yyless(yyleng - (yyleng - label_len));
                efree(CG(heredoc));
                CG(heredoc)=NULL;
                CG(heredoc_len)=0;
http://cvs.php.net/viewcvs.cgi/ZendEngine2/tests/bug35411.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/bug35411.phpt
diff -u /dev/null ZendEngine2/tests/bug35411.phpt:1.2
--- /dev/null   Tue Dec 13 21:00:33 2005
+++ ZendEngine2/tests/bug35411.phpt     Tue Dec 13 21:00:33 2005
@@ -0,0 +1,19 @@
+--TEST--
+Bug #35411 (Regression with \{$ handling)
+--FILE--
+<?php
+$abc = "bar";
+echo "foo\{$abc}baz\n";
+echo "foo\{ $abc}baz\n";
+echo <<<TEST
+foo{$abc}baz
+foo\{$abc}baz
+foo\{ $abc}baz
+TEST;
+?>
+--EXPECT--
+foo\{bar}baz
+foo\{ bar}baz
+foobarbaz
+foo\{bar}baz
+foo\{ bar}baz
http://cvs.php.net/viewcvs.cgi/ZendEngine2/tests/bug35655.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/bug35655.phpt
diff -u /dev/null ZendEngine2/tests/bug35655.phpt:1.2
--- /dev/null   Tue Dec 13 21:00:33 2005
+++ ZendEngine2/tests/bug35655.phpt     Tue Dec 13 21:00:33 2005
@@ -0,0 +1,18 @@
+--TEST--
+Bug #35655 (whitespace following end of heredoc is lost)
+--FILE--
+<?php
+$code = '
+<? 
+  $x = <<<EOT
+some string    
+EOT
+  $y = 2;
+?>';
+highlight_string($code);
+?>
+--EXPECT--
+<code><span style="color: #000000">
+<br /><span style="color: #0000BB">&lt;?&nbsp;<br 
/>&nbsp;&nbsp;$x&nbsp;</span><span style="color: 
#007700">=&nbsp;&lt;&lt;&lt;EOT<br /></span><span style="color: 
#0000BB">some&nbsp;string&nbsp;&nbsp;&nbsp;&nbsp;<br /></span><span 
style="color: #007700">EOT<br />&nbsp;&nbsp;</span><span style="color: 
#0000BB">$y&nbsp;</span><span style="color: #007700">=&nbsp;</span><span 
style="color: #0000BB">2</span><span style="color: #007700">;<br /></span><span 
style="color: #0000BB">?&gt;</span>
+</span>
+</code>

-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe