cvs: ZendEngine2 / zend_API.c zend_builtin_functions.c zend_compile.c zend_compile.h zend_constants.c zend_execute.c zend_execute_API.c
zend_reflection_api.c
| From: | Andi Gutmans | Date: | Mon, 24 Nov 2003 18:13:30 +0000 |
| Subject: | cvs: ZendEngine2 / zend_API.c zend_builtin_functions.c zend_compile.c zend_compile.h zend_constants.c zend_execute.c zend_execute_API.c zend_reflection_api.c |
||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-2001@lists.php.net to get a copy of this message | ||
andi Mon Nov 24 13:13:30 2003 EDT
Modified files:
/ZendEngine2 zend_API.c zend_builtin_functions.c zend_compile.c
zend_compile.h zend_constants.c zend_execute.c
zend_execute_API.c zend_reflection_api.c
Log:
- Fix __autoload() to preserve class case.
- Heads up, this patch might break stuff so please let me know if you
- bump into any problems.
Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.224 ZendEngine2/zend_API.c:1.225 --- ZendEngine2/zend_API.c:1.224 Sat Oct 25 18:58:06 2003 +++ ZendEngine2/zend_API.c Mon Nov 24 13:13:29 2003 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.c,v 1.224 2003/10/25 22:58:06 helly Exp $ */ +/* $Id: zend_API.c,v 1.225 2003/11/24 18:13:29 andi Exp $ */ #include "zend.h" #include "zend_execute.h" @@ -1622,13 +1622,11 @@ if (syntax_only) return 1; - lcname = zend_str_tolower_dup(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj)); - if (EG(active_op_array) && strcmp(lcname, "self") == 0) { ce = EG(active_op_array)->scope; } else if (strcmp(lcname, "parent") == 0 && EG(active_op_array) && EG(active_op_array)->scope) { ce = EG(active_op_array)->scope->parent; - } else if (zend_lookup_class(lcname, Z_STRLEN_PP(obj), &pce TSRMLS_CC) == SUCCESS) { + } else if (zend_lookup_class(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj), &pce TSRMLS_CC) == SUCCESS) { ce = *pce; } Index: ZendEngine2/zend_builtin_functions.c diff -u ZendEngine2/zend_builtin_functions.c:1.215 ZendEngine2/zend_builtin_functions.c:1.216 --- ZendEngine2/zend_builtin_functions.c:1.215 Tue Nov 18 04:25:04 2003 +++ ZendEngine2/zend_builtin_functions.c Mon Nov 24 13:13:29 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_builtin_functions.c,v 1.215 2003/11/18 09:25:04 andi Exp $ */ +/* $Id: zend_builtin_functions.c,v 1.216 2003/11/24 18:13:29 andi Exp $ */ #include "zend.h" #include "zend_API.h" @@ -567,8 +567,6 @@ } else if (Z_TYPE_PP(arg) == IS_STRING) { zend_class_entry **pce; - SEPARATE_ZVAL(arg); - zend_str_tolower(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg)); if (zend_lookup_class(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &pce TSRMLS_CC) == SUCCESS) { ce = *pce; } @@ -586,7 +584,6 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass) { zval **obj, **class_name; - char *lcname; zend_class_entry *instance_ce; zend_class_entry **ce; zend_bool retval; @@ -606,9 +603,7 @@ convert_to_string_ex(class_name); - lcname = zend_str_tolower_dup(Z_STRVAL_PP(class_name), Z_STRLEN_PP(class_name)); - - if (zend_lookup_class(lcname, Z_STRLEN_PP(class_name), &ce TSRMLS_CC) == FAILURE) { + if (zend_lookup_class(Z_STRVAL_PP(class_name), Z_STRLEN_PP(class_name), &ce TSRMLS_CC) == FAILURE) { retval = 0; } else { if (only_subclass) { @@ -618,7 +613,6 @@ } if (!instance_ce) { - efree(lcname); RETURN_FALSE; } @@ -629,8 +623,6 @@ } } - efree(lcname); - RETURN_BOOL(retval); } @@ -659,7 +651,6 @@ ZEND_FUNCTION(get_class_vars) { zval **class_name; - char *lcname; zend_class_entry *ce, **pce; zval *tmp; @@ -668,14 +659,11 @@ } convert_to_string_ex(class_name); - lcname = zend_str_tolower_dup((*class_name)->value.str.val, (*class_name)->value.str.len); - - if (zend_lookup_class(lcname, Z_STRLEN_PP(class_name), &pce TSRMLS_CC) == FAILURE) { - efree(lcname); + + if (zend_lookup_class(Z_STRVAL_PP(class_name), Z_STRLEN_PP(class_name), &pce TSRMLS_CC) == FAILURE) { RETURN_FALSE; } else { ce = *pce; - efree(lcname); array_init(return_value); if (!ce->constants_updated) { zend_hash_apply_with_argument(&ce->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC); @@ -746,9 +734,6 @@ } ce = Z_OBJCE_PP(class); } else if (Z_TYPE_PP(class) == IS_STRING) { - SEPARATE_ZVAL(class); - zend_str_tolower(Z_STRVAL_PP(class), Z_STRLEN_PP(class)); - if (zend_lookup_class(Z_STRVAL_PP(class), Z_STRLEN_PP(class), &pce TSRMLS_CC) == SUCCESS) { ce = *pce; } @@ -807,7 +792,6 @@ ZEND_FUNCTION(class_exists) { zval **class_name; - char *lcname; zend_class_entry **ce; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &class_name)==FAILURE) { @@ -815,12 +799,10 @@ } convert_to_string_ex(class_name); - lcname = zend_str_tolower_dup((*class_name)->value.str.val, (*class_name)->value.str.len); - if (zend_lookup_class(lcname, Z_STRLEN_PP(class_name), &ce TSRMLS_CC) == SUCCESS) { - efree(lcname); + + if (zend_lookup_class(Z_STRVAL_PP(class_name), Z_STRLEN_PP(class_name), &ce TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } else { - efree(lcname); RETURN_FALSE; } } Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.494 ZendEngine2/zend_compile.c:1.495 --- ZendEngine2/zend_compile.c:1.494 Tue Nov 18 02:19:55 2003 +++ ZendEngine2/zend_compile.c Mon Nov 24 13:13:29 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.494 2003/11/18 07:19:55 helly Exp $ */ +/* $Id: zend_compile.c,v 1.495 2003/11/24 18:13:29 andi Exp $ */ #include "zend_language_parser.h" #include "zend.h" @@ -1128,7 +1128,6 @@ if (class_type->op_type != IS_UNUSED) { cur_arg_info->class_name = class_type->u.constant.value.str.val; cur_arg_info->class_name_len = class_type->u.constant.value.str.len; - zend_str_tolower(cur_arg_info->class_name, cur_arg_info->class_name_len); } else { cur_arg_info->class_name = NULL; cur_arg_info->class_name_len = 0; @@ -1236,7 +1235,6 @@ if (class_name->op_type == IS_CONST) { int fetch_type; - zend_str_tolower(class_name->u.constant.value.str.val, class_name->u.constant.value.str.len); fetch_type = zend_get_class_fetch_type(class_name->u.constant.value.str.val, class_name->u.constant.value.str.len); switch (fetch_type) { case ZEND_FETCH_CLASS_SELF: @@ -1258,7 +1256,7 @@ } -void zend_do_fetch_class_name(znode *result, znode *class_name_entry, znode *class_name, zend_bool case_sensitive TSRMLS_DC) +void zend_do_fetch_class_name(znode *result, znode *class_name_entry, znode *class_name TSRMLS_DC) { zend_uint length; @@ -1267,9 +1265,6 @@ } else { *result = *class_name_entry; } - if (!case_sensitive) { - zend_str_tolower(class_name->u.constant.value.str.val, class_name->u.constant.value.str.len); - } length = sizeof("::")-1 + result->u.constant.value.str.len + class_name->u.constant.value.str.len; result->u.constant.value.str.val = erealloc(result->u.constant.value.str.val, length+1); @@ -2665,8 +2660,7 @@ switch (mode) { case ZEND_CT: if (constant_container) { - zend_str_tolower(constant_container->u.constant.value.str.val, constant_container->u.constant.value.str.len); - zend_do_fetch_class_name(NULL, constant_container, constant_name, 1 TSRMLS_CC); + zend_do_fetch_class_name(NULL, constant_container, constant_name TSRMLS_CC); *result = *constant_container; } else { *result = *constant_name; Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.262 ZendEngine2/zend_compile.h:1.263 --- ZendEngine2/zend_compile.h:1.262 Mon Nov 10 11:14:44 2003 +++ ZendEngine2/zend_compile.h Mon Nov 24 13:13:29 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.262 2003/11/10 16:14:44 helly Exp $ */ +/* $Id: zend_compile.h,v 1.263 2003/11/24 18:13:29 andi Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -343,7 +343,7 @@ void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC); void zend_do_begin_dynamic_function_call(znode *function_name TSRMLS_DC); void zend_do_fetch_class(znode *result, znode *class_name TSRMLS_DC); -void zend_do_fetch_class_name(znode *result, znode *class_entry, znode *class_name, zend_bool case_sensitive TSRMLS_DC); +void zend_do_fetch_class_name(znode *result, znode *class_entry, znode *class_name TSRMLS_DC); void zend_do_begin_class_member_function_call(TSRMLS_D); void zend_do_end_function_call(znode *function_name, znode *result, znode *argument_list, int is_method, int is_dynamic_fcall TSRMLS_DC); void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC); Index: ZendEngine2/zend_constants.c diff -u ZendEngine2/zend_constants.c:1.60 ZendEngine2/zend_constants.c:1.61 --- ZendEngine2/zend_constants.c:1.60 Tue Nov 18 04:25:04 2003 +++ ZendEngine2/zend_constants.c Mon Nov 24 13:13:29 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_constants.c,v 1.60 2003/11/18 09:25:04 andi Exp $ */ +/* $Id: zend_constants.c,v 1.61 2003/11/24 18:13:29 andi Exp $ */ #include "zend.h" #include "zend_constants.h" @@ -212,8 +212,8 @@ ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC) { zend_constant *c; - char *lookup_name; int retval = 1; + char *lookup_name; char *colon; if ((colon = memchr(name, ':', name_len)) && colon[1] == ':') { @@ -230,17 +230,14 @@ scope = CG(active_class_entry); } - lookup_name = do_alloca(class_name_len+1); - zend_str_tolower_copy(lookup_name, name, class_name_len); - lookup_name[class_name_len] = '\0'; - if (class_name_len == sizeof("self")-1 && strcmp(lookup_name, "self") == 0) { + if (class_name_len == sizeof("self")-1 && strcmp(name, "self") == 0) { if (scope) { ce = &scope; } else { zend_error(E_ERROR, "Cannot access self:: when no class scope is active"); retval = 0; } - } else if (class_name_len == sizeof("parent")-1 && strcmp(lookup_name, "parent") == 0) { + } else if (class_name_len == sizeof("parent")-1 && strcmp(name, "parent") == 0) { if (!scope) { zend_error(E_ERROR, "Cannot access parent:: when no class scope is active"); } else if (!scope->parent) { @@ -249,7 +246,7 @@ ce = &scope->parent; } } else { - if (zend_lookup_class(lookup_name, class_name_len, &ce TSRMLS_CC) != SUCCESS) { + if (zend_lookup_class(name, class_name_len, &ce TSRMLS_CC) != SUCCESS) { retval = 0; } } @@ -267,7 +264,6 @@ zval_copy_ctor(result); } - free_alloca(lookup_name); return retval; } Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.551 ZendEngine2/zend_execute.c:1.552 --- ZendEngine2/zend_execute.c:1.551 Thu Nov 20 23:45:43 2003 +++ ZendEngine2/zend_execute.c Mon Nov 24 13:13:29 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.c,v 1.551 2003/11/21 04:45:43 iliaa Exp $ */ +/* $Id: zend_execute.c,v 1.552 2003/11/24 18:13:29 andi Exp $ */ #define ZEND_INTENSIVE_DEBUGGING 0 @@ -2272,7 +2272,6 @@ int zend_fetch_class_handler(ZEND_OPCODE_HANDLER_ARGS) { - char *class_name_strval; zval *class_name; @@ -2288,13 +2287,7 @@ EX_T(EX(opline)->result.u.var).EA.class_entry = Z_OBJCE_P(class_name); break; case IS_STRING: - if (EX(opline)->op2.op_type != IS_CONST) { - class_name_strval = zend_str_tolower_dup(class_name->value.str.val, class_name->value.str.len); - EX_T(EX(opline)->result.u.var).EA.class_entry = zend_fetch_class(class_name_strval, Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); - efree(class_name_strval); - } else { - EX_T(EX(opline)->result.u.var).EA.class_entry = zend_fetch_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); - } + EX_T(EX(opline)->result.u.var).EA.class_entry = zend_fetch_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); break; default: zend_error(E_ERROR, "Class name must be a valid object or a string"); Index: ZendEngine2/zend_execute_API.c diff -u ZendEngine2/zend_execute_API.c:1.240 ZendEngine2/zend_execute_API.c:1.241 --- ZendEngine2/zend_execute_API.c:1.240 Fri Nov 7 06:47:50 2003 +++ ZendEngine2/zend_execute_API.c Mon Nov 24 13:13:29 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute_API.c,v 1.240 2003/11/07 11:47:50 helly Exp $ */ +/* $Id: zend_execute_API.c,v 1.241 2003/11/24 18:13:29 andi Exp $ */ #include <stdio.h> #include <signal.h> @@ -583,20 +583,17 @@ EX(object) = *fci->object_pp; } else if (Z_TYPE_PP(fci->object_pp) == IS_STRING) { zend_class_entry **ce; - char *lc_class; int found = FAILURE; - lc_class = zend_str_tolower_dup(Z_STRVAL_PP(fci->object_pp), Z_STRLEN_PP(fci->object_pp)); - if (EG(active_op_array) && strcmp(lc_class, "self") == 0) { + if (EG(active_op_array) && strcmp(Z_STRVAL_PP(fci->object_pp), "self") == 0) { ce = &(EG(active_op_array)->scope); found = (*ce != NULL?SUCCESS:FAILURE); - } else if (strcmp(lc_class, "parent") == 0 && EG(active_op_array) && EG(active_op_array)->scope) { + } else if (strcmp(Z_STRVAL_PP(fci->object_pp), "parent") == 0 && EG(active_op_array) && EG(active_op_array)->scope) { ce = &(EG(active_op_array)->scope->parent); found = (*ce != NULL?SUCCESS:FAILURE); } else { - found = zend_lookup_class(lc_class, Z_STRLEN_PP(fci->object_pp), &ce TSRMLS_CC); + found = zend_lookup_class(Z_STRVAL_PP(fci->object_pp), Z_STRLEN_PP(fci->object_pp), &ce TSRMLS_CC); } - efree(lc_class); if (found == FAILURE) return FAILURE; @@ -782,8 +779,13 @@ zval class_name, *class_name_ptr = &class_name; zval *retval_ptr; int retval; + char *lc_name; - if (zend_hash_find(EG(class_table), name, name_length+1, (void **) ce) == SUCCESS) { + lc_name = do_alloca(name_length + 1); + zend_str_tolower_copy(lc_name, name, name_length+1); + + if (zend_hash_find(EG(class_table), lc_name, name_length+1, (void **) ce) == SUCCESS) { + free_alloca(lc_name); return SUCCESS; } @@ -797,17 +799,21 @@ retval = call_user_function_ex(EG(function_table), NULL, &autoload_function, &retval_ptr, 1, args, 0, NULL TSRMLS_CC); if (retval == FAILURE) { + free_alloca(lc_name); return FAILURE; } if (EG(exception)) { + free_alloca(lc_name); zend_error(E_ERROR, "__autoload threw an exception"); } /* If an exception is thrown retval_ptr will be NULL but we bailout before we reach this point */ zval_ptr_dtor(&retval_ptr); - return zend_hash_find(EG(class_table), name, name_length + 1, (void **) ce); + retval = zend_hash_find(EG(class_table), lc_name, name_length + 1, (void **) ce); + free_alloca(lc_name); + return retval; } ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC) Index: ZendEngine2/zend_reflection_api.c diff -u ZendEngine2/zend_reflection_api.c:1.75 ZendEngine2/zend_reflection_api.c:1.76 --- ZendEngine2/zend_reflection_api.c:1.75 Sun Nov 23 07:55:22 2003 +++ ZendEngine2/zend_reflection_api.c Mon Nov 24 13:13:29 2003 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_reflection_api.c,v 1.75 2003/11/23 12:55:22 andi Exp $ */ +/* $Id: zend_reflection_api.c,v 1.76 2003/11/24 18:13:29 andi Exp $ */ #include "zend.h" #include "zend_API.h" #include "zend_default_classes.h" @@ -2386,7 +2386,6 @@ reflection_object *intern, *argument; zend_class_entry *ce, **pce, *class_ce; zval *class_name; - char *class_name_lc; METHOD_NOTSTATIC; GET_REFLECTION_OBJECT_PTR(ce); @@ -2397,15 +2396,11 @@ switch(class_name->type) { case IS_STRING: - class_name_lc = do_alloca(Z_STRLEN_P(class_name) + 1); - zend_str_tolower_copy(class_name_lc, Z_STRVAL_P(class_name), Z_STRLEN_P(class_name)+ 1); - if (zend_lookup_class(class_name_lc, Z_STRLEN_P(class_name), &pce TSRMLS_CC) == FAILURE) { - free_alloca(class_name_lc); + if (zend_lookup_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), &pce TSRMLS_CC) == FAILURE) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Interface %s doesn't exist", Z_STRVAL_P(class_name)); return; } - free_alloca(class_name_lc); class_ce = *pce; break; case IS_OBJECT: @@ -2437,7 +2432,6 @@ reflection_object *intern, *argument; zend_class_entry *ce, *interface_ce, **pce; zval *interface; - char *interface_lc; METHOD_NOTSTATIC; GET_REFLECTION_OBJECT_PTR(ce); @@ -2448,15 +2442,11 @@ switch(interface->type) { case IS_STRING: - interface_lc = do_alloca(Z_STRLEN_P(interface) + 1); - zend_str_tolower_copy(interface_lc, Z_STRVAL_P(interface), Z_STRLEN_P(interface)); - if (zend_lookup_class(interface_lc, Z_STRLEN_P(interface), &pce TSRMLS_CC) == FAILURE) { - free_alloca(interface_lc); + if (zend_lookup_class(Z_STRVAL_P(interface), Z_STRLEN_P(interface), &pce TSRMLS_CC) == FAILURE) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Interface %s doesn't exist", Z_STRVAL_P(interface)); return; } - free_alloca(interface_lc); interface_ce = *pce; break; case IS_OBJECT:
Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.224 ZendEngine2/zend_API.c:1.225 --- ZendEngine2/zend_API.c:1.224 Sat Oct 25 18:58:06 2003 +++ ZendEngine2/zend_API.c Mon Nov 24 13:13:29 2003 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.c,v 1.224 2003/10/25 22:58:06 helly Exp $ */ +/* $Id: zend_API.c,v 1.225 2003/11/24 18:13:29 andi Exp $ */ #include "zend.h" #include "zend_execute.h" @@ -1622,13 +1622,11 @@ if (syntax_only) return 1; - lcname = zend_str_tolower_dup(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj)); - if (EG(active_op_array) && strcmp(lcname, "self") == 0) { ce = EG(active_op_array)->scope; } else if (strcmp(lcname, "parent") == 0 && EG(active_op_array) && EG(active_op_array)->scope) { ce = EG(active_op_array)->scope->parent; - } else if (zend_lookup_class(lcname, Z_STRLEN_PP(obj), &pce TSRMLS_CC) == SUCCESS) { + } else if (zend_lookup_class(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj), &pce TSRMLS_CC) == SUCCESS) { ce = *pce; } Index: ZendEngine2/zend_builtin_functions.c diff -u ZendEngine2/zend_builtin_functions.c:1.215 ZendEngine2/zend_builtin_functions.c:1.216 --- ZendEngine2/zend_builtin_functions.c:1.215 Tue Nov 18 04:25:04 2003 +++ ZendEngine2/zend_builtin_functions.c Mon Nov 24 13:13:29 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_builtin_functions.c,v 1.215 2003/11/18 09:25:04 andi Exp $ */ +/* $Id: zend_builtin_functions.c,v 1.216 2003/11/24 18:13:29 andi Exp $ */ #include "zend.h" #include "zend_API.h" @@ -567,8 +567,6 @@ } else if (Z_TYPE_PP(arg) == IS_STRING) { zend_class_entry **pce; - SEPARATE_ZVAL(arg); - zend_str_tolower(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg)); if (zend_lookup_class(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &pce TSRMLS_CC) == SUCCESS) { ce = *pce; } @@ -586,7 +584,6 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass) { zval **obj, **class_name; - char *lcname; zend_class_entry *instance_ce; zend_class_entry **ce; zend_bool retval; @@ -606,9 +603,7 @@ convert_to_string_ex(class_name); - lcname = zend_str_tolower_dup(Z_STRVAL_PP(class_name), Z_STRLEN_PP(class_name)); - - if (zend_lookup_class(lcname, Z_STRLEN_PP(class_name), &ce TSRMLS_CC) == FAILURE) { + if (zend_lookup_class(Z_STRVAL_PP(class_name), Z_STRLEN_PP(class_name), &ce TSRMLS_CC) == FAILURE) { retval = 0; } else { if (only_subclass) { @@ -618,7 +613,6 @@ } if (!instance_ce) { - efree(lcname); RETURN_FALSE; } @@ -629,8 +623,6 @@ } } - efree(lcname); - RETURN_BOOL(retval); } @@ -659,7 +651,6 @@ ZEND_FUNCTION(get_class_vars) { zval **class_name; - char *lcname; zend_class_entry *ce, **pce; zval *tmp; @@ -668,14 +659,11 @@ } convert_to_string_ex(class_name); - lcname = zend_str_tolower_dup((*class_name)->value.str.val, (*class_name)->value.str.len); - - if (zend_lookup_class(lcname, Z_STRLEN_PP(class_name), &pce TSRMLS_CC) == FAILURE) { - efree(lcname); + + if (zend_lookup_class(Z_STRVAL_PP(class_name), Z_STRLEN_PP(class_name), &pce TSRMLS_CC) == FAILURE) { RETURN_FALSE; } else { ce = *pce; - efree(lcname); array_init(return_value); if (!ce->constants_updated) { zend_hash_apply_with_argument(&ce->default_properties, (apply_func_arg_t) zval_update_constant, (void *) 1 TSRMLS_CC); @@ -746,9 +734,6 @@ } ce = Z_OBJCE_PP(class); } else if (Z_TYPE_PP(class) == IS_STRING) { - SEPARATE_ZVAL(class); - zend_str_tolower(Z_STRVAL_PP(class), Z_STRLEN_PP(class)); - if (zend_lookup_class(Z_STRVAL_PP(class), Z_STRLEN_PP(class), &pce TSRMLS_CC) == SUCCESS) { ce = *pce; } @@ -807,7 +792,6 @@ ZEND_FUNCTION(class_exists) { zval **class_name; - char *lcname; zend_class_entry **ce; if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &class_name)==FAILURE) { @@ -815,12 +799,10 @@ } convert_to_string_ex(class_name); - lcname = zend_str_tolower_dup((*class_name)->value.str.val, (*class_name)->value.str.len); - if (zend_lookup_class(lcname, Z_STRLEN_PP(class_name), &ce TSRMLS_CC) == SUCCESS) { - efree(lcname); + + if (zend_lookup_class(Z_STRVAL_PP(class_name), Z_STRLEN_PP(class_name), &ce TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } else { - efree(lcname); RETURN_FALSE; } } Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.494 ZendEngine2/zend_compile.c:1.495 --- ZendEngine2/zend_compile.c:1.494 Tue Nov 18 02:19:55 2003 +++ ZendEngine2/zend_compile.c Mon Nov 24 13:13:29 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.494 2003/11/18 07:19:55 helly Exp $ */ +/* $Id: zend_compile.c,v 1.495 2003/11/24 18:13:29 andi Exp $ */ #include "zend_language_parser.h" #include "zend.h" @@ -1128,7 +1128,6 @@ if (class_type->op_type != IS_UNUSED) { cur_arg_info->class_name = class_type->u.constant.value.str.val; cur_arg_info->class_name_len = class_type->u.constant.value.str.len; - zend_str_tolower(cur_arg_info->class_name, cur_arg_info->class_name_len); } else { cur_arg_info->class_name = NULL; cur_arg_info->class_name_len = 0; @@ -1236,7 +1235,6 @@ if (class_name->op_type == IS_CONST) { int fetch_type; - zend_str_tolower(class_name->u.constant.value.str.val, class_name->u.constant.value.str.len); fetch_type = zend_get_class_fetch_type(class_name->u.constant.value.str.val, class_name->u.constant.value.str.len); switch (fetch_type) { case ZEND_FETCH_CLASS_SELF: @@ -1258,7 +1256,7 @@ } -void zend_do_fetch_class_name(znode *result, znode *class_name_entry, znode *class_name, zend_bool case_sensitive TSRMLS_DC) +void zend_do_fetch_class_name(znode *result, znode *class_name_entry, znode *class_name TSRMLS_DC) { zend_uint length; @@ -1267,9 +1265,6 @@ } else { *result = *class_name_entry; } - if (!case_sensitive) { - zend_str_tolower(class_name->u.constant.value.str.val, class_name->u.constant.value.str.len); - } length = sizeof("::")-1 + result->u.constant.value.str.len + class_name->u.constant.value.str.len; result->u.constant.value.str.val = erealloc(result->u.constant.value.str.val, length+1); @@ -2665,8 +2660,7 @@ switch (mode) { case ZEND_CT: if (constant_container) { - zend_str_tolower(constant_container->u.constant.value.str.val, constant_container->u.constant.value.str.len); - zend_do_fetch_class_name(NULL, constant_container, constant_name, 1 TSRMLS_CC); + zend_do_fetch_class_name(NULL, constant_container, constant_name TSRMLS_CC); *result = *constant_container; } else { *result = *constant_name; Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.262 ZendEngine2/zend_compile.h:1.263 --- ZendEngine2/zend_compile.h:1.262 Mon Nov 10 11:14:44 2003 +++ ZendEngine2/zend_compile.h Mon Nov 24 13:13:29 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.262 2003/11/10 16:14:44 helly Exp $ */ +/* $Id: zend_compile.h,v 1.263 2003/11/24 18:13:29 andi Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -343,7 +343,7 @@ void zend_do_begin_method_call(znode *left_bracket TSRMLS_DC); void zend_do_begin_dynamic_function_call(znode *function_name TSRMLS_DC); void zend_do_fetch_class(znode *result, znode *class_name TSRMLS_DC); -void zend_do_fetch_class_name(znode *result, znode *class_entry, znode *class_name, zend_bool case_sensitive TSRMLS_DC); +void zend_do_fetch_class_name(znode *result, znode *class_entry, znode *class_name TSRMLS_DC); void zend_do_begin_class_member_function_call(TSRMLS_D); void zend_do_end_function_call(znode *function_name, znode *result, znode *argument_list, int is_method, int is_dynamic_fcall TSRMLS_DC); void zend_do_return(znode *expr, int do_end_vparse TSRMLS_DC); Index: ZendEngine2/zend_constants.c diff -u ZendEngine2/zend_constants.c:1.60 ZendEngine2/zend_constants.c:1.61 --- ZendEngine2/zend_constants.c:1.60 Tue Nov 18 04:25:04 2003 +++ ZendEngine2/zend_constants.c Mon Nov 24 13:13:29 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_constants.c,v 1.60 2003/11/18 09:25:04 andi Exp $ */ +/* $Id: zend_constants.c,v 1.61 2003/11/24 18:13:29 andi Exp $ */ #include "zend.h" #include "zend_constants.h" @@ -212,8 +212,8 @@ ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC) { zend_constant *c; - char *lookup_name; int retval = 1; + char *lookup_name; char *colon; if ((colon = memchr(name, ':', name_len)) && colon[1] == ':') { @@ -230,17 +230,14 @@ scope = CG(active_class_entry); } - lookup_name = do_alloca(class_name_len+1); - zend_str_tolower_copy(lookup_name, name, class_name_len); - lookup_name[class_name_len] = '\0'; - if (class_name_len == sizeof("self")-1 && strcmp(lookup_name, "self") == 0) { + if (class_name_len == sizeof("self")-1 && strcmp(name, "self") == 0) { if (scope) { ce = &scope; } else { zend_error(E_ERROR, "Cannot access self:: when no class scope is active"); retval = 0; } - } else if (class_name_len == sizeof("parent")-1 && strcmp(lookup_name, "parent") == 0) { + } else if (class_name_len == sizeof("parent")-1 && strcmp(name, "parent") == 0) { if (!scope) { zend_error(E_ERROR, "Cannot access parent:: when no class scope is active"); } else if (!scope->parent) { @@ -249,7 +246,7 @@ ce = &scope->parent; } } else { - if (zend_lookup_class(lookup_name, class_name_len, &ce TSRMLS_CC) != SUCCESS) { + if (zend_lookup_class(name, class_name_len, &ce TSRMLS_CC) != SUCCESS) { retval = 0; } } @@ -267,7 +264,6 @@ zval_copy_ctor(result); } - free_alloca(lookup_name); return retval; } Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.551 ZendEngine2/zend_execute.c:1.552 --- ZendEngine2/zend_execute.c:1.551 Thu Nov 20 23:45:43 2003 +++ ZendEngine2/zend_execute.c Mon Nov 24 13:13:29 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.c,v 1.551 2003/11/21 04:45:43 iliaa Exp $ */ +/* $Id: zend_execute.c,v 1.552 2003/11/24 18:13:29 andi Exp $ */ #define ZEND_INTENSIVE_DEBUGGING 0 @@ -2272,7 +2272,6 @@ int zend_fetch_class_handler(ZEND_OPCODE_HANDLER_ARGS) { - char *class_name_strval; zval *class_name; @@ -2288,13 +2287,7 @@ EX_T(EX(opline)->result.u.var).EA.class_entry = Z_OBJCE_P(class_name); break; case IS_STRING: - if (EX(opline)->op2.op_type != IS_CONST) { - class_name_strval = zend_str_tolower_dup(class_name->value.str.val, class_name->value.str.len); - EX_T(EX(opline)->result.u.var).EA.class_entry = zend_fetch_class(class_name_strval, Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); - efree(class_name_strval); - } else { - EX_T(EX(opline)->result.u.var).EA.class_entry = zend_fetch_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); - } + EX_T(EX(opline)->result.u.var).EA.class_entry = zend_fetch_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); break; default: zend_error(E_ERROR, "Class name must be a valid object or a string"); Index: ZendEngine2/zend_execute_API.c diff -u ZendEngine2/zend_execute_API.c:1.240 ZendEngine2/zend_execute_API.c:1.241 --- ZendEngine2/zend_execute_API.c:1.240 Fri Nov 7 06:47:50 2003 +++ ZendEngine2/zend_execute_API.c Mon Nov 24 13:13:29 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute_API.c,v 1.240 2003/11/07 11:47:50 helly Exp $ */ +/* $Id: zend_execute_API.c,v 1.241 2003/11/24 18:13:29 andi Exp $ */ #include <stdio.h> #include <signal.h> @@ -583,20 +583,17 @@ EX(object) = *fci->object_pp; } else if (Z_TYPE_PP(fci->object_pp) == IS_STRING) { zend_class_entry **ce; - char *lc_class; int found = FAILURE; - lc_class = zend_str_tolower_dup(Z_STRVAL_PP(fci->object_pp), Z_STRLEN_PP(fci->object_pp)); - if (EG(active_op_array) && strcmp(lc_class, "self") == 0) { + if (EG(active_op_array) && strcmp(Z_STRVAL_PP(fci->object_pp), "self") == 0) { ce = &(EG(active_op_array)->scope); found = (*ce != NULL?SUCCESS:FAILURE); - } else if (strcmp(lc_class, "parent") == 0 && EG(active_op_array) && EG(active_op_array)->scope) { + } else if (strcmp(Z_STRVAL_PP(fci->object_pp), "parent") == 0 && EG(active_op_array) && EG(active_op_array)->scope) { ce = &(EG(active_op_array)->scope->parent); found = (*ce != NULL?SUCCESS:FAILURE); } else { - found = zend_lookup_class(lc_class, Z_STRLEN_PP(fci->object_pp), &ce TSRMLS_CC); + found = zend_lookup_class(Z_STRVAL_PP(fci->object_pp), Z_STRLEN_PP(fci->object_pp), &ce TSRMLS_CC); } - efree(lc_class); if (found == FAILURE) return FAILURE; @@ -782,8 +779,13 @@ zval class_name, *class_name_ptr = &class_name; zval *retval_ptr; int retval; + char *lc_name; - if (zend_hash_find(EG(class_table), name, name_length+1, (void **) ce) == SUCCESS) { + lc_name = do_alloca(name_length + 1); + zend_str_tolower_copy(lc_name, name, name_length+1); + + if (zend_hash_find(EG(class_table), lc_name, name_length+1, (void **) ce) == SUCCESS) { + free_alloca(lc_name); return SUCCESS; } @@ -797,17 +799,21 @@ retval = call_user_function_ex(EG(function_table), NULL, &autoload_function, &retval_ptr, 1, args, 0, NULL TSRMLS_CC); if (retval == FAILURE) { + free_alloca(lc_name); return FAILURE; } if (EG(exception)) { + free_alloca(lc_name); zend_error(E_ERROR, "__autoload threw an exception"); } /* If an exception is thrown retval_ptr will be NULL but we bailout before we reach this point */ zval_ptr_dtor(&retval_ptr); - return zend_hash_find(EG(class_table), name, name_length + 1, (void **) ce); + retval = zend_hash_find(EG(class_table), lc_name, name_length + 1, (void **) ce); + free_alloca(lc_name); + return retval; } ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC) Index: ZendEngine2/zend_reflection_api.c diff -u ZendEngine2/zend_reflection_api.c:1.75 ZendEngine2/zend_reflection_api.c:1.76 --- ZendEngine2/zend_reflection_api.c:1.75 Sun Nov 23 07:55:22 2003 +++ ZendEngine2/zend_reflection_api.c Mon Nov 24 13:13:29 2003 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_reflection_api.c,v 1.75 2003/11/23 12:55:22 andi Exp $ */ +/* $Id: zend_reflection_api.c,v 1.76 2003/11/24 18:13:29 andi Exp $ */ #include "zend.h" #include "zend_API.h" #include "zend_default_classes.h" @@ -2386,7 +2386,6 @@ reflection_object *intern, *argument; zend_class_entry *ce, **pce, *class_ce; zval *class_name; - char *class_name_lc; METHOD_NOTSTATIC; GET_REFLECTION_OBJECT_PTR(ce); @@ -2397,15 +2396,11 @@ switch(class_name->type) { case IS_STRING: - class_name_lc = do_alloca(Z_STRLEN_P(class_name) + 1); - zend_str_tolower_copy(class_name_lc, Z_STRVAL_P(class_name), Z_STRLEN_P(class_name)+ 1); - if (zend_lookup_class(class_name_lc, Z_STRLEN_P(class_name), &pce TSRMLS_CC) == FAILURE) { - free_alloca(class_name_lc); + if (zend_lookup_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), &pce TSRMLS_CC) == FAILURE) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Interface %s doesn't exist", Z_STRVAL_P(class_name)); return; } - free_alloca(class_name_lc); class_ce = *pce; break; case IS_OBJECT: @@ -2437,7 +2432,6 @@ reflection_object *intern, *argument; zend_class_entry *ce, *interface_ce, **pce; zval *interface; - char *interface_lc; METHOD_NOTSTATIC; GET_REFLECTION_OBJECT_PTR(ce); @@ -2448,15 +2442,11 @@ switch(interface->type) { case IS_STRING: - interface_lc = do_alloca(Z_STRLEN_P(interface) + 1); - zend_str_tolower_copy(interface_lc, Z_STRVAL_P(interface), Z_STRLEN_P(interface)); - if (zend_lookup_class(interface_lc, Z_STRLEN_P(interface), &pce TSRMLS_CC) == FAILURE) { - free_alloca(interface_lc); + if (zend_lookup_class(Z_STRVAL_P(interface), Z_STRLEN_P(interface), &pce TSRMLS_CC) == FAILURE) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Interface %s doesn't exist", Z_STRVAL_P(interface)); return; } - free_alloca(interface_lc); interface_ce = *pce; break; case IS_OBJECT: