Skip to content

Instantly share code, notes, and snippets.

@moriyoshi
Created March 21, 2009 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moriyoshi/82926 to your computer and use it in GitHub Desktop.
Save moriyoshi/82926 to your computer and use it in GitHub Desktop.
Index: Zend/zend_language_scanner.l
===================================================================
RCS file: /repository/ZendEngine2/zend_language_scanner.l,v
retrieving revision 1.131.2.11.2.13.2.35
diff -u -r1.131.2.11.2.13.2.35 zend_language_scanner.l
--- Zend/zend_language_scanner.l 9 Jan 2009 17:21:12 -0000 1.131.2.11.2.13.2.35
+++ Zend/zend_language_scanner.l 21 Mar 2009 18:39:29 -0000
@@ -1093,6 +1093,9 @@
}
<ST_IN_SCRIPTING>"\\" {
+ if (CG(ns_separator)[0] == '\0' || *yytext != CG(ns_separator)[0] || CG(ns_separator)[1] != '\0') {
+ zend_error_noreturn(E_COMPILE_ERROR, "%c is not a namespace separator", *yytext);
+ }
return T_NS_SEPARATOR;
}
@@ -1709,7 +1712,23 @@
return T_ENCAPSED_AND_WHITESPACE;
}
-<ST_IN_SCRIPTING,ST_VAR_OFFSET>{LABEL} {
+<ST_IN_SCRIPTING>{LABEL} {
+ size_t l = strlen(CG(ns_separator));
+ char *p = zend_memnstr(yytext, CG(ns_separator), l, yytext + yyleng);
+ if (p) {
+ if (p == yytext) {
+ yyless(l);
+ return T_NS_SEPARATOR;
+ } else {
+ yyless((p - yytext));
+ }
+ }
+ zend_copy_value(zendlval, yytext, yyleng);
+ zendlval->type = IS_STRING;
+ return T_STRING;
+}
+
+<ST_VAR_OFFSET>{LABEL} {
zend_copy_value(zendlval, yytext, yyleng);
zendlval->type = IS_STRING;
return T_STRING;
Index: Zend/zend_globals.h
===================================================================
RCS file: /repository/ZendEngine2/zend_globals.h,v
retrieving revision 1.141.2.3.2.7.2.22
diff -u -r1.141.2.3.2.7.2.22 zend_globals.h
--- Zend/zend_globals.h 16 Jan 2009 00:57:43 -0000 1.141.2.3.2.7.2.22
+++ Zend/zend_globals.h 21 Mar 2009 18:39:29 -0000
@@ -140,6 +140,8 @@
HashTable *labels;
zend_stack labels_stack;
+ char *ns_separator;
+
#ifdef ZEND_MULTIBYTE
zend_encoding **script_encoding_list;
size_t script_encoding_list_size;
Index: Zend/zend.c
===================================================================
RCS file: /repository/ZendEngine2/zend.c,v
retrieving revision 1.308.2.12.2.35.2.28
diff -u -r1.308.2.12.2.35.2.28 zend.c
--- Zend/zend.c 2 Jan 2009 13:14:49 -0000 1.308.2.12.2.35.2.28
+++ Zend/zend.c 21 Mar 2009 18:39:29 -0000
@@ -436,11 +436,13 @@
static zend_bool asp_tags_default = 0;
static zend_bool short_tags_default = 1;
static zend_bool ct_pass_ref_default = 1;
+static char *ns_separator_default = NULL;
static zend_uint compiler_options_default = ZEND_COMPILE_DEFAULT;
#else
# define asp_tags_default 0
# define short_tags_default 1
# define ct_pass_ref_default 1
+# define ns_separator_default "\\"
# define compiler_options_default ZEND_COMPILE_DEFAULT
#endif
@@ -449,6 +451,7 @@
/* default compile-time values */
CG(asp_tags) = asp_tags_default;
CG(short_tags) = short_tags_default;
+ CG(ns_separator) = estrdup(ns_separator_default ? ns_separator_default: "\\");
CG(allow_call_time_pass_reference) = ct_pass_ref_default;
CG(compiler_options) = compiler_options_default;
}
@@ -728,6 +731,7 @@
asp_tags_default = CG(asp_tags);
short_tags_default = CG(short_tags);
+ ns_separator_default = pestrdup(CG(ns_separator), 1);
ct_pass_ref_default = CG(allow_call_time_pass_reference);
compiler_options_default = CG(compiler_options);
@@ -763,6 +767,10 @@
free(GLOBAL_FUNCTION_TABLE);
free(GLOBAL_CLASS_TABLE);
+#ifdef ZTS
+ free(ns_separator_default);
+#endif
+
zend_hash_destroy(GLOBAL_CONSTANTS_TABLE);
free(GLOBAL_CONSTANTS_TABLE);
zend_shutdown_strtod();
Index: main/main.c
===================================================================
RCS file: /repository/php-src/main/main.c,v
retrieving revision 1.640.2.23.2.57.2.46
diff -u -r1.640.2.23.2.57.2.46 main.c
--- main/main.c 9 Feb 2009 09:20:34 -0000 1.640.2.23.2.57.2.46
+++ main/main.c 21 Mar 2009 18:39:29 -0000
@@ -496,6 +496,7 @@
STD_PHP_INI_ENTRY("user_ini.filename", ".user.ini", PHP_INI_SYSTEM, OnUpdateString, user_ini_filename, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("user_ini.cache_ttl", "300", PHP_INI_SYSTEM, OnUpdateLong, user_ini_cache_ttl, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("exit_on_timeout", "0", PHP_INI_ALL, OnUpdateBool, exit_on_timeout, php_core_globals, core_globals)
+ STD_PHP_INI_ENTRY("namespace_separator", "\\", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateString, ns_separator, zend_compiler_globals, compiler_globals)
PHP_INI_END()
/* }}} */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment