Unicode support: MS Visual C compatibility
authorDmitry Stogov <dmitry@php.net>
Sun, 26 Feb 2006 11:57:14 +0000 (11:57 +0000)
committerDmitry Stogov <dmitry@php.net>
Sun, 26 Feb 2006 11:57:14 +0000 (11:57 +0000)
30 files changed:
Zend/zend.c
Zend/zend.h
Zend/zend_API.c
Zend/zend_API.h
Zend/zend_builtin_functions.c
Zend/zend_compile.c
Zend/zend_compile.h
Zend/zend_constants.c
Zend/zend_execute.c
Zend/zend_execute.h
Zend/zend_execute_API.c
Zend/zend_hash.c
Zend/zend_interfaces.c
Zend/zend_language_scanner.l
Zend/zend_object_handlers.c
Zend/zend_objects.c
Zend/zend_operators.c
Zend/zend_operators.h
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
ext/libxml/libxml.c
ext/standard/array.c
ext/standard/incomplete_class.c
ext/standard/streamsfuncs.c
ext/standard/var.c
ext/unicode/unicode_iterators.c
main/main.c
main/output.c
main/php_variables.c
main/rfc1867.c

index 9701e4533d3ab7eab7a8422487550f70ab5a6090..85f76d4d351d4075e2274fdb0156d01b16cfbe50 100644 (file)
 #   define GLOBAL_CONSTANTS_TABLE   EG(zend_constants)
 #endif
 
+#ifndef __GNUC__
+ZEND_API zstr null_zstr;
+ZEND_API zstr empty_zstr;
+#endif
+
 #if defined(ZEND_WIN32) && ZEND_DEBUG
 BOOL WINAPI IsDebuggerPresent(VOID);
 #endif
