]> granicus.if.org Git - php/commitdiff
More cleanup of the zend_strip() function.
authorIlia Alshanetsky <iliaa@php.net>
Thu, 6 Mar 2003 15:38:28 +0000 (15:38 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 6 Mar 2003 15:38:28 +0000 (15:38 +0000)
No longer strip __LINE__, since while it may become useless it could break
code where __LINE__ is passed as a function parameter.

Zend/zend_highlight.c

index 6a6b9d25309190e807d68a8574a7fe9e6243c269..004999d18d4a20cb20021239c966094283ec5c96 100644 (file)
@@ -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:
  */
+