From: Ilia Alshanetsky Date: Thu, 6 Mar 2003 15:38:28 +0000 (+0000) Subject: More cleanup of the zend_strip() function. X-Git-Tag: RELEASE_0_5~591 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b13eb4f5352da0aa54bcc88c9407c40d8202e4e;p=php More cleanup of the zend_strip() function. No longer strip __LINE__, since while it may become useless it could break code where __LINE__ is passed as a function parameter. --- diff --git a/Zend/zend_highlight.c b/Zend/zend_highlight.c index 6a6b9d2530..004999d18d 100644 --- a/Zend/zend_highlight.c +++ b/Zend/zend_highlight.c @@ -185,42 +185,37 @@ ZEND_API void zend_strip(TSRMLS_D) { zval token; int token_type; + int prev_space = 0; token.type = 0; while ((token_type=lex_scan(&token TSRMLS_CC))) { switch (token_type) { - case T_COMMENT: - token.type = 0; - continue; - case T_WHITESPACE: - if (token.type) { + if (!prev_space) { putchar(' '); - token.type = 0; + prev_space = 1; } + /* lack of break; is intentional */ + case T_COMMENT: + token.type = 0; continue; - } - - switch (token_type) { - case T_CLASS: - break; - - default: { + + case T_END_HEREDOC: { char *ptr = LANG_SCNG(yy_text); - if (token_type != T_END_HEREDOC) { - fwrite(ptr, LANG_SCNG(yy_leng), 1, stdout); - } else { - fwrite(ptr, LANG_SCNG(yy_leng) - 1, 1, stdout); - /* The ensure that we only write one ; and that it followed by the required newline */ - putchar('\n'); - if (ptr[LANG_SCNG(yy_leng) - 1] == ';') { - lex_scan(&token TSRMLS_CC); - } - efree(token.value.str.val); + fwrite(ptr, LANG_SCNG(yy_leng) - 1, 1, stdout); + /* The ensure that we only write one ; and that it followed by the required newline */ + putchar('\n'); + if (ptr[LANG_SCNG(yy_leng) - 1] == ';') { + lex_scan(&token TSRMLS_CC); } + efree(token.value.str.val); } break; + + default: + fwrite(LANG_SCNG(yy_text), LANG_SCNG(yy_leng), 1, stdout); + break; } if (token.type == IS_STRING) { @@ -237,7 +232,7 @@ ZEND_API void zend_strip(TSRMLS_D) break; } } - token.type = 0; + prev_space = token.type = 0; } } @@ -248,3 +243,4 @@ ZEND_API void zend_strip(TSRMLS_D) * indent-tabs-mode: t * End: */ +