cvs: php-src /ext/dom php_dom.c /ext/libxml libxml.c /ext/spl spl_functions.c /main main.c ZendEngine2 zend.c zend_API.c zend_API.h zend_compile.c
zend_compile.h zend_constants.c zend_opcode.c
| From: | Dmitry Stogov | Date: | Fri, 17 Nov 2006 10:48:54 +0000 |
| Subject: | cvs: php-src /ext/dom php_dom.c /ext/libxml libxml.c /ext/spl spl_functions.c /main main.c ZendEngine2 zend.c zend_API.c zend_API.h zend_compile.c zend_compile.h zend_constants.c zend_opcode.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-41624@lists.php.net to get a copy of this message | ||
dmitry Fri Nov 17 10:48:54 2006 UTC
Modified files:
/ZendEngine2 zend.c zend_API.c zend_API.h zend_compile.c
zend_compile.h zend_constants.c zend_opcode.c
/php-src/ext/dom php_dom.c
/php-src/ext/libxml libxml.c
/php-src/ext/spl spl_functions.c
/php-src/main main.c
Log:
Unicode support.
Now the real UG(unicode) value is available during MINIT calls.
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.c?r1=1.382&r2=1.383&diff_format=u Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.382 ZendEngine2/zend.c:1.383 --- ZendEngine2/zend.c:1.382 Wed Nov 8 11:04:42 2006 +++ ZendEngine2/zend.c Fri Nov 17 10:48:53 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.c,v 1.382 2006/11/08 11:04:42 dmitry Exp $ */ +/* $Id: zend.c,v 1.383 2006/11/17 10:48:53 dmitry Exp $ */ #include "zend.h" #include "zend_extensions.h" @@ -671,7 +671,6 @@ } -#define ZEND_U_FUNCTION_DTOR (void (*)(void *)) zend_u_function_dtor #define ZEND_U_CONSTANT_DTOR (void (*)(void *)) free_u_zend_constant static void zval_copy_persistent(zval *zv) @@ -687,32 +686,6 @@ } } -static void zend_u_function_dtor(zend_function *function) -{ - TSRMLS_FETCH(); - - destroy_zend_function(function TSRMLS_CC); - if (function->type == ZEND_INTERNAL_FUNCTION) { - if (function->common.function_name.v) { - free(function->common.function_name.v); - } - if (function->common.arg_info) { - int n = function->common.num_args; - - while (n > 0) { - --n; - if (function->common.arg_info[n].name.v) { - free(function->common.arg_info[n].name.v); - } - if (function->common.arg_info[n].class_name.v) { - free(function->common.arg_info[n].class_name.v); - } - } - free(function->common.arg_info); - } - } -} - static void free_u_zend_constant(zend_constant *c) { if (!(c->flags & CONST_PERSISTENT)) { @@ -740,17 +713,17 @@ args = malloc((n + 1) * sizeof(zend_arg_info)); memcpy(args, func->common.arg_info, (n + 1) * sizeof(zend_arg_info)); while (n > 0) { - --n; - if (args[n].name.s) { + --n; + if (args[n].name.s) { UChar *uname = malloc(UBYTES(args[n].name_len + 1)); u_charsToUChars(args[n].name.s, uname, args[n].name_len+1); args[n].name.u = uname; - } - if (args[n].class_name.s) { + } + if (args[n].class_name.s) { UChar *uname = malloc(UBYTES(args[n].class_name_len + 1)); u_charsToUChars(args[n].class_name.s, uname, args[n].class_name_len+1); args[n].class_name.u = uname; - } + } } func->common.arg_info = args; } @@ -822,11 +795,11 @@ compiler_globals->compiled_filename = NULL; compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable)); - zend_u_hash_init_ex(compiler_globals->function_table, 100, NULL, ZEND_FUNCTION_DTOR, 1, UG(unicode), 0); + zend_u_hash_init_ex(compiler_globals->function_table, global_function_table->nNumOfElements, NULL, ZEND_FUNCTION_DTOR, 1, UG(unicode), 0); zend_hash_copy(compiler_globals->function_table, global_function_table, NULL, &tmp_func, sizeof(zend_function)); compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable)); - zend_u_hash_init_ex(compiler_globals->class_table, 10, NULL, ZEND_CLASS_DTOR, 1, UG(unicode), 0); + zend_u_hash_init_ex(compiler_globals->class_table, global_class_table->nNumOfElements, NULL, ZEND_CLASS_DTOR, 1, UG(unicode), 0); zend_hash_copy(compiler_globals->class_table, global_class_table, (copy_ctor_func_t) zend_class_add_ref, &tmp_class, sizeof(zend_class_entry *)); zend_set_default_compile_time_values(TSRMLS_C); @@ -835,7 +808,7 @@ CG(literal_type) = IS_STRING; compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable)); - zend_u_hash_init_ex(compiler_globals->auto_globals, 8, NULL, NULL, 1, UG(unicode), 0); + zend_u_hash_init_ex(compiler_globals->auto_globals, global_auto_globals_table->nNumOfElements, NULL, NULL, 1, UG(unicode), 0); zend_hash_copy(compiler_globals->auto_globals, global_auto_globals_table, NULL, NULL, sizeof(zend_auto_global) /* empty element */); compiler_globals->last_static_member = zend_hash_num_elements(compiler_globals->class_table); @@ -1135,21 +1108,6 @@ int module_number = 0; REGISTER_INI_ENTRIES(); -} - -/* Unlink the global (r/o) copies of the class, function and constant tables, - * and use a fresh r/w copy for the startup thread - */ -void zend_post_startup(TSRMLS_D) -{ -#ifdef ZTS - zend_compiler_globals *compiler_globals = ts_resource(compiler_globals_id); - zend_executor_globals *executor_globals = ts_resource(executor_globals_id); - - *GLOBAL_FUNCTION_TABLE = *compiler_globals->function_table; - *GLOBAL_CLASS_TABLE = *compiler_globals->class_table; - *GLOBAL_CONSTANTS_TABLE = *executor_globals->zend_constants; -#endif /* Make copies of HashTables with UNICODE */ @@ -1160,18 +1118,30 @@ old_runtime_encoding_conv = UG(runtime_encoding_conv); UG(runtime_encoding_conv) = ucnv_open("ASCII", &status); - zend_hash_to_unicode(GLOBAL_FUNCTION_TABLE, (apply_func_t)function_to_unicode TSRMLS_CC); - GLOBAL_FUNCTION_TABLE->pDestructor = ZEND_U_FUNCTION_DTOR; - zend_hash_to_unicode(GLOBAL_CLASS_TABLE, (apply_func_t)class_to_unicode TSRMLS_CC); - zend_hash_to_unicode(GLOBAL_AUTO_GLOBALS_TABLE, NULL TSRMLS_CC); - zend_hash_to_unicode(GLOBAL_CONSTANTS_TABLE, (apply_func_t)const_to_unicode TSRMLS_CC); - GLOBAL_CONSTANTS_TABLE->pDestructor = ZEND_U_CONSTANT_DTOR; + zend_hash_to_unicode(CG(function_table), (apply_func_t)function_to_unicode TSRMLS_CC); + CG(function_table)->pDestructor = ZEND_U_FUNCTION_DTOR; + zend_hash_to_unicode(CG(class_table), (apply_func_t)class_to_unicode TSRMLS_CC); + zend_hash_to_unicode(CG(auto_globals), NULL TSRMLS_CC); + zend_hash_to_unicode(EG(zend_constants), (apply_func_t)const_to_unicode TSRMLS_CC); + EG(zend_constants)->pDestructor = ZEND_U_CONSTANT_DTOR; ucnv_close(UG(runtime_encoding_conv)); UG(runtime_encoding_conv) = old_runtime_encoding_conv; } +} +/* Unlink the global (r/o) copies of the class, function and constant tables, + * and use a fresh r/w copy for the startup thread + */ +void zend_post_startup(TSRMLS_D) +{ #ifdef ZTS + zend_compiler_globals *compiler_globals = ts_resource(compiler_globals_id); + zend_executor_globals *executor_globals = ts_resource(executor_globals_id); + + *GLOBAL_FUNCTION_TABLE = *compiler_globals->function_table; + *GLOBAL_CLASS_TABLE = *compiler_globals->class_table; + *GLOBAL_CONSTANTS_TABLE = *executor_globals->zend_constants; zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC); free(compiler_globals->function_table); free(compiler_globals->class_table); http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.414&r2=1.415&diff_format=u Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.414 ZendEngine2/zend_API.c:1.415 --- ZendEngine2/zend_API.c:1.414 Fri Oct 27 21:22:05 2006 +++ ZendEngine2/zend_API.c Fri Nov 17 10:48:53 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.c,v 1.414 2006/10/27 21:22:05 andrei Exp $ */ +/* $Id: zend_API.c,v 1.415 2006/11/17 10:48:53 dmitry Exp $ */ #include "zend.h" #include "zend_execute.h" @@ -1940,8 +1940,8 @@ zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL, *__tostring = NULL; char *lowercase_name; int fname_len; - char *lc_class_name = NULL; - int class_name_len = 0; + zstr lc_class_name = NULL_ZSTR; + unsigned int lc_class_name_len = 0; if (type==MODULE_PERSISTENT) { error_type = E_CORE_WARNING; @@ -1956,17 +1956,44 @@ internal_function->module = EG(current_module); if (scope) { - class_name_len = scope->name_length; - lc_class_name = zend_str_tolower_dup(scope->name.s, class_name_len); + lc_class_name = zend_u_str_case_fold(ZEND_STR_TYPE, scope->name, scope->name_length, 0, &lc_class_name_len); } while (ptr->fname) { internal_function->handler = ptr->handler; - internal_function->function_name.s = ptr->fname; + if (UG(unicode)) { + int len = strlen(ptr->fname)+1; + + internal_function->function_name.u = malloc(UBYTES(len)); + u_charsToUChars(ptr->fname, internal_function->function_name.u, len); + } else { + internal_function->function_name.s = ptr->fname; + } internal_function->scope = scope; internal_function->prototype = NULL; if (ptr->arg_info) { - internal_function->arg_info = ptr->arg_info+1; + if (UG(unicode)) { + zend_arg_info *args; + int n = ptr->num_args; + + args = internal_function->arg_info = malloc((n + 1) * sizeof(zend_arg_info)); + memcpy(args, ptr->arg_info+1, (n + 1) * sizeof(zend_arg_info)); + while (n > 0) { + --n; + if (args[n].name.s) { + UChar *uname = malloc(UBYTES(args[n].name_len + 1)); + u_charsToUChars(args[n].name.s, uname, args[n].name_len+1); + args[n].name.u = uname; + } + if (args[n].class_name.s) { + UChar *uname = malloc(UBYTES(args[n].class_name_len + 1)); + u_charsToUChars(args[n].class_name.s, uname, args[n].class_name_len+1); + args[n].class_name.u = uname; + } + } + } else { + internal_function->arg_info = ptr->arg_info+1; + } internal_function->num_args = ptr->num_args; /* Currently you cannot denote that the function can accept less arguments than num_args */ if (ptr->arg_info[0].required_num_args == -1) { @@ -1986,7 +2013,7 @@ if (ptr->flags) { if (!(ptr->flags & ZEND_ACC_PPP_MASK)) { if (ptr->flags != ZEND_ACC_DEPRECATED || scope) { - zend_error(error_type, "Invalid access level for %s%s%s() - access must be exactly one of public, protected or private", scope ? scope->name.s : "", scope ? "::" : "", ptr->fname); + zend_error(error_type, "Invalid access level for %v%s%s() - access must be exactly one of public, protected or private", scope ? scope->name : EMPTY_ZSTR, scope ? "::" : "", ptr->fname); } internal_function->fn_flags = ZEND_ACC_PUBLIC | ptr->flags; } else { @@ -2007,19 +2034,19 @@ } } if (ptr->flags & ZEND_ACC_STATIC && (!scope || !(scope->ce_flags & ZEND_ACC_INTERFACE))) { - zend_error(error_type, "Static function %s%s%s() cannot be abstract", scope ? scope->name.s : "", scope ? "::" : "", ptr->fname); + zend_error(error_type, "Static function %v%s%s() cannot be abstract", scope ? scope->name : EMPTY_ZSTR, scope ? "::" : "", ptr->fname); } } else { if (scope && (scope->ce_flags & ZEND_ACC_INTERFACE)) { - efree(lc_class_name); - zend_error(error_type, "Interface %s cannot contain non abstract method %s()", scope->name, ptr->fname); + efree(lc_class_name.v); + zend_error(error_type, "Interface %v cannot contain non abstract method %s()", scope->name, ptr->fname); return FAILURE; } if (!internal_function->handler) { if (scope) { - efree(lc_class_name); + efree(lc_class_name.v); } - zend_error(error_type, "Method %s%s%s() cannot be a NULL function", scope ? scope->name.s : "", scope ? "::" : "", ptr->fname); + zend_error(error_type, "Method %v%s%s() cannot be a NULL function", scope ? scope->name : EMPTY_ZSTR, scope ? "::" : "", ptr->fname); zend_unregister_functions(functions, count, target_function_table TSRMLS_CC); return FAILURE; } @@ -2027,7 +2054,7 @@ fname_len = strlen(ptr->fname); lowercase_name = do_alloca(fname_len+1); zend_str_tolower_copy(lowercase_name, ptr->fname, fname_len); - if (zend_hash_add(target_function_table, lowercase_name, fname_len+1, &function, sizeof(zend_function), (void**)®_function) == FAILURE) { + if (zend_ascii_hash_add(target_function_table, lowercase_name, fname_len+1, &function, sizeof(zend_function), (void**)®_function) == FAILURE) { unload=1; free_alloca(lowercase_name); break; @@ -2037,14 +2064,17 @@ * If it's an old-style constructor, store it only if we don't have * a constructor already. */ - if ((fname_len == class_name_len) && !memcmp(lowercase_name, lc_class_name, class_name_len+1) && !ctor) { + unsigned int lc_func_name_len; + zstr lc_func_name = zend_u_str_case_fold(ZEND_STR_TYPE, internal_function->function_name, fname_len, 0, &lc_func_name_len); + + if ((lc_func_name_len == lc_class_name_len) && !memcmp(lc_func_name.v, lc_class_name.v, UG(unicode)?UBYTES(lc_class_name_len):lc_class_name_len) && !ctor) { ctor = reg_function; } else if ((fname_len == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) { ctor = reg_function; } else if ((fname_len == sizeof(ZEND_DESTRUCTOR_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_DESTRUCTOR_FUNC_NAME, sizeof(ZEND_DESTRUCTOR_FUNC_NAME))) { dtor = reg_function; if (internal_function->num_args) { - zend_error(error_type, "Destructor %s::%s() cannot take arguments", scope->name, ptr->fname); + zend_error(error_type, "Destructor %v::%s() cannot take arguments", scope->name, ptr->fname); } } else if ((fname_len == sizeof(ZEND_CLONE_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_CLONE_FUNC_NAME, sizeof(ZEND_CLONE_FUNC_NAME))) { clone = reg_function; @@ -2073,11 +2103,11 @@ } if (unload) { /* before unloading, display all remaining bad function in the module */ if (scope) { - free_alloca(lc_class_name); + free_alloca(lc_class_name.v); } while (ptr->fname) { if (zend_hash_exists(target_function_table, ptr->fname, strlen(ptr->fname)+1)) { - zend_error(error_type, "Function registration failed - duplicate name - %s%s%s", scope ? scope->name.s : "", scope ? "::" : "", ptr->fname); + zend_error(error_type, "Function registration failed - duplicate name - %v%s%s", scope ? scope->name : EMPTY_ZSTR, scope ? "::" : "", ptr->fname); } ptr++; } @@ -2097,61 +2127,61 @@ if (ctor) { ctor->common.fn_flags |= ZEND_ACC_CTOR; if (ctor->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Constructor %s::%s() cannot be static", scope->name, ctor->common.function_name); + zend_error(error_type, "Constructor %v::%v() cannot be static", scope->name, ctor->common.function_name); } ctor->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (dtor) { dtor->common.fn_flags |= ZEND_ACC_DTOR; if (dtor->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Destructor %s::%s() cannot be static", scope->name, dtor->common.function_name); + zend_error(error_type, "Destructor %v::%v() cannot be static", scope->name, dtor->common.function_name); } dtor->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (clone) { clone->common.fn_flags |= ZEND_ACC_CLONE; if (clone->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Constructor %s::%s() cannot be static", scope->name, clone->common.function_name); + zend_error(error_type, "Constructor %v::%v() cannot be static", scope->name, clone->common.function_name); } clone->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (__call) { if (__call->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __call->common.function_name); + zend_error(error_type, "Method %v::%v() cannot be static", scope->name, __call->common.function_name); } __call->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (__tostring) { if (__tostring->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __tostring->common.function_name); + zend_error(error_type, "Method %v::%v() cannot be static", scope->name, __tostring->common.function_name); } __tostring->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (__get) { if (__get->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __get->common.function_name); + zend_error(error_type, "Method %v::%v() cannot be static", scope->name, __get->common.function_name); } __get->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (__set) { if (__set->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __set->common.function_name); + zend_error(error_type, "Method %v::%v() cannot be static", scope->name, __set->common.function_name); } __set->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (__unset) { if (__unset->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __unset->common.function_name); + zend_error(error_type, "Method %v::%v() cannot be static", scope->name, __unset->common.function_name); } __unset->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (__isset) { if (__isset->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __isset->common.function_name); + zend_error(error_type, "Method %v::%v() cannot be static", scope->name, __isset->common.function_name); } __isset->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } - efree(lc_class_name); + efree(lc_class_name.v); } return SUCCESS; } @@ -2175,7 +2205,7 @@ #if 0 zend_printf("Unregistering %s()\n", ptr->fname); #endif - zend_hash_del(target_function_table, ptr->fname, strlen(ptr->fname)+1); + zend_ascii_hash_del(target_function_table, ptr->fname, strlen(ptr->fname)+1); ptr++; i++; } @@ -2288,7 +2318,9 @@ static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class_entry, zend_uint ce_flags TSRMLS_DC) { zend_class_entry *class_entry = malloc(sizeof(zend_class_entry)); - char *lowercase_name = malloc(orig_class_entry->name_length + 1); + zstr lcname; + unsigned int lcname_len; + *class_entry = *orig_class_entry; class_entry->type = ZEND_INTERNAL_CLASS; @@ -2300,9 +2332,9 @@ zend_register_functions(class_entry, class_entry->builtin_functions, &class_entry->function_table, MODULE_PERSISTENT TSRMLS_CC); } - zend_str_tolower_copy(lowercase_name, orig_class_entry->name.s, class_entry->name_length); - zend_hash_update(CG(class_table), lowercase_name, class_entry->name_length+1, &class_entry, sizeof(zend_class_entry *), NULL); - free(lowercase_name); + lcname = zend_u_str_case_fold(ZEND_STR_TYPE, class_entry->name, class_entry->name_length, 0, &lcname_len); + zend_u_hash_update(CG(class_table), ZEND_STR_TYPE, lcname, lcname_len+1, &class_entry, sizeof(zend_class_entry *), NULL); + efree(lcname.v); return class_entry; } @@ -2317,7 +2349,7 @@ if (!parent_ce && parent_name) { zend_class_entry **pce; - if (zend_hash_find(CG(class_table), parent_name, strlen(parent_name)+1, (void **) &pce)==FAILURE) { + if (zend_ascii_hash_find(CG(class_table), parent_name, strlen(parent_name)+1, (void **) &pce)==FAILURE) { return NULL; } else { parent_ce = *pce; @@ -2979,7 +3011,18 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, char *name, int name_length, zval *property, int access_type, zstr doc_comment, int doc_comment_len TSRMLS_DC) { - return zend_u_declare_property_ex(ce, IS_STRING, ZSTR(name), name_length, property, access_type, doc_comment, doc_comment_len TSRMLS_CC); + if (UG(unicode)) { + zstr uname; + int ret; + + uname.u = do_alloca(name_length+1); + u_charsToUChars(name, uname.u, name_length+1); + ret = zend_u_declare_property_ex(ce, IS_UNICODE, uname, name_length, property, access_type, doc_comment, doc_comment_len TSRMLS_CC); + free_alloca(uname.u); + return ret; + } else { + return zend_u_declare_property_ex(ce, IS_STRING, ZSTR(name), name_length, property, access_type, doc_comment, doc_comment_len TSRMLS_CC); + } } ZEND_API int zend_u_declare_property(zend_class_entry *ce, zend_uchar type, zstr name, int name_length, zval *property, int access_type TSRMLS_DC) @@ -2989,7 +3032,18 @@ ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_length, zval *property, int access_type TSRMLS_DC) { - return zend_u_declare_property_ex(ce, IS_STRING, ZSTR(name), name_length, property, access_type, NULL_ZSTR, 0 TSRMLS_CC); + if (UG(unicode)) { + zstr uname; + int ret; + + uname.u = do_alloca(name_length+1); + u_charsToUChars(name, uname.u, name_length+1); + ret = zend_u_declare_property_ex(ce, IS_UNICODE, uname, name_length, property, access_type, NULL_ZSTR, 0 TSRMLS_CC); + free_alloca(uname.u); + return ret; + } else { + return zend_u_declare_property_ex(ce, IS_STRING, ZSTR(name), name_length, property, access_type, NULL_ZSTR, 0 TSRMLS_CC); + } } ZEND_API int zend_declare_property_null(zend_class_entry *ce, char *name, int name_length, int access_type TSRMLS_DC) @@ -3054,10 +3108,17 @@ if (ce->type & ZEND_INTERNAL_CLASS) { property = malloc(sizeof(zval)); - ZVAL_STRINGL(property, zend_strndup(value, len), len, 0); + if (UG(unicode)) { + Z_TYPE_P(property) = IS_UNICODE; + Z_USTRVAL_P(property) = malloc(UBYTES(len+1)); + u_charsToUChars(value, Z_USTRVAL_P(property), len+1); + Z_USTRLEN_P(property) = len; + } else { + ZVAL_STRINGL(property, zend_strndup(value, len), len, 0); + } } else { ALLOC_ZVAL(property); - ZVAL_STRINGL(property, value, len, 1); + ZVAL_ASCII_STRINGL(property, value, len, 1); } INIT_PZVAL(property); return zend_declare_property(ce, name, name_length, property, access_type TSRMLS_CC); @@ -3069,10 +3130,17 @@ if (ce->type & ZEND_INTERNAL_CLASS) { property = malloc(sizeof(zval)); - ZVAL_STRINGL(property, zend_strndup(value, value_len), value_len, 0); + if (UG(unicode)) { + Z_TYPE_P(property) = IS_UNICODE; + Z_USTRVAL_P(property) = malloc(UBYTES(value_len+1)); + u_charsToUChars(value, Z_USTRVAL_P(property), value_len+1); + Z_USTRLEN_P(property) = value_len; + } else { + ZVAL_STRINGL(property, zend_strndup(value, value_len), value_len, 0); + } } else { ALLOC_ZVAL(property); - ZVAL_STRINGL(property, value, value_len, 1); + ZVAL_ASCII_STRINGL(property, value, value_len, 1); } INIT_PZVAL(property); return zend_declare_property(ce, name, name_length, property, access_type TSRMLS_CC); @@ -3080,7 +3148,7 @@ ZEND_API int zend_declare_class_constant(zend_class_entry *ce, char *name, size_t name_length, zval *value TSRMLS_DC) { - return zend_hash_update(&ce->constants_table, name, name_length+1, &value, sizeof(zval *), NULL); + return zend_ascii_hash_update(&ce->constants_table, name, name_length+1, &value, sizeof(zval *), NULL); } ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, char *name, size_t name_length TSRMLS_DC) @@ -3143,12 +3211,19 @@ { zval *constant; - if (ce->type & ZEND_INTERNAL_CLASS) { + if (ce->type & ZEND_INTERNAL_CLASS) { constant = malloc(sizeof(zval)); - ZVAL_STRINGL(constant, zend_strndup(value, value_length), value_length, 0); + if (UG(unicode)) { + Z_TYPE_P(constant) = IS_UNICODE; + Z_USTRVAL_P(constant) = malloc(UBYTES(value_length+1)); + u_charsToUChars(value, Z_USTRVAL_P(constant), value_length+1); + Z_USTRLEN_P(constant) = value_length; + } else { + ZVAL_STRINGL(constant, zend_strndup(value, value_length), value_length, 0); + } } else { ALLOC_ZVAL(constant); - ZVAL_STRINGL(constant, value, value_length, 1); + ZVAL_ASCII_STRINGL(constant, value, value_length, 1); } INIT_PZVAL(constant); return zend_declare_class_constant(ce, name, name_length, constant TSRMLS_CC); http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.h?r1=1.269&r2=1.270&diff_format=u Index: ZendEngine2/zend_API.h diff -u ZendEngine2/zend_API.h:1.269 ZendEngine2/zend_API.h:1.270 --- ZendEngine2/zend_API.h:1.269 Wed Nov 15 22:50:19 2006 +++ ZendEngine2/zend_API.h Fri Nov 17 10:48:53 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.h,v 1.269 2006/11/15 22:50:19 tony2001 Exp $ */ +/* $Id: zend_API.h,v 1.270 2006/11/17 10:48:53 dmitry Exp $ */ #ifndef ZEND_API_H #define ZEND_API_H @@ -121,12 +121,22 @@ #endif -#define INIT_CLASS_ENTRY(class_container, class_name, functions) INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL) +#define INIT_CLASS_ENTRY(class_container, class_name, functions) \ + INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL) -#define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \ +#define INIT_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions) \ + INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, NULL, NULL, NULL, NULL, NULL) + +#define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \ { \ - class_container.name.s = strdup(class_name); \ - class_container.name_length = sizeof(class_name) - 1; \ + int _len = class_name_len; \ + if (UG(unicode)) { \ + class_container.name.u = malloc(UBYTES(_len+1)); \ + u_charsToUChars(class_name, class_container.name.u, _len+1); \ + } else { \ + class_container.name.s = zend_strndup(class_name, _len); \ + } \ + class_container.name_length = _len; \ class_container.builtin_functions = functions; \ class_container.constructor = NULL; \ class_container.destructor = NULL; \ @@ -154,7 +164,7 @@ } #define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \ - INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset, NULL, NULL) + INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, sizeof(class_name)-1, functions, handle_fcall, handle_propget, handle_propset, NULL, NULL) #ifdef ZTS # define CE_STATIC_MEMBERS(ce) (((ce)->type==ZEND_USER_CLASS)?(ce)->static_members:CG(static_members)[(long)(ce)->static_members]) http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.727&r2=1.728&diff_format=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.727 ZendEngine2/zend_compile.c:1.728 --- ZendEngine2/zend_compile.c:1.727 Fri Oct 27 21:22:05 2006 +++ ZendEngine2/zend_compile.c Fri Nov 17 10:48:53 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.727 2006/10/27 21:22:05 andrei Exp $ */ +/* $Id: zend_compile.c,v 1.728 2006/11/17 10:48:53 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -1919,13 +1919,32 @@ zend_u_hash_init(op_array->static_variables, zend_hash_num_elements(static_variables), NULL, ZVAL_PTR_DTOR, 0, UG(unicode)); zend_hash_copy(op_array->static_variables, static_variables, (copy_ctor_func_t) zval_add_ref, (void *) &tmp_zval, sizeof(zval *)); } + } else if (UG(unicode) && function->type == ZEND_INTERNAL_FUNCTION) { + zend_internal_function *func = &function->internal_function; + + func->function_name.u = zend_ustrndup(func->function_name.u, u_strlen(func->function_name.u)); + if (func->arg_info) { + zend_arg_info *args; + int n = func->num_args; + + args = malloc((n + 1) * sizeof(zend_arg_info)); + memcpy(args, func->arg_info, (n + 1) * sizeof(zend_arg_info)); + while (n > 0) { + --n; + if (args[n].name.u) { + args[n].name.u = zend_ustrndup(args[n].name.u, u_strlen(args[n].name.u)); + } + if (args[n].class_name.s) { + args[n].class_name.u = zend_ustrndup(args[n].class_name.u, u_strlen(args[n].class_name.u)); + } + } + func->arg_info = args; + } } } static void do_inherit_parent_constructor(zend_class_entry *ce TSRMLS_DC) { - zend_function *function; - if (!ce->parent) { return; } @@ -1978,34 +1997,17 @@ ); } return; - } - - if (zend_hash_find(&ce->parent->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), (void **)&function)==SUCCESS) { - /* inherit parent's constructor */ - zend_hash_update(&ce->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), function, sizeof(zend_function), NULL); - function_add_ref(function TSRMLS_CC); - } else { - /* Don't inherit the old style constructor if we already have the new style constructor */ - unsigned int lc_class_name_len, lc_parent_class_name_len; - zstr lc_class_name; - zstr lc_parent_class_name; - zend_uchar utype = UG(unicode)?IS_UNICODE:IS_STRING; - - lc_class_name = zend_u_str_case_fold(utype, ce->name, ce->name_length, 0, &lc_class_name_len); - if (!zend_u_hash_exists(&ce->function_table, utype, lc_class_name, lc_class_name_len+1)) { - lc_parent_class_name = zend_u_str_case_fold(utype, ce->parent->name, ce->parent->name_length, 0, &lc_parent_class_name_len); - if (zend_u_hash_find(&ce->parent->function_table, utype, lc_parent_class_name, lc_parent_class_name_len+1, (void **)&function)==SUCCESS) { - if (function->common.fn_flags & ZEND_ACC_CTOR) { - /* inherit parent's constructor */ - zend_u_hash_update(&ce->function_table, utype, lc_class_name, lc_class_name_len+1, function, sizeof(zend_function), NULL); - function_add_ref(function TSRMLS_CC); - } - } - efree(lc_parent_class_name.v); + } else if (ce->parent->constructor) { + ce->constructor = ce->parent->constructor; + if (!zend_ascii_hash_exists(&ce->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) { + unsigned int lc_class_name_len; + zstr lc_class_name = zend_u_str_case_fold(ZEND_STR_TYPE, ce->name, ce->name_length, 0, &lc_class_name_len); + + zend_u_hash_update(&ce->function_table, ZEND_STR_TYPE, lc_class_name, lc_class_name_len+1, ce->constructor, sizeof(zend_function), NULL); + function_add_ref(ce->constructor TSRMLS_CC); + efree(lc_class_name.v); } - efree(lc_class_name.v); } - ce->constructor = ce->parent->constructor; } @@ -4347,7 +4349,7 @@ zend_u_hash_init_ex(&ce->properties_info, 0, NULL, (dtor_func_t) (persistent_hashes ? zend_destroy_property_info_internal : zend_destroy_property_info), persistent_hashes, UG(unicode), 0); zend_u_hash_init_ex(&ce->default_static_members, 0, NULL, zval_ptr_dtor_func, persistent_hashes, UG(unicode), 0); zend_u_hash_init_ex(&ce->constants_table, 0, NULL, zval_ptr_dtor_func, persistent_hashes, UG(unicode), 0); - zend_u_hash_init_ex(&ce->function_table, 0, NULL, ZEND_FUNCTION_DTOR, persistent_hashes, UG(unicode), 0); + zend_u_hash_init_ex(&ce->function_table, 0, NULL, UG(unicode)?ZEND_U_FUNCTION_DTOR:ZEND_FUNCTION_DTOR, persistent_hashes, UG(unicode), 0); if (ce->type == ZEND_INTERNAL_CLASS) { #ifdef ZTS http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.h?r1=1.349&r2=1.350&diff_format=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.349 ZendEngine2/zend_compile.h:1.350 --- ZendEngine2/zend_compile.h:1.349 Fri Oct 27 21:22:05 2006 +++ ZendEngine2/zend_compile.h Fri Nov 17 10:48:53 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.349 2006/10/27 21:22:05 andrei Exp $ */ +/* $Id: zend_compile.h,v 1.350 2006/11/17 10:48:53 dmitry Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -545,6 +545,7 @@ ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC); ZEND_API void zend_function_dtor(zend_function *function); +ZEND_API void zend_u_function_dtor(zend_function *function); ZEND_API void destroy_zend_class(zend_class_entry **pce); void zend_class_add_ref(zend_class_entry **ce); @@ -556,6 +557,7 @@ #define ZEND_FUNCTION_DTOR (void (*)(void *)) zend_function_dtor +#define ZEND_U_FUNCTION_DTOR (void (*)(void *)) zend_u_function_dtor #define ZEND_CLASS_DTOR (void (*)(void *)) destroy_zend_class zend_op *get_next_op(zend_op_array *op_array TSRMLS_DC); http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_constants.c?r1=1.88&r2=1.89&diff_format=u Index: ZendEngine2/zend_constants.c diff -u ZendEngine2/zend_constants.c:1.88 ZendEngine2/zend_constants.c:1.89 --- ZendEngine2/zend_constants.c:1.88 Wed Oct 18 16:34:25 2006 +++ ZendEngine2/zend_constants.c Fri Nov 17 10:48:53 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_constants.c,v 1.88 2006/10/18 16:34:25 johannes Exp $ */ +/* $Id: zend_constants.c,v 1.89 2006/11/17 10:48:53 dmitry Exp $ */ #include "zend.h" #include "zend_constants.h" @@ -186,13 +186,19 @@ { zend_constant c; + if (UG(unicode)) { + c.name.u = malloc(UBYTES(name_len)); + u_charsToUChars(name, c.name.u, name_len); + c.name_len = name_len; + } else { + c.name.s = zend_strndup(name, name_len-1); + c.name_len = name_len; + } Z_TYPE(c.value) = IS_LONG; Z_LVAL(c.value) = lval; c.flags = flags; - c.name.s = zend_strndup(name, name_len-1); - c.name_len = name_len; c.module_number = module_number; - zend_register_constant(&c TSRMLS_CC); + zend_u_register_constant(ZEND_STR_TYPE, &c TSRMLS_CC); } @@ -200,13 +206,19 @@ { zend_constant c; + if (UG(unicode)) { + c.name.u = malloc(UBYTES(name_len)); + u_charsToUChars(name, c.name.u, name_len); + c.name_len = name_len; + } else { + c.name.s = zend_strndup(name, name_len-1); + c.name_len = name_len; + } Z_TYPE(c.value) = IS_DOUBLE; Z_DVAL(c.value) = dval; c.flags = flags; - c.name.s = zend_strndup(name, name_len-1); - c.name_len = name_len; c.module_number = module_number; - zend_register_constant(&c TSRMLS_CC); + zend_u_register_constant(ZEND_STR_TYPE, &c TSRMLS_CC); } @@ -214,14 +226,31 @@ { zend_constant c; - Z_TYPE(c.value) = IS_STRING; - Z_STRVAL(c.value) = strval; - Z_STRLEN(c.value) = strlen; + if (UG(unicode)) { + c.name.u = malloc(UBYTES(name_len)); + u_charsToUChars(name, c.name.u, name_len); + c.name_len = name_len; + Z_TYPE(c.value) = IS_UNICODE; + if (flags & CONST_PERSISTENT) { + Z_USTRVAL(c.value) = malloc(UBYTES(strlen+1)); + } else { + Z_USTRVAL(c.value) = emalloc(UBYTES(strlen+1)); + } + u_charsToUChars(strval, Z_USTRVAL(c.value), strlen+1); + Z_USTRLEN(c.value) = strlen; + if (!(flags & CONST_PERSISTENT)) { + efree(strval); + } + } else { + c.name.s = zend_strndup(name, name_len-1); + c.name_len = name_len; + Z_TYPE(c.value) = IS_STRING; + Z_STRVAL(c.value) = strval; + Z_STRLEN(c.value) = strlen; + } c.flags = flags; - c.name.s = zend_strndup(name, name_len-1); - c.name_len = name_len; c.module_number = module_number; - zend_register_constant(&c TSRMLS_CC); + zend_u_register_constant(ZEND_STR_TYPE, &c TSRMLS_CC); } http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_opcode.c?r1=1.123&r2=1.124&diff_format=u Index: ZendEngine2/zend_opcode.c diff -u ZendEngine2/zend_opcode.c:1.123 ZendEngine2/zend_opcode.c:1.124 --- ZendEngine2/zend_opcode.c:1.123 Sat Oct 28 10:42:04 2006 +++ ZendEngine2/zend_opcode.c Fri Nov 17 10:48:53 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_opcode.c,v 1.123 2006/10/28 10:42:04 tony2001 Exp $ */ +/* $Id: zend_opcode.c,v 1.124 2006/11/17 10:48:53 dmitry Exp $ */ #include <stdio.h> @@ -124,6 +124,32 @@ destroy_zend_function(function TSRMLS_CC); } +ZEND_API void zend_u_function_dtor(zend_function *function) +{ + TSRMLS_FETCH(); + + destroy_zend_function(function TSRMLS_CC); + if (function->type == ZEND_INTERNAL_FUNCTION) { + if (function->common.function_name.v) { + free(function->common.function_name.v); + } + if (function->common.arg_info) { + int n = function->common.num_args; + + while (n > 0) { + --n; + if (function->common.arg_info[n].name.v) { + free(function->common.arg_info[n].name.v); + } + if (function->common.arg_info[n].class_name.v) { + free(function->common.arg_info[n].class_name.v); + } + } + free(function->common.arg_info); + } + } +} + static void zend_cleanup_op_array_data(zend_op_array *op_array) { if (op_array->static_variables) { http://cvs.php.net/viewvc.cgi/php-src/ext/dom/php_dom.c?r1=1.99&r2=1.100&diff_format=u Index: php-src/ext/dom/php_dom.c diff -u php-src/ext/dom/php_dom.c:1.99 php-src/ext/dom/php_dom.c:1.100 --- php-src/ext/dom/php_dom.c:1.99 Fri Sep 22 10:13:27 2006 +++ php-src/ext/dom/php_dom.c Fri Nov 17 10:48:53 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_dom.c,v 1.99 2006/09/22 10:13:27 rrichards Exp $ */ +/* $Id: php_dom.c,v 1.100 2006/11/17 10:48:53 dmitry Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -71,7 +71,6 @@ zend_object_handlers dom_object_handlers; static HashTable classes; -static HashTable u_classes; typedef int (*dom_read_t)(dom_object *obj, zval **retval TSRMLS_DC); typedef int (*dom_write_t)(dom_object *obj, zval *newval TSRMLS_DC); @@ -248,7 +247,7 @@ hnd.read_func = read_func ? read_func : dom_read_na; hnd.write_func = write_func ? write_func : dom_write_na; - zend_hash_add(prop_handler, name, strlen(name)+1, &hnd, sizeof(dom_prop_handler), NULL); + zend_ascii_hash_add(prop_handler, name, strlen(name)+1, &hnd, sizeof(dom_prop_handler), NULL); } /* }}} */ @@ -506,14 +505,6 @@ zend_hash_destroy(ht); } -static void dom_prop_handlers_ctor(HashTable *ht) -{ - HashTable tmp = *ht; - - zend_u_hash_init(ht, 0, NULL, NULL, 1, 1); - zend_hash_copy(ht, &tmp, NULL, NULL, sizeof(dom_prop_handler)); -} - /* {{{ PHP_MINIT_FUNCTION(dom) */ PHP_MINIT_FUNCTION(dom) { @@ -563,19 +554,19 @@ zend_hash_init(&dom_domstringlist_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_domstringlist_prop_handlers, "length", dom_domstringlist_length_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_domstringlist_prop_handlers, sizeof(dom_domstringlist_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_domstringlist_prop_handlers, sizeof(dom_domstringlist_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMNameList", NULL, php_dom_namelist_class_functions, dom_namelist_class_entry); zend_hash_init(&dom_namelist_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_namelist_prop_handlers, "length", dom_namelist_length_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_namelist_prop_handlers, sizeof(dom_namelist_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_namelist_prop_handlers, sizeof(dom_namelist_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMImplementationList", NULL, php_dom_domimplementationlist_class_functions, dom_domimplementationlist_class_entry); zend_hash_init(&dom_domimplementationlist_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_domimplementationlist_prop_handlers, "length", dom_domimplementationlist_length_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_domimplementationlist_prop_handlers, sizeof(dom_domimplementationlist_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_domimplementationlist_prop_handlers, sizeof(dom_domimplementationlist_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMImplementationSource", NULL, php_dom_domimplementationsource_class_functions, dom_domimplementationsource_class_entry); REGISTER_DOM_CLASS(ce, "DOMImplementation", NULL, php_dom_domimplementation_class_functions, dom_domimplementation_class_entry); @@ -599,7 +590,7 @@ dom_register_prop_handler(&dom_node_prop_handlers, "localName", dom_node_local_name_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_node_prop_handlers, "baseURI", dom_node_base_uri_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_node_prop_handlers, "textContent", dom_node_text_content_read, dom_node_text_content_write TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_node_prop_handlers, sizeof(dom_node_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_node_prop_handlers, sizeof(dom_node_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMNameSpaceNode", NULL, NULL, dom_namespace_node_class_entry); @@ -612,12 +603,12 @@ dom_register_prop_handler(&dom_namespace_node_prop_handlers, "namespaceURI", dom_node_namespace_uri_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_namespace_node_prop_handlers, "ownerDocument", dom_node_owner_document_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_namespace_node_prop_handlers, "parentNode", dom_node_parent_node_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_namespace_node_prop_handlers, sizeof(dom_namespace_node_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_namespace_node_prop_handlers, sizeof(dom_namespace_node_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMDocumentFragment", dom_node_class_entry, php_dom_documentfragment_class_functions, dom_documentfragment_class_entry); zend_hash_init(&dom_document_fragment_prop_handlers, 0, NULL, NULL, 1); zend_hash_copy(&dom_document_fragment_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler)); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_document_fragment_prop_handlers, sizeof(dom_node_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_document_fragment_prop_handlers, sizeof(dom_node_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMDocument", dom_node_class_entry, php_dom_document_class_functions, dom_document_class_entry); zend_hash_init(&dom_document_prop_handlers, 0, NULL, NULL, 1); @@ -642,7 +633,7 @@ dom_register_prop_handler(&dom_document_prop_handlers, "substituteEntities", dom_document_substitue_entities_read, dom_document_substitue_entities_write TSRMLS_CC); zend_hash_merge(&dom_document_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_document_prop_handlers, sizeof(dom_document_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_document_prop_handlers, sizeof(dom_document_prop_handlers), NULL); INIT_CLASS_ENTRY(ce, "DOMNodeList", php_dom_nodelist_class_functions); ce.create_object = dom_nnodemap_objects_new; @@ -651,7 +642,7 @@ zend_hash_init(&dom_nodelist_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_nodelist_prop_handlers, "length", dom_nodelist_length_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_nodelist_prop_handlers, sizeof(dom_nodelist_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_nodelist_prop_handlers, sizeof(dom_nodelist_prop_handlers), NULL); INIT_CLASS_ENTRY(ce, "DOMNamedNodeMap", php_dom_namednodemap_class_functions); ce.create_object = dom_nnodemap_objects_new; @@ -660,7 +651,7 @@ zend_hash_init(&dom_namednodemap_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_namednodemap_prop_handlers, "length", dom_namednodemap_length_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_namednodemap_prop_handlers, sizeof(dom_namednodemap_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_namednodemap_prop_handlers, sizeof(dom_namednodemap_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMCharacterData", dom_node_class_entry, php_dom_characterdata_class_functions, dom_characterdata_class_entry); @@ -668,7 +659,7 @@ dom_register_prop_handler(&dom_characterdata_prop_handlers, "data", dom_characterdata_data_read, dom_characterdata_data_write TSRMLS_CC); dom_register_prop_handler(&dom_characterdata_prop_handlers, "length", dom_characterdata_length_read, NULL TSRMLS_CC); zend_hash_merge(&dom_characterdata_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_characterdata_prop_handlers, sizeof(dom_characterdata_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_characterdata_prop_handlers, sizeof(dom_characterdata_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMAttr", dom_node_class_entry, php_dom_attr_class_functions, dom_attr_class_entry); @@ -679,7 +670,7 @@ dom_register_prop_handler(&dom_attr_prop_handlers, "ownerElement", dom_attr_owner_element_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_attr_prop_handlers, "schemaTypeInfo", dom_attr_schema_type_info_read, NULL TSRMLS_CC); zend_hash_merge(&dom_attr_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_attr_prop_handlers, sizeof(dom_attr_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_attr_prop_handlers, sizeof(dom_attr_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMElement", dom_node_class_entry, php_dom_element_class_functions, dom_element_class_entry); @@ -687,26 +678,26 @@ dom_register_prop_handler(&dom_element_prop_handlers, "tagName", dom_element_tag_name_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_element_prop_handlers, "schemaTypeInfo", dom_element_schema_type_info_read, NULL TSRMLS_CC); zend_hash_merge(&dom_element_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_element_prop_handlers, sizeof(dom_element_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_element_prop_handlers, sizeof(dom_element_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMText", dom_characterdata_class_entry, php_dom_text_class_functions, dom_text_class_entry); zend_hash_init(&dom_text_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_text_prop_handlers, "wholeText", dom_text_whole_text_read, NULL TSRMLS_CC); zend_hash_merge(&dom_text_prop_handlers, &dom_characterdata_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_text_prop_handlers, sizeof(dom_text_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_text_prop_handlers, sizeof(dom_text_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMComment", dom_characterdata_class_entry, php_dom_comment_class_functions, dom_comment_class_entry); zend_hash_init(&dom_comment_prop_handlers, 0, NULL, NULL, 1); zend_hash_copy(&dom_comment_prop_handlers, &dom_characterdata_prop_handlers, NULL, NULL, sizeof(dom_prop_handler)); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_comment_prop_handlers, sizeof(dom_comment_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_comment_prop_handlers, sizeof(dom_comment_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMTypeinfo", NULL, php_dom_typeinfo_class_functions, dom_typeinfo_class_entry); zend_hash_init(&dom_typeinfo_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_typeinfo_prop_handlers, "typeName", dom_typeinfo_type_name_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_typeinfo_prop_handlers, "typeNamespace", dom_typeinfo_type_namespace_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_typeinfo_prop_handlers, sizeof(dom_typeinfo_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_typeinfo_prop_handlers, sizeof(dom_typeinfo_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMUserDataHandler", NULL, php_dom_userdatahandler_class_functions, dom_userdatahandler_class_entry); REGISTER_DOM_CLASS(ce, "DOMDomError", NULL, php_dom_domerror_class_functions, dom_domerror_class_entry); @@ -718,7 +709,7 @@ dom_register_prop_handler(&dom_domerror_prop_handlers, "relatedException", dom_domerror_related_exception_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_domerror_prop_handlers, "related_data", dom_domerror_related_data_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_domerror_prop_handlers, "location", dom_domerror_location_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_domerror_prop_handlers, sizeof(dom_domerror_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_domerror_prop_handlers, sizeof(dom_domerror_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMErrorHandler", NULL, php_dom_domerrorhandler_class_functions, dom_domerrorhandler_class_entry); REGISTER_DOM_CLASS(ce, "DOMLocator", NULL, php_dom_domlocator_class_functions, dom_domlocator_class_entry); @@ -729,13 +720,13 @@ dom_register_prop_handler(&dom_domlocator_prop_handlers, "offset", dom_domlocator_offset_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_domlocator_prop_handlers, "relatedNode", dom_domlocator_related_node_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_domlocator_prop_handlers, "uri", dom_domlocator_uri_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_domlocator_prop_handlers, sizeof(dom_domlocator_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_domlocator_prop_handlers, sizeof(dom_domlocator_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMConfiguration", NULL, php_dom_domconfiguration_class_functions, dom_domconfiguration_class_entry); REGISTER_DOM_CLASS(ce, "DOMCdataSection", dom_text_class_entry, php_dom_cdatasection_class_functions, dom_cdatasection_class_entry); zend_hash_init(&dom_cdata_prop_handlers, 0, NULL, NULL, 1); zend_hash_copy(&dom_cdata_prop_handlers, &dom_text_prop_handlers, NULL, NULL, sizeof(dom_prop_handler)); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_cdata_prop_handlers, sizeof(dom_documenttype_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_cdata_prop_handlers, sizeof(dom_documenttype_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMDocumentType", dom_node_class_entry, php_dom_documenttype_class_functions, dom_documenttype_class_entry); @@ -747,7 +738,7 @@ dom_register_prop_handler(&dom_documenttype_prop_handlers, "systemId", dom_documenttype_system_id_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_documenttype_prop_handlers, "internalSubset", dom_documenttype_internal_subset_read, NULL TSRMLS_CC); zend_hash_merge(&dom_documenttype_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_documenttype_prop_handlers, sizeof(dom_documenttype_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_documenttype_prop_handlers, sizeof(dom_documenttype_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMNotation", NULL, php_dom_notation_class_functions, dom_notation_class_entry); @@ -758,7 +749,7 @@ dom_register_prop_handler(&dom_notation_prop_handlers, "nodeName", dom_node_node_name_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_notation_prop_handlers, "nodeValue", dom_node_node_value_read, dom_node_node_value_write TSRMLS_CC); dom_register_prop_handler(&dom_notation_prop_handlers, "attributes", dom_node_attributes_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_notation_prop_handlers, sizeof(dom_notation_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_notation_prop_handlers, sizeof(dom_notation_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMEntity", dom_node_class_entry, php_dom_entity_class_functions, dom_entity_class_entry); @@ -771,12 +762,12 @@ dom_register_prop_handler(&dom_entity_prop_handlers, "version", dom_entity_version_read, dom_entity_version_write TSRMLS_CC); zend_hash_merge(&dom_entity_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_entity_prop_handlers, sizeof(dom_entity_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_entity_prop_handlers, sizeof(dom_entity_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMEntityReference", dom_node_class_entry, php_dom_entityreference_class_functions, dom_entityreference_class_entry); zend_hash_init(&dom_entity_reference_prop_handlers, 0, NULL, NULL, 1); zend_hash_copy(&dom_entity_reference_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler)); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_entity_reference_prop_handlers, sizeof(dom_entity_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_entity_reference_prop_handlers, sizeof(dom_entity_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMProcessingInstruction", dom_node_class_entry, php_dom_processinginstruction_class_functions, dom_processinginstruction_class_entry); @@ -784,7 +775,7 @@ dom_register_prop_handler(&dom_processinginstruction_prop_handlers, "target", dom_processinginstruction_target_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_processinginstruction_prop_handlers, "data", dom_processinginstruction_data_read, dom_processinginstruction_data_write TSRMLS_CC); zend_hash_merge(&dom_processinginstruction_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_processinginstruction_prop_handlers, sizeof(dom_processinginstruction_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_processinginstruction_prop_handlers, sizeof(dom_processinginstruction_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMStringExtend", NULL, php_dom_string_extend_class_functions, dom_string_extend_class_entry); @@ -795,7 +786,7 @@ zend_hash_init(&dom_xpath_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_xpath_prop_handlers, "document", dom_xpath_document_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_xpath_prop_handlers, sizeof(dom_xpath_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_xpath_prop_handlers, sizeof(dom_xpath_prop_handlers), NULL); #endif REGISTER_LONG_CONSTANT("XML_ELEMENT_NODE", XML_ELEMENT_NODE, CONST_CS | CONST_PERSISTENT); @@ -851,9 +842,6 @@ php_libxml_register_export(dom_node_class_entry, php_dom_export_node); - zend_u_hash_init(&u_classes, 0, NULL, (void (*)(void *))dom_prop_handlers_dtor, 1, 1); - zend_hash_copy(&u_classes, &classes, (copy_ctor_func_t)dom_prop_handlers_ctor, NULL, sizeof(HashTable)); - return SUCCESS; } /* }}} */ @@ -885,7 +873,6 @@ PHP_MSHUTDOWN_FUNCTION(dom) { zend_hash_destroy(&classes); - zend_hash_destroy(&u_classes); /* If you want do find memleaks in this module, compile libxml2 with --with-mem-debug and uncomment the following line, this will tell you the amount of not freed memory @@ -1010,7 +997,7 @@ base_class = base_class->parent; } - zend_u_hash_find(UG(unicode)?&u_classes:&classes, UG(unicode)?IS_UNICODE:IS_STRING, base_class->name, base_class->name_length + 1, (void **) &intern->prop_handler); + zend_u_hash_find(&classes, UG(unicode)?IS_UNICODE:IS_STRING, base_class->name, base_class->name_length + 1, (void **) &intern->prop_handler); zend_object_std_init(&intern->std, class_type TSRMLS_CC); if (hash_copy) { http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.54&r2=1.55&diff_format=u Index: php-src/ext/libxml/libxml.c diff -u php-src/ext/libxml/libxml.c:1.54 php-src/ext/libxml/libxml.c:1.55 --- php-src/ext/libxml/libxml.c:1.54 Fri Nov 10 18:05:58 2006 +++ php-src/ext/libxml/libxml.c Fri Nov 17 10:48:53 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: libxml.c,v 1.54 2006/11/10 18:05:58 nlopess Exp $ */ +/* $Id: libxml.c,v 1.55 2006/11/17 10:48:53 dmitry Exp $ */ #define IS_EXT_MODULE @@ -859,22 +859,13 @@ int php_libxml_register_export(zend_class_entry *ce, php_libxml_export_node export_function) { php_libxml_func_handler export_hnd; + TSRMLS_FETCH(); /* Initialize in case this module hasnt been loaded yet */ php_libxml_initialize(); export_hnd.export_func = export_function; - if (zend_hash_add(&php_libxml_exports, ce->name.s, ce->name_length + 1, &export_hnd, sizeof(export_hnd), NULL) == SUCCESS) { - int ret; - zstr name; - - name.u = malloc(UBYTES(ce->name_length+1)); - u_charsToUChars(ce->name.s, name.u, ce->name_length+1); - ret = zend_u_hash_add(&php_libxml_exports, IS_UNICODE, name, ce->name_length + 1, &export_hnd, sizeof(export_hnd), NULL); - free(name.u); - return ret; - } - return FAILURE; + return zend_u_hash_add(&php_libxml_exports, ZEND_STR_TYPE, ce->name, ce->name_length + 1, &export_hnd, sizeof(export_hnd), NULL); } PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object TSRMLS_DC) http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_functions.c?r1=1.37&r2=1.38&diff_format=u Index: php-src/ext/spl/spl_functions.c diff -u php-src/ext/spl/spl_functions.c:1.37 php-src/ext/spl/spl_functions.c:1.38 --- php-src/ext/spl/spl_functions.c:1.37 Thu Jul 20 21:21:19 2006 +++ php-src/ext/spl/spl_functions.c Fri Nov 17 10:48:53 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_functions.c,v 1.37 2006/07/20 21:21:19 helly Exp $ */ +/* $Id: spl_functions.c,v 1.38 2006/11/17 10:48:53 dmitry Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -40,8 +40,7 @@ { zend_class_entry ce; - INIT_CLASS_ENTRY(ce, class_name, functions); - ce.name_length = strlen(class_name); + INIT_CLASS_ENTRY_EX(ce, class_name, strlen(class_name), functions); *ppce = zend_register_internal_interface(&ce TSRMLS_CC); } /* }}} */ @@ -51,8 +50,7 @@ { zend_class_entry ce; - INIT_CLASS_ENTRY(ce, class_name, function_list); - ce.name_length = strlen(class_name); + INIT_CLASS_ENTRY_EX(ce, class_name, strlen(class_name), function_list); *ppce = zend_register_internal_class(&ce TSRMLS_CC); /* entries changed by initialize */ @@ -67,8 +65,7 @@ { zend_class_entry ce; - INIT_CLASS_ENTRY(ce, class_name, function_list); - ce.name_length = strlen(class_name); + INIT_CLASS_ENTRY_EX(ce, class_name, strlen(class_name), function_list); *ppce = zend_register_internal_class_ex(&ce, parent_ce, NULL TSRMLS_CC); /* entries changed by initialize */ http://cvs.php.net/viewvc.cgi/php-src/main/main.c?r1=1.706&r2=1.707&diff_format=u Index: php-src/main/main.c diff -u php-src/main/main.c:1.706 php-src/main/main.c:1.707 --- php-src/main/main.c:1.706 Fri Nov 10 11:42:40 2006 +++ php-src/main/main.c Fri Nov 17 10:48:53 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.706 2006/11/10 11:42:40 dmitry Exp $ */ +/* $Id: main.c,v 1.707 2006/11/17 10:48:53 dmitry Exp $ */ /* {{{ includes */ @@ -1512,7 +1512,6 @@ zend_utility_values zuv; int module_number=0; /* for REGISTER_INI_ENTRIES() */ char *php_os; - zend_bool orig_unicode; #ifdef ZTS zend_executor_globals *executor_globals; void ***tsrm_ls; @@ -1650,9 +1649,6 @@ /* Register Zend ini entries */ zend_register_standard_ini_entries(TSRMLS_C); - orig_unicode = UG(unicode); - UG(unicode) = 0; - /* Disable realpath cache if open_basedir are set */ if ((PG(open_basedir) && *PG(open_basedir))) { CWDG(realpath_cache_size_limit) = 0; @@ -1752,7 +1748,6 @@ } } - UG(unicode) = orig_unicode; zend_post_startup(TSRMLS_C); module_initialized = 1;
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.c?r1=1.382&r2=1.383&diff_format=u Index: ZendEngine2/zend.c diff -u ZendEngine2/zend.c:1.382 ZendEngine2/zend.c:1.383 --- ZendEngine2/zend.c:1.382 Wed Nov 8 11:04:42 2006 +++ ZendEngine2/zend.c Fri Nov 17 10:48:53 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend.c,v 1.382 2006/11/08 11:04:42 dmitry Exp $ */ +/* $Id: zend.c,v 1.383 2006/11/17 10:48:53 dmitry Exp $ */ #include "zend.h" #include "zend_extensions.h" @@ -671,7 +671,6 @@ } -#define ZEND_U_FUNCTION_DTOR (void (*)(void *)) zend_u_function_dtor #define ZEND_U_CONSTANT_DTOR (void (*)(void *)) free_u_zend_constant static void zval_copy_persistent(zval *zv) @@ -687,32 +686,6 @@ } } -static void zend_u_function_dtor(zend_function *function) -{ - TSRMLS_FETCH(); - - destroy_zend_function(function TSRMLS_CC); - if (function->type == ZEND_INTERNAL_FUNCTION) { - if (function->common.function_name.v) { - free(function->common.function_name.v); - } - if (function->common.arg_info) { - int n = function->common.num_args; - - while (n > 0) { - --n; - if (function->common.arg_info[n].name.v) { - free(function->common.arg_info[n].name.v); - } - if (function->common.arg_info[n].class_name.v) { - free(function->common.arg_info[n].class_name.v); - } - } - free(function->common.arg_info); - } - } -} - static void free_u_zend_constant(zend_constant *c) { if (!(c->flags & CONST_PERSISTENT)) { @@ -740,17 +713,17 @@ args = malloc((n + 1) * sizeof(zend_arg_info)); memcpy(args, func->common.arg_info, (n + 1) * sizeof(zend_arg_info)); while (n > 0) { - --n; - if (args[n].name.s) { + --n; + if (args[n].name.s) { UChar *uname = malloc(UBYTES(args[n].name_len + 1)); u_charsToUChars(args[n].name.s, uname, args[n].name_len+1); args[n].name.u = uname; - } - if (args[n].class_name.s) { + } + if (args[n].class_name.s) { UChar *uname = malloc(UBYTES(args[n].class_name_len + 1)); u_charsToUChars(args[n].class_name.s, uname, args[n].class_name_len+1); args[n].class_name.u = uname; - } + } } func->common.arg_info = args; } @@ -822,11 +795,11 @@ compiler_globals->compiled_filename = NULL; compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable)); - zend_u_hash_init_ex(compiler_globals->function_table, 100, NULL, ZEND_FUNCTION_DTOR, 1, UG(unicode), 0); + zend_u_hash_init_ex(compiler_globals->function_table, global_function_table->nNumOfElements, NULL, ZEND_FUNCTION_DTOR, 1, UG(unicode), 0); zend_hash_copy(compiler_globals->function_table, global_function_table, NULL, &tmp_func, sizeof(zend_function)); compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable)); - zend_u_hash_init_ex(compiler_globals->class_table, 10, NULL, ZEND_CLASS_DTOR, 1, UG(unicode), 0); + zend_u_hash_init_ex(compiler_globals->class_table, global_class_table->nNumOfElements, NULL, ZEND_CLASS_DTOR, 1, UG(unicode), 0); zend_hash_copy(compiler_globals->class_table, global_class_table, (copy_ctor_func_t) zend_class_add_ref, &tmp_class, sizeof(zend_class_entry *)); zend_set_default_compile_time_values(TSRMLS_C); @@ -835,7 +808,7 @@ CG(literal_type) = IS_STRING; compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable)); - zend_u_hash_init_ex(compiler_globals->auto_globals, 8, NULL, NULL, 1, UG(unicode), 0); + zend_u_hash_init_ex(compiler_globals->auto_globals, global_auto_globals_table->nNumOfElements, NULL, NULL, 1, UG(unicode), 0); zend_hash_copy(compiler_globals->auto_globals, global_auto_globals_table, NULL, NULL, sizeof(zend_auto_global) /* empty element */); compiler_globals->last_static_member = zend_hash_num_elements(compiler_globals->class_table); @@ -1135,21 +1108,6 @@ int module_number = 0; REGISTER_INI_ENTRIES(); -} - -/* Unlink the global (r/o) copies of the class, function and constant tables, - * and use a fresh r/w copy for the startup thread - */ -void zend_post_startup(TSRMLS_D) -{ -#ifdef ZTS - zend_compiler_globals *compiler_globals = ts_resource(compiler_globals_id); - zend_executor_globals *executor_globals = ts_resource(executor_globals_id); - - *GLOBAL_FUNCTION_TABLE = *compiler_globals->function_table; - *GLOBAL_CLASS_TABLE = *compiler_globals->class_table; - *GLOBAL_CONSTANTS_TABLE = *executor_globals->zend_constants; -#endif /* Make copies of HashTables with UNICODE */ @@ -1160,18 +1118,30 @@ old_runtime_encoding_conv = UG(runtime_encoding_conv); UG(runtime_encoding_conv) = ucnv_open("ASCII", &status); - zend_hash_to_unicode(GLOBAL_FUNCTION_TABLE, (apply_func_t)function_to_unicode TSRMLS_CC); - GLOBAL_FUNCTION_TABLE->pDestructor = ZEND_U_FUNCTION_DTOR; - zend_hash_to_unicode(GLOBAL_CLASS_TABLE, (apply_func_t)class_to_unicode TSRMLS_CC); - zend_hash_to_unicode(GLOBAL_AUTO_GLOBALS_TABLE, NULL TSRMLS_CC); - zend_hash_to_unicode(GLOBAL_CONSTANTS_TABLE, (apply_func_t)const_to_unicode TSRMLS_CC); - GLOBAL_CONSTANTS_TABLE->pDestructor = ZEND_U_CONSTANT_DTOR; + zend_hash_to_unicode(CG(function_table), (apply_func_t)function_to_unicode TSRMLS_CC); + CG(function_table)->pDestructor = ZEND_U_FUNCTION_DTOR; + zend_hash_to_unicode(CG(class_table), (apply_func_t)class_to_unicode TSRMLS_CC); + zend_hash_to_unicode(CG(auto_globals), NULL TSRMLS_CC); + zend_hash_to_unicode(EG(zend_constants), (apply_func_t)const_to_unicode TSRMLS_CC); + EG(zend_constants)->pDestructor = ZEND_U_CONSTANT_DTOR; ucnv_close(UG(runtime_encoding_conv)); UG(runtime_encoding_conv) = old_runtime_encoding_conv; } +} +/* Unlink the global (r/o) copies of the class, function and constant tables, + * and use a fresh r/w copy for the startup thread + */ +void zend_post_startup(TSRMLS_D) +{ #ifdef ZTS + zend_compiler_globals *compiler_globals = ts_resource(compiler_globals_id); + zend_executor_globals *executor_globals = ts_resource(executor_globals_id); + + *GLOBAL_FUNCTION_TABLE = *compiler_globals->function_table; + *GLOBAL_CLASS_TABLE = *compiler_globals->class_table; + *GLOBAL_CONSTANTS_TABLE = *executor_globals->zend_constants; zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC); free(compiler_globals->function_table); free(compiler_globals->class_table); http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.414&r2=1.415&diff_format=u Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.414 ZendEngine2/zend_API.c:1.415 --- ZendEngine2/zend_API.c:1.414 Fri Oct 27 21:22:05 2006 +++ ZendEngine2/zend_API.c Fri Nov 17 10:48:53 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.c,v 1.414 2006/10/27 21:22:05 andrei Exp $ */ +/* $Id: zend_API.c,v 1.415 2006/11/17 10:48:53 dmitry Exp $ */ #include "zend.h" #include "zend_execute.h" @@ -1940,8 +1940,8 @@ zend_function *ctor = NULL, *dtor = NULL, *clone = NULL, *__get = NULL, *__set = NULL, *__unset = NULL, *__isset = NULL, *__call = NULL, *__tostring = NULL; char *lowercase_name; int fname_len; - char *lc_class_name = NULL; - int class_name_len = 0; + zstr lc_class_name = NULL_ZSTR; + unsigned int lc_class_name_len = 0; if (type==MODULE_PERSISTENT) { error_type = E_CORE_WARNING; @@ -1956,17 +1956,44 @@ internal_function->module = EG(current_module); if (scope) { - class_name_len = scope->name_length; - lc_class_name = zend_str_tolower_dup(scope->name.s, class_name_len); + lc_class_name = zend_u_str_case_fold(ZEND_STR_TYPE, scope->name, scope->name_length, 0, &lc_class_name_len); } while (ptr->fname) { internal_function->handler = ptr->handler; - internal_function->function_name.s = ptr->fname; + if (UG(unicode)) { + int len = strlen(ptr->fname)+1; + + internal_function->function_name.u = malloc(UBYTES(len)); + u_charsToUChars(ptr->fname, internal_function->function_name.u, len); + } else { + internal_function->function_name.s = ptr->fname; + } internal_function->scope = scope; internal_function->prototype = NULL; if (ptr->arg_info) { - internal_function->arg_info = ptr->arg_info+1; + if (UG(unicode)) { + zend_arg_info *args; + int n = ptr->num_args; + + args = internal_function->arg_info = malloc((n + 1) * sizeof(zend_arg_info)); + memcpy(args, ptr->arg_info+1, (n + 1) * sizeof(zend_arg_info)); + while (n > 0) { + --n; + if (args[n].name.s) { + UChar *uname = malloc(UBYTES(args[n].name_len + 1)); + u_charsToUChars(args[n].name.s, uname, args[n].name_len+1); + args[n].name.u = uname; + } + if (args[n].class_name.s) { + UChar *uname = malloc(UBYTES(args[n].class_name_len + 1)); + u_charsToUChars(args[n].class_name.s, uname, args[n].class_name_len+1); + args[n].class_name.u = uname; + } + } + } else { + internal_function->arg_info = ptr->arg_info+1; + } internal_function->num_args = ptr->num_args; /* Currently you cannot denote that the function can accept less arguments than num_args */ if (ptr->arg_info[0].required_num_args == -1) { @@ -1986,7 +2013,7 @@ if (ptr->flags) { if (!(ptr->flags & ZEND_ACC_PPP_MASK)) { if (ptr->flags != ZEND_ACC_DEPRECATED || scope) { - zend_error(error_type, "Invalid access level for %s%s%s() - access must be exactly one of public, protected or private", scope ? scope->name.s : "", scope ? "::" : "", ptr->fname); + zend_error(error_type, "Invalid access level for %v%s%s() - access must be exactly one of public, protected or private", scope ? scope->name : EMPTY_ZSTR, scope ? "::" : "", ptr->fname); } internal_function->fn_flags = ZEND_ACC_PUBLIC | ptr->flags; } else { @@ -2007,19 +2034,19 @@ } } if (ptr->flags & ZEND_ACC_STATIC && (!scope || !(scope->ce_flags & ZEND_ACC_INTERFACE))) { - zend_error(error_type, "Static function %s%s%s() cannot be abstract", scope ? scope->name.s : "", scope ? "::" : "", ptr->fname); + zend_error(error_type, "Static function %v%s%s() cannot be abstract", scope ? scope->name : EMPTY_ZSTR, scope ? "::" : "", ptr->fname); } } else { if (scope && (scope->ce_flags & ZEND_ACC_INTERFACE)) { - efree(lc_class_name); - zend_error(error_type, "Interface %s cannot contain non abstract method %s()", scope->name, ptr->fname); + efree(lc_class_name.v); + zend_error(error_type, "Interface %v cannot contain non abstract method %s()", scope->name, ptr->fname); return FAILURE; } if (!internal_function->handler) { if (scope) { - efree(lc_class_name); + efree(lc_class_name.v); } - zend_error(error_type, "Method %s%s%s() cannot be a NULL function", scope ? scope->name.s : "", scope ? "::" : "", ptr->fname); + zend_error(error_type, "Method %v%s%s() cannot be a NULL function", scope ? scope->name : EMPTY_ZSTR, scope ? "::" : "", ptr->fname); zend_unregister_functions(functions, count, target_function_table TSRMLS_CC); return FAILURE; } @@ -2027,7 +2054,7 @@ fname_len = strlen(ptr->fname); lowercase_name = do_alloca(fname_len+1); zend_str_tolower_copy(lowercase_name, ptr->fname, fname_len); - if (zend_hash_add(target_function_table, lowercase_name, fname_len+1, &function, sizeof(zend_function), (void**)®_function) == FAILURE) { + if (zend_ascii_hash_add(target_function_table, lowercase_name, fname_len+1, &function, sizeof(zend_function), (void**)®_function) == FAILURE) { unload=1; free_alloca(lowercase_name); break; @@ -2037,14 +2064,17 @@ * If it's an old-style constructor, store it only if we don't have * a constructor already. */ - if ((fname_len == class_name_len) && !memcmp(lowercase_name, lc_class_name, class_name_len+1) && !ctor) { + unsigned int lc_func_name_len; + zstr lc_func_name = zend_u_str_case_fold(ZEND_STR_TYPE, internal_function->function_name, fname_len, 0, &lc_func_name_len); + + if ((lc_func_name_len == lc_class_name_len) && !memcmp(lc_func_name.v, lc_class_name.v, UG(unicode)?UBYTES(lc_class_name_len):lc_class_name_len) && !ctor) { ctor = reg_function; } else if ((fname_len == sizeof(ZEND_CONSTRUCTOR_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) { ctor = reg_function; } else if ((fname_len == sizeof(ZEND_DESTRUCTOR_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_DESTRUCTOR_FUNC_NAME, sizeof(ZEND_DESTRUCTOR_FUNC_NAME))) { dtor = reg_function; if (internal_function->num_args) { - zend_error(error_type, "Destructor %s::%s() cannot take arguments", scope->name, ptr->fname); + zend_error(error_type, "Destructor %v::%s() cannot take arguments", scope->name, ptr->fname); } } else if ((fname_len == sizeof(ZEND_CLONE_FUNC_NAME)-1) && !memcmp(lowercase_name, ZEND_CLONE_FUNC_NAME, sizeof(ZEND_CLONE_FUNC_NAME))) { clone = reg_function; @@ -2073,11 +2103,11 @@ } if (unload) { /* before unloading, display all remaining bad function in the module */ if (scope) { - free_alloca(lc_class_name); + free_alloca(lc_class_name.v); } while (ptr->fname) { if (zend_hash_exists(target_function_table, ptr->fname, strlen(ptr->fname)+1)) { - zend_error(error_type, "Function registration failed - duplicate name - %s%s%s", scope ? scope->name.s : "", scope ? "::" : "", ptr->fname); + zend_error(error_type, "Function registration failed - duplicate name - %v%s%s", scope ? scope->name : EMPTY_ZSTR, scope ? "::" : "", ptr->fname); } ptr++; } @@ -2097,61 +2127,61 @@ if (ctor) { ctor->common.fn_flags |= ZEND_ACC_CTOR; if (ctor->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Constructor %s::%s() cannot be static", scope->name, ctor->common.function_name); + zend_error(error_type, "Constructor %v::%v() cannot be static", scope->name, ctor->common.function_name); } ctor->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (dtor) { dtor->common.fn_flags |= ZEND_ACC_DTOR; if (dtor->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Destructor %s::%s() cannot be static", scope->name, dtor->common.function_name); + zend_error(error_type, "Destructor %v::%v() cannot be static", scope->name, dtor->common.function_name); } dtor->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (clone) { clone->common.fn_flags |= ZEND_ACC_CLONE; if (clone->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Constructor %s::%s() cannot be static", scope->name, clone->common.function_name); + zend_error(error_type, "Constructor %v::%v() cannot be static", scope->name, clone->common.function_name); } clone->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (__call) { if (__call->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __call->common.function_name); + zend_error(error_type, "Method %v::%v() cannot be static", scope->name, __call->common.function_name); } __call->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (__tostring) { if (__tostring->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __tostring->common.function_name); + zend_error(error_type, "Method %v::%v() cannot be static", scope->name, __tostring->common.function_name); } __tostring->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (__get) { if (__get->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __get->common.function_name); + zend_error(error_type, "Method %v::%v() cannot be static", scope->name, __get->common.function_name); } __get->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (__set) { if (__set->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __set->common.function_name); + zend_error(error_type, "Method %v::%v() cannot be static", scope->name, __set->common.function_name); } __set->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (__unset) { if (__unset->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __unset->common.function_name); + zend_error(error_type, "Method %v::%v() cannot be static", scope->name, __unset->common.function_name); } __unset->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } if (__isset) { if (__isset->common.fn_flags & ZEND_ACC_STATIC) { - zend_error(error_type, "Method %s::%s() cannot be static", scope->name, __isset->common.function_name); + zend_error(error_type, "Method %v::%v() cannot be static", scope->name, __isset->common.function_name); } __isset->common.fn_flags &= ~ZEND_ACC_ALLOW_STATIC; } - efree(lc_class_name); + efree(lc_class_name.v); } return SUCCESS; } @@ -2175,7 +2205,7 @@ #if 0 zend_printf("Unregistering %s()\n", ptr->fname); #endif - zend_hash_del(target_function_table, ptr->fname, strlen(ptr->fname)+1); + zend_ascii_hash_del(target_function_table, ptr->fname, strlen(ptr->fname)+1); ptr++; i++; } @@ -2288,7 +2318,9 @@ static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class_entry, zend_uint ce_flags TSRMLS_DC) { zend_class_entry *class_entry = malloc(sizeof(zend_class_entry)); - char *lowercase_name = malloc(orig_class_entry->name_length + 1); + zstr lcname; + unsigned int lcname_len; + *class_entry = *orig_class_entry; class_entry->type = ZEND_INTERNAL_CLASS; @@ -2300,9 +2332,9 @@ zend_register_functions(class_entry, class_entry->builtin_functions, &class_entry->function_table, MODULE_PERSISTENT TSRMLS_CC); } - zend_str_tolower_copy(lowercase_name, orig_class_entry->name.s, class_entry->name_length); - zend_hash_update(CG(class_table), lowercase_name, class_entry->name_length+1, &class_entry, sizeof(zend_class_entry *), NULL); - free(lowercase_name); + lcname = zend_u_str_case_fold(ZEND_STR_TYPE, class_entry->name, class_entry->name_length, 0, &lcname_len); + zend_u_hash_update(CG(class_table), ZEND_STR_TYPE, lcname, lcname_len+1, &class_entry, sizeof(zend_class_entry *), NULL); + efree(lcname.v); return class_entry; } @@ -2317,7 +2349,7 @@ if (!parent_ce && parent_name) { zend_class_entry **pce; - if (zend_hash_find(CG(class_table), parent_name, strlen(parent_name)+1, (void **) &pce)==FAILURE) { + if (zend_ascii_hash_find(CG(class_table), parent_name, strlen(parent_name)+1, (void **) &pce)==FAILURE) { return NULL; } else { parent_ce = *pce; @@ -2979,7 +3011,18 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, char *name, int name_length, zval *property, int access_type, zstr doc_comment, int doc_comment_len TSRMLS_DC) { - return zend_u_declare_property_ex(ce, IS_STRING, ZSTR(name), name_length, property, access_type, doc_comment, doc_comment_len TSRMLS_CC); + if (UG(unicode)) { + zstr uname; + int ret; + + uname.u = do_alloca(name_length+1); + u_charsToUChars(name, uname.u, name_length+1); + ret = zend_u_declare_property_ex(ce, IS_UNICODE, uname, name_length, property, access_type, doc_comment, doc_comment_len TSRMLS_CC); + free_alloca(uname.u); + return ret; + } else { + return zend_u_declare_property_ex(ce, IS_STRING, ZSTR(name), name_length, property, access_type, doc_comment, doc_comment_len TSRMLS_CC); + } } ZEND_API int zend_u_declare_property(zend_class_entry *ce, zend_uchar type, zstr name, int name_length, zval *property, int access_type TSRMLS_DC) @@ -2989,7 +3032,18 @@ ZEND_API int zend_declare_property(zend_class_entry *ce, char *name, int name_length, zval *property, int access_type TSRMLS_DC) { - return zend_u_declare_property_ex(ce, IS_STRING, ZSTR(name), name_length, property, access_type, NULL_ZSTR, 0 TSRMLS_CC); + if (UG(unicode)) { + zstr uname; + int ret; + + uname.u = do_alloca(name_length+1); + u_charsToUChars(name, uname.u, name_length+1); + ret = zend_u_declare_property_ex(ce, IS_UNICODE, uname, name_length, property, access_type, NULL_ZSTR, 0 TSRMLS_CC); + free_alloca(uname.u); + return ret; + } else { + return zend_u_declare_property_ex(ce, IS_STRING, ZSTR(name), name_length, property, access_type, NULL_ZSTR, 0 TSRMLS_CC); + } } ZEND_API int zend_declare_property_null(zend_class_entry *ce, char *name, int name_length, int access_type TSRMLS_DC) @@ -3054,10 +3108,17 @@ if (ce->type & ZEND_INTERNAL_CLASS) { property = malloc(sizeof(zval)); - ZVAL_STRINGL(property, zend_strndup(value, len), len, 0); + if (UG(unicode)) { + Z_TYPE_P(property) = IS_UNICODE; + Z_USTRVAL_P(property) = malloc(UBYTES(len+1)); + u_charsToUChars(value, Z_USTRVAL_P(property), len+1); + Z_USTRLEN_P(property) = len; + } else { + ZVAL_STRINGL(property, zend_strndup(value, len), len, 0); + } } else { ALLOC_ZVAL(property); - ZVAL_STRINGL(property, value, len, 1); + ZVAL_ASCII_STRINGL(property, value, len, 1); } INIT_PZVAL(property); return zend_declare_property(ce, name, name_length, property, access_type TSRMLS_CC); @@ -3069,10 +3130,17 @@ if (ce->type & ZEND_INTERNAL_CLASS) { property = malloc(sizeof(zval)); - ZVAL_STRINGL(property, zend_strndup(value, value_len), value_len, 0); + if (UG(unicode)) { + Z_TYPE_P(property) = IS_UNICODE; + Z_USTRVAL_P(property) = malloc(UBYTES(value_len+1)); + u_charsToUChars(value, Z_USTRVAL_P(property), value_len+1); + Z_USTRLEN_P(property) = value_len; + } else { + ZVAL_STRINGL(property, zend_strndup(value, value_len), value_len, 0); + } } else { ALLOC_ZVAL(property); - ZVAL_STRINGL(property, value, value_len, 1); + ZVAL_ASCII_STRINGL(property, value, value_len, 1); } INIT_PZVAL(property); return zend_declare_property(ce, name, name_length, property, access_type TSRMLS_CC); @@ -3080,7 +3148,7 @@ ZEND_API int zend_declare_class_constant(zend_class_entry *ce, char *name, size_t name_length, zval *value TSRMLS_DC) { - return zend_hash_update(&ce->constants_table, name, name_length+1, &value, sizeof(zval *), NULL); + return zend_ascii_hash_update(&ce->constants_table, name, name_length+1, &value, sizeof(zval *), NULL); } ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, char *name, size_t name_length TSRMLS_DC) @@ -3143,12 +3211,19 @@ { zval *constant; - if (ce->type & ZEND_INTERNAL_CLASS) { + if (ce->type & ZEND_INTERNAL_CLASS) { constant = malloc(sizeof(zval)); - ZVAL_STRINGL(constant, zend_strndup(value, value_length), value_length, 0); + if (UG(unicode)) { + Z_TYPE_P(constant) = IS_UNICODE; + Z_USTRVAL_P(constant) = malloc(UBYTES(value_length+1)); + u_charsToUChars(value, Z_USTRVAL_P(constant), value_length+1); + Z_USTRLEN_P(constant) = value_length; + } else { + ZVAL_STRINGL(constant, zend_strndup(value, value_length), value_length, 0); + } } else { ALLOC_ZVAL(constant); - ZVAL_STRINGL(constant, value, value_length, 1); + ZVAL_ASCII_STRINGL(constant, value, value_length, 1); } INIT_PZVAL(constant); return zend_declare_class_constant(ce, name, name_length, constant TSRMLS_CC); http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.h?r1=1.269&r2=1.270&diff_format=u Index: ZendEngine2/zend_API.h diff -u ZendEngine2/zend_API.h:1.269 ZendEngine2/zend_API.h:1.270 --- ZendEngine2/zend_API.h:1.269 Wed Nov 15 22:50:19 2006 +++ ZendEngine2/zend_API.h Fri Nov 17 10:48:53 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.h,v 1.269 2006/11/15 22:50:19 tony2001 Exp $ */ +/* $Id: zend_API.h,v 1.270 2006/11/17 10:48:53 dmitry Exp $ */ #ifndef ZEND_API_H #define ZEND_API_H @@ -121,12 +121,22 @@ #endif -#define INIT_CLASS_ENTRY(class_container, class_name, functions) INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL) +#define INIT_CLASS_ENTRY(class_container, class_name, functions) \ + INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, NULL, NULL, NULL) -#define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \ +#define INIT_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions) \ + INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, NULL, NULL, NULL, NULL, NULL) + +#define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, class_name_len, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \ { \ - class_container.name.s = strdup(class_name); \ - class_container.name_length = sizeof(class_name) - 1; \ + int _len = class_name_len; \ + if (UG(unicode)) { \ + class_container.name.u = malloc(UBYTES(_len+1)); \ + u_charsToUChars(class_name, class_container.name.u, _len+1); \ + } else { \ + class_container.name.s = zend_strndup(class_name, _len); \ + } \ + class_container.name_length = _len; \ class_container.builtin_functions = functions; \ class_container.constructor = NULL; \ class_container.destructor = NULL; \ @@ -154,7 +164,7 @@ } #define INIT_OVERLOADED_CLASS_ENTRY(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset) \ - INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset, NULL, NULL) + INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, sizeof(class_name)-1, functions, handle_fcall, handle_propget, handle_propset, NULL, NULL) #ifdef ZTS # define CE_STATIC_MEMBERS(ce) (((ce)->type==ZEND_USER_CLASS)?(ce)->static_members:CG(static_members)[(long)(ce)->static_members]) http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.727&r2=1.728&diff_format=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.727 ZendEngine2/zend_compile.c:1.728 --- ZendEngine2/zend_compile.c:1.727 Fri Oct 27 21:22:05 2006 +++ ZendEngine2/zend_compile.c Fri Nov 17 10:48:53 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.727 2006/10/27 21:22:05 andrei Exp $ */ +/* $Id: zend_compile.c,v 1.728 2006/11/17 10:48:53 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -1919,13 +1919,32 @@ zend_u_hash_init(op_array->static_variables, zend_hash_num_elements(static_variables), NULL, ZVAL_PTR_DTOR, 0, UG(unicode)); zend_hash_copy(op_array->static_variables, static_variables, (copy_ctor_func_t) zval_add_ref, (void *) &tmp_zval, sizeof(zval *)); } + } else if (UG(unicode) && function->type == ZEND_INTERNAL_FUNCTION) { + zend_internal_function *func = &function->internal_function; + + func->function_name.u = zend_ustrndup(func->function_name.u, u_strlen(func->function_name.u)); + if (func->arg_info) { + zend_arg_info *args; + int n = func->num_args; + + args = malloc((n + 1) * sizeof(zend_arg_info)); + memcpy(args, func->arg_info, (n + 1) * sizeof(zend_arg_info)); + while (n > 0) { + --n; + if (args[n].name.u) { + args[n].name.u = zend_ustrndup(args[n].name.u, u_strlen(args[n].name.u)); + } + if (args[n].class_name.s) { + args[n].class_name.u = zend_ustrndup(args[n].class_name.u, u_strlen(args[n].class_name.u)); + } + } + func->arg_info = args; + } } } static void do_inherit_parent_constructor(zend_class_entry *ce TSRMLS_DC) { - zend_function *function; - if (!ce->parent) { return; } @@ -1978,34 +1997,17 @@ ); } return; - } - - if (zend_hash_find(&ce->parent->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), (void **)&function)==SUCCESS) { - /* inherit parent's constructor */ - zend_hash_update(&ce->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME), function, sizeof(zend_function), NULL); - function_add_ref(function TSRMLS_CC); - } else { - /* Don't inherit the old style constructor if we already have the new style constructor */ - unsigned int lc_class_name_len, lc_parent_class_name_len; - zstr lc_class_name; - zstr lc_parent_class_name; - zend_uchar utype = UG(unicode)?IS_UNICODE:IS_STRING; - - lc_class_name = zend_u_str_case_fold(utype, ce->name, ce->name_length, 0, &lc_class_name_len); - if (!zend_u_hash_exists(&ce->function_table, utype, lc_class_name, lc_class_name_len+1)) { - lc_parent_class_name = zend_u_str_case_fold(utype, ce->parent->name, ce->parent->name_length, 0, &lc_parent_class_name_len); - if (zend_u_hash_find(&ce->parent->function_table, utype, lc_parent_class_name, lc_parent_class_name_len+1, (void **)&function)==SUCCESS) { - if (function->common.fn_flags & ZEND_ACC_CTOR) { - /* inherit parent's constructor */ - zend_u_hash_update(&ce->function_table, utype, lc_class_name, lc_class_name_len+1, function, sizeof(zend_function), NULL); - function_add_ref(function TSRMLS_CC); - } - } - efree(lc_parent_class_name.v); + } else if (ce->parent->constructor) { + ce->constructor = ce->parent->constructor; + if (!zend_ascii_hash_exists(&ce->function_table, ZEND_CONSTRUCTOR_FUNC_NAME, sizeof(ZEND_CONSTRUCTOR_FUNC_NAME))) { + unsigned int lc_class_name_len; + zstr lc_class_name = zend_u_str_case_fold(ZEND_STR_TYPE, ce->name, ce->name_length, 0, &lc_class_name_len); + + zend_u_hash_update(&ce->function_table, ZEND_STR_TYPE, lc_class_name, lc_class_name_len+1, ce->constructor, sizeof(zend_function), NULL); + function_add_ref(ce->constructor TSRMLS_CC); + efree(lc_class_name.v); } - efree(lc_class_name.v); } - ce->constructor = ce->parent->constructor; } @@ -4347,7 +4349,7 @@ zend_u_hash_init_ex(&ce->properties_info, 0, NULL, (dtor_func_t) (persistent_hashes ? zend_destroy_property_info_internal : zend_destroy_property_info), persistent_hashes, UG(unicode), 0); zend_u_hash_init_ex(&ce->default_static_members, 0, NULL, zval_ptr_dtor_func, persistent_hashes, UG(unicode), 0); zend_u_hash_init_ex(&ce->constants_table, 0, NULL, zval_ptr_dtor_func, persistent_hashes, UG(unicode), 0); - zend_u_hash_init_ex(&ce->function_table, 0, NULL, ZEND_FUNCTION_DTOR, persistent_hashes, UG(unicode), 0); + zend_u_hash_init_ex(&ce->function_table, 0, NULL, UG(unicode)?ZEND_U_FUNCTION_DTOR:ZEND_FUNCTION_DTOR, persistent_hashes, UG(unicode), 0); if (ce->type == ZEND_INTERNAL_CLASS) { #ifdef ZTS http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.h?r1=1.349&r2=1.350&diff_format=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.349 ZendEngine2/zend_compile.h:1.350 --- ZendEngine2/zend_compile.h:1.349 Fri Oct 27 21:22:05 2006 +++ ZendEngine2/zend_compile.h Fri Nov 17 10:48:53 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.349 2006/10/27 21:22:05 andrei Exp $ */ +/* $Id: zend_compile.h,v 1.350 2006/11/17 10:48:53 dmitry Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -545,6 +545,7 @@ ZEND_API void destroy_zend_function(zend_function *function TSRMLS_DC); ZEND_API void zend_function_dtor(zend_function *function); +ZEND_API void zend_u_function_dtor(zend_function *function); ZEND_API void destroy_zend_class(zend_class_entry **pce); void zend_class_add_ref(zend_class_entry **ce); @@ -556,6 +557,7 @@ #define ZEND_FUNCTION_DTOR (void (*)(void *)) zend_function_dtor +#define ZEND_U_FUNCTION_DTOR (void (*)(void *)) zend_u_function_dtor #define ZEND_CLASS_DTOR (void (*)(void *)) destroy_zend_class zend_op *get_next_op(zend_op_array *op_array TSRMLS_DC); http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_constants.c?r1=1.88&r2=1.89&diff_format=u Index: ZendEngine2/zend_constants.c diff -u ZendEngine2/zend_constants.c:1.88 ZendEngine2/zend_constants.c:1.89 --- ZendEngine2/zend_constants.c:1.88 Wed Oct 18 16:34:25 2006 +++ ZendEngine2/zend_constants.c Fri Nov 17 10:48:53 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_constants.c,v 1.88 2006/10/18 16:34:25 johannes Exp $ */ +/* $Id: zend_constants.c,v 1.89 2006/11/17 10:48:53 dmitry Exp $ */ #include "zend.h" #include "zend_constants.h" @@ -186,13 +186,19 @@ { zend_constant c; + if (UG(unicode)) { + c.name.u = malloc(UBYTES(name_len)); + u_charsToUChars(name, c.name.u, name_len); + c.name_len = name_len; + } else { + c.name.s = zend_strndup(name, name_len-1); + c.name_len = name_len; + } Z_TYPE(c.value) = IS_LONG; Z_LVAL(c.value) = lval; c.flags = flags; - c.name.s = zend_strndup(name, name_len-1); - c.name_len = name_len; c.module_number = module_number; - zend_register_constant(&c TSRMLS_CC); + zend_u_register_constant(ZEND_STR_TYPE, &c TSRMLS_CC); } @@ -200,13 +206,19 @@ { zend_constant c; + if (UG(unicode)) { + c.name.u = malloc(UBYTES(name_len)); + u_charsToUChars(name, c.name.u, name_len); + c.name_len = name_len; + } else { + c.name.s = zend_strndup(name, name_len-1); + c.name_len = name_len; + } Z_TYPE(c.value) = IS_DOUBLE; Z_DVAL(c.value) = dval; c.flags = flags; - c.name.s = zend_strndup(name, name_len-1); - c.name_len = name_len; c.module_number = module_number; - zend_register_constant(&c TSRMLS_CC); + zend_u_register_constant(ZEND_STR_TYPE, &c TSRMLS_CC); } @@ -214,14 +226,31 @@ { zend_constant c; - Z_TYPE(c.value) = IS_STRING; - Z_STRVAL(c.value) = strval; - Z_STRLEN(c.value) = strlen; + if (UG(unicode)) { + c.name.u = malloc(UBYTES(name_len)); + u_charsToUChars(name, c.name.u, name_len); + c.name_len = name_len; + Z_TYPE(c.value) = IS_UNICODE; + if (flags & CONST_PERSISTENT) { + Z_USTRVAL(c.value) = malloc(UBYTES(strlen+1)); + } else { + Z_USTRVAL(c.value) = emalloc(UBYTES(strlen+1)); + } + u_charsToUChars(strval, Z_USTRVAL(c.value), strlen+1); + Z_USTRLEN(c.value) = strlen; + if (!(flags & CONST_PERSISTENT)) { + efree(strval); + } + } else { + c.name.s = zend_strndup(name, name_len-1); + c.name_len = name_len; + Z_TYPE(c.value) = IS_STRING; + Z_STRVAL(c.value) = strval; + Z_STRLEN(c.value) = strlen; + } c.flags = flags; - c.name.s = zend_strndup(name, name_len-1); - c.name_len = name_len; c.module_number = module_number; - zend_register_constant(&c TSRMLS_CC); + zend_u_register_constant(ZEND_STR_TYPE, &c TSRMLS_CC); } http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_opcode.c?r1=1.123&r2=1.124&diff_format=u Index: ZendEngine2/zend_opcode.c diff -u ZendEngine2/zend_opcode.c:1.123 ZendEngine2/zend_opcode.c:1.124 --- ZendEngine2/zend_opcode.c:1.123 Sat Oct 28 10:42:04 2006 +++ ZendEngine2/zend_opcode.c Fri Nov 17 10:48:53 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_opcode.c,v 1.123 2006/10/28 10:42:04 tony2001 Exp $ */ +/* $Id: zend_opcode.c,v 1.124 2006/11/17 10:48:53 dmitry Exp $ */ #include <stdio.h> @@ -124,6 +124,32 @@ destroy_zend_function(function TSRMLS_CC); } +ZEND_API void zend_u_function_dtor(zend_function *function) +{ + TSRMLS_FETCH(); + + destroy_zend_function(function TSRMLS_CC); + if (function->type == ZEND_INTERNAL_FUNCTION) { + if (function->common.function_name.v) { + free(function->common.function_name.v); + } + if (function->common.arg_info) { + int n = function->common.num_args; + + while (n > 0) { + --n; + if (function->common.arg_info[n].name.v) { + free(function->common.arg_info[n].name.v); + } + if (function->common.arg_info[n].class_name.v) { + free(function->common.arg_info[n].class_name.v); + } + } + free(function->common.arg_info); + } + } +} + static void zend_cleanup_op_array_data(zend_op_array *op_array) { if (op_array->static_variables) { http://cvs.php.net/viewvc.cgi/php-src/ext/dom/php_dom.c?r1=1.99&r2=1.100&diff_format=u Index: php-src/ext/dom/php_dom.c diff -u php-src/ext/dom/php_dom.c:1.99 php-src/ext/dom/php_dom.c:1.100 --- php-src/ext/dom/php_dom.c:1.99 Fri Sep 22 10:13:27 2006 +++ php-src/ext/dom/php_dom.c Fri Nov 17 10:48:53 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_dom.c,v 1.99 2006/09/22 10:13:27 rrichards Exp $ */ +/* $Id: php_dom.c,v 1.100 2006/11/17 10:48:53 dmitry Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -71,7 +71,6 @@ zend_object_handlers dom_object_handlers; static HashTable classes; -static HashTable u_classes; typedef int (*dom_read_t)(dom_object *obj, zval **retval TSRMLS_DC); typedef int (*dom_write_t)(dom_object *obj, zval *newval TSRMLS_DC); @@ -248,7 +247,7 @@ hnd.read_func = read_func ? read_func : dom_read_na; hnd.write_func = write_func ? write_func : dom_write_na; - zend_hash_add(prop_handler, name, strlen(name)+1, &hnd, sizeof(dom_prop_handler), NULL); + zend_ascii_hash_add(prop_handler, name, strlen(name)+1, &hnd, sizeof(dom_prop_handler), NULL); } /* }}} */ @@ -506,14 +505,6 @@ zend_hash_destroy(ht); } -static void dom_prop_handlers_ctor(HashTable *ht) -{ - HashTable tmp = *ht; - - zend_u_hash_init(ht, 0, NULL, NULL, 1, 1); - zend_hash_copy(ht, &tmp, NULL, NULL, sizeof(dom_prop_handler)); -} - /* {{{ PHP_MINIT_FUNCTION(dom) */ PHP_MINIT_FUNCTION(dom) { @@ -563,19 +554,19 @@ zend_hash_init(&dom_domstringlist_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_domstringlist_prop_handlers, "length", dom_domstringlist_length_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_domstringlist_prop_handlers, sizeof(dom_domstringlist_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_domstringlist_prop_handlers, sizeof(dom_domstringlist_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMNameList", NULL, php_dom_namelist_class_functions, dom_namelist_class_entry); zend_hash_init(&dom_namelist_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_namelist_prop_handlers, "length", dom_namelist_length_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_namelist_prop_handlers, sizeof(dom_namelist_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_namelist_prop_handlers, sizeof(dom_namelist_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMImplementationList", NULL, php_dom_domimplementationlist_class_functions, dom_domimplementationlist_class_entry); zend_hash_init(&dom_domimplementationlist_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_domimplementationlist_prop_handlers, "length", dom_domimplementationlist_length_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_domimplementationlist_prop_handlers, sizeof(dom_domimplementationlist_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_domimplementationlist_prop_handlers, sizeof(dom_domimplementationlist_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMImplementationSource", NULL, php_dom_domimplementationsource_class_functions, dom_domimplementationsource_class_entry); REGISTER_DOM_CLASS(ce, "DOMImplementation", NULL, php_dom_domimplementation_class_functions, dom_domimplementation_class_entry); @@ -599,7 +590,7 @@ dom_register_prop_handler(&dom_node_prop_handlers, "localName", dom_node_local_name_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_node_prop_handlers, "baseURI", dom_node_base_uri_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_node_prop_handlers, "textContent", dom_node_text_content_read, dom_node_text_content_write TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_node_prop_handlers, sizeof(dom_node_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_node_prop_handlers, sizeof(dom_node_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMNameSpaceNode", NULL, NULL, dom_namespace_node_class_entry); @@ -612,12 +603,12 @@ dom_register_prop_handler(&dom_namespace_node_prop_handlers, "namespaceURI", dom_node_namespace_uri_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_namespace_node_prop_handlers, "ownerDocument", dom_node_owner_document_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_namespace_node_prop_handlers, "parentNode", dom_node_parent_node_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_namespace_node_prop_handlers, sizeof(dom_namespace_node_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_namespace_node_prop_handlers, sizeof(dom_namespace_node_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMDocumentFragment", dom_node_class_entry, php_dom_documentfragment_class_functions, dom_documentfragment_class_entry); zend_hash_init(&dom_document_fragment_prop_handlers, 0, NULL, NULL, 1); zend_hash_copy(&dom_document_fragment_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler)); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_document_fragment_prop_handlers, sizeof(dom_node_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_document_fragment_prop_handlers, sizeof(dom_node_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMDocument", dom_node_class_entry, php_dom_document_class_functions, dom_document_class_entry); zend_hash_init(&dom_document_prop_handlers, 0, NULL, NULL, 1); @@ -642,7 +633,7 @@ dom_register_prop_handler(&dom_document_prop_handlers, "substituteEntities", dom_document_substitue_entities_read, dom_document_substitue_entities_write TSRMLS_CC); zend_hash_merge(&dom_document_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_document_prop_handlers, sizeof(dom_document_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_document_prop_handlers, sizeof(dom_document_prop_handlers), NULL); INIT_CLASS_ENTRY(ce, "DOMNodeList", php_dom_nodelist_class_functions); ce.create_object = dom_nnodemap_objects_new; @@ -651,7 +642,7 @@ zend_hash_init(&dom_nodelist_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_nodelist_prop_handlers, "length", dom_nodelist_length_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_nodelist_prop_handlers, sizeof(dom_nodelist_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_nodelist_prop_handlers, sizeof(dom_nodelist_prop_handlers), NULL); INIT_CLASS_ENTRY(ce, "DOMNamedNodeMap", php_dom_namednodemap_class_functions); ce.create_object = dom_nnodemap_objects_new; @@ -660,7 +651,7 @@ zend_hash_init(&dom_namednodemap_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_namednodemap_prop_handlers, "length", dom_namednodemap_length_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_namednodemap_prop_handlers, sizeof(dom_namednodemap_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_namednodemap_prop_handlers, sizeof(dom_namednodemap_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMCharacterData", dom_node_class_entry, php_dom_characterdata_class_functions, dom_characterdata_class_entry); @@ -668,7 +659,7 @@ dom_register_prop_handler(&dom_characterdata_prop_handlers, "data", dom_characterdata_data_read, dom_characterdata_data_write TSRMLS_CC); dom_register_prop_handler(&dom_characterdata_prop_handlers, "length", dom_characterdata_length_read, NULL TSRMLS_CC); zend_hash_merge(&dom_characterdata_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_characterdata_prop_handlers, sizeof(dom_characterdata_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_characterdata_prop_handlers, sizeof(dom_characterdata_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMAttr", dom_node_class_entry, php_dom_attr_class_functions, dom_attr_class_entry); @@ -679,7 +670,7 @@ dom_register_prop_handler(&dom_attr_prop_handlers, "ownerElement", dom_attr_owner_element_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_attr_prop_handlers, "schemaTypeInfo", dom_attr_schema_type_info_read, NULL TSRMLS_CC); zend_hash_merge(&dom_attr_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_attr_prop_handlers, sizeof(dom_attr_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_attr_prop_handlers, sizeof(dom_attr_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMElement", dom_node_class_entry, php_dom_element_class_functions, dom_element_class_entry); @@ -687,26 +678,26 @@ dom_register_prop_handler(&dom_element_prop_handlers, "tagName", dom_element_tag_name_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_element_prop_handlers, "schemaTypeInfo", dom_element_schema_type_info_read, NULL TSRMLS_CC); zend_hash_merge(&dom_element_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_element_prop_handlers, sizeof(dom_element_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_element_prop_handlers, sizeof(dom_element_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMText", dom_characterdata_class_entry, php_dom_text_class_functions, dom_text_class_entry); zend_hash_init(&dom_text_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_text_prop_handlers, "wholeText", dom_text_whole_text_read, NULL TSRMLS_CC); zend_hash_merge(&dom_text_prop_handlers, &dom_characterdata_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_text_prop_handlers, sizeof(dom_text_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_text_prop_handlers, sizeof(dom_text_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMComment", dom_characterdata_class_entry, php_dom_comment_class_functions, dom_comment_class_entry); zend_hash_init(&dom_comment_prop_handlers, 0, NULL, NULL, 1); zend_hash_copy(&dom_comment_prop_handlers, &dom_characterdata_prop_handlers, NULL, NULL, sizeof(dom_prop_handler)); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_comment_prop_handlers, sizeof(dom_comment_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_comment_prop_handlers, sizeof(dom_comment_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMTypeinfo", NULL, php_dom_typeinfo_class_functions, dom_typeinfo_class_entry); zend_hash_init(&dom_typeinfo_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_typeinfo_prop_handlers, "typeName", dom_typeinfo_type_name_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_typeinfo_prop_handlers, "typeNamespace", dom_typeinfo_type_namespace_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_typeinfo_prop_handlers, sizeof(dom_typeinfo_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_typeinfo_prop_handlers, sizeof(dom_typeinfo_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMUserDataHandler", NULL, php_dom_userdatahandler_class_functions, dom_userdatahandler_class_entry); REGISTER_DOM_CLASS(ce, "DOMDomError", NULL, php_dom_domerror_class_functions, dom_domerror_class_entry); @@ -718,7 +709,7 @@ dom_register_prop_handler(&dom_domerror_prop_handlers, "relatedException", dom_domerror_related_exception_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_domerror_prop_handlers, "related_data", dom_domerror_related_data_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_domerror_prop_handlers, "location", dom_domerror_location_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_domerror_prop_handlers, sizeof(dom_domerror_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_domerror_prop_handlers, sizeof(dom_domerror_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMErrorHandler", NULL, php_dom_domerrorhandler_class_functions, dom_domerrorhandler_class_entry); REGISTER_DOM_CLASS(ce, "DOMLocator", NULL, php_dom_domlocator_class_functions, dom_domlocator_class_entry); @@ -729,13 +720,13 @@ dom_register_prop_handler(&dom_domlocator_prop_handlers, "offset", dom_domlocator_offset_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_domlocator_prop_handlers, "relatedNode", dom_domlocator_related_node_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_domlocator_prop_handlers, "uri", dom_domlocator_uri_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_domlocator_prop_handlers, sizeof(dom_domlocator_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_domlocator_prop_handlers, sizeof(dom_domlocator_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMConfiguration", NULL, php_dom_domconfiguration_class_functions, dom_domconfiguration_class_entry); REGISTER_DOM_CLASS(ce, "DOMCdataSection", dom_text_class_entry, php_dom_cdatasection_class_functions, dom_cdatasection_class_entry); zend_hash_init(&dom_cdata_prop_handlers, 0, NULL, NULL, 1); zend_hash_copy(&dom_cdata_prop_handlers, &dom_text_prop_handlers, NULL, NULL, sizeof(dom_prop_handler)); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_cdata_prop_handlers, sizeof(dom_documenttype_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_cdata_prop_handlers, sizeof(dom_documenttype_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMDocumentType", dom_node_class_entry, php_dom_documenttype_class_functions, dom_documenttype_class_entry); @@ -747,7 +738,7 @@ dom_register_prop_handler(&dom_documenttype_prop_handlers, "systemId", dom_documenttype_system_id_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_documenttype_prop_handlers, "internalSubset", dom_documenttype_internal_subset_read, NULL TSRMLS_CC); zend_hash_merge(&dom_documenttype_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_documenttype_prop_handlers, sizeof(dom_documenttype_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_documenttype_prop_handlers, sizeof(dom_documenttype_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMNotation", NULL, php_dom_notation_class_functions, dom_notation_class_entry); @@ -758,7 +749,7 @@ dom_register_prop_handler(&dom_notation_prop_handlers, "nodeName", dom_node_node_name_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_notation_prop_handlers, "nodeValue", dom_node_node_value_read, dom_node_node_value_write TSRMLS_CC); dom_register_prop_handler(&dom_notation_prop_handlers, "attributes", dom_node_attributes_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_notation_prop_handlers, sizeof(dom_notation_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_notation_prop_handlers, sizeof(dom_notation_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMEntity", dom_node_class_entry, php_dom_entity_class_functions, dom_entity_class_entry); @@ -771,12 +762,12 @@ dom_register_prop_handler(&dom_entity_prop_handlers, "version", dom_entity_version_read, dom_entity_version_write TSRMLS_CC); zend_hash_merge(&dom_entity_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_entity_prop_handlers, sizeof(dom_entity_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_entity_prop_handlers, sizeof(dom_entity_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMEntityReference", dom_node_class_entry, php_dom_entityreference_class_functions, dom_entityreference_class_entry); zend_hash_init(&dom_entity_reference_prop_handlers, 0, NULL, NULL, 1); zend_hash_copy(&dom_entity_reference_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler)); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_entity_reference_prop_handlers, sizeof(dom_entity_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_entity_reference_prop_handlers, sizeof(dom_entity_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMProcessingInstruction", dom_node_class_entry, php_dom_processinginstruction_class_functions, dom_processinginstruction_class_entry); @@ -784,7 +775,7 @@ dom_register_prop_handler(&dom_processinginstruction_prop_handlers, "target", dom_processinginstruction_target_read, NULL TSRMLS_CC); dom_register_prop_handler(&dom_processinginstruction_prop_handlers, "data", dom_processinginstruction_data_read, dom_processinginstruction_data_write TSRMLS_CC); zend_hash_merge(&dom_processinginstruction_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_processinginstruction_prop_handlers, sizeof(dom_processinginstruction_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_processinginstruction_prop_handlers, sizeof(dom_processinginstruction_prop_handlers), NULL); REGISTER_DOM_CLASS(ce, "DOMStringExtend", NULL, php_dom_string_extend_class_functions, dom_string_extend_class_entry); @@ -795,7 +786,7 @@ zend_hash_init(&dom_xpath_prop_handlers, 0, NULL, NULL, 1); dom_register_prop_handler(&dom_xpath_prop_handlers, "document", dom_xpath_document_read, NULL TSRMLS_CC); - zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_xpath_prop_handlers, sizeof(dom_xpath_prop_handlers), NULL); + zend_u_hash_add(&classes, ZEND_STR_TYPE, ce.name, ce.name_length + 1, &dom_xpath_prop_handlers, sizeof(dom_xpath_prop_handlers), NULL); #endif REGISTER_LONG_CONSTANT("XML_ELEMENT_NODE", XML_ELEMENT_NODE, CONST_CS | CONST_PERSISTENT); @@ -851,9 +842,6 @@ php_libxml_register_export(dom_node_class_entry, php_dom_export_node); - zend_u_hash_init(&u_classes, 0, NULL, (void (*)(void *))dom_prop_handlers_dtor, 1, 1); - zend_hash_copy(&u_classes, &classes, (copy_ctor_func_t)dom_prop_handlers_ctor, NULL, sizeof(HashTable)); - return SUCCESS; } /* }}} */ @@ -885,7 +873,6 @@ PHP_MSHUTDOWN_FUNCTION(dom) { zend_hash_destroy(&classes); - zend_hash_destroy(&u_classes); /* If you want do find memleaks in this module, compile libxml2 with --with-mem-debug and uncomment the following line, this will tell you the amount of not freed memory @@ -1010,7 +997,7 @@ base_class = base_class->parent; } - zend_u_hash_find(UG(unicode)?&u_classes:&classes, UG(unicode)?IS_UNICODE:IS_STRING, base_class->name, base_class->name_length + 1, (void **) &intern->prop_handler); + zend_u_hash_find(&classes, UG(unicode)?IS_UNICODE:IS_STRING, base_class->name, base_class->name_length + 1, (void **) &intern->prop_handler); zend_object_std_init(&intern->std, class_type TSRMLS_CC); if (hash_copy) { http://cvs.php.net/viewvc.cgi/php-src/ext/libxml/libxml.c?r1=1.54&r2=1.55&diff_format=u Index: php-src/ext/libxml/libxml.c diff -u php-src/ext/libxml/libxml.c:1.54 php-src/ext/libxml/libxml.c:1.55 --- php-src/ext/libxml/libxml.c:1.54 Fri Nov 10 18:05:58 2006 +++ php-src/ext/libxml/libxml.c Fri Nov 17 10:48:53 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: libxml.c,v 1.54 2006/11/10 18:05:58 nlopess Exp $ */ +/* $Id: libxml.c,v 1.55 2006/11/17 10:48:53 dmitry Exp $ */ #define IS_EXT_MODULE @@ -859,22 +859,13 @@ int php_libxml_register_export(zend_class_entry *ce, php_libxml_export_node export_function) { php_libxml_func_handler export_hnd; + TSRMLS_FETCH(); /* Initialize in case this module hasnt been loaded yet */ php_libxml_initialize(); export_hnd.export_func = export_function; - if (zend_hash_add(&php_libxml_exports, ce->name.s, ce->name_length + 1, &export_hnd, sizeof(export_hnd), NULL) == SUCCESS) { - int ret; - zstr name; - - name.u = malloc(UBYTES(ce->name_length+1)); - u_charsToUChars(ce->name.s, name.u, ce->name_length+1); - ret = zend_u_hash_add(&php_libxml_exports, IS_UNICODE, name, ce->name_length + 1, &export_hnd, sizeof(export_hnd), NULL); - free(name.u); - return ret; - } - return FAILURE; + return zend_u_hash_add(&php_libxml_exports, ZEND_STR_TYPE, ce->name, ce->name_length + 1, &export_hnd, sizeof(export_hnd), NULL); } PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object TSRMLS_DC) http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_functions.c?r1=1.37&r2=1.38&diff_format=u Index: php-src/ext/spl/spl_functions.c diff -u php-src/ext/spl/spl_functions.c:1.37 php-src/ext/spl/spl_functions.c:1.38 --- php-src/ext/spl/spl_functions.c:1.37 Thu Jul 20 21:21:19 2006 +++ php-src/ext/spl/spl_functions.c Fri Nov 17 10:48:53 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_functions.c,v 1.37 2006/07/20 21:21:19 helly Exp $ */ +/* $Id: spl_functions.c,v 1.38 2006/11/17 10:48:53 dmitry Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -40,8 +40,7 @@ { zend_class_entry ce; - INIT_CLASS_ENTRY(ce, class_name, functions); - ce.name_length = strlen(class_name); + INIT_CLASS_ENTRY_EX(ce, class_name, strlen(class_name), functions); *ppce = zend_register_internal_interface(&ce TSRMLS_CC); } /* }}} */ @@ -51,8 +50,7 @@ { zend_class_entry ce; - INIT_CLASS_ENTRY(ce, class_name, function_list); - ce.name_length = strlen(class_name); + INIT_CLASS_ENTRY_EX(ce, class_name, strlen(class_name), function_list); *ppce = zend_register_internal_class(&ce TSRMLS_CC); /* entries changed by initialize */ @@ -67,8 +65,7 @@ { zend_class_entry ce; - INIT_CLASS_ENTRY(ce, class_name, function_list); - ce.name_length = strlen(class_name); + INIT_CLASS_ENTRY_EX(ce, class_name, strlen(class_name), function_list); *ppce = zend_register_internal_class_ex(&ce, parent_ce, NULL TSRMLS_CC); /* entries changed by initialize */ http://cvs.php.net/viewvc.cgi/php-src/main/main.c?r1=1.706&r2=1.707&diff_format=u Index: php-src/main/main.c diff -u php-src/main/main.c:1.706 php-src/main/main.c:1.707 --- php-src/main/main.c:1.706 Fri Nov 10 11:42:40 2006 +++ php-src/main/main.c Fri Nov 17 10:48:53 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.706 2006/11/10 11:42:40 dmitry Exp $ */ +/* $Id: main.c,v 1.707 2006/11/17 10:48:53 dmitry Exp $ */ /* {{{ includes */ @@ -1512,7 +1512,6 @@ zend_utility_values zuv; int module_number=0; /* for REGISTER_INI_ENTRIES() */ char *php_os; - zend_bool orig_unicode; #ifdef ZTS zend_executor_globals *executor_globals; void ***tsrm_ls; @@ -1650,9 +1649,6 @@ /* Register Zend ini entries */ zend_register_standard_ini_entries(TSRMLS_C); - orig_unicode = UG(unicode); - UG(unicode) = 0; - /* Disable realpath cache if open_basedir are set */ if ((PG(open_basedir) && *PG(open_basedir))) { CWDG(realpath_cache_size_limit) = 0; @@ -1752,7 +1748,6 @@ } } - UG(unicode) = orig_unicode; zend_post_startup(TSRMLS_C); module_initialized = 1;