summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2007-09-26 15:46:28 +0000
committerIlia Alshanetsky <iliaa@php.net>2007-09-26 15:46:28 +0000
commit43f492c872d5365b49fa33e269671748b6cd05f1 (patch)
tree68a276abad53efcd03f550867900cbea1dd9950a
parented72c6c50b522fd56c6b946a054192a26a638410 (diff)
downloadphp-git-43f492c872d5365b49fa33e269671748b6cd05f1.tar.gz
MFB: Fixed bug #42767 (highlight_string() truncates trailing comment).
-rw-r--r--Zend/tests/bug42767.phpt11
-rw-r--r--Zend/zend_highlight.c14
2 files changed, 25 insertions, 0 deletions
diff --git a/Zend/tests/bug42767.phpt b/Zend/tests/bug42767.phpt
new file mode 100644
index 0000000000..0de4dba5fb
--- /dev/null
+++ b/Zend/tests/bug42767.phpt
@@ -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>
diff --git a/Zend/zend_highlight.c b/Zend/zend_highlight.c
index 07445f1fc8..de411506c9 100644
--- a/Zend/zend_highlight.c
+++ b/Zend/zend_highlight.c
@@ -160,6 +160,20 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
}
Z_TYPE(token) = 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);
+ }
+
if (last_color != syntax_highlighter_ini->highlight_html) {
zend_printf("</span>\n");
}