]> granicus.if.org Git - php/commitdiff
Fixed in zend_strip() that corrupted heredoc.
authorIlia Alshanetsky <iliaa@php.net>
Thu, 6 Mar 2003 14:47:13 +0000 (14:47 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 6 Mar 2003 14:47:13 +0000 (14:47 +0000)
Optimized the writing routine by moving from putchar() to fwrite().
Changed hardcoded opcode # to it's defined name.

Zend/zend_highlight.c

index 22a87cf71f6e5a9f82b6102e549ee05153ddc458..6a6b9d25309190e807d68a8574a7fe9e6243c269 100644 (file)
@@ -202,14 +202,22 @@ ZEND_API void zend_strip(TSRMLS_D)
                }
 
                switch (token_type) {
-                       case 349:
+                       case T_CLASS:
                                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);
+                                       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);
                                        }
                                }
                                break;
@@ -228,14 +236,6 @@ ZEND_API void zend_strip(TSRMLS_D)
                                        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;
        }