diff options
author | Sebastian Bergmann <sebastian@php.net> | 2001-12-11 06:30:30 +0000 |
---|---|---|
committer | Sebastian Bergmann <sebastian@php.net> | 2001-12-11 06:30:30 +0000 |
commit | ff4cc2c6e2547f12a7e8d5516403efb6c076fe8d (patch) | |
tree | c0b6a8a9b51c60344bfaa3615dbf6f30810fcbfd /Zend/zend_highlight.c | |
parent | 51a29e57f80edbcaba79740f87b37b1d4612a2e9 (diff) | |
download | php-git-ff4cc2c6e2547f12a7e8d5516403efb6c076fe8d.tar.gz |
MFZE1 (added zend_strip mode in the highliter)
Diffstat (limited to 'Zend/zend_highlight.c')
-rw-r--r-- | Zend/zend_highlight.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/Zend/zend_highlight.c b/Zend/zend_highlight.c index ec14175320..3d2482c734 100644 --- a/Zend/zend_highlight.c +++ b/Zend/zend_highlight.c @@ -173,6 +173,67 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini zend_printf("</code>"); } + + +ZEND_API void zend_strip(TSRMLS_D) +{ + zval token; + int token_type; + + token.type = 0; + while ((token_type=lex_scan(&token TSRMLS_CC))) { + switch (token_type) { + case T_COMMENT: + token.type = 0; + break; + + case T_WHITESPACE: + if (token.type) { + putchar(' '); + token.type = 0; + } + continue; + } + + switch (token_type) { + case 349: + break; + + default: { + char c, *ptr=LANG_SCNG(yy_text), *end=LANG_SCNG(yy_text)+LANG_SCNG(yy_leng); + while (ptr<end) { + c = *ptr++; + putchar(c); + } + } + break; + } + + if (token.type == IS_STRING) { + switch (token_type) { + case T_OPEN_TAG: + case T_OPEN_TAG_WITH_ECHO: + case T_CLOSE_TAG: + case T_WHITESPACE: + case T_COMMENT: + break; + + default: + efree(token.value.str.val); + break; + } + } else if (token_type == T_END_HEREDOC) { + zend_bool has_semicolon=(strchr(token.value.str.val, ';')?1:0); + + efree(token.value.str.val); + if (has_semicolon) { + /* the following semicolon was unput(), ignore it */ + lex_scan(&token TSRMLS_CC); + } + } + token.type = 0; + } +} /* * Local variables: * tab-width: 4 |