MFZE1 (added zend_strip mode in the highliter)

This commit is contained in:
Sebastian Bergmann 2001-12-11 06:30:30 +00:00
parent 51a29e57f8
commit ff4cc2c6e2
2 changed files with 62 additions and 0 deletions

View File

@ -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

View File

@ -40,6 +40,7 @@ typedef struct _zend_syntax_highlighter_ini {
BEGIN_EXTERN_C()
ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC);
ZEND_API void zend_strip(TSRMLS_D);
ZEND_API int highlight_file(char *filename, zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC);
ZEND_API int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_ini, char *str_name TSRMLS_DC);
ZEND_API void zend_html_putc(char c);