cvs: ZendEngine2 / zend_compile.c
| From: | Marcus Boerger | Date: | Mon, 22 Dec 2003 22:34:28 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-2149@lists.php.net to get a copy of this message | ||
helly Mon Dec 22 17:34:28 2003 EDT
Modified files:
/ZendEngine2 zend_compile.c
Log:
Preserve class name casing.
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.504 ZendEngine2/zend_compile.c:1.505
--- ZendEngine2/zend_compile.c:1.504 Wed Dec 17 09:45:59 2003
+++ ZendEngine2/zend_compile.c Mon Dec 22 17:34:28 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.504 2003/12/17 14:45:59 dmitry Exp $ */
+/* $Id: zend_compile.c,v 1.505 2003/12/22 22:34:28 helly Exp $ */
#include "zend_language_parser.h"
#include "zend.h"
@@ -1024,6 +1024,10 @@
fn_flags |= ZEND_ACC_PUBLIC;
}
+ 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) {
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)))) {
@@ -1039,6 +1043,7 @@
} else if ((name_len == sizeof(ZEND_SET_FUNC_NAME)-1) && (!memcmp(lcname,
ZEND_SET_FUNC_NAME, sizeof(ZEND_SET_FUNC_NAME)))) {
CG(active_class_entry)->__set = (zend_function *) CG(active_op_array);
}
+ free_alloca(short_class_name);
efree(lcname);
} else {
@@ -2309,10 +2314,10 @@
zend_op *opline;
int doing_inheritance = 0;
zend_class_entry *new_class_entry = emalloc(sizeof(zend_class_entry));
+ char *lcname = zend_str_tolower_dup(class_name->u.constant.value.str.val,
class_name->u.constant.value.str.len);
- zend_str_tolower(class_name->u.constant.value.str.val,
class_name->u.constant.value.str.len);
-
- if (!(strcmp(class_name->u.constant.value.str.val, "self") &&
strcmp(class_name->u.constant.value.str.val, "parent"))) {
+ if (!(strcmp(lcname, "self") && strcmp(lcname, "parent"))) {
+ efree(lcname);
zend_error(E_COMPILE_ERROR, "Cannot use '%s' as class name as it is
reserved", class_name->u.constant.value.str.val);
}
@@ -2329,10 +2334,9 @@
doing_inheritance = 1;
}
- zend_str_tolower(new_class_entry->name, new_class_entry->name_length);
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->op1.op_type = IS_CONST;
- build_runtime_defined_function_key(&opline->op1.u.constant, new_class_entry->name,
new_class_entry->name_length, opline TSRMLS_CC);
+ build_runtime_defined_function_key(&opline->op1.u.constant, lcname,
new_class_entry->name_length, opline TSRMLS_CC);
opline->op2.op_type = IS_CONST;
opline->op2.u.constant.type = IS_STRING;
@@ -2345,7 +2349,7 @@
opline->opcode = ZEND_DECLARE_CLASS;
}
- opline->op2.u.constant.value.str.val = estrndup(new_class_entry->name,
new_class_entry->name_length);
+ opline->op2.u.constant.value.str.val = lcname;
opline->op2.u.constant.value.str.len = new_class_entry->name_length;
zend_hash_update(CG(class_table), opline->op1.u.constant.value.str.val,
opline->op1.u.constant.value.str.len, &new_class_entry, sizeof(zend_class_entry *), NULL);