Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
diff --git a/Zend/zend.c b/Zend/zend.c
index dd299f1..d3501eb 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -466,20 +466,14 @@ static FILE *zend_fopen_wrapper(const char *filename, char **opened_path TSRMLS_
/* }}} */
#ifdef ZTS
-static zend_bool asp_tags_default = 0;
-static zend_bool short_tags_default = 1;
static zend_uint compiler_options_default = ZEND_COMPILE_DEFAULT;
#else
-# define asp_tags_default 0
-# define short_tags_default 1
# define compiler_options_default ZEND_COMPILE_DEFAULT
#endif
static void zend_set_default_compile_time_values(TSRMLS_D) /* {{{ */
{
/* default compile-time values */
- CG(asp_tags) = asp_tags_default;
- CG(short_tags) = short_tags_default;
CG(compiler_options) = compiler_options_default;
}
/* }}} */
@@ -788,8 +782,6 @@ void zend_post_startup(TSRMLS_D) /* {{{ */
*GLOBAL_CLASS_TABLE = *compiler_globals->class_table;
*GLOBAL_CONSTANTS_TABLE = *executor_globals->zend_constants;
- asp_tags_default = CG(asp_tags);
- short_tags_default = CG(short_tags);
compiler_options_default = CG(compiler_options);
zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC);
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index c3c35eb..04c6d01 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -196,6 +196,7 @@ void zend_init_compiler_data_structures(TSRMLS_D) /* {{{ */
zend_llist_init(&CG(dimension_llist), sizeof(int), NULL, 0);
zend_stack_init(&CG(list_stack));
CG(in_compilation) = 0;
+ CG(first_token) = 1;
CG(start_lineno) = 0;
CG(current_namespace) = NULL;
CG(in_namespace) = 0;
@@ -6690,24 +6691,24 @@ again:
Z_TYPE(zendlval->u.constant) = IS_LONG;
retval = lex_scan(&zendlval->u.constant TSRMLS_CC);
switch (retval) {
+ case T_OPEN_TAG:
+ if (CG(first_token)) {
+ goto again;
+ }
+ zend_error(E_COMPILE_ERROR, "Open tag must occur at the top of the script");
+ break;
+
case T_COMMENT:
case T_DOC_COMMENT:
- case T_OPEN_TAG:
case T_WHITESPACE:
goto again;
case T_CLOSE_TAG:
- if (LANG_SCNG(yy_text)[LANG_SCNG(yy_leng)-1] != '>') {
- CG(increment_lineno) = 1;
- }
- if (CG(has_bracketed_namespaces) && !CG(in_namespace)) {
- goto again;
+ if (CG(has_bracketed_namespaces) && CG(in_namespace)) {
+ zend_error(E_COMPILE_ERROR, "Close tag may not occur in the namespace");
}
retval = ';'; /* implicit ; */
break;
- case T_OPEN_TAG_WITH_ECHO:
- retval = T_ECHO;
- break;
case T_END_HEREDOC:
efree(Z_STRVAL(zendlval->u.constant));
break;
@@ -6715,6 +6716,7 @@ again:
INIT_PZVAL(&zendlval->u.constant);
zendlval->op_type = IS_CONST;
+ CG(first_token) = 0;
return retval;
}
/* }}} */
diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h
index dbbcf97..0f9d0d5 100644
--- a/Zend/zend_globals.h
+++ b/Zend/zend_globals.h
@@ -103,8 +103,7 @@ struct _zend_compiler_globals {
zend_bool parse_error;
zend_bool in_compilation;
- zend_bool short_tags;
- zend_bool asp_tags;
+ zend_bool first_token;
zend_declarables declarables;
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index d530b53..52f255d 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -519,7 +519,7 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle TSRMLS_DC)
zend_error_noreturn(E_COMPILE_ERROR, "zend_stream_mmap() failed");
}
- BEGIN(INITIAL);
+ BEGIN(ST_IN_SCRIPTING);
if (file_handle->opened_path) {
file_path = file_handle->opened_path;
@@ -812,7 +812,7 @@ int highlight_string(zval *str, zend_syntax_highlighter_ini *syntax_highlighter_
zend_restore_lexical_state(&original_lex_state TSRMLS_CC);
return FAILURE;
}
- BEGIN(INITIAL);
+ BEGIN(ST_IN_SCRIPTING);
zend_highlight(syntax_highlighter_ini TSRMLS_CC);
if (SCNG(script_filtered)) {
efree(SCNG(script_filtered));
@@ -1705,142 +1705,32 @@ NEWLINE ("\r"|"\n"|"\r\n")
return T_NS_C;
}
-<INITIAL>"<script"{WHITESPACE}+"language"{WHITESPACE}*"="{WHITESPACE}*("php"|"\"php\""|"'php'"){WHITESPACE}*">" {
- YYCTYPE *bracket = (YYCTYPE*)zend_memrchr(yytext, '<', yyleng - (sizeof("script language=php>") - 1));
-
- if (bracket != SCNG(yy_text)) {
- /* Handle previously scanned HTML, as possible <script> tags found are assumed to not be PHP's */
- YYCURSOR = bracket;
- goto inline_html;
- }
-
- HANDLE_NEWLINES(yytext, yyleng);
+<ST_IN_SCRIPTING>"<%" {
zendlval->value.str.val = yytext; /* no copying - intentional */
zendlval->value.str.len = yyleng;
zendlval->type = IS_STRING;
- BEGIN(ST_IN_SCRIPTING);
return T_OPEN_TAG;
}
-<INITIAL>"<%=" {
- if (CG(asp_tags)) {
- zendlval->value.str.val = yytext; /* no copying - intentional */
- zendlval->value.str.len = yyleng;
- zendlval->type = IS_STRING;
- BEGIN(ST_IN_SCRIPTING);
- return T_OPEN_TAG_WITH_ECHO;
- } else {
- goto inline_char_handler;
- }
-}
-
-
-<INITIAL>"<?=" {
+<ST_IN_SCRIPTING>"<?php"([ \t]|{NEWLINE}) {
zendlval->value.str.val = yytext; /* no copying - intentional */
zendlval->value.str.len = yyleng;
zendlval->type = IS_STRING;
- BEGIN(ST_IN_SCRIPTING);
- return T_OPEN_TAG_WITH_ECHO;
-}
-
-
-<INITIAL>"<%" {
- if (CG(asp_tags)) {
- zendlval->value.str.val = yytext; /* no copying - intentional */
- zendlval->value.str.len = yyleng;
- zendlval->type = IS_STRING;
- BEGIN(ST_IN_SCRIPTING);
- return T_OPEN_TAG;
- } else {
- goto inline_char_handler;
- }
+ HANDLE_NEWLINE(yytext[yyleng-1]);
+ return T_OPEN_TAG;
}
-<INITIAL>"<?php"([ \t]|{NEWLINE}) {
+<ST_IN_SCRIPTING>"<?" {
zendlval->value.str.val = yytext; /* no copying - intentional */
zendlval->value.str.len = yyleng;
zendlval->type = IS_STRING;
- HANDLE_NEWLINE(yytext[yyleng-1]);
BEGIN(ST_IN_SCRIPTING);
return T_OPEN_TAG;
}
-<INITIAL>"<?" {
- if (CG(short_tags)) {
- zendlval->value.str.val = yytext; /* no copying - intentional */
- zendlval->value.str.len = yyleng;
- zendlval->type = IS_STRING;
- BEGIN(ST_IN_SCRIPTING);
- return T_OPEN_TAG;
- } else {
- goto inline_char_handler;
- }
-}
-
-<INITIAL>{ANY_CHAR} {
- if (YYCURSOR > YYLIMIT) {
- return 0;
- }
-
-inline_char_handler:
-
- while (1) {
- YYCTYPE *ptr = memchr(YYCURSOR, '<', YYLIMIT - YYCURSOR);
-
- YYCURSOR = ptr ? ptr + 1 : YYLIMIT;
-
- if (YYCURSOR < YYLIMIT) {
- switch (*YYCURSOR) {
- case '?':
- if (CG(short_tags) || !strncasecmp((char*)YYCURSOR + 1, "php", 3) || (*(YYCURSOR + 1) == '=')) { /* Assume [ \t\n\r] follows "php" */
- break;
- }
- continue;
- case '%':
- if (CG(asp_tags)) {
- break;
- }
- continue;
- case 's':
- case 'S':
- /* Probably NOT an opening PHP <script> tag, so don't end the HTML chunk yet
- * If it is, the PHP <script> tag rule checks for any HTML scanned before it */
- YYCURSOR--;
- yymore();
- default:
- continue;
- }
-
- YYCURSOR--;
- }
-
- break;
- }
-
-inline_html:
- yyleng = YYCURSOR - SCNG(yy_text);
-
- if (SCNG(output_filter)) {
- int readsize;
- size_t sz = 0;
- readsize = SCNG(output_filter)((unsigned char **)&(zendlval->value.str.val), &sz, (unsigned char *)yytext, (size_t)yyleng TSRMLS_CC);
- zendlval->value.str.len = sz;
- if (readsize < yyleng) {
- yyless(readsize);
- }
- } else {
- zendlval->value.str.val = (char *) estrndup(yytext, yyleng);
- zendlval->value.str.len = yyleng;
- }
- zendlval->type = IS_STRING;
- HANDLE_NEWLINES(yytext, yyleng);
- return T_INLINE_HTML;
-}
-
-
/* Make sure a label character follows "->", otherwise there is no property
* and "->" will be taken literally
*/
@@ -1904,10 +1794,6 @@ inline_html:
CG(zend_lineno)++;
break;
case '%':
- if (!CG(asp_tags)) {
- continue;
- }
- /* fall through */
case '?':
if (*YYCURSOR == '>') {
YYCURSOR--;
@@ -1964,22 +1850,15 @@ inline_html:
zendlval->value.str.val = yytext; /* no copying - intentional */
zendlval->value.str.len = yyleng;
zendlval->type = IS_STRING;
- BEGIN(INITIAL);
return T_CLOSE_TAG; /* implicit ';' at php-end tag */
}
<ST_IN_SCRIPTING>"%>"{NEWLINE}? {
- if (CG(asp_tags)) {
- BEGIN(INITIAL);
- zendlval->value.str.len = yyleng;
- zendlval->type = IS_STRING;
- zendlval->value.str.val = yytext; /* no copying - intentional */
- return T_CLOSE_TAG; /* implicit ';' at php-end tag */
- } else {
- yyless(1);
- return yytext[0];
- }
+ zendlval->value.str.len = yyleng;
+ zendlval->type = IS_STRING;
+ zendlval->value.str.val = yytext; /* no copying - intentional */
+ return T_CLOSE_TAG; /* implicit ';' at php-end tag */
}
diff --git a/Zend/zend_language_scanner_defs.h b/Zend/zend_language_scanner_defs.h
index 015a903..ff8d13a 100644
--- a/Zend/zend_language_scanner_defs.h
+++ b/Zend/zend_language_scanner_defs.h
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Thu Mar 1 21:27:30 2012 */
+/* Generated by re2c 0.13.5 on Sun Apr 1 01:38:20 2012 */
#line 3 "Zend/zend_language_scanner_defs.h"
enum YYCONDTYPE {
@@ -9,7 +9,6 @@ enum YYCONDTYPE {
yycST_HEREDOC,
yycST_LOOKING_FOR_VARNAME,
yycST_VAR_OFFSET,
- yycINITIAL,
yycST_END_HEREDOC,
yycST_NOWDOC,
};
diff --git a/ext/tokenizer/tokenizer.c b/ext/tokenizer/tokenizer.c
index c5cbf6c..effa815 100644
--- a/ext/tokenizer/tokenizer.c
+++ b/ext/tokenizer/tokenizer.c
@@ -121,7 +121,6 @@ static void tokenize(zval *return_value TSRMLS_DC)
CG(zend_lineno)++;
}
case T_OPEN_TAG:
- case T_OPEN_TAG_WITH_ECHO:
case T_WHITESPACE:
case T_COMMENT:
case T_DOC_COMMENT:
@@ -200,7 +199,7 @@ PHP_FUNCTION(token_get_all)
RETURN_FALSE;
}
- LANG_SCNG(yy_state) = yycINITIAL;
+ LANG_SCNG(yy_state) = yycST_IN_SCRIPTING;
tokenize(return_value TSRMLS_CC);
diff --git a/main/main.c b/main/main.c
index 6ec8d79..ba6a49d 100644
--- a/main/main.c
+++ b/main/main.c
@@ -483,7 +483,6 @@ PHP_INI_BEGIN()
PHP_INI_ENTRY_EX("highlight.keyword", HL_KEYWORD_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
PHP_INI_ENTRY_EX("highlight.string", HL_STRING_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
- STD_PHP_INI_BOOLEAN("asp_tags", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, asp_tags, zend_compiler_globals, compiler_globals)
STD_PHP_INI_ENTRY_EX("display_errors", "1", PHP_INI_ALL, OnUpdateDisplayErrors, display_errors, php_core_globals, core_globals, display_errors_mode)
STD_PHP_INI_BOOLEAN("display_startup_errors", "0", PHP_INI_ALL, OnUpdateBool, display_startup_errors, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateBool, enable_dl, php_core_globals, core_globals)
@@ -506,7 +505,6 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("output_handler", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateString, output_handler, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("register_argc_argv", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_argc_argv, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("auto_globals_jit", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, auto_globals_jit, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("short_open_tag", DEFAULT_SHORT_OPEN_TAG, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, short_tags, zend_compiler_globals, compiler_globals)
STD_PHP_INI_BOOLEAN("sql.safe_mode", "0", PHP_INI_SYSTEM, OnUpdateBool, sql_safe_mode, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("track_errors", "0", PHP_INI_ALL, OnUpdateBool, track_errors, php_core_globals, core_globals)
@yohgaki

Nice work. I would like to see option that controls w/ and w/o tag ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.