@@ -527,7 +532,7 @@ ZEND_API void zend_print_flat_zval_r(zval *expr TSRMLS_DC)
                case IS_OBJECT:
                {
                        HashTable *properties = NULL;
-                       zstr class_name = (zstr)NULL;
+                       zstr class_name = NULL_ZSTR;
                        zend_uint clen;
 
                        if (Z_OBJ_HANDLER_P(expr, get_class_name)) {
@@ -584,7 +589,7 @@ ZEND_API void zend_print_zval_r_ex(zend_write_func_t write_func, zval *expr, int
                case IS_OBJECT:
                        {
                                HashTable *properties = NULL;
-                               zstr class_name = (zstr)NULL;
+                               zstr class_name = NULL_ZSTR;
                                zend_uint clen;
 
                                if (Z_OBJ_HANDLER_P(expr, get_class_name)) {
@@ -970,6 +975,11 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
        extern zend_unicode_globals unicode_globals;
 #endif
 
+#ifndef __GNUC__
+       null_zstr.v = NULL;
+       empty_zstr.u = EMPTY_STR;
+#endif
+
 #ifdef ZTS
        ts_allocate_id(&alloc_globals_id, sizeof(zend_alloc_globals), (ts_allocate_ctor) alloc_globals_ctor, (ts_allocate_dtor) alloc_globals_dtor);
 #else
index e3377c58c006c952eb55f934f8ae30ce0deb12ed..02508c14389ac8c5fbbb4ea335065b10ca9c33ef 100644 (file)
@@ -246,6 +246,25 @@ typedef union _zstr {
        void  *v;
 } zstr;
 
+#ifdef __GNUC__
+#      define ZSTR(x)    ((zstr)(x))
+#      define NULL_ZSTR  ZSTR(NULL)
+#      define EMPTY_ZSTR ZSTR("\0\0")
+#else
+extern ZEND_API zstr null_zstr;
+extern ZEND_API zstr empty_zstr;
+
+static inline zstr _to_zstr(void *v) {
+       zstr ret;
+       ret.v = v;
+       return ret;
+}
+
+#      define ZSTR(x)    _to_zstr(x)
+#      define NULL_ZSTR  null_zstr
+#      define EMPTY_ZSTR empty_zstr
+#endif
+
 #define EMPTY_STR ((UChar*)"\0\0")
 
 #undef SUCCESS
@@ -302,6 +321,10 @@ typedef union _zvalue_value {
                UChar *val;
                int len;
        } ustr;
+       struct {                    /* Unicersal string type */
+               zstr val;
+               int len;
+       } uni;
        HashTable *ht;                          /* hash table value */
        zend_object_value obj;
 } zvalue_value;
index d4291864597f1f9a08630951886d342d18395c81..c67c60f38f05478f3b4dbe15f540850a99854467 100644 (file)
@@ -2889,7 +2889,7 @@ ZEND_API int zend_u_declare_property_ex(zend_class_entry *ce, zend_uchar type, z
                                zstr prot_name;
                                int prot_name_length;
 
-                               zend_u_mangle_property_name(&prot_name, &prot_name_length, type, (zstr)"*", 1, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
+                               zend_u_mangle_property_name(&prot_name, &prot_name_length, type, ZSTR("*"), 1, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
                                zend_u_hash_update(target_symbol_table, type, prot_name, prot_name_length+1, &property, sizeof(zval *), NULL);
                                property_info.name = prot_name;
                                property_info.name_length = prot_name_length;
@@ -2900,7 +2900,7 @@ ZEND_API int zend_u_declare_property_ex(zend_class_entry *ce, zend_uchar type, z
                                zstr prot_name;
                                int prot_name_length;
 
-                               zend_u_mangle_property_name(&prot_name, &prot_name_length, type, (zstr)"*", 1, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
+                               zend_u_mangle_property_name(&prot_name, &prot_name_length, type, ZSTR("*"), 1, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
                                zend_u_hash_del(target_symbol_table, type, prot_name, prot_name_length+1);
                                pefree(prot_name.v, ce->type & ZEND_INTERNAL_CLASS);
                        }
@@ -2924,7 +2924,7 @@ ZEND_API int zend_u_declare_property_ex(zend_class_entry *ce, zend_uchar type, z
 
 ZEND_API int zend_declare_property_ex(zend_class_entry *ce, char *name, int name_length, zval *property, int access_type, char *doc_comment, int doc_comment_len TSRMLS_DC)
 {
-       return zend_u_declare_property_ex(ce, IS_STRING, (zstr)name, name_length, property, access_type, NULL, 0 TSRMLS_CC);
+       return zend_u_declare_property_ex(ce, IS_STRING, ZSTR(name), name_length, property, access_type, NULL, 0 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)
@@ -2934,7 +2934,7 @@ ZEND_API int zend_u_declare_property(zend_class_entry *ce, zend_uchar type, zstr
 
 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, 0 TSRMLS_CC);
+       return zend_u_declare_property_ex(ce, IS_STRING, ZSTR(name), name_length, property, access_type, NULL, 0 TSRMLS_CC);
 }
 
 ZEND_API int zend_declare_property_null(zend_class_entry *ce, char *name, int name_length, int access_type TSRMLS_DC)
@@ -3251,7 +3251,7 @@ ZEND_API int zend_update_static_property(zend_class_entry *scope, char *name, in
        zend_class_entry *old_scope = EG(scope);
 
        EG(scope) = scope;
-       property = zend_std_get_static_property(scope, IS_STRING, (zstr)name, name_length, 0 TSRMLS_CC);
+       property = zend_std_get_static_property(scope, IS_STRING, ZSTR(name), name_length, 0 TSRMLS_CC);
        EG(scope) = old_scope;
        if (!property) {
                return FAILURE;
@@ -3441,7 +3441,7 @@ ZEND_API zval *zend_read_static_property(zend_class_entry *scope, char *name, in
        zend_class_entry *old_scope = EG(scope);
 
        EG(scope) = scope;
-       property = zend_std_get_static_property(scope, IS_STRING, (zstr)name, name_length, silent TSRMLS_CC);
+       property = zend_std_get_static_property(scope, IS_STRING, ZSTR(name), name_length, silent TSRMLS_CC);
        EG(scope) = old_scope;
 
        return property?*property:NULL;
index 528e20b40e9621fe131c85a3b21a33fe709eb742..25a0b8cf1b4dc991bbc2f07bd546d0a509cc9362 100644 (file)
@@ -927,7 +927,7 @@ END_EXTERN_C()
        }
 
 #define ZEND_SET_SYMBOL_WITH_LENGTH(symtable, name, name_length, var, _refcount, _is_ref)                              \
-       ZEND_U_SET_SYMBOL_WITH_LENGTH(symtable, IS_STRING, (zstr)name, name_length, var, _refcount, _is_ref)
+               ZEND_U_SET_SYMBOL_WITH_LENGTH(symtable, IS_STRING, ZSTR(name), name_length, var, _refcount, _is_ref)
 
 #define ZEND_SET_GLOBAL_VAR(name, var)                         \
        ZEND_SET_SYMBOL(&EG(symbol_table), name, var)
index 23ef30f8ecd5e716a959b5d4b554ed92908853c6..b8072a1e53d5c831c46e053b70b04e47164cf8bb 100644 (file)
@@ -568,7 +568,7 @@ ZEND_FUNCTION(defined)
 ZEND_FUNCTION(get_class)
 {
        zval **arg;
-       zstr name = (zstr)EMPTY_STR;
+       zstr name = EMPTY_ZSTR;
        zend_uint name_len = 0;
        int dup;
 
@@ -1776,10 +1776,10 @@ ZEND_FUNCTION(debug_print_backtrace)
        array_init(return_value);
 
        while (ptr) {
-               zstr free_class_name = (zstr)NULL;
+               zstr free_class_name = NULL_ZSTR;
                int     function_name_string = 1;
 
-               class_name = (zstr)NULL;
+               class_name = NULL_ZSTR;
                call_type = NULL;
                arg_array = NULL;
 
@@ -1824,7 +1824,7 @@ ZEND_FUNCTION(debug_print_backtrace)
                                class_name = ptr->function_state.function->common.scope->name;
                                call_type = "::";
                        } else {
-                               class_name = (zstr)NULL;
+                               class_name = NULL_ZSTR;
                                call_type = NULL;
                        }
                        if ((! ptr->opline) || ((ptr->opline->opcode == ZEND_DO_FCALL_BY_NAME) || (ptr->opline->opcode == ZEND_DO_FCALL))) {
index f74838d4d7d6da9c9714cfa4ba3e7b8abf91898a..164599b94abc5eb28091f04ec3865d9e8a1be601 100644 (file)
@@ -1109,7 +1109,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n
                fn_flags = 0;
        }
        if ((fn_flags & ZEND_ACC_STATIC) && (fn_flags & ZEND_ACC_ABSTRACT) && !(CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE)) {
-               zend_error(E_COMPILE_ERROR, "Static function %v%s%R() cannot be abstract", is_method ? CG(active_class_entry)->name : (zstr)EMPTY_STR, is_method ? "::" : "", Z_TYPE(function_name->u.constant), Z_UNIVAL(function_name->u.constant));
+               zend_error(E_COMPILE_ERROR, "Static function %v%s%R() cannot be abstract", is_method ? CG(active_class_entry)->name : EMPTY_ZSTR, is_method ? "::" : "", Z_TYPE(function_name->u.constant), Z_UNIVAL(function_name->u.constant));
        }
 
        function_token->u.op_array = CG(active_op_array);
@@ -1361,7 +1361,7 @@ void zend_do_receive_arg(zend_uchar op, znode *var, znode *offset, znode *initia
                        }
                } else {
                        cur_arg_info->array_type_hint = 1;
-                       cur_arg_info->class_name.v = NULL;
+                       cur_arg_info->class_name = NULL_ZSTR;
                        cur_arg_info->class_name_len = 0;
                        if (op == ZEND_RECV_INIT) {
                                if (Z_TYPE(initialization->u.constant) == IS_NULL ||
@@ -1375,7 +1375,7 @@ void zend_do_receive_arg(zend_uchar op, znode *var, znode *offset, znode *initia
                        }
                }
        } else {
-               cur_arg_info->class_name.v = NULL;
+               cur_arg_info->class_name = NULL_ZSTR;
                cur_arg_info->class_name_len = 0;
        }
        opline->result.u.EA.type |= EXT_TYPE_UNUSED;
@@ -2209,7 +2209,7 @@ static zend_bool do_inherit_property_access_check(HashTable *target_ht, zend_pro
                        zstr prot_name;
                        int prot_name_length;
 
-                       zend_u_mangle_property_name(&prot_name, &prot_name_length, utype, (zstr)"*", 1, child_info->name, child_info->name_length, ce->type & ZEND_INTERNAL_CLASS);
+                       zend_u_mangle_property_name(&prot_name, &prot_name_length, utype, ZSTR("*"), 1, child_info->name, child_info->name_length, ce->type & ZEND_INTERNAL_CLASS);
                        if (child_info->flags & ZEND_ACC_STATIC) {
                                zval **prop;
                                HashTable *ht;
@@ -4158,7 +4158,7 @@ zend_bool zend_u_is_auto_global(zend_uchar type, zstr name, uint name_len TSRMLS
 
 zend_bool zend_is_auto_global(char *name, uint name_len TSRMLS_DC)
 {
-       return zend_u_is_auto_global(IS_STRING, (zstr)name, name_len TSRMLS_CC);
+       return zend_u_is_auto_global(IS_STRING, ZSTR(name), name_len TSRMLS_CC);
 }
 
 
index 7fc564eda221a97b71b8d83b902795d8610a3749..cb5d5bf9c2577601158886a9f7f12a10d534bc57 100644 (file)
@@ -242,7 +242,7 @@ typedef struct _zend_internal_function {
        struct _zend_module_entry *module;
 } zend_internal_function;
 
-#define ZEND_FN_SCOPE_NAME(function)  ((function) && (function)->common.scope ? (function)->common.scope->name : (zstr)EMPTY_STR)
+#define ZEND_FN_SCOPE_NAME(function)  ((function) && (function)->common.scope ? (function)->common.scope->name : EMPTY_ZSTR)
 
 typedef union _zend_function {
        zend_uchar type;        /* MUST be the first element of this struct! */
index 2bc0e53dd4e8845a202c7a0b9e47565b149d4356..7e4ecf14f85d38a291df52514f2ac7b198c132b8 100644 (file)
@@ -322,7 +322,7 @@ ZEND_API int zend_u_get_constant(zend_uchar type, zstr name, uint name_len, zval
 
 ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC)
 {
-       return zend_u_get_constant(IS_STRING, (zstr)name, name_len, result TSRMLS_CC);
+       return zend_u_get_constant(IS_STRING, ZSTR(name), name_len, result TSRMLS_CC);
 }
 
 ZEND_API int zend_u_register_constant(zend_uchar type, zend_constant *c TSRMLS_DC)
@@ -343,7 +343,7 @@ ZEND_API int zend_u_register_constant(zend_uchar type, zend_constant *c TSRMLS_D
        } else {
                lookup_name_len = c->name_len;
                name = c->name;
-               lookup_name.v = NULL;
+               lookup_name = NULL_ZSTR;
        }
 
        if (zend_u_hash_add(EG(zend_constants), type, name, lookup_name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) {
index 075b42a302ff064268844a1490f3d636591eeb6d..fc1d169de33644f28859e79c9dcc5b8128945413 100644 (file)
@@ -485,7 +485,7 @@ static inline void zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zv
        cur_arg_info = &zf->common.arg_info[arg_num-1];
        fname = zf->common.function_name;
        fsep = zf->common.scope ? "::" : "";
-       fclass = zf->common.scope ? zf->common.scope->name : (zstr)EMPTY_STR;
+       fclass = zf->common.scope ? zf->common.scope->name : EMPTY_ZSTR;
 
        if (cur_arg_info->class_name.v) {
                if (!arg) {
index ceef36dc757bfe0b0dcdc0d2524d21804898cb51..e1c309ed9f86aaf6988a177a1f4e48ffc188410b 100644 (file)
@@ -203,7 +203,7 @@ void zend_shutdown_timeout_thread();
 /* The following tries to resolve the classname of a zval of type object.
  * Since it is slow it should be only used in error messages.
  */
-#define Z_OBJ_CLASS_NAME_P(zval) ((zval) && Z_TYPE_P(zval) == IS_OBJECT && Z_OBJ_HT_P(zval)->get_class_entry != NULL && Z_OBJ_HT_P(zval)->get_class_entry(zval TSRMLS_CC) ? Z_OBJ_HT_P(zval)->get_class_entry(zval TSRMLS_CC)->name : (zstr)EMPTY_STR)
+#define Z_OBJ_CLASS_NAME_P(zval) ((zval) && Z_TYPE_P(zval) == IS_OBJECT && Z_OBJ_HT_P(zval)->get_class_entry != NULL && Z_OBJ_HT_P(zval)->get_class_entry(zval TSRMLS_CC) ? Z_OBJ_HT_P(zval)->get_class_entry(zval TSRMLS_CC)->name : EMPTY_ZSTR)
 
 ZEND_API zval** zend_get_compiled_variable_value(zend_execute_data *execute_data_ptr, zend_uint var);
 
index 1ce4b853eb0777f2cf3cce241e5df131200acc7f..c8ec851149aa95e5685ce277a281b2ef266beea3 100644 (file)
@@ -314,7 +314,7 @@ ZEND_API zstr get_active_class_name(char **space TSRMLS_DC)
                if (space) {
                        *space = "";
                }
-               return (zstr)EMPTY_STR;
+               return EMPTY_ZSTR;
        }
        switch (EG(function_state_ptr)->function->type) {
                case ZEND_USER_FUNCTION:
@@ -325,21 +325,23 @@ ZEND_API zstr get_active_class_name(char **space TSRMLS_DC)
                        if (space) {
                                *space = ce ? "::" : "";
                        }
-                       return ce ? ce->name : (zstr)EMPTY_STR;
+                       return ce ? ce->name : EMPTY_ZSTR;
                }
                default:
                        if (space) {
                                *space = "";
                        }
-                       return (zstr)EMPTY_STR;
+                       return EMPTY_ZSTR;
        }
 }
 
 
 ZEND_API zstr get_active_function_name(TSRMLS_D)
 {
+       zstr ret;
+
        if (!zend_is_executing(TSRMLS_C)) {
-               return (zstr)NULL;
+               return NULL_ZSTR;
        }
        switch (EG(function_state_ptr)->function->type) {
                case ZEND_USER_FUNCTION: {
@@ -347,16 +349,19 @@ ZEND_API zstr get_active_function_name(TSRMLS_D)
 
                                if (function_name.v) {
                                        return function_name;
+                               } else if (UG(unicode)) {
+                                       ret.u = u_main;
                                } else {
-                                       return UG(unicode)?(zstr)u_main:(zstr)"main";
+                                       ret.s = "main";
                                }
+                               return ret;
                        }
                        break;
                case ZEND_INTERNAL_FUNCTION:
                        return ((zend_internal_function *) EG(function_state_ptr)->function)->function_name;
                        break;
                default:
-                       return (zstr)NULL;
+                       return NULL_ZSTR;
        }
 }
 
@@ -530,13 +535,13 @@ ZEND_API int zval_update_constant(zval **pp, void *arg TSRMLS_DC)
                                        break;
                                case IS_BOOL:
                                case IS_LONG:
-                                       zend_hash_update_current_key(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, (zstr)NULL, 0, Z_LVAL(const_value));
+                                       zend_hash_update_current_key(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, NULL_ZSTR, 0, Z_LVAL(const_value));
                                        break;
                                case IS_DOUBLE:
-                                       zend_hash_update_current_key(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, (zstr)NULL, 0, (long)Z_DVAL(const_value));
+                                       zend_hash_update_current_key(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, NULL_ZSTR, 0, (long)Z_DVAL(const_value));
                                        break;
                                case IS_NULL:
-                                       zend_hash_update_current_key(Z_ARRVAL_P(p), HASH_KEY_IS_STRING, (zstr)EMPTY_STR, 1, 0);
+                                       zend_hash_update_current_key(Z_ARRVAL_P(p), HASH_KEY_IS_STRING, EMPTY_ZSTR, 1, 0);
                                        break;
                        }
                        zend_hash_move_forward(Z_ARRVAL_P(p));
@@ -865,7 +870,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
                }
                if (EX(function_state).function->common.fn_flags & ZEND_ACC_DEPRECATED) {
                        zend_error(E_STRICT, "Function %v%s%v() is deprecated",
-                               EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : (zstr)EMPTY_STR,
+                               EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : EMPTY_ZSTR,
                                EX(function_state).function->common.scope ? "::" : "",
                                EX(function_state).function->common.function_name);
                }
@@ -1134,7 +1139,7 @@ ZEND_API int zend_u_lookup_class(zend_uchar type, zstr name, int name_length, ze
 
 ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC)
 {
-       return zend_u_lookup_class(IS_STRING, (zstr)name, name_length, ce TSRMLS_CC);
+       return zend_u_lookup_class(IS_STRING, ZSTR(name), name_length, ce TSRMLS_CC);
 }
 
 ZEND_API int zend_u_eval_string(zend_uchar type, zstr string, zval *retval_ptr, char *string_name TSRMLS_DC)
@@ -1222,7 +1227,7 @@ ZEND_API int zend_u_eval_string(zend_uchar type, zstr string, zval *retval_ptr,
 
 ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC)
 {
-       return zend_u_eval_string(IS_STRING, (zstr)str, retval_ptr, string_name TSRMLS_CC);
+       return zend_u_eval_string(IS_STRING, ZSTR(str), retval_ptr, string_name TSRMLS_CC);
 }
 
 ZEND_API int zend_u_eval_string_ex(zend_uchar type, zstr str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC)
@@ -1239,7 +1244,7 @@ ZEND_API int zend_u_eval_string_ex(zend_uchar type, zstr str, zval *retval_ptr,
 
 ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC)
 {
-       return zend_u_eval_string_ex(IS_STRING, (zstr)str, retval_ptr, string_name, handle_exceptions TSRMLS_CC);
+       return zend_u_eval_string_ex(IS_STRING, ZSTR(str), retval_ptr, string_name, handle_exceptions TSRMLS_CC);
 }
 
 
@@ -1543,16 +1548,16 @@ check_fetch_type:
 
 zend_class_entry *zend_fetch_class(char *class_name, uint class_name_len, int fetch_type TSRMLS_DC)
 {
-       return zend_u_fetch_class(IS_STRING, (zstr)class_name, class_name_len, fetch_type TSRMLS_CC);
+       return zend_u_fetch_class(IS_STRING, ZSTR(class_name), class_name_len, fetch_type TSRMLS_CC);
 }
 
 
 #define MAX_ABSTRACT_INFO_CNT 3
 #define MAX_ABSTRACT_INFO_FMT "%v%s%v%s"
 #define DISPLAY_ABSTRACT_FN(idx) \
-       ai.afn[idx] ? ZEND_FN_SCOPE_NAME(ai.afn[idx]) : (zstr)EMPTY_STR, \
+       ai.afn[idx] ? ZEND_FN_SCOPE_NAME(ai.afn[idx]) : EMPTY_ZSTR, \
        ai.afn[idx] ? "::" : "", \
-       ai.afn[idx] ? ai.afn[idx]->common.function_name : (zstr)EMPTY_STR, \
+       ai.afn[idx] ? ai.afn[idx]->common.function_name : EMPTY_ZSTR, \
        ai.afn[idx] && ai.afn[idx+1] ? ", " : (ai.afn[idx] && ai.cnt > MAX_ABSTRACT_INFO_CNT ? ", ..." : "")
 
 typedef struct _zend_abstract_info {
@@ -1634,7 +1639,7 @@ ZEND_API int zend_u_delete_global_variable(zend_uchar type, zstr name, int name_
 
 ZEND_API int zend_delete_global_variable(char *name, int name_len TSRMLS_DC)
 {
-       return zend_u_delete_global_variable(IS_STRING, (zstr)name, name_len TSRMLS_CC);
+       return zend_u_delete_global_variable(IS_STRING, ZSTR(name), name_len TSRMLS_CC);
 }
 
 /*
index 2a5f371b18865043cd7affc02a36ea3ad5477e29..5ade50d466ad793c9ca00eb5a59d99deaefb648e 100644 (file)
@@ -121,7 +121,7 @@ ZEND_API ulong zend_u_hash_func(zend_uchar type, zstr arKey, uint nKeyLength)
 
 ZEND_API ulong zend_hash_func(char *arKey, uint nKeyLength)
 {
-       return zend_u_hash_func(IS_STRING, (zstr)arKey, nKeyLength);
+       return zend_u_hash_func(IS_STRING, ZSTR(arKey), nKeyLength);
 }
 
 #define UPDATE_DATA(ht, p, pData, nDataSize)                                                                                   \
@@ -312,7 +312,7 @@ ZEND_API int _zend_u_hash_add_or_update(HashTable *ht, zend_uchar type, zstr arK
 
 ZEND_API int _zend_hash_add_or_update(HashTable *ht, char *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)
 {
-       return _zend_u_hash_add_or_update(ht, IS_STRING, (zstr)arKey, nKeyLength, pData, nDataSize, pDest, flag ZEND_FILE_LINE_CC);
+       return _zend_u_hash_add_or_update(ht, IS_STRING, ZSTR(arKey), nKeyLength, pData, nDataSize, pDest, flag ZEND_FILE_LINE_CC);
 }
 
 ZEND_API int _zend_u_hash_quick_add_or_update(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, ulong h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)
@@ -400,7 +400,7 @@ ZEND_API int _zend_u_hash_quick_add_or_update(HashTable *ht, zend_uchar type, zs
 
 ZEND_API int _zend_hash_quick_add_or_update(HashTable *ht, char *arKey, uint nKeyLength, ulong h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)
 {
-       return _zend_u_hash_quick_add_or_update(ht, IS_STRING, (zstr)arKey, nKeyLength, h, pData, nDataSize, pDest, flag ZEND_FILE_LINE_CC);
+       return _zend_u_hash_quick_add_or_update(ht, IS_STRING, ZSTR(arKey), nKeyLength, h, pData, nDataSize, pDest, flag ZEND_FILE_LINE_CC);
 }
 
 ZEND_API int zend_u_hash_add_empty_element(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength)
@@ -414,7 +414,7 @@ ZEND_API int zend_hash_add_empty_element(HashTable *ht, char *arKey, uint nKeyLe
 {
        void *dummy = (void *) 1;
 
-       return zend_u_hash_add(ht, IS_STRING, (zstr)arKey, nKeyLength, &dummy, sizeof(void *), NULL);
+       return zend_u_hash_add(ht, IS_STRING, ZSTR(arKey), nKeyLength, &dummy, sizeof(void *), NULL);
 }
 
 
@@ -594,7 +594,7 @@ ZEND_API int zend_u_hash_del_key_or_index(HashTable *ht, zend_uchar type, zstr a
 
 ZEND_API int zend_hash_del_key_or_index(HashTable *ht, char *arKey, uint nKeyLength, ulong h, int flag)
 {
-       return zend_u_hash_del_key_or_index(ht, IS_STRING, (zstr)arKey, nKeyLength, h, flag);
+       return zend_u_hash_del_key_or_index(ht, IS_STRING, ZSTR(arKey), nKeyLength, h, flag);
 }
 
 ZEND_API void zend_hash_destroy(HashTable *ht)
@@ -830,7 +830,7 @@ ZEND_API void zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func TSR
                        if (q->nKeyLength==0) {
                                zend_hash_index_del(ht, q->h);
                        } else {
-                               zend_u_hash_del(ht, q->key.type, (zstr)q->key.arKey.s, q->nKeyLength);
+                               zend_u_hash_del(ht, q->key.type, ZSTR(q->key.arKey.s), q->nKeyLength);
                        }
                }
                if (result & ZEND_HASH_APPLY_STOP) {
@@ -854,7 +854,7 @@ ZEND_API void zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_fun
                if (p->nKeyLength == 0) {
                        zend_hash_index_update(target, p->h, p->pData, size, &new_entry);
                } else {
-                       zend_u_hash_update(target, p->key.type, (zstr)p->key.arKey.s, p->nKeyLength, p->pData, size, &new_entry);
+                       zend_u_hash_update(target, p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength, p->pData, size, &new_entry);
                }
                if (pCopyConstructor) {
                        pCopyConstructor(new_entry);
@@ -881,7 +881,7 @@ ZEND_API void _zend_hash_merge(HashTable *target, HashTable *source, copy_ctor_f
                                pCopyConstructor(t);
                        }
                } else {
-                       if (_zend_u_hash_add_or_update(target, p->key.type, (zstr)p->key.arKey.s, p->nKeyLength, p->pData, size, &t, mode ZEND_FILE_LINE_RELAY_CC)==SUCCESS && pCopyConstructor) {
+                       if (_zend_u_hash_add_or_update(target, p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength, p->pData, size, &t, mode ZEND_FILE_LINE_RELAY_CC)==SUCCESS && pCopyConstructor) {
                                pCopyConstructor(t);
                        }
                }
@@ -914,7 +914,7 @@ ZEND_API void zend_hash_merge_ex(HashTable *target, HashTable *source, copy_ctor
        p = source->pListHead;
        while (p) {
                if (zend_hash_replace_checker_wrapper(target, p->pData, p, pParam, pMergeSource)) {
-                       if (zend_u_hash_quick_update(target, p->key.type, (zstr)p->key.arKey.s, p->nKeyLength, p->h, p->pData, size, &t)==SUCCESS && pCopyConstructor) {
+                       if (zend_u_hash_quick_update(target, p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength, p->h, p->pData, size, &t)==SUCCESS && pCopyConstructor) {
                                pCopyConstructor(t);
                        }
                }
@@ -931,7 +931,7 @@ ZEND_API ulong zend_u_get_hash_value(zend_uchar type, zstr arKey, uint nKeyLengt
 
 ZEND_API ulong zend_get_hash_value(char *arKey, uint nKeyLength)
 {
-       return zend_u_get_hash_value(IS_STRING, (zstr)arKey, nKeyLength);
+       return zend_u_get_hash_value(IS_STRING, ZSTR(arKey), nKeyLength);
 }
 
 
@@ -973,7 +973,7 @@ ZEND_API int zend_u_hash_find(HashTable *ht, zend_uchar type, zstr arKey, uint n
 
 ZEND_API int zend_hash_find(HashTable *ht, char *arKey, uint nKeyLength, void **pData)
 {
-       return zend_u_hash_find(ht, IS_STRING, (zstr)arKey, nKeyLength, pData);
+       return zend_u_hash_find(ht, IS_STRING, ZSTR(arKey), nKeyLength, pData);
 }
 
 
@@ -1016,7 +1016,7 @@ ZEND_API int zend_u_hash_quick_find(HashTable *ht, zend_uchar type, zstr arKey,
 
 ZEND_API int zend_hash_quick_find(HashTable *ht, char *arKey, uint nKeyLength, ulong h, void **pData)
 {
-       return zend_u_hash_quick_find(ht, IS_STRING, (zstr)arKey, nKeyLength, h, pData);
+       return zend_u_hash_quick_find(ht, IS_STRING, ZSTR(arKey), nKeyLength, h, pData);
 }
 
 ZEND_API int zend_u_hash_exists(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength)
@@ -1052,7 +1052,7 @@ ZEND_API int zend_u_hash_exists(HashTable *ht, zend_uchar type, zstr arKey, uint
 
 ZEND_API int zend_hash_exists(HashTable *ht, char *arKey, uint nKeyLength)
 {
-       return zend_u_hash_exists(ht, IS_STRING, (zstr)arKey, nKeyLength);
+       return zend_u_hash_exists(ht, IS_STRING, ZSTR(arKey), nKeyLength);
 }
 
 ZEND_API int zend_u_hash_quick_exists(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, ulong h)
@@ -1093,7 +1093,7 @@ ZEND_API int zend_u_hash_quick_exists(HashTable *ht, zend_uchar type, zstr arKey
 
 ZEND_API int zend_hash_quick_exists(HashTable *ht, char *arKey, uint nKeyLength, ulong h)
 {
-       return zend_u_hash_quick_exists(ht, IS_STRING, (zstr)arKey, nKeyLength, h);
+       return zend_u_hash_quick_exists(ht, IS_STRING, ZSTR(arKey), nKeyLength, h);
 }
 
 ZEND_API int zend_hash_index_find(HashTable *ht, ulong h, void **pData)
@@ -1505,7 +1505,7 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t co
                                        return 1;
                                }
                        } else { /* string, binary or unicode index */
-                               if (zend_u_hash_find(ht2, p1->key.type, (zstr)p1->key.arKey.s, p1->nKeyLength, &pData2)==FAILURE) {
+                               if (zend_u_hash_find(ht2, p1->key.type, ZSTR(p1->key.arKey.s), p1->nKeyLength, &pData2)==FAILURE) {
                                        HASH_UNPROTECT_RECURSION(ht1);
                                        HASH_UNPROTECT_RECURSION(ht2);
                                        return 1;
@@ -1687,10 +1687,10 @@ ZEND_API int zend_u_symtable_update_current_key(HashTable *ht, zend_uchar type,
 
        if (type == IS_STRING) {
                key_type = HASH_KEY_IS_STRING;
-               HANDLE_NUMERIC(arKey.s, nKeyLength, zend_hash_update_current_key(ht, HASH_KEY_IS_LONG, (zstr)NULL, 0, idx));
+               HANDLE_NUMERIC(arKey.s, nKeyLength, zend_hash_update_current_key(ht, HASH_KEY_IS_LONG, NULL_ZSTR, 0, idx));
        } else {
                key_type = HASH_KEY_IS_UNICODE;
-               HANDLE_U_NUMERIC(arKey.u, nKeyLength, zend_hash_update_current_key(ht, HASH_KEY_IS_LONG, (zstr)NULL, 0, idx));
+               HANDLE_U_NUMERIC(arKey.u, nKeyLength, zend_hash_update_current_key(ht, HASH_KEY_IS_LONG, NULL_ZSTR, 0, idx));
        }
        return zend_hash_update_current_key(ht, key_type, arKey, nKeyLength, 0);
 }
@@ -1726,8 +1726,8 @@ ZEND_API int zend_symtable_exists(HashTable *ht, char *arKey, uint nKeyLength)
 
 ZEND_API int zend_symtable_update_current_key(HashTable *ht, char *arKey, uint nKeyLength)
 {
-       HANDLE_NUMERIC(arKey, nKeyLength, zend_hash_update_current_key(ht, HASH_KEY_IS_LONG, (zstr)NULL, 0, idx));
-       return zend_hash_update_current_key(ht, HASH_KEY_IS_STRING, (zstr)arKey, nKeyLength, 0);
+       HANDLE_NUMERIC(arKey, nKeyLength, zend_hash_update_current_key(ht, HASH_KEY_IS_LONG, NULL_ZSTR, 0, idx));
+       return zend_hash_update_current_key(ht, HASH_KEY_IS_STRING, ZSTR(arKey), nKeyLength, 0);
 }
 
 ZEND_API void zend_hash_to_unicode(HashTable *ht, apply_func_t apply_func TSRMLS_DC)
index 4a02875938fe4fd2c2d99912a2dd470f1921d096..fff11583da82fba44e86cd22cf46a594f6d32123 100755 (executable)
@@ -76,7 +76,7 @@ ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce, zend
                if (!fn_proxy || !*fn_proxy) {
                        if (zend_hash_find(function_table, function_name, function_name_len+1, (void **) &fcic.function_handler) == FAILURE) {
                                /* error at c-level */
-                               zend_error(E_CORE_ERROR, "Couldn't find implementation for method %v%s%s", obj_ce ? obj_ce->name : (zstr)EMPTY_STR, obj_ce ? "::" : "", function_name);
+                               zend_error(E_CORE_ERROR, "Couldn't find implementation for method %v%s%s", obj_ce ? obj_ce->name : EMPTY_ZSTR, obj_ce ? "::" : "", function_name);
                        }
                        if (fn_proxy) {
                                *fn_proxy = fcic.function_handler;
@@ -93,7 +93,7 @@ ZEND_API zval* zend_call_method(zval **object_pp, zend_class_entry *obj_ce, zend
                if (!obj_ce) {
                        obj_ce = object_pp ? Z_OBJCE_PP(object_pp) : NULL;
                }
-               zend_error(E_CORE_ERROR, "Couldn't execute method %v%s%s", obj_ce ? obj_ce->name : (zstr)EMPTY_STR, obj_ce ? "::" : "", function_name);
+               zend_error(E_CORE_ERROR, "Couldn't execute method %v%s%s", obj_ce ? obj_ce->name : EMPTY_ZSTR, obj_ce ? "::" : "", function_name);
        }
        if (!retval_ptr_ptr) {
                if (retval) {
index 938147f6ecb100e859406371e2d89e2e74a0972b..dc7e3fac818d42b73fee1ab6c6b1d50ccd02a7f1 100644 (file)
@@ -1891,7 +1891,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
 }
 
 <ST_IN_SCRIPTING>"__CLASS__" {
-       zstr class_name = (zstr)NULL;
+       zstr class_name = NULL_ZSTR;
 
        if (CG(active_class_entry)) {
                class_name = CG(active_class_entry)->name;
@@ -1906,7 +1906,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
 }
 
 <ST_IN_SCRIPTING>"__FUNCTION__" {
-       zstr func_name = (zstr)NULL;
+       zstr func_name = NULL_ZSTR;
 
        if (CG(active_op_array)) {
                func_name = CG(active_op_array)->function_name;
@@ -1921,8 +1921,8 @@ NEWLINE ("\r"|"\n"|"\r\n")
 }
 
 <ST_IN_SCRIPTING>"__METHOD__" {
-       zstr class_name = CG(active_class_entry) ? CG(active_class_entry)->name : (zstr)NULL;
-       zstr func_name = CG(active_op_array)? CG(active_op_array)->function_name : (zstr)NULL;
+       zstr class_name = CG(active_class_entry) ? CG(active_class_entry)->name : NULL_ZSTR;
+       zstr func_name = CG(active_op_array)? CG(active_op_array)->function_name : NULL_ZSTR;
        size_t len = 0;
 
        if (UG(unicode)) {
index db38d87b6f21832860b1e00b95427c230745c711..803be752e39682ac1f9a25fd4998ec24c27f1c10 100644 (file)
@@ -792,14 +792,14 @@ static union _zend_function *zend_std_get_method(zval **object_ptr, zstr method_
                 */
                updated_fbc = zend_check_private_int(fbc, Z_OBJ_HANDLER_P(object, get_class_entry)(object TSRMLS_CC), lc_method_name, method_len TSRMLS_CC);
                if (!updated_fbc) {
-                       zend_error(E_ERROR, "Call to %s method %v::%v() from context '%v'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), method_name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                       zend_error(E_ERROR, "Call to %s method %v::%v() from context '%v'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), method_name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                }
                fbc = updated_fbc;
        } else if ((fbc->common.fn_flags & ZEND_ACC_PROTECTED)) {
                /* Ensure that if we're calling a protected function, we're allowed to do so.
                 */
                if (!zend_check_protected(fbc->common.scope, EG(scope))) {
-                       zend_error(E_ERROR, "Call to %s method %v::%v() from context '%v'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), method_name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                       zend_error(E_ERROR, "Call to %s method %v::%v() from context '%v'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), method_name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                }
        }
 
@@ -839,14 +839,14 @@ ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zstr fu
                 */
                updated_fbc = zend_check_private_int(fbc, EG(scope), function_name_strval, function_name_strlen TSRMLS_CC);
                if (!updated_fbc) {
-                       zend_error(E_ERROR, "Call to %s method %v::%v() from context '%v'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), fbc->common.function_name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                       zend_error(E_ERROR, "Call to %s method %v::%v() from context '%v'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), fbc->common.function_name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                }
                fbc = updated_fbc;
        } else if ((fbc->common.fn_flags & ZEND_ACC_PROTECTED)) {
                /* Ensure that if we're calling a protected function, we're allowed to do so.
                 */
                if (!zend_check_protected(EG(scope), fbc->common.scope)) {
-                       zend_error(E_ERROR, "Call to %s method %v::%v() from context '%v'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), fbc->common.function_name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                       zend_error(E_ERROR, "Call to %s method %v::%v() from context '%v'", zend_visibility_string(fbc->common.fn_flags), ZEND_FN_SCOPE_NAME(fbc), fbc->common.function_name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                }
        }
 
@@ -915,13 +915,13 @@ static union _zend_function *zend_std_get_constructor(zval *object TSRMLS_DC)
                        /* Ensure that if we're calling a private function, we're allowed to do so.
                         */
                        if (Z_OBJ_HANDLER_P(object, get_class_entry)(object TSRMLS_CC) != EG(scope)) {
-                               zend_error(E_ERROR, "Call to private %v::%v() from context '%v'", constructor->common.scope->name, constructor->common.function_name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                               zend_error(E_ERROR, "Call to private %v::%v() from context '%v'", constructor->common.scope->name, constructor->common.function_name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                        }
                } else if ((constructor->common.fn_flags & ZEND_ACC_PROTECTED)) {
                        /* Ensure that if we're calling a protected function, we're allowed to do so.
                         */
                        if (!zend_check_protected(constructor->common.scope, EG(scope))) {
-                               zend_error(E_ERROR, "Call to protected %v::%v() from context '%v'", constructor->common.scope->name, constructor->common.function_name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                               zend_error(E_ERROR, "Call to protected %v::%v() from context '%v'", constructor->common.scope->name, constructor->common.function_name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                        }
                }
        }
index 1d10f57e857c35092f1bdf3365e6a5bf97d572eb..1ce9caeae344a8fb829f50fd143bb1e85633e39c 100644 (file)
@@ -44,7 +44,7 @@ ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handl
                                        zend_error(EG(in_execution) ? E_ERROR : E_WARNING,
                                                "Call to private %v::__destruct() from context '%v'%s",
                                                ce->name,
-                                               EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR,
+                                               EG(scope) ? EG(scope)->name : EMPTY_ZSTR,
                                                EG(in_execution) ? "" : " during shutdown ignored");
                                        return;
                                }
@@ -57,7 +57,7 @@ ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handl
                                        zend_error(EG(in_execution) ? E_ERROR : E_WARNING,
                                                "Call to protected %v::__destruct() from context '%v'%s",
                                                ce->name,
-                                               EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR,
+                                               EG(scope) ? EG(scope)->name : EMPTY_ZSTR,
                                                EG(in_execution) ? "" : " during shutdown ignored");
                                        return;
                                }
index 7648d0f4cf0efd386bfe28b621897c3a6efdff33..337c241e32d0dfbbc27fe3673a58c2c9a5a7a765 100644 (file)
@@ -2084,17 +2084,24 @@ ZEND_API zstr zend_u_str_tolower_copy(zend_uchar type, zstr dest, zstr source, u
 
                return dest;
        } else {
-               return (zstr)zend_str_tolower_copy(dest.s, source.s, length);
+               zstr ret;
+               
+               ret.s = zend_str_tolower_copy(dest.s, source.s, length);
+               return ret;
        }
 }
 
 ZEND_API zstr zend_u_str_tolower_dup(zend_uchar type, zstr source, unsigned int length)
 {
+       zstr ret;
+
        if (type == IS_UNICODE) {
-               return zend_u_str_tolower_copy(IS_UNICODE, (zstr)emalloc(UBYTES(length+1)), source, length);
+               ret.u = eumalloc(length+1);
+               ret = zend_u_str_tolower_copy(IS_UNICODE, ret, source, length);
        } else {
-               return (zstr)zend_str_tolower_copy((char*)emalloc(length+1), source.s, length);
+               ret.s = zend_str_tolower_copy((char*)emalloc(length+1), source.s, length);
        }
+       return ret;
 }
 
 ZEND_API void zend_str_tolower(char *str, unsigned int length)
@@ -2124,24 +2131,25 @@ ZEND_API void zend_u_str_tolower(zend_uchar type, zstr str, unsigned int length)
 
 ZEND_API zstr zend_u_str_case_fold(zend_uchar type, zstr source, unsigned int length, zend_bool normalize, unsigned int *new_len)
 {
+       zstr ret;
+
        if (type == IS_UNICODE) {
-               UChar *ret;
                int ret_len;
 
                if (normalize) {
-                       zend_normalize_identifier(&ret, &ret_len, source.u, length, 1);
+                       zend_normalize_identifier(&ret.u, &ret_len, source.u, length, 1);
                } else {
                        UErrorCode status = U_ZERO_ERROR;
 
-                       zend_case_fold_string(&ret, &ret_len, source.u, length, U_FOLD_CASE_DEFAULT, &status);
+                       zend_case_fold_string(&ret.u, &ret_len, source.u, length, U_FOLD_CASE_DEFAULT, &status);
                }
 
                *new_len = ret_len;
-               return (zstr)ret;
-       } else {
+       } else {                
                *new_len = length;
-               return (zstr)zend_str_tolower_dup(source.s, length);
+               ret.s = zend_str_tolower_dup(source.s, length);
        }
+       return ret;
 }
 
 ZEND_API int zend_binary_strcmp(char *s1, uint len1, char *s2, uint len2)
index 2edb1609d719eb2cf83156e17c71e27a6f345965..24feea02d09e8fa87d32639d7af4b3fd65b3a21c 100644 (file)
@@ -388,8 +388,8 @@ END_EXTERN_C()
 #define Z_OBJPROP(zval)                        Z_OBJ_HT((zval))->get_properties(&(zval) TSRMLS_CC)
 #define Z_OBJ_HANDLER(zval, hf) Z_OBJ_HT((zval))->hf
 #define Z_RESVAL(zval)                 (zval).value.lval
-#define Z_UNIVAL(zval)                 ((zstr)(Z_STRVAL(zval)))
-#define Z_UNILEN(zval)                 Z_STRLEN(zval)
+#define Z_UNIVAL(zval)                 (zval).value.uni.val
+#define Z_UNILEN(zval)                 (zval).value.uni.len
 
 #define Z_LVAL_P(zval_p)               Z_LVAL(*zval_p)
 #define Z_BVAL_P(zval_p)               Z_BVAL(*zval_p)
index 20e0f56cdfa65dc41b68dee8bd9ccfac04071731..90ac745a2c1f753f7309af9ada031669428e5b12 100644 (file)
@@ -1821,7 +1821,7 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
                }
                if (EX(function_state).function->common.fn_flags & ZEND_ACC_DEPRECATED) {
                        zend_error(E_STRICT, "Function %v%s%v() is deprecated",
-                               EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : (zstr)EMPTY_STR,
+                               EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : EMPTY_ZSTR,
                                EX(function_state).function->common.scope ? "::" : "",
                                EX(function_state).function->common.function_name);
                }
@@ -2509,13 +2509,13 @@ ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMP|VAR|UNUSED|CV, ANY)
                        /* Ensure that if we're calling a private function, we're allowed to do so.
                         */
                        if (ce != EG(scope)) {
-                               zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                               zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                        }
                } else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) {
                        /* Ensure that if we're calling a protected function, we're allowed to do so.
                         */
                        if (!zend_check_protected(clone->common.scope, EG(scope))) {
-                               zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                               zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                        }
                }
        }
index 4106bdaf636dc80ad1d0f1e14bfa8e1749cb3199..542d4e4d4ab33cd54d67ea75e5ba82f55bb59356 100644 (file)
@@ -147,7 +147,7 @@ static int zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)
                }
                if (EX(function_state).function->common.fn_flags & ZEND_ACC_DEPRECATED) {
                        zend_error(E_STRICT, "Function %v%s%v() is deprecated",
-                               EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : (zstr)EMPTY_STR,
+                               EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : EMPTY_ZSTR,
                                EX(function_state).function->common.scope ? "::" : "",
                                EX(function_state).function->common.function_name);
                }
@@ -1720,13 +1720,13 @@ static int ZEND_CLONE_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                        /* Ensure that if we're calling a private function, we're allowed to do so.
                         */
                        if (ce != EG(scope)) {
-                               zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                               zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                        }
                } else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) {
                        /* Ensure that if we're calling a protected function, we're allowed to do so.
                         */
                        if (!zend_check_protected(clone->common.scope, EG(scope))) {
-                               zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                               zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                        }
                }
        }
@@ -4220,13 +4220,13 @@ static int ZEND_CLONE_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                        /* Ensure that if we're calling a private function, we're allowed to do so.
                         */
                        if (ce != EG(scope)) {
-                               zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                               zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                        }
                } else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) {
                        /* Ensure that if we're calling a protected function, we're allowed to do so.
                         */
                        if (!zend_check_protected(clone->common.scope, EG(scope))) {
-                               zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                               zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                        }
                }
        }
@@ -7317,13 +7317,13 @@ static int ZEND_CLONE_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                        /* Ensure that if we're calling a private function, we're allowed to do so.
                         */
                        if (ce != EG(scope)) {
-                               zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                               zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                        }
                } else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) {
                        /* Ensure that if we're calling a protected function, we're allowed to do so.
                         */
                        if (!zend_check_protected(clone->common.scope, EG(scope))) {
-                               zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                               zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                        }
                }
        }
@@ -14423,13 +14423,13 @@ static int ZEND_CLONE_SPEC_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                        /* Ensure that if we're calling a private function, we're allowed to do so.
                         */
                        if (ce != EG(scope)) {
-                               zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                               zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                        }
                } else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) {
                        /* Ensure that if we're calling a protected function, we're allowed to do so.
                         */
                        if (!zend_check_protected(clone->common.scope, EG(scope))) {
-                               zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                               zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                        }
                }
        }
@@ -19951,13 +19951,13 @@ static int ZEND_CLONE_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                        /* Ensure that if we're calling a private function, we're allowed to do so.
                         */
                        if (ce != EG(scope)) {
-                               zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                               zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                        }
                } else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) {
                        /* Ensure that if we're calling a protected function, we're allowed to do so.
                         */
                        if (!zend_check_protected(clone->common.scope, EG(scope))) {
-                               zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
+                               zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : EMPTY_ZSTR);
                        }
                }
        }
index e38940f38a44feb7170e76f4e607232102ced164..dc286894aa0c734af0e61589458cba7d65e967e4 100644 (file)
@@ -843,12 +843,12 @@ int php_libxml_register_export(zend_class_entry *ce, php_libxml_export_node expo
 
        if (zend_hash_add(&php_libxml_exports, ce->name.s, ce->name_length + 1, &export_hnd, sizeof(export_hnd), NULL) == SUCCESS) {
                int ret;
-               UChar *uname;
+               zstr name;
 
-               uname = malloc(UBYTES(ce->name_length+1));
-               u_charsToUChars(ce->name.s, uname, ce->name_length+1);
-               ret = zend_u_hash_add(&php_libxml_exports, IS_UNICODE, (zstr)uname, ce->name_length + 1, &export_hnd, sizeof(export_hnd), NULL);
-               free(uname);
+               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;
index 38a16316d0a99c6380c94d57f2482f904b413886..86e2c19b5de80c7c75323bb1484cd6801a352a69 100644 (file)
@@ -1988,7 +1988,7 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length,
                if (p->nKeyLength == 0) {
                        zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL);
                } else {
-                       zend_u_hash_update(out_hash, p->key.type, (zstr)p->key.arKey.s, p->nKeyLength, &entry, sizeof(zval *), NULL);
+                       zend_u_hash_update(out_hash, p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength, &entry, sizeof(zval *), NULL);
                }
        }
        
@@ -2000,7 +2000,7 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length,
                        if (p->nKeyLength == 0) {
                                zend_hash_next_index_insert(*removed, &entry, sizeof(zval *), NULL);
                        } else {                        
-                               zend_u_hash_update(*removed, p->key.type, (zstr)p->key.arKey.s, p->nKeyLength, &entry, sizeof(zval *), NULL);
+                               zend_u_hash_update(*removed, p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength, &entry, sizeof(zval *), NULL);
                        }
                }
        } else /* otherwise just skip those entries */
@@ -2033,7 +2033,7 @@ HashTable* php_splice(HashTable *in_hash, int offset, int length,
                if (p->nKeyLength == 0) {
                        zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL);
                } else {
-                       zend_u_hash_update(out_hash, p->key.type, (zstr)p->key.arKey.s, p->nKeyLength, &entry, sizeof(zval *), NULL);
+                       zend_u_hash_update(out_hash, p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength, &entry, sizeof(zval *), NULL);
                }
        }
 
@@ -2094,7 +2094,7 @@ static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
 {
        zval **stack,                   /* Input stack */
             **val;                     /* Value to be popped */
-       zstr key = (zstr)NULL;
+       zstr key = NULL_ZSTR;
        int key_len = 0;
        ulong index;
        zend_uchar key_type;
@@ -3043,9 +3043,9 @@ PHP_FUNCTION(array_unique)
                                zend_hash_index_del(Z_ARRVAL_P(return_value), p->h);
                        } else {
                                if (Z_ARRVAL_P(return_value) == &EG(symbol_table)) {
-                                       zend_u_delete_global_variable(p->key.type, (zstr)p->key.arKey.s, p->nKeyLength-1 TSRMLS_CC);
+                                       zend_u_delete_global_variable(p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength-1 TSRMLS_CC);
                                } else {
-                                       zend_u_hash_del(Z_ARRVAL_P(return_value), p->key.type, (zstr)p->key.arKey.s, p->nKeyLength);
+                                       zend_u_hash_del(Z_ARRVAL_P(return_value), p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength);
                                }
                        }
                }
