]> granicus.if.org Git - php/commitdiff
Fixed bug #42767 (highlight_string() truncates trailing comment)
authorIlia Alshanetsky <iliaa@php.net>
Wed, 26 Sep 2007 15:43:58 +0000 (15:43 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 26 Sep 2007 15:43:58 +0000 (15:43 +0000)
Zend/tests/bug42767.phpt [new file with mode: 0644]
Zend/zend_highlight.c

diff --git a/Zend/tests/bug42767.phpt b/Zend/tests/bug42767.phpt
new file mode 100644 (file)
index 0000000..0de4dba
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Bug #42767 (highlight_string() truncates trailing comments)
+--FILE--
+<?php
+highlight_string('<?php /*some comment..');
+?>
+--EXPECT--
+<code><span style="color: #000000">
+<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #FF8000">/*some&nbsp;comment..</span>
+</span>
+</code>
index 3daa644d83ad923c92e4ea8fbedd6c0d546b0101..ca7f93b9ff4eb125ba106d823506c0b680966dbe 100644 (file)
@@ -177,6 +177,19 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
                }
                token.type = 0;
        }
+
+       /* handler for trailing comments, see bug #42767 */
+       if (LANG_SCNG(yy_leng) && LANG_SCNG(_yy_more_len)) {
+               if (last_color != syntax_highlighter_ini->highlight_comment) {
+                       if (last_color != syntax_highlighter_ini->highlight_html) {
+                               zend_printf("</span>");
+                       }
+                       if (syntax_highlighter_ini->highlight_comment != syntax_highlighter_ini->highlight_html) {
+                               zend_printf("<span style=\"color: %s\">", syntax_highlighter_ini->highlight_comment);
+                       }
+               }
+               zend_html_puts(LANG_SCNG(yy_text), LANG_SCNG(_yy_more_len) TSRMLS_CC);
+       }
 done:
        if (last_color != syntax_highlighter_ini->highlight_html) {
                zend_printf("</span>\n");
@@ -185,8 +198,6 @@ done:
        zend_printf("</code>");
 }
 
-
-
 ZEND_API void zend_strip(TSRMLS_D)
 {
        zval token;