cvs: ZendEngine2 / zend_execute.c
| From: | Stanislav Malyshev | Date: | Mon, 21 Apr 2003 12:14:12 +0000 |
| Subject: | cvs: ZendEngine2 / zend_execute.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-1170@lists.php.net to get a copy of this message | ||
stas Mon Apr 21 08:14:12 2003 EDT
Modified files:
/ZendEngine2 zend_execute.c
Log:
make import * fail if such classes or functions already there
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.454 ZendEngine2/zend_execute.c:1.455
--- ZendEngine2/zend_execute.c:1.454 Wed Apr 2 10:28:30 2003
+++ ZendEngine2/zend_execute.c Mon Apr 21 08:14:12 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.454 2003/04/02 15:28:30 stas Exp $ */
+/* $Id: zend_execute.c,v 1.455 2003/04/21 12:14:12 stas Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -2196,6 +2196,13 @@
NEXT_OPCODE();
}
+static int zend_import_check_function(HashTable *target_ht, zend_function *function, zend_hash_key
*hash_key, void *param)
+{
+ if(zend_hash_quick_exists(target_ht, hash_key->arKey, hash_key->nKeyLength, hash_key->h))
{
+ zend_error(E_ERROR, "Import: function %s() already exists in current scope",
function->common.function_name?function->common.function_name:"main");
+ }
+ return 1; /* OK */
+}
int zend_import_function_handler(ZEND_OPCODE_HANDLER_ARGS)
{
@@ -2219,13 +2226,18 @@
}
function_add_ref(function);
} else {
- zend_function tmp_zend_function;
-
- zend_hash_copy(EG(function_table), &ce->function_table, (copy_ctor_func_t)
function_add_ref, &tmp_zend_function, sizeof(zend_function));
+ zend_hash_merge_ex(EG(function_table), &ce->function_table, (copy_ctor_func_t)
function_add_ref, sizeof(zend_function), (merge_checker_func_t)zend_import_check_function, NULL);
}
NEXT_OPCODE();
}
+static int zend_import_check_class(HashTable *target_ht, zend_class_entry **ce, zend_hash_key
*hash_key, void *param)
+{
+ if(zend_hash_quick_exists(target_ht, hash_key->arKey, hash_key->nKeyLength, hash_key->h))
{
+ zend_error(E_ERROR, "Import: class '%s' already exists in current scope",
(*ce)->name);
+ }
+ return 1; /* OK */
+}
int zend_import_class_handler(ZEND_OPCODE_HANDLER_ARGS)
{
@@ -2249,9 +2261,7 @@
}
zend_class_add_ref(import_ce);
} else {
- zend_class_entry *tmp_zend_class_entry;
-
- zend_hash_copy(EG(class_table), &ce->class_table, (copy_ctor_func_t) zend_class_add_ref,
&tmp_zend_class_entry, sizeof(zend_class_entry *));
+ zend_hash_merge_ex(EG(class_table), &ce->class_table, (copy_ctor_func_t)
zend_class_add_ref, sizeof(zend_class_entry *), (merge_checker_func_t)zend_import_check_class,
NULL);
}
NEXT_OPCODE();