@@ -3303,7 +3303,7 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int
                                        if (p->nKeyLength == 0) {
                                                zend_hash_index_del(Z_ARRVAL_P(return_value), p->h);
                                        } else {
-                                               zend_u_hash_del(Z_ARRVAL_P(return_value), p->key.type, (zstr)p->key.arKey.s, p->nKeyLength);
+                                               zend_u_hash_del(Z_ARRVAL_P(return_value), p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength);
                                        }
                                }
                        }
@@ -3319,7 +3319,7 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int
                                if (p->nKeyLength == 0) {
                                        zend_hash_index_del(Z_ARRVAL_P(return_value), p->h);  
                                } else {
-                                       zend_u_hash_del(Z_ARRVAL_P(return_value), p->key.type, (zstr)p->key.arKey.s, p->nKeyLength);  
+                                       zend_u_hash_del(Z_ARRVAL_P(return_value), p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength);  
                                }
                                if (!*++ptrs[0]) { 
                                        goto out;
@@ -3702,7 +3702,7 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
                                if (p->nKeyLength == 0) {
                                        zend_hash_index_del(Z_ARRVAL_P(return_value), p->h);
                                } else {
-                                       zend_u_hash_del(Z_ARRVAL_P(return_value), p->key.type, (zstr)p->key.arKey.s, p->nKeyLength);
+                                       zend_u_hash_del(Z_ARRVAL_P(return_value), p->key.type, ZSTR(p->key.arKey.s), p->nKeyLength);
                                }
                                if (!*++ptrs[0]) {
                                        goto out;
index 054fa94cb45ffc76c93dd477f939ccaa2d951797..7ad7ee9e25e58b3afbaa37327d6986c030743916 100644 (file)
@@ -126,7 +126,7 @@ zend_class_entry *php_create_incomplete_class(TSRMLS_D)
 PHPAPI zstr php_lookup_class_name(zval *object, zend_uint *nlen)
 {
        zval **val;
-       zstr retval = (zstr)NULL;
+       zstr retval = NULL_ZSTR;
        HashTable *object_properties;
        TSRMLS_FETCH();
 
index 3d5391a04a9323abdd54b2ac8798d3fe92cfc1b7..2cbbc0f65dc013d4b3a647573482b197c5916739 100644 (file)
@@ -907,20 +907,8 @@ static int parse_context_params(php_stream_context *context, zval *params TSRMLS
 {
        int ret = SUCCESS;
        zval **tmp;
-       U_STRING_DECL(u_notification, "notification", 12);
-       U_STRING_DECL(u_options, "options", 7);
-       U_STRING_DECL(u_input_encoding, "input_encoding", 14);
-       U_STRING_DECL(u_output_encoding, "output_encoding", 15);
-       U_STRING_DECL(u_default_mode, "default_mode", 12);
-
-       U_STRING_INIT(u_notification, "notification", 12);
-       U_STRING_INIT(u_options, "options", 7);
-       U_STRING_INIT(u_input_encoding, "input_encoding", 14);
-       U_STRING_INIT(u_output_encoding, "output_encoding", 15);
-       U_STRING_INIT(u_default_mode, "default_mode", 12);
-
-       if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "notification", sizeof("notification"), (void**)&tmp) ||
-               SUCCESS == zend_u_hash_find(Z_ARRVAL_P(params), IS_UNICODE, (zstr)u_notification, sizeof("notification"), (void**)&tmp)) {
+
+       if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "notification", sizeof("notification"), (void**)&tmp)) {
                
                if (context->notifier) {
                        php_stream_notification_free(context->notifier);
@@ -933,12 +921,10 @@ static int parse_context_params(php_stream_context *context, zval *params TSRMLS
                ZVAL_ADDREF(*tmp);
                context->notifier->dtor = user_space_stream_notifier_dtor;
        }
-       if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "options", sizeof("options"), (void**)&tmp) ||
-               SUCCESS == zend_u_hash_find(Z_ARRVAL_P(params), IS_UNICODE, (zstr)u_options, sizeof("options"), (void**)&tmp)) {
+       if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "options", sizeof("options"), (void**)&tmp)) {
                parse_context_options(context, *tmp TSRMLS_CC);
        }
-       if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "input_encoding", sizeof("input_encoding"), (void**)&tmp) ||
-               SUCCESS == zend_u_hash_find(Z_ARRVAL_P(params), IS_UNICODE, (zstr)u_input_encoding, sizeof("input_encoding"), (void**)&tmp)) {
+       if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "input_encoding", sizeof("input_encoding"), (void**)&tmp)) {
                zval strval = **tmp;
 
                if (context->input_encoding) {
@@ -949,8 +935,7 @@ static int parse_context_params(php_stream_context *context, zval *params TSRMLS
                convert_to_string(&strval);
                context->input_encoding = Z_STRVAL(strval);
        }
-       if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "output_encoding", sizeof("output_encoding"), (void**)&tmp) ||
-               SUCCESS == zend_u_hash_find(Z_ARRVAL_P(params), IS_UNICODE, (zstr)u_output_encoding, sizeof("output_encoding"), (void**)&tmp)) {
+       if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "output_encoding", sizeof("output_encoding"), (void**)&tmp)) {
                zval strval = **tmp;
 
                if (context->output_encoding) {
@@ -961,8 +946,7 @@ static int parse_context_params(php_stream_context *context, zval *params TSRMLS
                convert_to_string(&strval);
                context->output_encoding = Z_STRVAL(strval);
        }
-       if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "default_mode", sizeof("default_mode"), (void**)&tmp) ||
-               SUCCESS == zend_u_hash_find(Z_ARRVAL_P(params), IS_UNICODE, (zstr)u_default_mode, sizeof("default_mode"), (void**)&tmp)) {
+       if (SUCCESS == zend_hash_find(Z_ARRVAL_P(params), "default_mode", sizeof("default_mode"), (void**)&tmp)) {
                zval longval = **tmp;
 
                zval_copy_ctor(&longval);
index 2598e9e6d9b3202b51b2bfca560de675333dbaa7..350ba582cb86a2456ebb68a364135b277522c9e2 100644 (file)
@@ -684,6 +684,9 @@ static void php_var_serialize_class(smart_str *buf, zval **struc, zval *retval_p
 {
        int count;
        zend_bool  incomplete_class;
+       zstr star;
+
+       star.s = "*";
 
        incomplete_class = php_var_serialize_class_name(buf, struc TSRMLS_CC);
        /* count after serializing name, since php_var_serialize_class_name
@@ -762,7 +765,7 @@ static void php_var_serialize_class(smart_str *buf, zval **struc, zval *retval_p
                                                        break;
                                                }
                                                efree(priv_name.v);
-                                               zend_u_mangle_property_name(&prot_name, &prop_name_length,  Z_TYPE_PP(name), (zstr)"*", 1, 
+                                               zend_u_mangle_property_name(&prot_name, &prop_name_length,  Z_TYPE_PP(name), star, 1, 
                                                                        Z_UNIVAL_PP(name), Z_UNILEN_PP(name), ce->type & ZEND_INTERNAL_CLASS);
                                                if (zend_u_hash_find(Z_OBJPROP_PP(struc), Z_TYPE_PP(name), prot_name, prop_name_length+1, (void *) &d) == SUCCESS) {
                                                        if (Z_TYPE_PP(name) == IS_UNICODE) {
index 77ad25482e5bde581405afcaeec97794ec237151..a8c8a39f9d4396a514a3a527442b383db5f5d0c3 100644 (file)
@@ -415,7 +415,7 @@ static void text_iter_get_current_data(zend_object_iterator* iter, zval*** data
        *data = &obj->current;
 }
 
-static int text_iter_get_current_key(zend_object_iterator* iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
+static int text_iter_get_current_key(zend_object_iterator* iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
 {
        text_iter_obj* obj = text_iter_to_obj(iter);
 
index 239d1ed31d8aacfaba290babae226458f1ed9d7f..e640ceb19e100c2d29aaccd540b82b813a6faa24 100644 (file)
@@ -550,7 +550,7 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c
        char *space;
        zstr class_name = get_active_class_name(&space TSRMLS_CC);
        int origin_len;
-       zstr function = (zstr)NULL;
+       zstr function = NULL_ZSTR;
        char *origin;
        char *message;
        char *stage;
index e60dda96e9dc10940a012b975d62089af4e84edb..840eef42b7be5fd6683e40eea77b5043beb2bfc4 100644 (file)
@@ -500,58 +500,58 @@ static int php_ob_init(uint initial_size, uint block_size, zval *output_handler,
        zval *handler_zval;
 
        if (output_handler && output_handler->type == IS_STRING) {
-               char* next_handler_name;
-               char* handler_name = Z_STRVAL_P(output_handler);
-               handler_len  = Z_STRLEN_P(output_handler);
+               zstr next_handler_name;
+               zstr handler_name = Z_UNIVAL_P(output_handler);
+               handler_len  = Z_UNILEN_P(output_handler);
 
                result = SUCCESS;
-               if (handler_len && handler_name[0] != '\0') {
-                       while ((next_handler_name=strchr(handler_name, ',')) != NULL) {
-                               len = next_handler_name-handler_name;
-                               next_handler_name = estrndup(handler_name, len);
-                               handler_zval = php_ob_handler_from_string(next_handler_name, len TSRMLS_CC);
-                               result = php_ob_init_named(initial_size, block_size, IS_STRING, (zstr)next_handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
+               if (handler_len && handler_name.s[0] != '\0') {
+                       while ((next_handler_name.s=strchr(handler_name.s, ',')) != NULL) {
+                               len = next_handler_name.s-handler_name.s;
+                               next_handler_name.s = estrndup(handler_name.s, len);
+                               handler_zval = php_ob_handler_from_string(next_handler_name.s, len TSRMLS_CC);
+                               result = php_ob_init_named(initial_size, block_size, IS_STRING, next_handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
                                if (result != SUCCESS) {
                                        zval_dtor(handler_zval);
                                        FREE_ZVAL(handler_zval);
                                }
-                               handler_name += len+1;
+                               handler_name.s += len+1;
                                handler_len -= len+1;
-                               efree(next_handler_name);
+                               efree(next_handler_name.s);
                        }
                }
                if (result == SUCCESS) {
-                       handler_zval = php_ob_handler_from_string(handler_name, handler_len TSRMLS_CC);
-                       result = php_ob_init_named(initial_size, block_size, IS_STRING, (zstr)handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
+                       handler_zval = php_ob_handler_from_string(handler_name.s, handler_len TSRMLS_CC);
+                       result = php_ob_init_named(initial_size, block_size, IS_STRING, handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
                        if (result != SUCCESS) {
                                zval_dtor(handler_zval);
                                FREE_ZVAL(handler_zval);
                        }
                }
        } else if (output_handler && output_handler->type == IS_UNICODE) {
-               UChar* next_handler_name;
-               UChar* handler_name = Z_USTRVAL_P(output_handler);
-               handler_len  = Z_USTRLEN_P(output_handler);
+               zstr next_handler_name;
+               zstr handler_name = Z_UNIVAL_P(output_handler);
+               handler_len  = Z_UNILEN_P(output_handler);
 
                result = SUCCESS;
-               if (handler_len && handler_name[0] != 0) {
-                       while ((next_handler_name=u_strchr(handler_name, ',')) != NULL) {
-                               len = next_handler_name-handler_name;
-                               next_handler_name = eustrndup(handler_name, len);
-                               handler_zval = php_ob_handler_from_unicode(next_handler_name, len TSRMLS_CC);
-                               result = php_ob_init_named(initial_size, block_size, IS_UNICODE, (zstr)next_handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
+               if (handler_len && handler_name.u[0] != 0) {
+                       while ((next_handler_name.u=u_strchr(handler_name.u, ',')) != NULL) {
+                               len = next_handler_name.u-handler_name.u;
+                               next_handler_name.u = eustrndup(handler_name.u, len);
+                               handler_zval = php_ob_handler_from_unicode(next_handler_name.u, len TSRMLS_CC);
+                               result = php_ob_init_named(initial_size, block_size, IS_UNICODE, next_handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
                                if (result != SUCCESS) {
                                        zval_dtor(handler_zval);
                                        FREE_ZVAL(handler_zval);
                                }
-                               handler_name += len+1;
+                               handler_name.u += len+1;
                                handler_len -= len+1;
-                               efree(next_handler_name);
+                               efree(next_handler_name.u);
                        }
                }
                if (result == SUCCESS) {
-                       handler_zval = php_ob_handler_from_unicode(handler_name, handler_len TSRMLS_CC);
-                       result = php_ob_init_named(initial_size, block_size, IS_UNICODE, (zstr)handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
+                       handler_zval = php_ob_handler_from_unicode(handler_name.u, handler_len TSRMLS_CC);
+                       result = php_ob_init_named(initial_size, block_size, IS_UNICODE, handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
                        if (result != SUCCESS) {
                                zval_dtor(handler_zval);
                                FREE_ZVAL(handler_zval);
@@ -582,7 +582,10 @@ static int php_ob_init(uint initial_size, uint block_size, zval *output_handler,
                php_error_docref(NULL TSRMLS_CC, E_ERROR, "No method name given: use ob_start(array($object,'method')) to specify instance $object and the name of a method of class %v to use as output handler", Z_OBJCE_P(output_handler)->name);
                result = FAILURE;
        } else {
-               result = php_ob_init_named(initial_size, block_size, IS_STRING, (zstr)OB_DEFAULT_HANDLER_NAME, NULL, chunk_size, erase TSRMLS_CC);
+               zstr z_name;
+
+               z_name.s = OB_DEFAULT_HANDLER_NAME;
+               result = php_ob_init_named(initial_size, block_size, IS_STRING, z_name, NULL, chunk_size, erase TSRMLS_CC);
        }
        return result;
 }
index 0555c23e9f7d0f59860e33e4285ae1c38e19c14f..0d61ebc0b4962738e75c31d8cf23e6e63c37a612 100644 (file)
@@ -296,7 +296,8 @@ PHPAPI void php_u_register_variable_ex(UChar *var, zval *val, zval *track_vars_a
 
        while (1) {
                if (is_array) {
-                       UChar *escaped_index = NULL, *index_s;
+                       zstr escaped_index = NULL_ZSTR;
+                       UChar *index_s;
                        int32_t new_idx_len = 0;
 
                        ip++;
@@ -332,18 +333,18 @@ PHPAPI void php_u_register_variable_ex(UChar *var, zval *val, zval *track_vars_a
                                        /* UTODO fix for magic_quotes_gpc case */
                                        /* no need to addslashes() the index if it's the main variable name */
                                        //escaped_index = php_addslashes(index, index_len, &index_len, 0 TSRMLS_CC);
-                                       escaped_index = index;
+                                       escaped_index.u = index;
                                } else {
-                                       escaped_index = index;
+                                       escaped_index.u = index;
                                }
-                               if (zend_u_symtable_find(symtable1, IS_UNICODE, (zstr)escaped_index, index_len+1, (void **) &gpc_element_p)==FAILURE
+                               if (zend_u_symtable_find(symtable1, IS_UNICODE, escaped_index, index_len+1, (void **) &gpc_element_p)==FAILURE
                                        || Z_TYPE_PP(gpc_element_p) != IS_ARRAY) {
                                        MAKE_STD_ZVAL(gpc_element);
                                        array_init(gpc_element);
-                                       zend_u_symtable_update(symtable1, IS_UNICODE, (zstr)escaped_index, index_len+1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
+                                       zend_u_symtable_update(symtable1, IS_UNICODE, escaped_index, index_len+1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
                                }
-                               if (index!=escaped_index) {
-                                       efree(escaped_index);
+                               if (index!=escaped_index.u) {
+                                       efree(escaped_index.u);
                                }
                        }
                        symtable1 = Z_ARRVAL_PP(gpc_element_p);
@@ -368,8 +369,10 @@ plain_var:
                        } else {
                                /* UTODO fix for php_addslashes case */
                                //char *escaped_index = php_addslashes(index, index_len, &index_len, 0 TSRMLS_CC);
-                               UChar *escaped_index = index;
-                               zend_u_symtable_update(symtable1, IS_UNICODE, (zstr)escaped_index, index_len+1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
+                               zstr escaped_index;
+
+                               escaped_index.u = index;
+                               zend_u_symtable_update(symtable1, IS_UNICODE, escaped_index, index_len+1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
                                //efree(escaped_index);
                        }
                        break;
index 72b25bd4e22d2e2392afd66361ec0f7f095aa9d9..1cea3b173fb8513bbc0dc2c13e263e12bfa117c9 100644 (file)
@@ -264,7 +264,7 @@ static void add_u_protected_variable(UChar *varname TSRMLS_DC)
        int dummy=1;
 
        normalize_u_protected_variable(varname TSRMLS_CC);
-       zend_u_hash_add(&PG(rfc1867_protected_variables), IS_UNICODE, (zstr)varname, u_strlen(varname)+1, &dummy, sizeof(int), NULL);
+       zend_u_hash_add(&PG(rfc1867_protected_variables), IS_UNICODE, ZSTR(varname), u_strlen(varname)+1, &dummy, sizeof(int), NULL);
 }
 
 
@@ -278,7 +278,7 @@ static zend_bool is_protected_variable(char *varname TSRMLS_DC)
 static zend_bool is_u_protected_variable(UChar *varname TSRMLS_DC)
 {
        normalize_u_protected_variable(varname TSRMLS_CC);
-       return zend_u_hash_exists(&PG(rfc1867_protected_variables), IS_UNICODE, (zstr)varname, u_strlen(varname)+1);
+       return zend_u_hash_exists(&PG(rfc1867_protected_variables), IS_UNICODE, ZSTR(varname), u_strlen(varname)+1);
 }
 
 
@@ -1316,7 +1316,7 @@ var_done:
                                }
                                temp_filename = EMPTY_STR;
                        } else {
-                               zend_u_hash_add(SG(rfc1867_uploaded_files), IS_UNICODE, (zstr)temp_filename, u_strlen(temp_filename) + 1, &temp_filename, sizeof(UChar *), NULL);
+                               zend_u_hash_add(SG(rfc1867_uploaded_files), IS_UNICODE, ZSTR(temp_filename), u_strlen(temp_filename) + 1, &temp_filename, sizeof(UChar *), NULL);
                        }
 
                        /* is_arr_upload is true when name of file upload field