cvs: Zend(PHP_4_3) / zend_highlight.c

From: Date: Thu, 06 Mar 2003 15:41:52 +0000
Subject: cvs: Zend(PHP_4_3) / zend_highlight.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-1001@lists.php.net to get a copy of this message
iliaa Thu Mar 6 10:41:52 2003 EDT Modified files: (Branch: PHP_4_3) /Zend zend_highlight.c Log: MFBZE2 Index: Zend/zend_highlight.c diff -u Zend/zend_highlight.c:1.31.2.2 Zend/zend_highlight.c:1.31.2.3 --- Zend/zend_highlight.c:1.31.2.2 Wed Jan 8 10:39:12 2003 +++ Zend/zend_highlight.c Thu Mar 6 10:41:52 2003 @@ -195,39 +195,41 @@ } - 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 349: - break; + + case T_END_HEREDOC: { + char *ptr = LANG_SCNG(yy_text); - default: { - char c, *ptr=LANG_SCNG(yy_text), *end=LANG_SCNG(yy_text)+LANG_SCNG(yy_leng); - while (ptr<end) { - c = *ptr++; - putchar(c); + 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) { @@ -243,29 +245,15 @@ 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; - } -#ifdef ZEND_MULTIBYTE - if (LANG_SCNG(code)) { - efree(LANG_SCNG(code)); - } - if (LANG_SCNG(current_code)) { - efree(LANG_SCNG(current_code)); + prev_space = token.type = 0; } -#endif /* ZEND_MULTIBYTE */ } + /* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: */ +

« previous php.zend-engine.cvs (#1001) next »