com php-src: Fix constant resolution.: Zend/zend_compile.c Zend/zend_compile.h
| From: | Ferenc Kovacs | Date: | Sat, 09 Nov 2013 02:37:38 +0000 |
| Subject: | com php-src: Fix constant resolution.: Zend/zend_compile.c Zend/zend_compile.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74282@lists.php.net to get a copy of this message | ||
Commit: da553a816653e7c19bbfb5454fced91b929a6075
Author: Adam Harvey <aharvey@php.net> Fri, 8 Nov 2013 21:37:38 -0500
Parents: 95675dfba9e417667e1e093084b27fd8f93d8724
Branches: PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=da553a816653e7c19bbfb5454fced91b929a6075
Log:
Fix constant resolution.
Changed paths:
M Zend/zend_compile.c
M Zend/zend_compile.h
Diff:
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index bd90477..96fb77a 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -7157,10 +7157,9 @@ void zend_do_use(znode *ns_name, znode *new_name, int is_global TSRMLS_DC) /*
{{
}
/* }}} */
-void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_global, const char *type,
zend_bool case_sensitive, HashTable *current_import_sub, HashTable *lookup_table TSRMLS_DC) /* {{{
*/
+void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_global, int is_function,
zend_bool case_sensitive, HashTable *current_import_sub, HashTable *lookup_table TSRMLS_DC) /* {{{
*/
{
char *lookup_name;
- zend_function *function = NULL;
zval *name, *ns, tmp;
zend_bool warn = 0;
@@ -7202,28 +7201,42 @@ void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_global,
const
if (Z_STRLEN_P(ns) != Z_STRLEN_P(CG(current_namespace)) + 1 + Z_STRLEN_P(name) ||
memcmp(tmp2, c_ns_name, Z_STRLEN_P(ns))) {
- zend_error(E_COMPILE_ERROR, "Cannot use %s %s as %s because the name is already in
use", type, Z_STRVAL_P(ns), Z_STRVAL_P(name));
+ zend_error(E_COMPILE_ERROR, "Cannot use %s %s as %s because the name is already in
use", is_function ? "function" : "const", Z_STRVAL_P(ns),
Z_STRVAL_P(name));
}
efree(tmp2);
}
efree(c_ns_name);
- } else {
+ } else if (is_function) {
+ zend_function *function;
+
if (zend_hash_find(lookup_table, lookup_name, Z_STRLEN_P(name)+1, (void **) &function) ==
SUCCESS && strcmp(function->op_array.filename, CG(compiled_filename)) == 0) {
char *c_tmp = zend_str_tolower_dup(Z_STRVAL_P(ns), Z_STRLEN_P(ns));
if (Z_STRLEN_P(ns) != Z_STRLEN_P(name) ||
memcmp(c_tmp, lookup_name, Z_STRLEN_P(ns))) {
- zend_error(E_COMPILE_ERROR, "Cannot use %s %s as %s because the name is already in
use", type, Z_STRVAL_P(ns), Z_STRVAL_P(name));
+ zend_error(E_COMPILE_ERROR, "Cannot use function %s as %s because the name is already in
use", Z_STRVAL_P(ns), Z_STRVAL_P(name));
+ }
+ efree(c_tmp);
+ }
+ } else {
+ const char *filename;
+
+ if (zend_hash_find(lookup_table, lookup_name, Z_STRLEN_P(name)+1, (void **) &filename) ==
SUCCESS && strcmp(filename, CG(compiled_filename)) == 0) {
+ char *c_tmp = zend_str_tolower_dup(Z_STRVAL_P(ns), Z_STRLEN_P(ns));
+
+ if (Z_STRLEN_P(ns) != Z_STRLEN_P(name) ||
+ memcmp(c_tmp, lookup_name, Z_STRLEN_P(ns))) {
+ zend_error(E_COMPILE_ERROR, "Cannot use const %s as %s because the name is already in
use", Z_STRVAL_P(ns), Z_STRVAL_P(name));
}
efree(c_tmp);
}
}
if (zend_hash_add(current_import_sub, lookup_name, Z_STRLEN_P(name)+1, &ns, sizeof(zval*),
NULL) != SUCCESS) {
- zend_error(E_COMPILE_ERROR, "Cannot use %s %s as %s because the name is already in
use", type, Z_STRVAL_P(ns), Z_STRVAL_P(name));
+ zend_error(E_COMPILE_ERROR, "Cannot use %s %s as %s because the name is already in
use", is_function ? "function" : "const", Z_STRVAL_P(ns),
Z_STRVAL_P(name));
}
if (warn) {
- zend_error(E_WARNING, "The use %s statement with non-compound name '%s' has no
effect", type, Z_STRVAL_P(name));
+ zend_error(E_WARNING, "The use %s statement with non-compound name '%s' has no
effect", is_function ? "function" : "const", Z_STRVAL_P(name));
}
efree(lookup_name);
zval_dtor(name);
@@ -7237,7 +7250,7 @@ void zend_do_use_function(znode *ns_name, znode *new_name, int is_global
TSRMLS_
zend_hash_init(CG(current_import_function), 0, NULL, ZVAL_PTR_DTOR, 0);
}
- zend_do_use_non_class(ns_name, new_name, is_global, "function", 0,
CG(current_import_function), CG(function_table) TSRMLS_CC);
+ zend_do_use_non_class(ns_name, new_name, is_global, 1, 0, CG(current_import_function),
CG(function_table) TSRMLS_CC);
}
/* }}} */
@@ -7248,7 +7261,7 @@ void zend_do_use_const(znode *ns_name, znode *new_name, int is_global
TSRMLS_DC)
zend_hash_init(CG(current_import_const), 0, NULL, ZVAL_PTR_DTOR, 0);
}
- zend_do_use_non_class(ns_name, new_name, is_global, "const", 1,
CG(current_import_const), &CG(const_filenames) TSRMLS_CC);
+ zend_do_use_non_class(ns_name, new_name, is_global, 0, 1, CG(current_import_const),
&CG(const_filenames) TSRMLS_CC);
}
/* }}} */
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index 55575f3..53bff38 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -638,7 +638,7 @@ void zend_do_begin_namespace(const znode *name, zend_bool with_brackets TSRMLS_D
void zend_do_end_namespace(TSRMLS_D);
void zend_verify_namespace(TSRMLS_D);
void zend_do_use(znode *name, znode *new_name, int is_global TSRMLS_DC);
-void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_global, const char *type,
zend_bool case_sensitive, HashTable *current_import_sub, HashTable *lookup_table TSRMLS_DC);
+void zend_do_use_non_class(znode *ns_name, znode *new_name, int is_global, int is_function,
zend_bool case_sensitive, HashTable *current_import_sub, HashTable *lookup_table TSRMLS_DC);
void zend_do_use_function(znode *name, znode *new_name, int is_global TSRMLS_DC);
void zend_do_use_const(znode *name, znode *new_name, int is_global TSRMLS_DC);
void zend_do_end_compilation(TSRMLS_D);