summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorJani Taskinen <jani@php.net>2010-03-11 10:24:29 +0000
committerJani Taskinen <jani@php.net>2010-03-11 10:24:29 +0000
commit06f072cb5e4e3582e20b8762141eccbc4dce85fa (patch)
tree511382440db96edad3a2627ce361113e29d672ab /Zend
parentf60946eb5430cd11daa9f88503dc9b1a9b7bd634 (diff)
downloadphp-git-06f072cb5e4e3582e20b8762141eccbc4dce85fa.tar.gz
MFH: Improved / fixed output buffering (Michael Wallner)
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend_highlight.c45
-rw-r--r--Zend/zend_indent.c28
2 files changed, 37 insertions, 36 deletions
diff --git a/Zend/zend_highlight.c b/Zend/zend_highlight.c
index 171789b83b..a229fb6dda 100644
--- a/Zend/zend_highlight.c
+++ b/Zend/zend_highlight.c
@@ -26,7 +26,7 @@
#include "zend_ptr_stack.h"
#include "zend_globals.h"
-ZEND_API void zend_html_putc(char c)
+ZEND_API void zend_html_putc(char c) /* {{{ */
{
switch (c) {
case '\n':
@@ -52,9 +52,9 @@ ZEND_API void zend_html_putc(char c)
break;
}
}
+/* }}} */
-
-ZEND_API void zend_html_puts(const char *s, uint len TSRMLS_DC)
+ZEND_API void zend_html_puts(const char *s, uint len TSRMLS_DC) /* {{{ */
{
const char *ptr=s, *end=s+len;
@@ -85,9 +85,9 @@ ZEND_API void zend_html_puts(const char *s, uint len TSRMLS_DC)
}
#endif /* ZEND_MULTIBYTE */
}
+/* }}} */
-
-ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC)
+ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini TSRMLS_DC) /* {{{ */
{
zval token;
int token_type;
@@ -97,7 +97,7 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
zend_printf("<code>");
zend_printf("<span style=\"color: %s\">\n", last_color);
/* highlight stuff coming back from zendlex() */
- token.type = 0;
+ Z_TYPE(token) = 0;
while ((token_type=lex_scan(&token TSRMLS_CC))) {
switch (token_type) {
case T_INLINE_HTML:
@@ -121,11 +121,11 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
break;
case T_WHITESPACE:
zend_html_puts(LANG_SCNG(yy_text), LANG_SCNG(yy_leng) TSRMLS_CC); /* no color needed */
- token.type = 0;
+ Z_TYPE(token) = 0;
continue;
break;
default:
- if (token.type == 0) {
+ if (Z_TYPE(token) == 0) {
next_color = syntax_highlighter_ini->highlight_keyword;
} else {
next_color = syntax_highlighter_ini->highlight_default;
@@ -145,7 +145,7 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
zend_html_puts(LANG_SCNG(yy_text), LANG_SCNG(yy_leng) TSRMLS_CC);
- if (token.type == IS_STRING) {
+ if (Z_TYPE(token) == IS_STRING) {
switch (token_type) {
case T_OPEN_TAG:
case T_OPEN_TAG_WITH_ECHO:
@@ -155,13 +155,13 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
case T_DOC_COMMENT:
break;
default:
- efree(token.value.str.val);
+ efree(Z_STRVAL(token));
break;
}
} else if (token_type == T_END_HEREDOC) {
- efree(token.value.str.val);
+ efree(Z_STRVAL(token));
}
- token.type = 0;
+ Z_TYPE(token) = 0;
}
if (last_color != syntax_highlighter_ini->highlight_html) {
@@ -170,14 +170,15 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
zend_printf("</span>\n");
zend_printf("</code>");
}
+/* }}} */
-ZEND_API void zend_strip(TSRMLS_D)
+ZEND_API void zend_strip(TSRMLS_D) /* {{{ */
{
zval token;
int token_type;
int prev_space = 0;
- token.type = 0;
+ Z_TYPE(token) = 0;
while ((token_type=lex_scan(&token TSRMLS_CC))) {
switch (token_type) {
case T_WHITESPACE:
@@ -188,19 +189,19 @@ ZEND_API void zend_strip(TSRMLS_D)
/* lack of break; is intentional */
case T_COMMENT:
case T_DOC_COMMENT:
- token.type = 0;
+ Z_TYPE(token) = 0;
continue;
-
+
case T_END_HEREDOC:
zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
- efree(token.value.str.val);
+ efree(Z_STRVAL(token));
/* read the following character, either newline or ; */
if (lex_scan(&token TSRMLS_CC) != T_WHITESPACE) {
zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
}
zend_write("\n", sizeof("\n") - 1);
prev_space = 1;
- token.type = 0;
+ Z_TYPE(token) = 0;
continue;
default:
@@ -208,7 +209,7 @@ ZEND_API void zend_strip(TSRMLS_D)
break;
}
- if (token.type == IS_STRING) {
+ if (Z_TYPE(token) == IS_STRING) {
switch (token_type) {
case T_OPEN_TAG:
case T_OPEN_TAG_WITH_ECHO:
@@ -219,13 +220,14 @@ ZEND_API void zend_strip(TSRMLS_D)
break;
default:
- efree(token.value.str.val);
+ efree(Z_STRVAL(token));
break;
}
}
- prev_space = token.type = 0;
+ prev_space = Z_TYPE(token) = 0;
}
}
+/* }}} */
/*
* Local variables:
@@ -234,4 +236,3 @@ ZEND_API void zend_strip(TSRMLS_D)
* indent-tabs-mode: t
* End:
*/
-
diff --git a/Zend/zend_indent.c b/Zend/zend_indent.c
index 8c44c50cd0..edcd252a85 100644
--- a/Zend/zend_indent.c
+++ b/Zend/zend_indent.c
@@ -30,11 +30,10 @@
#define zendtext LANG_SCNG(yy_text)
#define zendleng LANG_SCNG(yy_leng)
-
-static void handle_whitespace(int *emit_whitespace)
+static void handle_whitespace(unsigned int *emit_whitespace) /* {{{ */
{
unsigned char c;
- int i;
+ unsigned int i;
for (c=0; c<128; c++) {
if (emit_whitespace[c]>0) {
@@ -45,29 +44,29 @@ static void handle_whitespace(int *emit_whitespace)
}
memset(emit_whitespace, 0, sizeof(int)*256);
}
+/* }}} */
-
-ZEND_API void zend_indent()
+ZEND_API void zend_indent(void) /* {{{ */
{
zval token;
int token_type;
int in_string=0;
- int nest_level=0;
- int emit_whitespace[256];
- int i;
+ unsigned int nest_level=0;
+ unsigned int emit_whitespace[256];
+ unsigned int i;
TSRMLS_FETCH();
memset(emit_whitespace, 0, sizeof(int)*256);
/* highlight stuff coming back from zendlex() */
- token.type = 0;
+ Z_TYPE(token) = 0;
while ((token_type=lex_scan(&token TSRMLS_CC))) {
switch (token_type) {
case T_INLINE_HTML:
zend_write(LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
break;
case T_WHITESPACE: {
- token.type = 0;
+ Z_TYPE(token) = 0;
/* eat whitespace, emit newlines */
for (i=0; i<LANG_SCNG(yy_leng); i++) {
emit_whitespace[(unsigned char) LANG_SCNG(yy_text)[i]]++;
@@ -79,7 +78,7 @@ ZEND_API void zend_indent()
in_string = !in_string;
/* break missing intentionally */
default:
- if (token.type==0) {
+ if (Z_TYPE(token)==0) {
/* keyword */
switch (token_type) {
case ',':
@@ -132,20 +131,21 @@ dflt_printout:
}
break;
}
- if (token.type == IS_STRING) {
+ if (Z_TYPE(token) == IS_STRING) {
switch (token_type) {
case T_OPEN_TAG:
case T_CLOSE_TAG:
case T_WHITESPACE:
break;
default:
- efree(token.value.str.val);
+ efree(Z_STRVAL(token));
break;
}
}
- token.type = 0;
+ Z_TYPE(token) = 0;
}
}
+/* }}} */
/*
* Local variables: