cvs: ZendEngine2 / zend_compile.c

From: Date: Thu, 04 Mar 2004 10:02:59 +0000
Subject: cvs: ZendEngine2 / zend_compile.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-2441@lists.php.net to get a copy of this message
stas Thu Mar 4 05:02:59 2004 EDT Modified files: /ZendEngine2 zend_compile.c Log: Disallow redefining ctors and cleanup http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.551&r2=1.552&ty=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.551 ZendEngine2/zend_compile.c:1.552 --- ZendEngine2/zend_compile.c:1.551 Tue Mar 2 06:03:48 2004 +++ ZendEngine2/zend_compile.c Thu Mar 4 05:02:59 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.551 2004/03/02 11:03:48 andi Exp $ */ +/* $Id: zend_compile.c,v 1.552 2004/03/04 10:02:59 stas Exp $ */ #include "zend_language_parser.h" #include "zend.h" @@ -995,14 +995,7 @@ if (is_method) { char *short_class_name = CG(active_class_entry)->name; int short_class_name_length = CG(active_class_entry)->name_length; - zend_uint i; - for (i=0; i < CG(active_class_entry)->name_length; i++) { - if (CG(active_class_entry)->name[i] == ':') { - short_class_name = &CG(active_class_entry)->name[i+1]; - short_class_name_length = strlen(short_class_name); - } - } if (zend_hash_add(&CG(active_class_entry)->function_table, lcname, name_len+1, &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array)) == FAILURE) { zend_op_array *child_op_array, *parent_op_array; if (CG(active_class_entry)->parent @@ -1025,12 +1018,18 @@ } short_class_name = do_alloca(short_class_name_length + 1); - if (!CG(active_class_entry)->constructor) { - zend_str_tolower_copy(short_class_name, CG(active_class_entry)->name, short_class_name_length); - } - if ((short_class_name_length == name_len) && (!memcmp(short_class_name, lcname, name_len)) && !CG(active_class_entry)->constructor) { + zend_str_tolower_copy(short_class_name, CG(active_class_entry)->name, short_class_name_length); + /* Improve after RC: cache the lowercase class name */ + + if ((short_class_name_length == name_len) && (!memcmp(short_class_name, lcname, name_len))) { + if(CG(active_class_entry)->constructor) { + zend_error(E_COMPILE_ERROR, "Cannot redefine constructor for class %s", CG(active_class_entry)->name); + } CG(active_class_entry)->constructor = (zend_function *) CG(active_op_array); } else if ((name_len == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)))) { + if(CG(active_class_entry)->constructor) { + zend_error(E_COMPILE_ERROR, "Cannot redefine constructor for class %s", CG(active_class_entry)->name); + } CG(active_class_entry)->constructor = (zend_function *) CG(active_op_array); } else if ((name_len == sizeof(ZEND_DESTRUCTOR_FUNC_NAME)-1) && (!memcmp(lcname, ZEND_DESTRUCTOR_FUNC_NAME, sizeof(ZEND_DESTRUCTOR_FUNC_NAME)))) { CG(active_class_entry)->destructor = (zend_function *) CG(active_op_array);

« previous php.zend-engine.cvs (#2441) next »