static void print_hash(HashTable *ht, int indent, zend_bool is_object TSRMLS_DC)
{
zval **tmp;
- char *string_key;
+ zstr string_key;
HashPosition iterator;
ulong num_key;
uint str_len;
ztype = IS_UNICODE;
str_type:
if (is_object) {
- char *prop_name, *class_name;
+ zstr prop_name, class_name;
zend_u_unmangle_property_name(ztype, string_key, &class_name, &prop_name);
- if (class_name) {
- if (class_name[0]=='*') {
+ if (class_name.v) {
+ if (class_name.s[0]=='*') {
zend_printf("%R:protected", ztype, prop_name);
} else {
zend_printf("%R:%v:private", ztype, prop_name, class_name);
static void print_flat_hash(HashTable *ht TSRMLS_DC)
{
zval **tmp;
- char *string_key;
+ zstr string_key;
HashPosition iterator;
ulong num_key;
uint str_len;
ZEND_PUTS("[");
switch (zend_hash_get_current_key_ex(ht, &string_key, &str_len, &num_key, 0, &iterator)) {
case HASH_KEY_IS_STRING:
- ZEND_PUTS(string_key);
+ ZEND_PUTS(string_key.s);
break;
case HASH_KEY_IS_UNICODE:
- zend_printf("%r", string_key);
+ zend_printf("%r", string_key.u);
break;
case HASH_KEY_IS_LONG:
zend_printf("%ld", num_key);
case IS_OBJECT:
{
HashTable *properties = NULL;
- char *class_name = NULL;
+ zstr class_name = (zstr)NULL;
zend_uint clen;
if (Z_OBJ_HANDLER_P(expr, get_class_name)) {
Z_OBJ_HANDLER_P(expr, get_class_name)(expr, &class_name, &clen, 0 TSRMLS_CC);
}
- if (class_name) {
- zend_printf("%v Object (", class_name);
+ if (class_name.v) {
+ zend_printf("%v Object (", class_name.v);
} else {
zend_printf("%s Object (", "Unknown Class");
}
- if (class_name) {
- efree(class_name);
+ if (class_name.v) {
+ efree(class_name.v);
}
if (Z_OBJ_HANDLER_P(expr, get_properties)) {
properties = Z_OBJPROP_P(expr);
case IS_OBJECT:
{
HashTable *properties = NULL;
- char *class_name = NULL;
+ zstr class_name = (zstr)NULL;
zend_uint clen;
if (Z_OBJ_HANDLER_P(expr, get_class_name)) {
Z_OBJ_HANDLER_P(expr, get_class_name)(expr, &class_name, &clen, 0 TSRMLS_CC);
}
- if (class_name) {
- zend_printf("%v Object\n", class_name);
+ if (class_name.v) {
+ zend_printf("%v Object\n", class_name.v);
} else {
zend_printf("%s Object\n", "Unknown Class");
}
- if (class_name) {
- efree(class_name);
+ if (class_name.v) {
+ efree(class_name.v);
}
if (Z_OBJ_HANDLER_P(expr, get_properties)) {
properties = Z_OBJPROP_P(expr);
zend_standard_class_def->type = ZEND_INTERNAL_CLASS;
zend_standard_class_def->name_length = sizeof("stdClass") - 1;
- zend_standard_class_def->name = zend_strndup("stdClass", zend_standard_class_def->name_length);
+ zend_standard_class_def->name.s = zend_strndup("stdClass", zend_standard_class_def->name_length);
zend_initialize_class_data(zend_standard_class_def, 1 TSRMLS_CC);
zend_hash_add(CG(class_table), "stdclass", sizeof("stdclass"), &zend_standard_class_def, sizeof(zend_class_entry *), NULL);
destroy_zend_function(function TSRMLS_CC);
if (function->type == ZEND_INTERNAL_FUNCTION) {
- if (function->common.function_name) {
- free(function->common.function_name);
+ 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) {
- free(function->common.arg_info[n].name);
+ if (function->common.arg_info[n].name.v) {
+ free(function->common.arg_info[n].name.v);
}
- if (function->common.arg_info[n].class_name) {
- free(function->common.arg_info[n].class_name);
+ if (function->common.arg_info[n].class_name.v) {
+ free(function->common.arg_info[n].class_name.v);
}
}
free(function->common.arg_info);
} else {
zval_internal_dtor(&c->value);
}
- free(c->name);
+ free(c->name.v);
}
static void function_to_unicode(zend_function *func TSRMLS_DC)
{
- if (func->common.function_name) {
+ if (func->common.function_name.s) {
UChar *uname;
- int len = strlen(func->common.function_name)+1;
+ int len = strlen(func->common.function_name.s)+1;
uname = malloc(UBYTES(len));
- u_charsToUChars(func->common.function_name, uname, len);
- func->common.function_name = (char*)uname;
+ u_charsToUChars(func->common.function_name.s, uname, len);
+ func->common.function_name.u = uname;
}
if (func->common.arg_info) {
zend_arg_info *args;
memcpy(args, func->common.arg_info, (n + 1) * sizeof(zend_arg_info));
while (n > 0) {
--n;
- if (args[n].name) {
+ if (args[n].name.s) {
UChar *uname = malloc(UBYTES(args[n].name_len));
- u_charsToUChars(args[n].name, uname, args[n].name_len);
- args[n].name = (char*)uname;
+ u_charsToUChars(args[n].name.s, uname, args[n].name_len);
+ args[n].name.u = uname;
}
- if (args[n].class_name) {
+ if (args[n].class_name.s) {
UChar *uname = malloc(UBYTES(args[n].class_name_len));
- u_charsToUChars(args[n].class_name, uname, args[n].class_name_len);
- args[n].class_name = (char*)uname;
+ u_charsToUChars(args[n].class_name.s, uname, args[n].class_name_len);
+ args[n].class_name.u = uname;
}
}
func->common.arg_info = args;
static void property_info_to_unicode(zend_property_info *info TSRMLS_DC)
{
- if (info->name) {
+ if (info->name.s) {
UChar *uname;
uname = malloc(UBYTES(info->name_length+1));
- u_charsToUChars(info->name, uname, info->name_length+1);
- free(info->name);
- info->name = (char*)uname;
+ u_charsToUChars(info->name.s, uname, info->name_length+1);
+ free(info->name.s);
+ info->name.u = uname;
info->h = zend_u_get_hash_value(IS_UNICODE, info->name, info->name_length+1);
}
}
{
UChar *uname;
- if (c->name) {
+ if (c->name.s) {
uname = malloc(UBYTES(c->name_len));
- u_charsToUChars(c->name, uname, c->name_len);
- free(c->name);
- c->name = (char*)uname;
+ u_charsToUChars(c->name.s, uname, c->name_len);
+ free(c->name.s);
+ c->name.u = uname;
}
if (Z_TYPE(c->value) == IS_STRING || Z_TYPE(c->value) == IS_CONSTANT) {
UChar *ustr;
static void class_to_unicode(zend_class_entry **ce TSRMLS_DC)
{
/* Convert name to unicode */
- if ((*ce)->name) {
+ if ((*ce)->name.s) {
UChar *uname = malloc(UBYTES((*ce)->name_length+1));
- u_charsToUChars((*ce)->name, uname, (*ce)->name_length+1);
- free((*ce)->name);
- (*ce)->name = (char*)uname;
+ u_charsToUChars((*ce)->name.s, uname, (*ce)->name_length+1);
+ free((*ce)->name.s);
+ (*ce)->name.u = uname;
}
zend_hash_to_unicode(&(*ce)->function_table, (apply_func_t)function_to_unicode TSRMLS_CC);
if (EG(exception)) {
char ex_class_name[128];
if (Z_TYPE_P(EG(exception)) == IS_OBJECT) {
- strncpy(ex_class_name, Z_OBJ_CLASS_NAME_P(EG(exception)), 127);
+ /* CHECK ME: why strings only */
+ strncpy(ex_class_name, Z_OBJ_CLASS_NAME_P(EG(exception)).s, 127);
ex_class_name[127] = '\0';
} else {
strcpy(ex_class_name, "Unknown Exception");
#define LONG_MIN (- LONG_MAX - 1)
#endif
+typedef union _zstr {
+ char *s;
+ UChar *u;
+ void *v;
+} zstr;
+
#define EMPTY_STR ((UChar*)"\0\0")
#undef SUCCESS
} str;
struct { /* Unicode string type */
UChar *val;
- int32_t len;
+ int len;
} ustr;
HashTable *ht; /* hash table value */
zend_object_value obj;
struct _zend_class_entry {
char type;
- char *name;
+ zstr name;
zend_uint name_length;
struct _zend_class_entry *parent;
int refcount;
#define ZEND_U_EQUAL(type, ustr, ulen, str, slen) \
((type == IS_STRING)? \
- (!memcmp((ustr),(str),(slen))): \
- (!zend_cmp_unicode_and_literal(((UChar*)(ustr)), ulen, str, slen)))
+ (!memcmp((ustr).s,(str),(slen))): \
+ (!zend_cmp_unicode_and_literal((ustr).u, ulen, str, slen)))
#endif /* ZEND_H */
if (EG(ze1_compatibility_mode) && Z_TYPE_PP(value) == IS_OBJECT) {
zval *value_ptr;
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
int dup;
ALLOC_ZVAL(value_ptr);
*value_ptr = **value;
INIT_PZVAL(value_ptr);
- zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", class_name);
+ zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", class_name.v);
if(!dup) {
- efree(class_name);
+ efree(class_name.v);
}
Z_OBJVAL_P(value_ptr) = Z_OBJ_HANDLER_PP(value, clone_obj)(*value TSRMLS_CC);
zval_ptr_dtor(value);
ZEND_API void zend_wrong_param_count(TSRMLS_D)
{
char *space;
- char *class_name = get_active_class_name(&space TSRMLS_CC);
+ zstr class_name = get_active_class_name(&space TSRMLS_CC);
zend_error(E_WARNING, "Wrong parameter count for %v%s%v()", class_name, space, get_active_function_name(TSRMLS_C));
}
}
/* returns 1 if you need to copy result, 0 if it's already a copy */
-ZEND_API int zend_get_object_classname(zval *object, char **class_name, zend_uint *class_name_len TSRMLS_DC)
+ZEND_API int zend_get_object_classname(zval *object, zstr *class_name, zend_uint *class_name_len TSRMLS_DC)
{
if (Z_OBJ_HT_P(object)->get_class_name == NULL ||
Z_OBJ_HT_P(object)->get_class_name(object, class_name, class_name_len, 0 TSRMLS_CC) != SUCCESS) {
case 'u':
{
UChar **p = va_arg(*va, UChar **);
- int32_t *pl = va_arg(*va, int32_t *);
+ int *pl = va_arg(*va, int *);
switch (Z_TYPE_PP(arg)) {
case IS_NULL:
if (return_null) {
if (T_arg_type != -1)
{
void **p = va_arg(*va, void **);
- int32_t *pl = va_arg(*va, int32_t *);
+ int *pl = va_arg(*va, int *);
zend_uchar *type = va_arg(*va, zend_uchar *);
switch (Z_TYPE_PP(arg)) {
case IS_NULL:
} else {
if (Z_TYPE_PP(arg) == IS_UNICODE) {
char *space;
- char *class_name = get_active_class_name(&space TSRMLS_CC);
+ zstr class_name = get_active_class_name(&space TSRMLS_CC);
zend_error(E_WARNING, "%v%s%v() does not allow mixing binary and Unicode parameters",
class_name, space, get_active_function_name(TSRMLS_C));
return "";
if (Z_OBJ_HANDLER_PP(arg, cast_object)) {
SEPARATE_ZVAL_IF_NOT_REF(arg);
if (Z_OBJ_HANDLER_PP(arg, cast_object)(*arg, *arg, T_arg_type TSRMLS_CC) == SUCCESS) {
- *(char**)p = Z_UNIVAL_PP(arg);
+ /* FIXME: Unicode support??? */
+ *(char**)p = Z_STRVAL_PP(arg);
*pl = Z_UNILEN_PP(arg);
*type = Z_TYPE_PP(arg);
RETURN_AS_UNICODE(arg, p, pl, type);
case 't':
{
void **p = va_arg(*va, void **);
- int32_t *pl = va_arg(*va, int32_t *);
+ int *pl = va_arg(*va, int *);
zend_uchar *type = va_arg(*va, zend_uchar *);
switch (Z_TYPE_PP(arg)) {
case IS_NULL:
if (Z_TYPE_PP(arg) == IS_NULL && return_null) {
*p = NULL;
} else {
- return ce ? ce->name : "object";
+ /* FIXME: Unicode support??? */
+ return ce ? ce->name.s : "object";
}
}
}
zend_class_entry **lookup, **pce = va_arg(*va, zend_class_entry **);
zend_class_entry *ce_base = *pce;
- if (UG(unicode)) {
- convert_to_unicode_ex(arg);
- } else {
- convert_to_string_ex(arg);
- }
- if (zend_u_lookup_class(Z_TYPE_PP(arg), Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &lookup TSRMLS_CC) == FAILURE) {
+ convert_to_text_ex(arg);
+ if (zend_u_lookup_class(Z_TYPE_PP(arg), Z_UNIVAL_PP(arg), Z_UNILEN_PP(arg), &lookup TSRMLS_CC) == FAILURE) {
*pce = NULL;
} else {
*pce = *lookup;
if (ce_base) {
if ((!*pce || !instanceof_function(*pce, ce_base TSRMLS_CC)) && !return_null) {
char *space;
- char *class_name = get_active_class_name(&space TSRMLS_CC);
+ zstr class_name = get_active_class_name(&space TSRMLS_CC);
zend_error(E_WARNING, "%v%s%v() expects parameter %d to be a class name derived from %v, '%v' given",
class_name, space, get_active_function_name(TSRMLS_C),
arg_num, ce_base->name, Z_STRVAL_PP(arg));
}
if (!*pce && !return_null) {
char *space;
- char *class_name = get_active_class_name(&space TSRMLS_CC);
+ zstr class_name = get_active_class_name(&space TSRMLS_CC);
zend_error(E_WARNING, "%v%s%v() expects parameter %d to be a valid class name, '%v' given",
class_name, space, get_active_function_name(TSRMLS_C),
arg_num, Z_STRVAL_PP(arg));
if (expected_type) {
if (!quiet && *expected_type) {
char *space;
- char *class_name = get_active_class_name(&space TSRMLS_CC);
+ zstr class_name = get_active_class_name(&space TSRMLS_CC);
zend_error(E_WARNING, "%v%s%v() expects parameter %d to be %s, %s given",
class_name, space, get_active_function_name(TSRMLS_C), arg_num, expected_type,
default:
if (!quiet) {
char *space;
- char *class_name = get_active_class_name(&space TSRMLS_CC);
+ zstr class_name = get_active_class_name(&space TSRMLS_CC);
zend_error(E_WARNING, "%v%s%v(): bad type specifier while parsing parameters",
class_name, space,
get_active_function_name(TSRMLS_C));
if (num_args < min_num_args || num_args > max_num_args) {
if (!quiet) {
char *space;
- char *class_name = get_active_class_name(&space TSRMLS_CC);
+ zstr class_name = get_active_class_name(&space TSRMLS_CC);
zend_error(E_WARNING, "%v%s%v() expects %s %d parameter%s, %d given",
class_name, space,
get_active_function_name(TSRMLS_C),
MAKE_STD_ZVAL(member);
if (hash_key->type == IS_STRING) {
- ZVAL_STRINGL(member, hash_key->u.string, hash_key->nKeyLength-1, 1);
+ ZVAL_STRINGL(member, hash_key->arKey.s, hash_key->nKeyLength-1, 1);
} else if (hash_key->type == IS_UNICODE) {
- ZVAL_UNICODEL(member, hash_key->u.unicode, hash_key->nKeyLength-1, 1);
+ ZVAL_UNICODEL(member, hash_key->arKey.u, hash_key->nKeyLength-1, 1);
}
obj_ht->write_property(obj, member, *value TSRMLS_CC);
zend_hash_internal_pointer_reset_ex(&class_type->default_static_members, &pos);
while (zend_hash_get_current_data_ex(&class_type->default_static_members, (void**)&p, &pos) == SUCCESS) {
- char *str_index;
+ zstr str_index;
uint str_length;
ulong num_index;
zend_uchar utype;
return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
}
-ZEND_API int add_assoc_unicode_ex(zval *arg, char *key, uint key_len, void *str, int duplicate)
+ZEND_API int add_assoc_unicode_ex(zval *arg, char *key, uint key_len, UChar *str, int duplicate)
{
zval *tmp;
}
-ZEND_API int add_assoc_unicodel_ex(zval *arg, char *key, uint key_len, void *str, uint length, int duplicate)
+ZEND_API int add_assoc_unicodel_ex(zval *arg, char *key, uint key_len, UChar *str, uint length, int duplicate)
{
zval *tmp;
return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &value, sizeof(zval *), NULL);
}
-ZEND_API int add_u_assoc_zval_ex(zval *arg, zend_uchar type, void *key, uint key_len, zval *value)
+ZEND_API int add_u_assoc_zval_ex(zval *arg, zend_uchar type, zstr key, uint key_len, zval *value)
{
return zend_u_symtable_update(Z_ARRVAL_P(arg), type, key, key_len, (void *) &value, sizeof(zval *), NULL);
}
ZEND_API void zend_check_magic_method_implementation(zend_class_entry *ce, zend_function *fptr, int error_type TSRMLS_DC)
{
unsigned int lcname_len;
- char *lcname;
+ zstr lcname;
int name_len;
zend_uchar utype = UG(unicode)?IS_UNICODE:IS_STRING;
/* we don't care if the function name is longer, in fact lowercasing only
* the beginning of the name speeds up the check process */
if (UG(unicode)) {
- name_len = u_strlen((UChar*)fptr->common.function_name);
+ name_len = u_strlen(fptr->common.function_name.u);
} else {
- name_len = strlen(fptr->common.function_name);
+ name_len = strlen(fptr->common.function_name.s);
}
lcname = zend_u_str_case_fold(utype, fptr->common.function_name, name_len, 0, &lcname_len);
ZEND_U_EQUAL(utype, lcname, lcname_len, ZEND_TOSTRING_FUNC_NAME, sizeof(ZEND_TOSTRING_FUNC_NAME)-1) && fptr->common.num_args != 0) {
zend_error(error_type, "Method %v::%s() cannot take arguments", ce->name, ZEND_CALL_FUNC_NAME);
}
- efree(lcname);
+ efree(lcname.v);
}
/* registers all functions in *library_functions in the function hash */
if (scope) {
class_name_len = scope->name_length;
- lc_class_name = zend_str_tolower_dup(scope->name, class_name_len);
+ lc_class_name = zend_str_tolower_dup(scope->name.s, class_name_len);
}
while (ptr->fname) {
internal_function->handler = ptr->handler;
- internal_function->function_name = ptr->fname;
+ internal_function->function_name.s = ptr->fname;
internal_function->scope = scope;
internal_function->prototype = NULL;
if (ptr->arg_info) {
}
if (ptr->flags) {
if (!(ptr->flags & ZEND_ACC_PPP_MASK)) {
- zend_error(error_type, "Invalid access level for %s%s%s() - access must be exactly one of public, protected or private", scope ? scope->name : "", scope ? "::" : "", ptr->fname);
+ 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);
internal_function->fn_flags = ZEND_ACC_PUBLIC | ptr->flags;
} else {
internal_function->fn_flags = ptr->flags;
}
}
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 : "", scope ? "::" : "", ptr->fname);
+ zend_error(error_type, "Static function %s%s%s() cannot be abstract", scope ? scope->name.s : "", scope ? "::" : "", ptr->fname);
}
} else {
if (scope && (scope->ce_flags & ZEND_ACC_INTERFACE)) {
if (scope) {
efree(lc_class_name);
}
- zend_error(error_type, "Method %s%s%s() cannot be a NULL function", scope ? scope->name : "", scope ? "::" : "", ptr->fname);
+ zend_error(error_type, "Method %s%s%s() cannot be a NULL function", scope ? scope->name.s : "", scope ? "::" : "", ptr->fname);
zend_unregister_functions(functions, count, target_function_table TSRMLS_CC);
return FAILURE;
}
}
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 : "", scope ? "::" : "", ptr->fname);
+ zend_error(error_type, "Function registration failed - duplicate name - %s%s%s", scope ? scope->name.s : "", scope ? "::" : "", ptr->fname);
}
ptr++;
}
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, class_entry->name_length);
+ 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);
return class_entry;
static int zend_is_callable_check_func(int check_flags, zval ***zobj_ptr_ptr, zend_class_entry *ce_org, zval *callable, zend_class_entry **ce_ptr, zend_function **fptr_ptr TSRMLS_DC)
{
int retval;
- char *lcname, *lmname, *mname, *colon;
+ zstr lcname, lmname, mname, colon;
unsigned int clen, mlen;
zend_function *fptr;
zend_class_entry **pce;
*fptr_ptr = NULL;
if (Z_TYPE_P(callable) == IS_UNICODE) {
- if ((colon = (char*)u_strstr((UChar*)Z_UNIVAL_P(callable), (UChar*)":\0:\0")) != NULL) {
- mlen = u_strlen((UChar*)(colon+4));
- clen = Z_UNILEN_P(callable) - mlen - 2;
- mname = colon + 4;
+ if ((colon.u = u_strstr(Z_USTRVAL_P(callable), (UChar*)":\0:\0")) != NULL) {
+ mlen = u_strlen(colon.u+2);
+ clen = Z_USTRLEN_P(callable) - mlen - 2;
+ mname.u = colon.u + 2;
}
} else {
- if ((colon = strstr(Z_STRVAL_P(callable), "::")) != NULL) {
- clen = colon - Z_STRVAL_P(callable);
+ if ((colon.s = strstr(Z_STRVAL_P(callable), "::")) != NULL) {
+ clen = colon.s - Z_STRVAL_P(callable);
mlen = Z_STRLEN_P(callable) - clen - 2;
- mname = colon + 2;
+ mname.s = colon.s + 2;
}
}
- if (colon != NULL) {
- if (zend_u_lookup_class(Z_TYPE_P(callable), Z_STRVAL_P(callable), clen, &pce TSRMLS_CC) == SUCCESS) {
+ if (colon.v != NULL) {
+ if (zend_u_lookup_class(Z_TYPE_P(callable), Z_UNIVAL_P(callable), clen, &pce TSRMLS_CC) == SUCCESS) {
*ce_ptr = *pce;
} else {
lcname = zend_u_str_case_fold(Z_TYPE_P(callable), Z_UNIVAL_P(callable), clen, 0, &clen);
/* caution: lcname is not '\0' terminated */
- if (clen == sizeof("self") - 1 && memcmp(lcname, "self", sizeof("self") - 1) == 0) {
+ /* FIXME: Unicode support??? */
+ if (clen == sizeof("self") - 1 && memcmp(lcname.s, "self", sizeof("self") - 1) == 0) {
*ce_ptr = EG(scope);
- } else if (clen == sizeof("parent") - 1 && memcmp(lcname, "parent", sizeof("parent") - 1) == 0 && EG(active_op_array)->scope) {
+ } else if (clen == sizeof("parent") - 1 && memcmp(lcname.s, "parent", sizeof("parent") - 1) == 0 && EG(active_op_array)->scope) {
*ce_ptr = EG(scope) ? EG(scope)->parent : NULL;
}
- efree(lcname);
+ efree(lcname.v);
}
if (!*ce_ptr) {
return 0;
}
lmname = zend_u_str_case_fold(Z_TYPE_P(callable), mname, mlen, 0, &mlen);
} else {
- lmname = zend_u_str_case_fold(Z_TYPE_P(callable), Z_STRVAL_P(callable), Z_STRLEN_P(callable), 0, &mlen);
+ lmname = zend_u_str_case_fold(Z_TYPE_P(callable), Z_UNIVAL_P(callable), Z_UNILEN_P(callable), 0, &mlen);
if (ce_org) {
ftable = &ce_org->function_table;
*ce_ptr = ce_org;
}
}
- retval = zend_hash_find(ftable, lmname, mlen+1, (void**)&fptr) == SUCCESS ? 1 : 0;
+ retval = zend_u_hash_find(ftable, Z_TYPE_P(callable), lmname, mlen+1, (void**)&fptr) == SUCCESS ? 1 : 0;
if (!retval) {
if (*zobj_ptr_ptr && *ce_ptr && (*ce_ptr)->__call != 0) {
}
}
}
- efree(lmname);
+ efree(lmname.v);
return retval;
}
ZEND_API zend_bool zend_is_callable_ex(zval *callable, uint check_flags, zval *callable_name, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zval ***zobj_ptr_ptr TSRMLS_DC)
{
- char *lcname;
+ zstr lcname;
unsigned int lcname_len;
zend_class_entry *ce_local, **pce;
zend_function *fptr_local;
} else if (zend_u_lookup_class(Z_TYPE_PP(obj), Z_UNIVAL_PP(obj), Z_UNILEN_PP(obj), &pce TSRMLS_CC) == SUCCESS) {
ce = *pce;
}
- efree(lcname);
+ efree(lcname.v);
} else {
ce = Z_OBJCE_PP(obj); /* TBFixed: what if it's overloaded? */
Z_TYPE_P(callable_name) = IS_UNICODE;
Z_USTRLEN_P(callable_name) = ce->name_length + Z_UNILEN_PP(method) + 2;
Z_USTRVAL_P(callable_name) = eumalloc(Z_USTRLEN_P(callable_name)+1);
- memcpy(Z_USTRVAL_P(callable_name), ce->name, UBYTES(ce->name_length));
+ memcpy(Z_USTRVAL_P(callable_name), ce->name.u, UBYTES(ce->name_length));
Z_USTRVAL_P(callable_name)[ce->name_length] = ':';
Z_USTRVAL_P(callable_name)[ce->name_length+1] = ':';
if (Z_TYPE_PP(method) == IS_UNICODE) {
Z_TYPE_P(callable_name) = IS_STRING;
Z_STRLEN_P(callable_name) = ce->name_length + Z_UNILEN_PP(method) + 2;
Z_STRVAL_P(callable_name) = emalloc(Z_STRLEN_P(callable_name)+1);
- memcpy(Z_STRVAL_P(callable_name), ce->name, ce->name_length);
+ memcpy(Z_STRVAL_P(callable_name), ce->name.s, ce->name_length);
Z_STRVAL_P(callable_name)[ce->name_length] = ':';
Z_STRVAL_P(callable_name)[ce->name_length+1] = ':';
if (Z_TYPE_PP(method) == IS_STRING) {
return module->version;
}
-ZEND_API int zend_u_declare_property_ex(zend_class_entry *ce, zend_uchar type, void *name, int name_length, zval *property, int access_type, char *doc_comment, int doc_comment_len TSRMLS_DC)
+ZEND_API int zend_u_declare_property_ex(zend_class_entry *ce, zend_uchar type, zstr name, int name_length, zval *property, int access_type, char *doc_comment, int doc_comment_len TSRMLS_DC)
{
zend_property_info property_info;
HashTable *target_symbol_table;
}
switch (access_type & ZEND_ACC_PPP_MASK) {
case ZEND_ACC_PRIVATE: {
- char *priv_name;
+ zstr priv_name;
int priv_name_length;
zend_u_mangle_property_name(&priv_name, &priv_name_length, type, ce->name, ce->name_length, name, name_length, ce->type & ZEND_INTERNAL_CLASS);
}
break;
case ZEND_ACC_PROTECTED: {
- char *prot_name;
+ zstr prot_name;
int prot_name_length;
- zend_u_mangle_property_name(&prot_name, &prot_name_length, type, "*", 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;
break;
case ZEND_ACC_PUBLIC:
if (ce->parent) {
- char *prot_name;
+ zstr prot_name;
int prot_name_length;
- zend_u_mangle_property_name(&prot_name, &prot_name_length, type, "*", 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, ce->type & ZEND_INTERNAL_CLASS);
+ pefree(prot_name.v, ce->type & ZEND_INTERNAL_CLASS);
}
zend_u_hash_update(target_symbol_table, type, name, name_length+1, &property, sizeof(zval *), NULL);
- property_info.name = ce->type & ZEND_INTERNAL_CLASS ?
- (type==IS_UNICODE?(char*)zend_ustrndup(name, name_length):zend_strndup(name, name_length)) :
- (type==IS_UNICODE?(char*)eustrndup(name, name_length):estrndup(name, name_length));
+ property_info.name.s = ce->type & ZEND_INTERNAL_CLASS ?
+ (type==IS_UNICODE?(char*)zend_ustrndup(name.u, name_length):zend_strndup(name.s, name_length)) :
+ (type==IS_UNICODE?(char*)eustrndup(name.u, name_length):estrndup(name.s, name_length));
property_info.name_length = name_length;
break;
}
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, 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, void *name, int name_length, zval *property, int access_type TSRMLS_DC)
+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)
{
return zend_u_declare_property_ex(ce, type, name, name_length, property, access_type, NULL, 0 TSRMLS_CC);
}
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, 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)
EG(scope) = scope;
if (!Z_OBJ_HT_P(object)->write_property) {
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);
- zend_error(E_CORE_ERROR, "Property %s of class %v cannot be updated", name, class_name);
+ zend_error(E_CORE_ERROR, "Property %s of class %v cannot be updated", name, class_name.v);
}
MAKE_STD_ZVAL(property);
ZVAL_ASCII_STRINGL(property, name, name_length, 1);
zend_class_entry *old_scope = EG(scope);
EG(scope) = scope;
- property = zend_std_get_static_property(scope, IS_STRING, 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;
EG(scope) = scope;
if (!Z_OBJ_HT_P(object)->read_property) {
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);
- zend_error(E_CORE_ERROR, "Property %s of class %v cannot be read", name, class_name);
+ zend_error(E_CORE_ERROR, "Property %s of class %v cannot be read", name, class_name.v);
}
MAKE_STD_ZVAL(property);
zend_class_entry *old_scope = EG(scope);
EG(scope) = scope;
- property = zend_std_get_static_property(scope, IS_STRING, 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;
ZEND_FENTRY(name, ZEND_FN(classname##_##alias), arg_info, flags)
#define ZEND_ME_MAPPING(name, func_name, arg_types) ZEND_NAMED_FE(name, ZEND_FN(func_name), arg_types)
-#define ZEND_ARG_INFO(pass_by_ref, name) { #name, sizeof(#name)-1, NULL, 0, 0, 0, pass_by_ref, 0, 0 },
-#define ZEND_ARG_PASS_INFO(pass_by_ref) { NULL, 0, NULL, 0, 0, 0, pass_by_ref, 0, 0 },
-#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) { #name, sizeof(#name)-1, #classname, sizeof(#classname)-1, 0, allow_null, pass_by_ref, 0, 0 },
-#define ZEND_ARG_ARRAY_INFO(pass_by_ref, name, allow_null) { #name, sizeof(#name)-1, NULL, 0, 1, allow_null, pass_by_ref, 0, 0 },
+#define ZEND_ARG_INFO(pass_by_ref, name) { {#name}, sizeof(#name)-1, {NULL}, 0, 0, 0, pass_by_ref, 0, 0 },
+#define ZEND_ARG_PASS_INFO(pass_by_ref) { {NULL}, 0, {NULL}, 0, 0, 0, pass_by_ref, 0, 0 },
+#define ZEND_ARG_OBJ_INFO(pass_by_ref, name, classname, allow_null) { {#name}, sizeof(#name)-1, {#classname}, sizeof(#classname)-1, 0, allow_null, pass_by_ref, 0, 0 },
+#define ZEND_ARG_ARRAY_INFO(pass_by_ref, name, allow_null) { {#name}, sizeof(#name)-1, {NULL}, 0, 1, allow_null, pass_by_ref, 0, 0 },
#define ZEND_BEGIN_ARG_INFO_EX(name, pass_rest_by_reference, return_reference, required_num_args) \
zend_arg_info name[] = { \
- { NULL, 0, NULL, 0, 0, 0, pass_rest_by_reference, return_reference, required_num_args },
+ { {NULL}, 0, {NULL}, 0, 0, 0, pass_rest_by_reference, return_reference, required_num_args },
#define ZEND_BEGIN_ARG_INFO(name, pass_rest_by_reference) \
ZEND_BEGIN_ARG_INFO_EX(name, pass_rest_by_reference, ZEND_RETURN_VALUE, -1)
#define ZEND_END_ARG_INFO() };
#define INIT_OVERLOADED_CLASS_ENTRY_EX(class_container, class_name, functions, handle_fcall, handle_propget, handle_propset, handle_propunset, handle_propisset) \
{ \
- class_container.name = strdup(class_name); \
+ class_container.name.s = strdup(class_name); \
class_container.name_length = sizeof(class_name) - 1; \
class_container.builtin_functions = functions; \
class_container.constructor = NULL; \
ZEND_API int zend_declare_property_string(zend_class_entry *ce, char *name, int name_length, char *value, int access_type TSRMLS_DC);
ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, char *name, int name_length, char *value, int value_len, int access_type TSRMLS_DC);
-ZEND_API int zend_u_declare_property(zend_class_entry *ce, zend_uchar type, void *name, int name_length, zval *property, int access_type TSRMLS_DC);
-ZEND_API int zend_u_declare_property_ex(zend_class_entry *ce, zend_uchar type, void *name, int name_length, zval *property, int access_type, char *doc_comment, int doc_comment_len TSRMLS_DC);
+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);
+ZEND_API int zend_u_declare_property_ex(zend_class_entry *ce, zend_uchar type, zstr name, int name_length, zval *property, int access_type, char *doc_comment, int doc_comment_len TSRMLS_DC);
ZEND_API int zend_declare_class_constant(zend_class_entry *ce, char *name, size_t name_length, zval *value TSRMLS_DC);
ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, char *name, size_t name_length, long value TSRMLS_DC);
ZEND_API zval *zend_read_static_property(zend_class_entry *scope, char *name, int name_length, zend_bool silent TSRMLS_DC);
ZEND_API zend_class_entry *zend_get_class_entry(zval *zobject TSRMLS_DC);
-ZEND_API int zend_get_object_classname(zval *object, char **class_name, zend_uint *class_name_len TSRMLS_DC);
+ZEND_API int zend_get_object_classname(zval *object, zstr *class_name, zend_uint *class_name_len TSRMLS_DC);
ZEND_API zend_uchar zend_get_unified_string_type(int num_args TSRMLS_DC, ...);
#define getThis() (this_ptr)
ZEND_API int add_assoc_double_ex(zval *arg, char *key, uint key_len, double d);
ZEND_API int add_assoc_string_ex(zval *arg, char *key, uint key_len, char *str, int duplicate);
ZEND_API int add_assoc_stringl_ex(zval *arg, char *key, uint key_len, char *str, uint length, int duplicate);
-ZEND_API int add_assoc_unicode_ex(zval *arg, char *key, uint key_len, void *str, int duplicate);
-ZEND_API int add_assoc_unicodel_ex(zval *arg, char *key, uint key_len, void *str, uint length, int duplicate);
+ZEND_API int add_assoc_unicode_ex(zval *arg, char *key, uint key_len, UChar *str, int duplicate);
+ZEND_API int add_assoc_unicodel_ex(zval *arg, char *key, uint key_len, UChar *str, uint length, int duplicate);
ZEND_API int add_assoc_zval_ex(zval *arg, char *key, uint key_len, zval *value);
#define add_assoc_text_ex(arg, key, key_len, str, duplicate) \
if (UG(unicode)) { \
- add_assoc_unicode_ex(arg, key, key_len, (UChar*)(str), duplicate); \
+ add_assoc_unicode_ex(arg, key, key_len, (str).u, duplicate); \
} else { \
- add_assoc_string_ex(arg, key, key_len, (char*)(str), duplicate); \
+ add_assoc_string_ex(arg, key, key_len, (str).s, duplicate); \
}
#define add_assoc_textl_ex(arg, key, key_len, str, length, duplicate) \
if (UG(unicode)) { \
- add_assoc_unicodel_ex(arg, key, key_len, (UChar*)(str), length, duplicate); \
+ add_assoc_unicodel_ex(arg, key, key_len, (str).u, length, duplicate); \
} else { \
- add_assoc_stringl_ex(arg, key, key_len, (char*)(str), length, duplicate); \
+ add_assoc_stringl_ex(arg, key, key_len, (str).s, length, duplicate); \
}
#define add_assoc_ascii_string_ex(arg, key, key_len, str, duplicate) \
if (UG(unicode)) { \
UErrorCode status = U_ZERO_ERROR; \
UChar *u_str; \
- int32_t u_len; \
+ int u_len; \
int length = strlen(str); \
zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, str, length, &status); \
add_assoc_unicodel_ex(arg, key, key_len, u_str, u_len, 0); \
if (UG(unicode)) { \
UErrorCode status = U_ZERO_ERROR; \
UChar *u_str; \
- int32_t u_len; \
+ int u_len; \
zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, str, length, &status); \
add_assoc_unicodel_ex(arg, key, key_len, u_str, u_len, 0); \
} else { \
add_assoc_stringl(arg, key, (char*)(str), length, duplicate); \
}
-ZEND_API int add_u_assoc_zval_ex(zval *arg, zend_uchar type, void *key, uint key_len, zval *value);
+ZEND_API int add_u_assoc_zval_ex(zval *arg, zend_uchar type, zstr key, uint key_len, zval *value);
-#define add_u_assoc_zval(__arg, __type, __key, __value) add_u_assoc_zval_ex(__arg, __type, __key, (((__type)==IS_UNICODE)?u_strlen((UChar*)__key):strlen(__key))+1, __value)
+#define add_u_assoc_zval(__arg, __type, __key, __value) add_u_assoc_zval_ex(__arg, __type, __key, (((__type)==IS_UNICODE)?u_strlen((__key).u):strlen((__key).s))+1, __value)
/* unset() functions are only suported for legacy modules and null() functions should be used */
#define add_assoc_unset(__arg, __key) add_assoc_null_ex(__arg, __key, strlen(__key) + 1)
#define add_next_index_text(arg, str, duplicate) \
if (UG(unicode)) { \
- add_next_index_unicode(arg, (UChar*)(str), duplicate); \
+ add_next_index_unicode(arg, (str).u, duplicate); \
} else { \
- add_next_index_string(arg, (char*)(str), duplicate); \
+ add_next_index_string(arg, (str).s, duplicate); \
}
#define add_next_index_textl(arg, str, length, duplicate) \
if (UG(unicode)) { \
- add_next_index_unicodel(arg, (UChar*)(str), length, duplicate); \
+ add_next_index_unicodel(arg, (str).u, length, duplicate); \
} else { \
- add_next_index_stringl(arg, (char*)(str), length, duplicate); \
+ add_next_index_stringl(arg, (str).s, length, duplicate); \
}
#define add_next_index_ascii_string(arg, str, duplicate) \
if (UG(unicode)) { \
UErrorCode status = U_ZERO_ERROR; \
UChar *u_str; \
- int32_t u_len; \
+ int u_len; \
int length = strlen(str); \
zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, str, length, &status); \
add_next_index_unicodel(arg, u_str, u_len, 0); \
if (UG(unicode)) { \
UErrorCode status = U_ZERO_ERROR; \
UChar *u_str; \
- int32_t u_len; \
+ int u_len; \
zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, str, length, &status); \
add_next_index_unicodel(arg, u_str, u_len, 0); \
} else { \
zend_bool is_ref, int num_symbol_tables, ...);
ZEND_API int zend_delete_global_variable(char *name, int name_len TSRMLS_DC);
-ZEND_API int zend_u_delete_global_variable(zend_uchar type, void *name, int name_len TSRMLS_DC);
+ZEND_API int zend_u_delete_global_variable(zend_uchar type, zstr name, int name_len TSRMLS_DC);
ZEND_API void zend_reset_all_cv(HashTable *symbol_table TSRMLS_DC);
#define ZVAL_U_STRING(conv, z, s, duplicate) \
if (UG(unicode)) { \
- UErrorCode status = U_ZERO_ERROR; \
+ UErrorCode status = U_ZERO_ERROR; \
UChar *u_str; \
- int32_t u_len; \
+ int u_len; \
uint length = strlen(s); \
zend_convert_to_unicode(conv, &u_str, &u_len, s, length, &status); \
ZVAL_UNICODEL(z, u_str, u_len, 0); \
#define ZVAL_U_STRINGL(conv, z, s, l, duplicate) \
if (UG(unicode)) { \
- UErrorCode status = U_ZERO_ERROR; \
+ UErrorCode status = U_ZERO_ERROR; \
UChar *u_str; \
- int32_t u_len; \
+ int u_len; \
zend_convert_to_unicode(conv, &u_str, &u_len, s, l, &status); \
ZVAL_UNICODEL(z, u_str, u_len, 0); \
} else { \
}
#define ZVAL_UNICODEL(z, u, l, duplicate) { \
- UChar *__u=(u); int32_t __l=l; \
- Z_USTRLEN_P(z) = __l; \
+ UChar *__u=(u); int __l=l; \
+ Z_USTRLEN_P(z) = __l; \
Z_USTRVAL_P(z) = (duplicate?eustrndup(__u, __l):__u); \
Z_TYPE_P(z) = IS_UNICODE; \
}
#define ZVAL_TEXT(z, t, duplicate) \
do { \
if (UG(unicode)) { \
- ZVAL_UNICODE(z, (UChar*)(t), duplicate); \
+ ZVAL_UNICODE(z, t.u, duplicate); \
} else { \
- ZVAL_STRING(z, (char*)(t), duplicate); \
+ ZVAL_STRING(z, t.s, duplicate); \
} \
} while (0);
#define ZVAL_TEXTL(z, t, l, duplicate) \
do { \
if (UG(unicode)) { \
- ZVAL_UNICODEL(z, (UChar*)(t), l, duplicate); \
+ ZVAL_UNICODEL(z, t.u, l, duplicate);\
} else { \
- ZVAL_STRINGL(z, (char*)(t), l, duplicate); \
+ ZVAL_STRINGL(z, t.s, l, duplicate); \
} \
} while (0);
}
#define ZEND_SET_SYMBOL_WITH_LENGTH(symtable, name, name_length, var, _refcount, _is_ref) \
- ZEND_U_SET_SYMBOL_WITH_LENGTH(symtable, IS_STRING, 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)
}
-ZEND_API UChar *_eustrndup(const UChar *s, int32_t length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
+ZEND_API UChar *_eustrndup(const UChar *s, int length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
{
UChar *p;
ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
ZEND_API UChar *_eustrdup(const UChar *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
-ZEND_API UChar *_eustrndup(const UChar *s, int32_t length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
+ZEND_API UChar *_eustrndup(const UChar *s, int length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
#if USE_ZEND_ALLOC
ZEND_FUNCTION(strcmp)
{
void *s1, *s2;
- int32_t s1_len, s2_len;
+ int s1_len, s2_len;
zend_uchar s1_type, s2_type;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "TT", &s1, &s1_len,
ZEND_FUNCTION(strncmp)
{
void *s1, *s2;
- int32_t s1_len, s2_len;
+ int s1_len, s2_len;
long count;
zend_uchar s1_type, s2_type;
ZEND_FUNCTION(strcasecmp)
{
void *s1, *s2;
- int32_t s1_len, s2_len;
+ int s1_len, s2_len;
zend_uchar s1_type, s2_type;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "TT", &s1, &s1_len,
ZEND_FUNCTION(each)
{
zval **array, *entry, **entry_ptr, *tmp;
- char *string_key;
+ zstr string_key;
uint string_key_len;
ulong num_key;
zval **inserted_pointer;
/* add the key elements */
switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_key_len, &num_key, 1, NULL)) {
case HASH_KEY_IS_STRING:
- add_get_index_stringl(return_value, 0, string_key, string_key_len-1, (void **) &inserted_pointer, 0);
+ add_get_index_stringl(return_value, 0, string_key.s, string_key_len-1, (void **) &inserted_pointer, 0);
break;
case HASH_KEY_IS_UNICODE:
- add_get_index_unicodel(return_value, 0, (UChar*)string_key, string_key_len-1, (void **) &inserted_pointer, 0);
+ add_get_index_unicodel(return_value, 0, string_key.u, string_key_len-1, (void **) &inserted_pointer, 0);
break;
case HASH_KEY_IS_LONG:
add_get_index_long(return_value, 0, num_key, (void **) &inserted_pointer);
zval_copy_ctor(&c.value);
c.flags = case_sensitive; /* non persistent */
if (Z_TYPE_PP(var) == IS_UNICODE) {
- c.name = (char*)zend_ustrndup(Z_USTRVAL_PP(var), Z_USTRLEN_PP(var));
+ c.name.u = zend_ustrndup(Z_USTRVAL_PP(var), Z_USTRLEN_PP(var));
} else {
- c.name = zend_strndup(Z_STRVAL_PP(var), Z_STRLEN_PP(var));
+ c.name.s = zend_strndup(Z_STRVAL_PP(var), Z_STRLEN_PP(var));
}
c.name_len = Z_UNILEN_PP(var)+1;
c.module_number = PHP_USER_CONSTANT;
ZEND_FUNCTION(get_class)
{
zval **arg;
- char *name = (char*)EMPTY_STR;
+ zstr name = (zstr)EMPTY_STR;
zend_uint name_len = 0;
int dup;
{
zval **arg;
zend_class_entry *ce = NULL;
- char *name;
+ zstr name;
zend_uint name_length;
if (!ZEND_NUM_ARGS()) {
zend_hash_internal_pointer_reset_ex(properties, &pos);
while (zend_hash_get_current_data_ex(properties, (void **) &prop, &pos) == SUCCESS) {
- char *key, *class_name, *prop_name;
+ zstr key, class_name, prop_name;
uint key_len;
ulong num_index;
zval *prop_copy;
key_type = zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos);
zend_hash_move_forward_ex(properties, &pos);
- zend_unmangle_property_name(key, &class_name, &prop_name);
- if (class_name) {
- if (class_name[0] != '*' && strcmp(class_name, ce->name)) {
+ zend_u_unmangle_property_name(key_type, key, &class_name, &prop_name);
+ if (class_name.v) {
+ /* FIXME: Unicode support??? */
+ if (class_name.s[0] != '*' && strcmp(class_name.s, ce->name.s)) {
/* filter privates from base classes */
continue;
} else if (!instanceof) {
Returns an array of default properties of the class. */
ZEND_FUNCTION(get_class_vars)
{
- char *class_name;
+ zstr class_name;
int class_name_len;
zend_uchar type;
zend_class_entry **pce;
zval **value;
HashTable *properties;
HashPosition pos;
- char *key, *prop_name, *class_name;
+ zstr key, prop_name, class_name;
uint key_len;
ulong num_index;
int instanceof;
while (zend_hash_get_current_data_ex(properties, (void **) &value, &pos) == SUCCESS) {
if (zend_hash_get_current_key_ex(properties, &key, &key_len, &num_index, 0, &pos) == (UG(unicode)?HASH_KEY_IS_UNICODE:HASH_KEY_IS_STRING)) {
zend_u_unmangle_property_name(UG(unicode)?IS_UNICODE:IS_STRING, key, &class_name, &prop_name);
- if (class_name == NULL) {
+ if (class_name.v == NULL) {
/* Not separating references */
(*value)->refcount++;
add_u_assoc_zval_ex(return_value, UG(unicode)?IS_UNICODE:IS_STRING, key, key_len, *value);
} else if (instanceof) {
- if (class_name[0] == '*' ||
+ if (class_name.s[0] == '*' ||
(Z_OBJCE_P(EG(This)) == Z_OBJCE_PP(obj) &&
- UG(unicode)?!u_strcmp((UChar*)Z_OBJCE_P(EG(This))->name, (UChar*)class_name):!strcmp(Z_OBJCE_P(EG(This))->name, class_name))) {
+ UG(unicode)?!u_strcmp(Z_OBJCE_P(EG(This))->name.u, class_name.u):!strcmp(Z_OBJCE_P(EG(This))->name.s, class_name.s))) {
/* Not separating references */
(*value)->refcount++;
add_u_assoc_zval(return_value, UG(unicode)?IS_UNICODE:IS_STRING, prop_name, *value);
{
zval **klass, **method_name;
unsigned int lcname_len;
- char *lcname;
+ zstr lcname;
zend_class_entry * ce, **pce;
if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &klass, &method_name)==FAILURE) {
}
lcname = zend_u_str_case_fold(Z_TYPE_PP(method_name), Z_UNIVAL_PP(method_name), Z_UNILEN_PP(method_name), 1, &lcname_len);
if (zend_u_hash_exists(&ce->function_table, Z_TYPE_PP(method_name), lcname, lcname_len+1)) {
- efree(lcname);
+ efree(lcname.v);
RETURN_TRUE;
} else {
union _zend_function *func = NULL;
- efree(lcname);
+ efree(lcname.v);
if (Z_TYPE_PP(klass) == IS_OBJECT
&& Z_OBJ_HT_PP(klass)->get_method != NULL
- && (func = Z_OBJ_HT_PP(klass)->get_method(klass, Z_STRVAL_PP(method_name), Z_STRLEN_PP(method_name) TSRMLS_CC)) != NULL
+ && (func = Z_OBJ_HT_PP(klass)->get_method(klass, Z_UNIVAL_PP(method_name), Z_UNILEN_PP(method_name) TSRMLS_CC)) != NULL
) {
if (func->type == ZEND_INTERNAL_FUNCTION
&& ((zend_internal_function*)func)->handler == zend_std_call_user_call
) {
- efree(((zend_internal_function*)func)->function_name);
+ efree(((zend_internal_function*)func)->function_name.v);
efree(func);
RETURN_FALSE;
}
zval **object, **property;
zend_class_entry *ce, **pce;
zend_property_info *property_info;
- char *prop_name, *class_name;
+ zstr prop_name, class_name;
if (ZEND_NUM_ARGS()!= 2 || zend_get_parameters_ex(2, &object, &property)==FAILURE) {
ZEND_WRONG_PARAM_COUNT();
RETURN_TRUE;
}
zend_u_unmangle_property_name(Z_TYPE_PP(property), property_info->name, &class_name, &prop_name);
- if (class_name[0] == '*') {
+ if (class_name.s[0] == '*') {
if (instanceof_function(EG(scope), ce TSRMLS_CC)) {
RETURN_TRUE;
}
ZEND_FUNCTION(class_exists)
{
unsigned int lc_name_len;
- void *class_name, *lc_name;
+ zstr class_name, lc_name;
zend_class_entry **ce;
int class_name_len;
zend_bool autoload = 1;
if (!autoload) {
lc_name = zend_u_str_case_fold(type, class_name, class_name_len, 1, &lc_name_len);
found = zend_u_hash_find(EG(class_table), type, lc_name, lc_name_len+1, (void **) &ce);
- efree(lc_name);
+ efree(lc_name.v);
RETURN_BOOL(found == SUCCESS && !((*ce)->ce_flags & ZEND_ACC_INTERFACE));
}
ZEND_FUNCTION(interface_exists)
{
unsigned int lc_name_len;
- void *iface_name, *lc_name;
+ zstr iface_name, lc_name;
zend_class_entry **ce;
int iface_name_len;
zend_uchar type;
if (!autoload) {
lc_name = zend_u_str_case_fold(type, iface_name, iface_name_len, 1, &lc_name_len);
found = zend_u_hash_find(EG(class_table), type, lc_name, lc_name_len+1, (void **) &ce);
- efree(lc_name);
+ efree(lc_name.v);
RETURN_BOOL(found == SUCCESS && (*ce)->ce_flags & ZEND_ACC_INTERFACE);
}
zval **function_name;
zend_function *func;
unsigned int lcname_len;
- char *lcname;
+ zstr lcname;
zend_bool retval;
if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &function_name)==FAILURE) {
retval = (zend_u_hash_find(EG(function_table), Z_TYPE_PP(function_name), lcname, lcname_len+1, (void **)&func) == SUCCESS);
- efree(lcname);
+ efree(lcname.v);
/*
* A bit of a hack, but not a bad one: we see if the handler of the function
Returns an array with the file names that were include_once()'d */
ZEND_FUNCTION(get_included_files)
{
- char *entry;
+ zstr entry;
if (ZEND_NUM_ARGS() != 0) {
ZEND_WRONG_PARAM_COUNT();
}
array_init(return_value);
zend_hash_internal_pointer_reset(&EG(included_files));
while (zend_hash_get_current_key(&EG(included_files), &entry, NULL, 0) == HASH_KEY_IS_STRING) {
- add_next_index_rt_string(return_value, entry, 1);
+ add_next_index_rt_string(return_value, entry.s, 1);
zend_hash_move_forward(&EG(included_files));
}
}
TSRMLS_FETCH();
if ((hash_key->nKeyLength==0 ||
- (hash_key->type == IS_UNICODE && hash_key->u.unicode[0] != 0) ||
- (hash_key->type == IS_STRING && hash_key->u.string[0] != 0))
+ (hash_key->type == IS_UNICODE && hash_key->arKey.u[0] != 0) ||
+ (hash_key->type == IS_STRING && hash_key->arKey.s[0] != 0))
&& (comply_mask == (ce->ce_flags & mask))) {
add_next_index_textl(array, ce->name, ce->name_length, 1);
}
*user_ar = va_arg(args, zval *);
if (hash_key->nKeyLength == 0 ||
- (hash_key->type == IS_UNICODE && hash_key->u.unicode[0] == 0) ||
- (hash_key->type == IS_STRING && hash_key->u.unicode[0] == 0)) {
+ (hash_key->type == IS_UNICODE && hash_key->arKey.u[0] == 0) ||
+ (hash_key->type == IS_STRING && hash_key->arKey.s[0] == 0)) {
return 0;
}
if (func->type == ZEND_INTERNAL_FUNCTION) {
if (hash_key->type == IS_STRING) {
- add_next_index_stringl(internal_ar, hash_key->u.string, hash_key->nKeyLength-1, 1);
+ add_next_index_stringl(internal_ar, hash_key->arKey.s, hash_key->nKeyLength-1, 1);
} else {
- add_next_index_unicodel(internal_ar, hash_key->u.unicode, hash_key->nKeyLength-1, 1);
+ add_next_index_unicodel(internal_ar, hash_key->arKey.u, hash_key->nKeyLength-1, 1);
}
} else if (func->type == ZEND_USER_FUNCTION) {
if (hash_key->type == IS_STRING) {
- add_next_index_stringl(user_ar, hash_key->u.string, hash_key->nKeyLength-1, 1);
+ add_next_index_stringl(user_ar, hash_key->arKey.s, hash_key->nKeyLength-1, 1);
} else {
- add_next_index_unicodel(user_ar, hash_key->u.unicode, hash_key->nKeyLength-1, 1);
+ add_next_index_unicodel(user_ar, hash_key->arKey.u, hash_key->nKeyLength-1, 1);
}
}
zval_copy_ctor(const_val);
INIT_PZVAL(const_val);
- add_assoc_zval_ex(modules[module_number], val->name, val->name_len, const_val);
+ /* FIXME: Unicode support??? */
+ add_assoc_zval_ex(modules[module_number], val->name.s, val->name_len, const_val);
bad_module_id:
zend_hash_move_forward_ex(EG(zend_constants), &pos);
}
{
zend_execute_data *ptr, *skip;
int lineno;
- char *function_name;
+ zstr function_name;
char *filename;
- char *class_name = NULL;
+ zstr class_name;
char *call_type;
char *include_filename = NULL;
zval *arg_array = NULL;
array_init(return_value);
while (ptr) {
- char *free_class_name = NULL;
+ zstr free_class_name = (zstr)NULL;
int function_name_string = 1;
- class_name = call_type = NULL;
+ class_name = (zstr)NULL;
+ call_type = NULL;
arg_array = NULL;
skip = ptr;
function_name = ptr->function_state.function->common.function_name;
- if (function_name) {
+ if (function_name.v) {
function_name_string = !UG(unicode);
if (ptr->object) {
if (ptr->function_state.function->common.scope) {
class_name = ptr->function_state.function->common.scope->name;
call_type = "::";
} else {
- class_name = NULL;
+ class_name = (zstr)NULL;
call_type = NULL;
}
if ((! ptr->opline) || ((ptr->opline->opcode == ZEND_DO_FCALL_BY_NAME) || (ptr->opline->opcode == ZEND_DO_FCALL))) {
if (!ptr->opline || ptr->opline->opcode != ZEND_INCLUDE_OR_EVAL) {
/* can happen when calling eval from a custom sapi */
- function_name = "unknown";
+ function_name.s = "unknown";
build_filename_arg = 0;
} else
switch (Z_LVAL(ptr->opline->op2.u.constant)) {
case ZEND_EVAL:
- function_name = "eval";
+ function_name.s = "eval";
build_filename_arg = 0;
break;
case ZEND_INCLUDE:
- function_name = "include";
+ function_name.s = "include";
break;
case ZEND_REQUIRE:
- function_name = "require";
+ function_name.s = "require";
break;
case ZEND_INCLUDE_ONCE:
- function_name = "include_once";
+ function_name.s = "include_once";
break;
case ZEND_REQUIRE_ONCE:
- function_name = "require_once";
+ function_name.s = "require_once";
break;
default:
/* this can actually happen if you use debug_backtrace() in your error_handler and
* you're in the top-scope */
- function_name = "unknown";
+ function_name.s = "unknown";
build_filename_arg = 0;
break;
}
call_type = NULL;
}
zend_printf("#%-2d ", indent);
- if (class_name) {
+ if (class_name.v) {
if (UG(unicode)) {
- zend_printf("%r", class_name);
+ zend_printf("%r", class_name.u);
} else {
- ZEND_PUTS(class_name);
+ ZEND_PUTS(class_name.s);
}
ZEND_PUTS(call_type);
}
if (function_name_string) {
- zend_printf("%s(", function_name?function_name:"main");
+ zend_printf("%s(", function_name.s?function_name.s:"main");
} else {
- zend_printf("%r(", function_name);
+ zend_printf("%r(", function_name.u);
}
if (arg_array) {
debug_print_backtrace_args(arg_array TSRMLS_CC);
include_filename = filename;
ptr = skip->prev_execute_data;
++indent;
- if (free_class_name) {
- efree(free_class_name);
+ if (free_class_name.v) {
+ efree(free_class_name.v);
}
}
}
{
zend_execute_data *ptr, *skip;
int lineno;
- char *function_name;
+ zstr function_name;
char *filename;
- char *class_name;
+ zstr class_name;
char *include_filename = NULL;
zval *stack_frame;
void **cur_arg_pos = EG(argument_stack).top_element;
function_name = ptr->function_state.function->common.function_name;
- if (function_name) {
+ if (function_name.v) {
add_assoc_text_ex(stack_frame, "function", sizeof("function"), function_name, 1);
if (ptr->object && Z_TYPE_P(ptr->object) == IS_OBJECT) {
if (!ptr->opline || ptr->opline->opcode != ZEND_INCLUDE_OR_EVAL) {
/* can happen when calling eval from a custom sapi */
- function_name = "unknown";
+ function_name.s = "unknown";
build_filename_arg = 0;
} else
switch (Z_LVAL(ptr->opline->op2.u.constant)) {
case ZEND_EVAL:
- function_name = "eval";
+ function_name.s = "eval";
build_filename_arg = 0;
break;
case ZEND_INCLUDE:
- function_name = "include";
+ function_name.s = "include";
break;
case ZEND_REQUIRE:
- function_name = "require";
+ function_name.s = "require";
break;
case ZEND_INCLUDE_ONCE:
- function_name = "include_once";
+ function_name.s = "include_once";
break;
case ZEND_REQUIRE_ONCE:
- function_name = "require_once";
+ function_name.s = "require_once";
break;
default:
/* this can actually happen if you use debug_backtrace() in your error_handler and
* you're in the top-scope */
- function_name = "unknown";
+ function_name.s = "unknown";
build_filename_arg = 0;
break;
}
add_assoc_zval_ex(stack_frame, "args", sizeof("args"), arg_array);
}
- add_assoc_ascii_string_ex(stack_frame, "function", sizeof("function"), function_name, 1);
+ add_assoc_ascii_string_ex(stack_frame, "function", sizeof("function"), function_name.s, 1);
}
add_next_index_zval(return_value, stack_frame);
TSRMLS_FETCH();
if (UG(unicode)) {
- property_info->name = (char*)eustrndup((UChar*)property_info->name, property_info->name_length);
+ property_info->name.u = eustrndup(property_info->name.u, property_info->name_length);
} else {
- property_info->name = estrndup(property_info->name, property_info->name_length);
+ property_info->name.s = estrndup(property_info->name.s, property_info->name_length);
}
if (property_info->doc_comment) {
property_info->doc_comment = estrndup(property_info->doc_comment, property_info->doc_comment_len);
TSRMLS_FETCH();
if (UG(unicode)) {
- property_info->name = (char*)zend_ustrndup((UChar*)property_info->name, property_info->name_length);
+ property_info->name.u = zend_ustrndup(property_info->name.u, property_info->name_length);
} else {
- property_info->name = zend_strndup(property_info->name, property_info->name_length);
+ property_info->name.s = zend_strndup(property_info->name.s, property_info->name_length);
}
}
static void zend_destroy_property_info(zend_property_info *property_info)
{
- efree(property_info->name);
+ efree(property_info->name.v);
if (property_info->doc_comment) {
efree(property_info->doc_comment);
}
static void zend_destroy_property_info_internal(zend_property_info *property_info)
{
- free(property_info->name);
+ free(property_info->name.v);
}
static void build_runtime_defined_function_key(zval *result, zend_uchar type, char *name, int name_length TSRMLS_DC)
return (op_array->T)++ * sizeof(temp_variable);
}
-static int lookup_cv(zend_op_array *op_array, zend_uchar type, void *name, int name_len)
+static int lookup_cv(zend_op_array *op_array, zend_uchar type, zstr name, int name_len)
{
int i = 0;
ulong hash_value = zend_u_inline_hash_func(type, name, name_len+1);
while (i < op_array->last_var) {
if (op_array->vars[i].hash_value == hash_value &&
op_array->vars[i].name_len == name_len &&
- !memcmp(op_array->vars[i].name, name, type==IS_UNICODE?UBYTES(name_len):name_len)) {
- efree(name);
+ !memcmp(op_array->vars[i].name.v, name.v, type==IS_UNICODE?UBYTES(name_len):name_len)) {
+ efree(name.v);
return i;
}
i++;
void zend_do_begin_function_declaration(znode *function_token, znode *function_name, int is_method, int return_reference, znode *fn_flags_znode TSRMLS_DC)
{
zend_op_array op_array;
- char *name = Z_UNIVAL(function_name->u.constant);
+ zstr name = Z_UNIVAL(function_name->u.constant);
int name_len = Z_UNILEN(function_name->u.constant);
int function_begin_line = function_token->u.opline_num;
zend_uint fn_flags;
unsigned int lcname_len;
- char *lcname;
+ zstr lcname;
if (is_method) {
if (CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE) {
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 : "", 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 : (zstr)EMPTY_STR, is_method ? "::" : "", Z_TYPE(function_name->u.constant), Z_UNIVAL(function_name->u.constant));
}
function_token->u.op_array = CG(active_op_array);
op_array.line_start = zend_get_compiled_lineno(TSRMLS_C);
if (is_method) {
- char *short_class_name = CG(active_class_entry)->name;
+ zstr short_class_name = CG(active_class_entry)->name;
unsigned int short_class_name_length = CG(active_class_entry)->name_length;
if (zend_u_hash_add(&CG(active_class_entry)->function_table, Z_TYPE(function_name->u.constant), lcname, lcname_len+1, &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array)) == FAILURE) {
&& (child_op_array == parent_op_array)) {
zend_u_hash_update(&CG(active_class_entry)->function_table, Z_TYPE(function_name->u.constant), name, name_len+1, &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array));
} else {
- efree(lcname);
+ efree(lcname.v);
zend_error(E_COMPILE_ERROR, "Cannot redeclare %v::%R()", CG(active_class_entry)->name, Z_TYPE(function_name->u.constant), name);
}
}
short_class_name = zend_u_str_case_fold(UG(unicode)?IS_UNICODE:IS_STRING, CG(active_class_entry)->name, short_class_name_length, 0, &short_class_name_length);
/* Improve after RC: cache the lowercase class name */
- if ((short_class_name_length == name_len) && (!memcmp(short_class_name, lcname, UG(unicode)?UBYTES(lcname_len):lcname_len))) {
+ if ((short_class_name_length == name_len) && (!memcmp(short_class_name.v, lcname.v, UG(unicode)?UBYTES(lcname_len):lcname_len))) {
if (CG(active_class_entry)->constructor) {
zend_error(E_STRICT, "Redefining already defined constructor for class %v", CG(active_class_entry)->name);
} else {
} else if (!(fn_flags & ZEND_ACC_STATIC)) {
CG(active_op_array)->fn_flags |= ZEND_ACC_ALLOW_STATIC;
}
- efree(short_class_name);
+ efree(short_class_name.v);
}
- efree(lcname);
+ efree(lcname.v);
} else {
zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->opcode = ZEND_DECLARE_FUNCTION;
opline->op1.op_type = IS_CONST;
- build_runtime_defined_function_key(&opline->op1.u.constant, Z_TYPE(function_name->u.constant), lcname, lcname_len TSRMLS_CC);
+ build_runtime_defined_function_key(&opline->op1.u.constant, Z_TYPE(function_name->u.constant), lcname.s, lcname_len TSRMLS_CC);
opline->op2.op_type = IS_CONST;
Z_TYPE(opline->op2.u.constant) = Z_TYPE(function_name->u.constant);
- Z_STRVAL(opline->op2.u.constant) = lcname;
+ Z_STRVAL(opline->op2.u.constant) = lcname.s;
Z_STRLEN(opline->op2.u.constant) = lcname_len;
opline->op2.u.constant.refcount = 1;
opline->extended_value = ZEND_DECLARE_FUNCTION;
void zend_do_end_function_declaration(znode *function_token TSRMLS_DC)
{
unsigned int lcname_len;
- char *lcname;
+ zstr lcname;
char lcname_buf[16];
int name_len;
* the beginning of the name speeds up the check process */
if (UG(unicode)) {
utype = IS_UNICODE;
- name_len = u_strlen((UChar*)CG(active_op_array)->function_name);
+ name_len = u_strlen(CG(active_op_array)->function_name.u);
lcname = zend_u_str_case_fold(utype, CG(active_op_array)->function_name, name_len, 0, &lcname_len);
} else {
utype = IS_STRING;
- lcname_len = name_len = strlen(CG(active_op_array)->function_name);
- zend_str_tolower_copy(lcname_buf, CG(active_op_array)->function_name, MIN(name_len, sizeof(lcname_buf)-1));
+ lcname_len = name_len = strlen(CG(active_op_array)->function_name.s);
+ zend_str_tolower_copy(lcname_buf, CG(active_op_array)->function_name.s, MIN(name_len, sizeof(lcname_buf)-1));
lcname_buf[sizeof(lcname_buf)-1] = '\0'; /* zend_str_tolower_copy won't necessarily set the zero byte */
- lcname = lcname_buf;
+ lcname.s = lcname_buf;
}
if (lcname_len == sizeof(ZEND_AUTOLOAD_FUNC_NAME) - 1 &&
ZEND_U_EQUAL(utype, lcname, lcname_len, ZEND_AUTOLOAD_FUNC_NAME, sizeof(ZEND_AUTOLOAD_FUNC_NAME)-1) &&
CG(active_op_array)->num_args != 1) {
zend_error(E_COMPILE_ERROR, "%s() must take exactly 1 argument", ZEND_AUTOLOAD_FUNC_NAME);
}
- if (lcname != lcname_buf) {
- efree(lcname);
+ if (lcname.s != lcname_buf) {
+ efree(lcname.s);
}
}
}
-static inline int ZEND_U_CASE_EQUAL(zend_uchar type, void *ustr, int ulen, char *str, int slen)
+static inline int ZEND_U_CASE_EQUAL(zend_uchar type, zstr ustr, int ulen, char *str, int slen)
{
- void* lcname;
+ zstr lcname;
unsigned int lcname_len;
int ret;
lcname = zend_u_str_case_fold(type, ustr, ulen, 0, &lcname_len);
ret = ZEND_U_EQUAL(type, lcname, lcname_len, str, slen);
- efree(lcname);
+ efree(lcname.v);
return ret;
}
CG(active_op_array)->arg_info = erealloc(CG(active_op_array)->arg_info, sizeof(zend_arg_info)*(CG(active_op_array)->num_args));
cur_arg_info = &CG(active_op_array)->arg_info[CG(active_op_array)->num_args-1];
if (Z_TYPE(varname->u.constant) == IS_UNICODE) {
- cur_arg_info->name = (char*)eustrndup(Z_USTRVAL(varname->u.constant), Z_USTRLEN(varname->u.constant));
+ cur_arg_info->name.u = eustrndup(Z_USTRVAL(varname->u.constant), Z_USTRLEN(varname->u.constant));
} else {
- cur_arg_info->name = estrndup(Z_STRVAL(varname->u.constant), Z_STRLEN(varname->u.constant));
+ cur_arg_info->name.s = estrndup(Z_STRVAL(varname->u.constant), Z_STRLEN(varname->u.constant));
}
cur_arg_info->name_len = Z_UNILEN(varname->u.constant);
cur_arg_info->array_type_hint = 0;
}
} else {
cur_arg_info->array_type_hint = 1;
- cur_arg_info->class_name = NULL;
+ cur_arg_info->class_name.v = NULL;
cur_arg_info->class_name_len = 0;
if (op == ZEND_RECV_INIT) {
if (Z_TYPE(initialization->u.constant) == IS_NULL ||
}
}
} else {
- cur_arg_info->class_name = NULL;
+ cur_arg_info->class_name.v = NULL;
cur_arg_info->class_name_len = 0;
}
opline->result.u.EA.type |= EXT_TYPE_UNUSED;
{
zend_function *function;
unsigned int lcname_len;
- char *lcname;
+ zstr lcname;
lcname = zend_u_str_case_fold(Z_TYPE(function_name->u.constant), Z_UNIVAL(function_name->u.constant), Z_UNILEN(function_name->u.constant), 0, &lcname_len);
if (zend_u_hash_find(CG(function_table), Z_TYPE(function_name->u.constant), lcname, lcname_len+1, (void **) &function)==FAILURE) {
zend_do_begin_dynamic_function_call(function_name TSRMLS_CC);
- efree(lcname);
+ efree(lcname.v);
return 1; /* Dynamic */
}
- efree(Z_UNIVAL(function_name->u.constant));
+ efree(Z_UNIVAL(function_name->u.constant).v);
if (Z_TYPE(function_name->u.constant) == IS_UNICODE) {
- Z_USTRVAL(function_name->u.constant) = (UChar *)lcname;
+ Z_USTRVAL(function_name->u.constant) = lcname.u;
Z_USTRLEN(function_name->u.constant) = lcname_len;
} else {
- Z_STRVAL(function_name->u.constant) = lcname;
+ Z_STRVAL(function_name->u.constant) = lcname.s;
}
switch (function->type) {
} else {
if (Z_TYPE(opline->op2.u.constant) == IS_UNICODE) {
unsigned int lcname_len;
- UChar *lcname;
+ zstr lcname;
lcname = zend_u_str_case_fold(Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(opline->op2.u.constant), 0, &lcname_len);
efree(Z_USTRVAL(opline->op2.u.constant));
- Z_USTRVAL(opline->op2.u.constant) = lcname;
+ Z_USTRVAL(opline->op2.u.constant) = lcname.u;
Z_USTRLEN(opline->op2.u.constant) = lcname_len;
} else {
- zend_str_tolower(Z_UNIVAL(opline->op2.u.constant), Z_UNILEN(opline->op2.u.constant));
+ zend_str_tolower(Z_STRVAL(opline->op2.u.constant), Z_STRLEN(opline->op2.u.constant));
}
}
}
"allow_call_time_pass_reference to true in your INI file. "
"However, future versions may not support this any longer. ",
(function_ptr && UG(unicode))?IS_UNICODE:IS_STRING,
- (function_ptr?function_ptr->common.function_name:"[runtime function name]"));
+ (function_ptr?function_ptr->common.function_name.s:"[runtime function name]"));
}
if (function_ptr) {
} 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;
- char *lc_class_name;
- char *lc_parent_class_name;
+ 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);
function_add_ref(function TSRMLS_CC);
}
}
- efree(lc_parent_class_name);
+ efree(lc_parent_class_name.v);
}
- efree(lc_class_name);
+ efree(lc_class_name.v);
}
ce->constructor = ce->parent->constructor;
}
}
for (i=0; i < proto->common.num_args; i++) {
- if (ZEND_LOG_XOR(fe->common.arg_info[i].class_name, proto->common.arg_info[i].class_name)) {
+ if (ZEND_LOG_XOR(fe->common.arg_info[i].class_name.v, proto->common.arg_info[i].class_name.v)) {
/* Only one has a type hint and the other one doesn't */
return 0;
}
- if (fe->common.arg_info[i].class_name
- && strcmp(fe->common.arg_info[i].class_name, proto->common.arg_info[i].class_name)!=0) {
+ if (fe->common.arg_info[i].class_name.v
+ && strcmp(fe->common.arg_info[i].class_name.s, proto->common.arg_info[i].class_name.s)!=0) {
+ /* FIXME: Unicode support??? */
return 0;
}
if (fe->common.arg_info[i].array_type_hint != proto->common.arg_info[i].array_type_hint) {
zend_function *child;
TSRMLS_FETCH();
- if (zend_u_hash_quick_find(child_function_table, hash_key->type, hash_key->u.string, hash_key->nKeyLength, hash_key->h, (void **) &child)==FAILURE) {
+ if (zend_u_hash_quick_find(child_function_table, hash_key->type, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child)==FAILURE) {
if (parent_flags & (ZEND_ACC_ABSTRACT)) {
child_ce->ce_flags |= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS;
}
}
if (parent_flags & ZEND_ACC_FINAL) {
- zend_error(E_COMPILE_ERROR, "Cannot override final method %v::%v()", ZEND_FN_SCOPE_NAME(parent), child->common.function_name);
+ zend_error(E_COMPILE_ERROR, "Cannot override final method %v::%v()", ZEND_FN_SCOPE_NAME(parent), child->common.function_name.v);
}
child_flags = child->common.fn_flags;
utype = UG(unicode)?IS_UNICODE:IS_STRING;
if (parent_info->flags & (ZEND_ACC_PRIVATE|ZEND_ACC_SHADOW)) {
- if (zend_u_hash_quick_find(&ce->properties_info, hash_key->type, hash_key->u.string, hash_key->nKeyLength, hash_key->h, (void **) &child_info)==SUCCESS) {
+ if (zend_u_hash_quick_find(&ce->properties_info, hash_key->type, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child_info)==SUCCESS) {
child_info->flags |= ZEND_ACC_CHANGED;
} else {
- zend_u_hash_quick_update(&ce->properties_info, hash_key->type, hash_key->u.string, hash_key->nKeyLength, hash_key->h, parent_info, sizeof(zend_property_info), (void **) &child_info);
+ zend_u_hash_quick_update(&ce->properties_info, hash_key->type, hash_key->arKey, hash_key->nKeyLength, hash_key->h, parent_info, sizeof(zend_property_info), (void **) &child_info);
if(ce->type & ZEND_INTERNAL_CLASS) {
zend_duplicate_property_info_internal(child_info);
} else {
return 0; /* don't copy access information to child */
}
- if (zend_u_hash_quick_find(&ce->properties_info, hash_key->type, hash_key->u.string, hash_key->nKeyLength, hash_key->h, (void **) &child_info)==SUCCESS) {
+ if (zend_u_hash_quick_find(&ce->properties_info, hash_key->type, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **) &child_info)==SUCCESS) {
if ((parent_info->flags & ZEND_ACC_STATIC) != (child_info->flags & ZEND_ACC_STATIC)) {
zend_error(E_COMPILE_ERROR, "Cannot redeclare %s%v::$%R as %s%v::$%R",
- (parent_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", parent_ce->name, hash_key->type, hash_key->u.string,
- (child_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", ce->name, hash_key->type, hash_key->u.string);
+ (parent_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", parent_ce->name, hash_key->type, hash_key->arKey,
+ (child_info->flags & ZEND_ACC_STATIC) ? "static " : "non static ", ce->name, hash_key->type, hash_key->arKey);
}
if(parent_info->flags & ZEND_ACC_CHANGED) {
}
if ((child_info->flags & ZEND_ACC_PPP_MASK) > (parent_info->flags & ZEND_ACC_PPP_MASK)) {
- zend_error(E_COMPILE_ERROR, "Access level to %v::$%R must be %s (as in class %v)%s", ce->name, hash_key->type, hash_key->u.string, zend_visibility_string(parent_info->flags), parent_ce->name, (parent_info->flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
+ zend_error(E_COMPILE_ERROR, "Access level to %v::$%R must be %s (as in class %v)%s", ce->name, hash_key->type, hash_key->arKey, zend_visibility_string(parent_info->flags), parent_ce->name, (parent_info->flags&ZEND_ACC_PUBLIC) ? "" : " or weaker");
} else if (child_info->flags & ZEND_ACC_IMPLICIT_PUBLIC) {
if (!(parent_info->flags & ZEND_ACC_IMPLICIT_PUBLIC)) {
/* Explicitly copy the default value from the parent (if it has one) */
}
return 1; /* Inherit from the parent */
} else if ((child_info->flags & ZEND_ACC_PUBLIC) && (parent_info->flags & ZEND_ACC_PROTECTED)) {
- char *prot_name;
+ zstr prot_name;
int prot_name_length;
- zend_u_mangle_property_name(&prot_name, &prot_name_length, utype, "*", 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;
zval **new_prop;
if (zend_u_hash_find(&ce->default_static_members, utype, child_info->name, child_info->name_length+1, (void**)&new_prop) == SUCCESS) {
if (Z_TYPE_PP(new_prop) != IS_NULL && Z_TYPE_PP(prop) != IS_NULL) {
- char *prop_name, *tmp;
+ zstr prop_name, tmp;
zend_u_unmangle_property_name(utype, child_info->name, &tmp, &prop_name);
zend_error(E_COMPILE_ERROR, "Cannot change initial value of property static protected %v::$%v in class %v",
} else {
zend_u_hash_del(&ce->default_properties, utype, prot_name, prot_name_length+1);
}
- pefree(prot_name, ce->type & ZEND_INTERNAL_CLASS);
+ pefree(prot_name.v, ce->type & ZEND_INTERNAL_CLASS);
}
return 0; /* Don't copy from parent */
} else {
{
zval **old_constant;
- if (zend_u_hash_quick_find(child_constants_table, hash_key->type, hash_key->u.string, hash_key->nKeyLength, hash_key->h, (void**)&old_constant) == SUCCESS) {
+ if (zend_u_hash_quick_find(child_constants_table, hash_key->type, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void**)&old_constant) == SUCCESS) {
if (*old_constant != *parent_constant) {
- zend_error(E_COMPILE_ERROR, "Cannot inherit previously-inherited constant %R from interface %v", hash_key->type, hash_key->u.string, iface->name);
+ zend_error(E_COMPILE_ERROR, "Cannot inherit previously-inherited constant %R from interface %v", hash_key->type, hash_key->arKey, iface->name);
}
return 0;
}
int doing_inheritance = 0;
zend_class_entry *new_class_entry = emalloc(sizeof(zend_class_entry));
unsigned int lcname_len;
- char *lcname = zend_u_str_case_fold(Z_TYPE(class_name->u.constant), Z_UNIVAL(class_name->u.constant), Z_UNILEN(class_name->u.constant), 0, &lcname_len);
+ zstr lcname = zend_u_str_case_fold(Z_TYPE(class_name->u.constant), Z_UNIVAL(class_name->u.constant), Z_UNILEN(class_name->u.constant), 0, &lcname_len);
if (CG(active_class_entry)) {
zend_error(E_COMPILE_ERROR, "Class declarations may not be nested");
ZEND_U_EQUAL(Z_TYPE(class_name->u.constant), lcname, lcname_len, "self", sizeof("self")-1)) ||
(lcname_len == sizeof("parent")-1 &&
ZEND_U_EQUAL(Z_TYPE(class_name->u.constant), lcname, lcname_len, "parent", sizeof("parent")-1))) {
- efree(lcname);
+ efree(lcname.v);
zend_error(E_COMPILE_ERROR, "Cannot use '%R' as class name as it is reserved", Z_TYPE(class_name->u.constant), Z_UNIVAL(class_name->u.constant));
}
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
opline->op1.op_type = IS_CONST;
- build_runtime_defined_function_key(&opline->op1.u.constant, Z_TYPE(class_name->u.constant), lcname, lcname_len TSRMLS_CC);
+ build_runtime_defined_function_key(&opline->op1.u.constant, Z_TYPE(class_name->u.constant), lcname.s, lcname_len TSRMLS_CC);
opline->op2.op_type = IS_CONST;
Z_TYPE(opline->op2.u.constant) = Z_TYPE(class_name->u.constant);
}
if (Z_TYPE(opline->op2.u.constant) == IS_UNICODE) {
- Z_USTRVAL(opline->op2.u.constant) = (UChar *)lcname;
+ Z_USTRVAL(opline->op2.u.constant) = lcname.u;
Z_USTRLEN(opline->op2.u.constant) = lcname_len;
} else {
- Z_STRVAL(opline->op2.u.constant) = lcname;
+ Z_STRVAL(opline->op2.u.constant) = lcname.s;
Z_STRLEN(opline->op2.u.constant) = lcname_len;
}
*dest_length = prop_name_length;
}
-ZEND_API void zend_u_mangle_property_name(char **dest, int *dest_length, zend_uchar type, char *src1, int src1_length, char *src2, int src2_length, int internal)
+ZEND_API void zend_u_mangle_property_name(zstr *dest, int *dest_length, zend_uchar type, zstr src1, int src1_length, zstr src2, int src2_length, int internal)
{
if (type == IS_UNICODE) {
UChar *prop_name;
prop_name_length = 1 + src1_length + 1 + src2_length;
prop_name = pemalloc(UBYTES(prop_name_length + 1), internal);
prop_name[0] = 0;
- if (src1_length == 1 && src1[0] == '*') {
+ if (src1_length == 1 && src1.s[0] == '*') {
prop_name[1] = '*';
prop_name[2] = 0;
} else {
- memcpy(prop_name + 1, src1, UBYTES(src1_length+1));
+ memcpy(prop_name + 1, src1.s, UBYTES(src1_length+1));
}
- memcpy(prop_name + 1 + src1_length + 1, src2, UBYTES(src2_length+1));
+ memcpy(prop_name + 1 + src1_length + 1, src2.s, UBYTES(src2_length+1));
- *dest = (char*)prop_name;
+ dest->u = prop_name;
*dest_length = prop_name_length;
} else {
- zend_mangle_property_name(dest, dest_length, src1, src1_length, src2, src2_length, internal);
+ zend_mangle_property_name(&dest->s, dest_length, src1.s, src1_length, src2.s, src2_length, internal);
}
}
*prop_name = (*class_name)+strlen(*class_name)+1;
}
-ZEND_API void zend_u_unmangle_property_name(zend_uchar type, char *mangled_property, char **class_name, char **prop_name)
+ZEND_API void zend_u_unmangle_property_name(zend_uchar type, zstr mangled_property, zstr *class_name, zstr *prop_name)
{
if (type == IS_UNICODE) {
- *prop_name = *class_name = NULL;
+ prop_name->v = class_name->v = NULL;
- if (((UChar*)mangled_property)[0]!=0) {
+ if ((mangled_property.u)[0]!=0) {
*prop_name = mangled_property;
return;
}
- *class_name = mangled_property+UBYTES(1);
- *prop_name = (*class_name)+UBYTES(u_strlen((UChar*)*class_name)+1);
- if ((*(UChar**)class_name)[0] == '*') {
- *class_name = "*";
+ class_name->u = mangled_property.u + 1;
+ prop_name->u = class_name->u + u_strlen(class_name->u)+1;
+ if (class_name->u[0] == '*') {
+ class_name->s = "*";
}
} else {
- zend_unmangle_property_name(mangled_property, class_name, prop_name);
+ zend_unmangle_property_name(mangled_property.s, &class_name->s, &prop_name->s);
}
}
}
-zend_bool zend_u_is_auto_global(zend_uchar type, void *name, uint name_len TSRMLS_DC)
+zend_bool zend_u_is_auto_global(zend_uchar type, zstr name, uint name_len TSRMLS_DC)
{
zend_auto_global *auto_global;
zend_bool zend_is_auto_global(char *name, uint name_len TSRMLS_DC)
{
- return zend_u_is_auto_global(IS_STRING, name, name_len TSRMLS_CC);
+ return zend_u_is_auto_global(IS_STRING, (zstr)name, name_len TSRMLS_CC);
}
}
-int zend_get_class_fetch_type(zend_uchar type, char *class_name, uint class_name_len)
+int zend_get_class_fetch_type(zend_uchar type, zstr class_name, uint class_name_len)
{
if ((class_name_len == sizeof("self")-1) &&
ZEND_U_EQUAL(type, class_name, class_name_len, "self", sizeof("self")-1)) {
}
}
-ZEND_API char* zend_get_compiled_variable_name(zend_op_array *op_array, zend_uint var, int* name_len)
+ZEND_API zstr zend_get_compiled_variable_name(zend_op_array *op_array, zend_uint var, int* name_len)
{
if (name_len) {
*name_len = op_array->vars[var].name_len;
typedef struct _zend_property_info {
zend_uint flags;
- char *name;
+ zstr name;
int name_length;
ulong h;
char *doc_comment;
typedef struct _zend_arg_info {
- char *name;
+ zstr name;
zend_uint name_len;
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
zend_bool array_type_hint;
zend_bool allow_null;
} zend_arg_info;
typedef struct _zend_compiled_variable {
- char *name;
+ zstr name;
int name_len;
ulong hash_value;
} zend_compiled_variable;
struct _zend_op_array {
/* Common elements */
zend_uchar type;
- char *function_name;
+ zstr function_name;
zend_class_entry *scope;
zend_uint fn_flags;
union _zend_function *prototype;
typedef struct _zend_internal_function {
/* Common elements */
zend_uchar type;
- char *function_name;
+ zstr function_name;
zend_class_entry *scope;
zend_uint fn_flags;
union _zend_function *prototype;
struct _zend_module_entry *module;
} zend_internal_function;
-#define ZEND_FN_SCOPE_NAME(function) ((function) && (function)->common.scope ? (function)->common.scope->name : (char*)EMPTY_STR)
+#define ZEND_FN_SCOPE_NAME(function) ((function) && (function)->common.scope ? (function)->common.scope->name : (zstr)EMPTY_STR)
typedef union _zend_function {
zend_uchar type; /* MUST be the first element of this struct! */
struct {
zend_uchar type; /* never used */
- char *function_name;
+ zstr function_name;
zend_class_entry *scope;
zend_uint fn_flags;
union _zend_function *prototype;
ZEND_API void zend_restore_compiled_script_encoding(char *original_script_enc TSRMLS_DC);
ZEND_API char *zend_get_compiled_script_encoding(TSRMLS_D);
-ZEND_API char* zend_get_compiled_variable_name(zend_op_array *op_array, zend_uint var, int* name_len);
+ZEND_API zstr zend_get_compiled_variable_name(zend_op_array *op_array, zend_uint var, int* name_len);
ZEND_API int zend_prepare_scanner_converters(const char *onetime_encoding, int run_time TSRMLS_DC);
-ZEND_API int32_t zend_convert_scanner_output(UChar **target, int32_t *target_len, const char *source, int32_t source_len, UErrorCode *status TSRMLS_DC);
+ZEND_API int zend_convert_scanner_output(UChar **target, int *target_len, const char *source, int source_len, UErrorCode *status TSRMLS_DC);
int zend_unicode_yyinput(zend_file_handle *file_handle, char *buf, size_t len TSRMLS_DC);
#ifdef ZTS
ZEND_API void zend_mangle_property_name(char **dest, int *dest_length, char *src1, int src1_length, char *src2, int src2_length, int internal);
ZEND_API void zend_unmangle_property_name(char *mangled_property, char **prop_name, char **class_name);
-ZEND_API void zend_u_mangle_property_name(char **dest, int *dest_length, zend_uchar type, char *src1, int src1_length, char *src2, int src2_length, int internal);
-ZEND_API void zend_u_unmangle_property_name(zend_uchar type, char *mangled_property, char **prop_name, char **class_name);
+ZEND_API void zend_u_mangle_property_name(zstr *dest, int *dest_length, zend_uchar type, zstr src1, int src1_length, zstr src2, int src2_length, int internal);
+ZEND_API void zend_u_unmangle_property_name(zend_uchar type, zstr mangled_property, zstr *prop_name, zstr *class_name);
#define ZEND_FUNCTION_DTOR (void (*)(void *)) zend_function_dtor
ZEND_API zend_bool zend_is_compiling(TSRMLS_D);
ZEND_API char *zend_make_compiled_string_description(char *name TSRMLS_DC);
ZEND_API void zend_initialize_class_data(zend_class_entry *ce, zend_bool nullify_handlers TSRMLS_DC);
-int zend_get_class_fetch_type(zend_uchar type, char *class_name, uint class_name_len);
+int zend_get_class_fetch_type(zend_uchar type, zstr class_name, uint class_name_len);
typedef zend_bool (*zend_auto_global_callback)(char *name, uint name_len TSRMLS_DC);
typedef struct _zend_auto_global {
void zend_auto_global_dtor(zend_auto_global *auto_global);
ZEND_API int zend_register_auto_global(char *name, uint name_len, zend_auto_global_callback auto_global_callback TSRMLS_DC);
ZEND_API zend_bool zend_is_auto_global(char *name, uint name_len TSRMLS_DC);
-ZEND_API zend_bool zend_u_is_auto_global(zend_uchar type, void *name, uint name_len TSRMLS_DC);
+ZEND_API zend_bool zend_u_is_auto_global(zend_uchar type, zstr name, uint name_len TSRMLS_DC);
ZEND_API int zend_auto_global_disable_jit(char *varname, zend_uint varname_length TSRMLS_DC);
int zendlex(znode *zendlval TSRMLS_DC);
if (!(c->flags & CONST_PERSISTENT)) {
zval_dtor(&c->value);
}
- free(c->name);
+ free(c->name.v);
}
void copy_zend_constant(zend_constant *c)
{
- c->name = zend_strndup(c->name, c->name_len - 1);
+ /* FIXME: Unicode support??? */
+ c->name.s = zend_strndup(c->name.s, c->name_len - 1);
if (!(c->flags & CONST_PERSISTENT)) {
zval_copy_ctor(&c->value);
}
c.flags = CONST_PERSISTENT;
c.module_number = 0;
- c.name = zend_strndup(ZEND_STRL("TRUE"));
+ c.name.s = zend_strndup(ZEND_STRL("TRUE"));
c.name_len = sizeof("TRUE");
Z_LVAL(c.value) = 1;
Z_TYPE(c.value) = IS_BOOL;
zend_register_constant(&c TSRMLS_CC);
- c.name = zend_strndup(ZEND_STRL("FALSE"));
+ c.name.s = zend_strndup(ZEND_STRL("FALSE"));
c.name_len = sizeof("FALSE");
Z_LVAL(c.value) = 0;
Z_TYPE(c.value) = IS_BOOL;
zend_register_constant(&c TSRMLS_CC);
- c.name = zend_strndup(ZEND_STRL("ZEND_THREAD_SAFE"));
+ c.name.s = zend_strndup(ZEND_STRL("ZEND_THREAD_SAFE"));
c.name_len = sizeof("ZEND_THREAD_SAFE");
Z_LVAL(c.value) = ZTS_V;
Z_TYPE(c.value) = IS_BOOL;
zend_register_constant(&c TSRMLS_CC);
- c.name = zend_strndup(ZEND_STRL("NULL"));
+ c.name.s = zend_strndup(ZEND_STRL("NULL"));
c.name_len = sizeof("NULL");
Z_TYPE(c.value) = IS_NULL;
zend_register_constant(&c TSRMLS_CC);
Z_TYPE(c.value) = IS_LONG;
Z_LVAL(c.value) = lval;
c.flags = flags;
- c.name = zend_strndup(name, name_len-1);
+ 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);
Z_TYPE(c.value) = IS_DOUBLE;
Z_DVAL(c.value) = dval;
c.flags = flags;
- c.name = zend_strndup(name, name_len-1);
+ 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);
Z_STRVAL(c.value) = strval;
Z_STRLEN(c.value) = strlen;
c.flags = flags;
- c.name = zend_strndup(name, name_len-1);
+ 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_API int zend_u_get_constant(zend_uchar type, void *name, uint name_len, zval *result TSRMLS_DC)
+ZEND_API int zend_u_get_constant(zend_uchar type, zstr name, uint name_len, zval *result TSRMLS_DC)
{
zend_constant *c;
int retval = 1;
- char *lookup_name;
- char *colon;
+ zstr lookup_name;
+ zstr colon;
- if ((UG(unicode) && (colon = (char*)u_memchr((UChar*)name, ':', name_len)) && ((UChar*)colon)[1] == ':') ||
- (!UG(unicode) && (colon = memchr(name, ':', name_len)) && colon[1] == ':')) {
+ if ((UG(unicode) && (colon.u = u_memchr(name.u, ':', name_len)) && colon.u[1] == ':') ||
+ (!UG(unicode) && (colon.s = memchr(name.s, ':', name_len)) && colon.s[1] == ':')) {
/* class constant */
zend_class_entry **ce = NULL, *scope;
- int class_name_len = UG(unicode)?((colon-(char*)name)/sizeof(UChar)):colon-(char*)name;
+ int class_name_len = UG(unicode)?colon.u-name.u:colon.s-name.s;
int const_name_len = name_len - class_name_len - 2;
- char *constant_name = colon + (UG(unicode)?UBYTES(2):2);
+ zstr constant_name, class_name;
zval **ret_constant;
- char *class_name;
+
+ if (UG(unicode)) {
+ constant_name.u = colon.u + 2;
+ } else {
+ constant_name.s = colon.s + 2;
+ }
if (EG(in_execution)) {
scope = EG(scope);
}
if (UG(unicode)) {
- class_name = (char*)eustrndup((UChar*)name, class_name_len);
+ class_name.u = eustrndup(name.u, class_name_len);
} else {
- class_name = estrndup(name, class_name_len);
+ class_name.s = estrndup(name.s, class_name_len);
}
if (class_name_len == sizeof("self")-1 &&
retval = 0;
}
}
- efree(class_name);
+ efree(class_name.v);
if (retval && ce) {
if (zend_u_hash_find(&((*ce)->constants_table), type, constant_name, const_name_len+1, (void **) &ret_constant) != SUCCESS) {
lookup_name = zend_u_str_case_fold(type, name, name_len, 1, &lookup_name_len);
if (zend_u_hash_find(EG(zend_constants), type, lookup_name, lookup_name_len+1, (void **) &c)==SUCCESS) {
- if ((c->flags & CONST_CS) && memcmp(c->name, name, UG(unicode)?UBYTES(name_len):name_len)!=0) {
+ if ((c->flags & CONST_CS) && memcmp(c->name.v, name.v, UG(unicode)?UBYTES(name_len):name_len)!=0) {
retval=0;
}
} else {
retval=0;
}
- efree(lookup_name);
+ efree(lookup_name.v);
}
if (retval) {
ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC)
{
- return zend_u_get_constant(IS_STRING, 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)
{
unsigned int lookup_name_len;
- char *lookup_name = NULL;
- char *name;
+ zstr lookup_name;
+ zstr name;
int ret = SUCCESS;
#if 0
} else {
lookup_name_len = c->name_len;
name = c->name;
+ lookup_name.v = NULL;
}
if (zend_u_hash_add(EG(zend_constants), type, name, lookup_name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) {
zend_error(E_NOTICE,"Constant %R already defined", type, name);
- free(c->name);
+ free(c->name.v);
if (!(c->flags & CONST_PERSISTENT)) {
zval_dtor(&c->value);
}
ret = FAILURE;
}
- if (lookup_name) {
- efree(lookup_name);
+ if (lookup_name.v) {
+ efree(lookup_name.v);
}
return ret;
}
typedef struct _zend_constant {
zval value;
int flags;
- char *name;
+ zstr name;
uint name_len;
int module_number;
} zend_constant;
void zend_register_standard_constants(TSRMLS_D);
void clean_non_persistent_constants(TSRMLS_D);
ZEND_API int zend_get_constant(char *name, uint name_len, zval *result TSRMLS_DC);
-ZEND_API int zend_u_get_constant(zend_uchar type, void *name, uint name_len, zval *result TSRMLS_DC);
+ZEND_API int zend_u_get_constant(zend_uchar type, zstr name, uint name_len, zval *result TSRMLS_DC);
ZEND_API void zend_register_long_constant(char *name, uint name_len, long lval, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_double_constant(char *name, uint name_len, double dval, int flags, int module_number TSRMLS_DC);
ZEND_API void zend_register_string_constant(char *name, uint name_len, char *strval, int flags, int module_number TSRMLS_DC);
} else if (UG(unicode)) {
UErrorCode status = U_ZERO_ERROR;
UChar *u_str;
- int32_t u_len;
+ int u_len;
zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, message, message_len, &status);
zend_update_property_unicodel(default_exception_ce, object, "message", sizeof("message")-1, u_str, u_len TSRMLS_CC);
if (message_type == IS_UNICODE) {
zend_update_property_unicodel(default_exception_ce, object, "message", sizeof("message")-1, message, message_len TSRMLS_CC);
} else if (UG(unicode)) {
- UErrorCode status = U_ZERO_ERROR;
+ UErrorCode status = U_ZERO_ERROR;
UChar *u_str;
- int32_t u_len;
+ int u_len;
zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u_str, &u_len, message, message_len, &status);
zend_update_property_unicodel(default_exception_ce, object, "message", sizeof("message")-1, u_str, u_len TSRMLS_CC);
TRACE_APPEND_STR("Array, ");
break;
case IS_OBJECT: {
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
int dup;
TSRMLS_FETCH();
if (UG(unicode)) {
zval tmp;
- ZVAL_UNICODEL(&tmp, (UChar*)class_name, class_name_len, 1);
+ ZVAL_UNICODEL(&tmp, class_name.u, class_name_len, 1);
convert_to_string_with_converter(&tmp, ZEND_U_CONVERTER(UG(output_encoding_conv)));
TRACE_APPEND_STRL(Z_STRVAL(tmp), Z_STRLEN(tmp));
zval_dtor(&tmp);
} else {
- TRACE_APPEND_STRL(class_name, class_name_len);
+ TRACE_APPEND_STRL(class_name.s, class_name_len);
}
if(!dup) {
- efree(class_name);
+ efree(class_name.v);
}
TRACE_APPEND_STR("), ");
if (Z_TYPE_P(str) != IS_STRING) {
zend_error(E_WARNING, "%v::__toString() must return a string", ce_exception->name);
} else {
- zend_update_property_string(default_exception_ce, exception, "string", sizeof("string")-1, EG(exception) ? ce_exception->name : Z_STRVAL_P(str) TSRMLS_CC);
+ /* FIXME: Unicode support??? */
+ zend_update_property_string(default_exception_ce, exception, "string", sizeof("string")-1, EG(exception) ? ce_exception->name.s : Z_STRVAL_P(str) TSRMLS_CC);
}
}
zval_ptr_dtor(&str);
{
zend_arg_info *cur_arg_info;
zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data;
- char *fclass, *fsep, *fname;
+ char *fsep;
+ zstr fclass, fname;
if (!zf->common.arg_info
|| arg_num>zf->common.num_args) {
cur_arg_info = &zf->common.arg_info[arg_num-1];
fname = zf->common.function_name;
- fsep = zf->common.scope ? "::" : (char*)EMPTY_STR;
- fclass = zf->common.scope ? zf->common.scope->name : (char*)EMPTY_STR;
+ fsep = zf->common.scope ? "::" : "";
+ fclass = zf->common.scope ? zf->common.scope->name : (zstr)EMPTY_STR;
- if (cur_arg_info->class_name) {
+ if (cur_arg_info->class_name.v) {
if (!arg) {
if (ptr && ptr->op_array) {
zend_error(E_RECOVERABLE_ERROR, "Argument %d passed to %v%s%v() must be an object of class %v, called in %s on line %d and defined", arg_num, fclass, fsep, fname, cur_arg_info->class_name, ptr->op_array->filename, ptr->opline->lineno);
/* separate our value if necessary */
if (EG(ze1_compatibility_mode) && Z_TYPE_P(value) == IS_OBJECT) {
zval *orig_value = value;
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
int dup;
value->refcount = 0;
dup = zend_get_object_classname(orig_value, &class_name, &class_name_len TSRMLS_CC);
if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", class_name);
+ zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", class_name.v);
}
- zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", class_name);
+ zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", class_name.v);
Z_OBJVAL_P(value) = Z_OBJ_HANDLER_P(orig_value, clone_obj)(orig_value TSRMLS_CC);
if (!dup) {
- efree(class_name);
+ efree(class_name.v);
}
} else if (value_op->op_type == IS_TMP_VAR) {
zval *orig_value = value;
}
if (EG(ze1_compatibility_mode) && Z_TYPE_P(value) == IS_OBJECT) {
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
int dup;
dup = zend_get_object_classname(value, &class_name, &class_name_len TSRMLS_CC);
if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", class_name);
+ zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", class_name.v);
} else if (PZVAL_IS_REF(variable_ptr)) {
if (variable_ptr != value) {
zend_uint refcount = variable_ptr->refcount;
*variable_ptr = *value;
variable_ptr->refcount = refcount;
variable_ptr->is_ref = 1;
- zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", class_name);
+ zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", class_name.v);
Z_OBJVAL_P(variable_ptr) = Z_OBJ_HANDLER_P(value, clone_obj)(value TSRMLS_CC);
if (type != IS_TMP_VAR) {
value->refcount--;
}
*variable_ptr = *value;
INIT_PZVAL(variable_ptr);
- zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", class_name);
+ zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", class_name.v);
Z_OBJVAL_P(variable_ptr) = Z_OBJ_HANDLER_P(value, clone_obj)(value TSRMLS_CC);
zval_ptr_dtor(&value);
}
}
if (!dup) {
- efree(class_name);
+ efree(class_name.v);
}
} else if (PZVAL_IS_REF(variable_ptr)) {
if (variable_ptr!=value) {
zval *variable_ptr = *variable_ptr_ptr;
if (EG(ze1_compatibility_mode) && Z_TYPE_P(value) == IS_OBJECT) {
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
int dup;
dup = zend_get_object_classname(value, &class_name, &class_name_len TSRMLS_CC);
if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", class_name);
+ zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", class_name.v);
} else {
variable_ptr->refcount--;
ALLOC_ZVAL(variable_ptr);
*variable_ptr_ptr = variable_ptr;
*variable_ptr = *value;
INIT_PZVAL(variable_ptr);
- zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", class_name);
+ zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", class_name.v);
Z_OBJVAL_P(variable_ptr) = Z_OBJ_HANDLER_P(value, clone_obj)(value TSRMLS_CC);
}
if (!dup) {
- efree(class_name);
+ efree(class_name.v);
}
} else {
variable_ptr->refcount--;
static inline zval **zend_fetch_dimension_address_inner(HashTable *ht, zval *dim, int type TSRMLS_DC)
{
zval **retval;
- char *offset_key;
+ zstr offset_key;
int offset_key_length;
zend_uchar ztype = Z_TYPE_P(dim);
int free_offset = 0;
switch (ztype) {
case IS_NULL:
ztype = IS_STRING;
- offset_key = "";
+ offset_key.s = "";
offset_key_length = 1;
goto fetch_string_dim;
case IS_STRING:
if (UG(unicode) && ht == &EG(symbol_table) && ztype == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
- if (!zend_normalize_identifier(&norm, &norm_len, (UChar*)offset_key, offset_key_length, 0)) {
+ if (!zend_normalize_identifier(&norm, &norm_len, offset_key.u, offset_key_length, 0)) {
zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_key_length = norm_len;
free_offset = 1;
}
}
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
case IS_RESOURCE:
}
}
ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC);
-ZEND_API int zend_u_lookup_class(zend_uchar type, void *name, int name_length, zend_class_entry ***ce TSRMLS_DC);
-ZEND_API int zend_u_lookup_class_ex(zend_uchar type, void *name, int name_length, int use_autoload, zend_class_entry ***ce TSRMLS_DC);
+ZEND_API int zend_u_lookup_class(zend_uchar type, zstr name, int name_length, zend_class_entry ***ce TSRMLS_DC);
+ZEND_API int zend_u_lookup_class_ex(zend_uchar type, zstr name, int name_length, int use_autoload, zend_class_entry ***ce TSRMLS_DC);
ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC);
ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
-ZEND_API int zend_u_eval_string(zend_uchar type, void *str, zval *retval_ptr, char *string_name TSRMLS_DC);
-ZEND_API int zend_u_eval_string_ex(zend_uchar type, void *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
+ZEND_API int zend_u_eval_string(zend_uchar type, zstr str, zval *retval_ptr, char *string_name TSRMLS_DC);
+ZEND_API int zend_u_eval_string_ex(zend_uchar type, zstr str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC);
static inline int i_zend_is_true(zval *op)
{
/* services */
-ZEND_API char *get_active_class_name(char **space TSRMLS_DC);
-ZEND_API char *get_active_function_name(TSRMLS_D);
+ZEND_API zstr get_active_class_name(char **space TSRMLS_DC);
+ZEND_API zstr get_active_function_name(TSRMLS_D);
ZEND_API char *zend_get_executed_filename(TSRMLS_D);
ZEND_API uint zend_get_executed_lineno(TSRMLS_D);
ZEND_API zend_bool zend_is_executing(TSRMLS_D);
ZEND_API void zend_unset_timeout(TSRMLS_D);
ZEND_API void zend_timeout(int dummy);
ZEND_API zend_class_entry *zend_fetch_class(char *class_name, uint class_name_len, int fetch_type TSRMLS_DC);
-ZEND_API zend_class_entry *zend_u_fetch_class(zend_uchar type, void *class_name, uint class_name_len, int fetch_type TSRMLS_DC);
+ZEND_API zend_class_entry *zend_u_fetch_class(zend_uchar type, zstr class_name, uint class_name_len, int fetch_type TSRMLS_DC);
void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC);
#ifdef ZEND_WIN32
/* 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 : (char*)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 : (zstr)EMPTY_STR)
ZEND_API zval** zend_get_compiled_variable_value(zend_execute_data *execute_data_ptr, zend_uint var);
fprintf(stderr, "SIGSEGV caught on opcode %d on opline %d of %s() at %s:%d\n\n",
active_opline->opcode,
active_opline-EG(active_op_array)->opcodes,
- get_active_function_name(TSRMLS_C),
+ get_active_function_name(TSRMLS_C).s,
zend_get_executed_filename(TSRMLS_C),
zend_get_executed_lineno(TSRMLS_C));
}
/* return class name and "::" or "". */
-ZEND_API char *get_active_class_name(char **space TSRMLS_DC)
+ZEND_API zstr get_active_class_name(char **space TSRMLS_DC)
{
if (!zend_is_executing(TSRMLS_C)) {
if (space) {
*space = "";
}
- return (char*)EMPTY_STR;
+ return (zstr)EMPTY_STR;
}
switch (EG(function_state_ptr)->function->type) {
case ZEND_USER_FUNCTION:
if (space) {
*space = ce ? "::" : "";
}
- return ce ? ce->name : (char*)EMPTY_STR;
+ return ce ? ce->name : (zstr)EMPTY_STR;
}
default:
if (space) {
*space = "";
}
- return (char*)EMPTY_STR;
+ return (zstr)EMPTY_STR;
}
}
-ZEND_API char *get_active_function_name(TSRMLS_D)
+ZEND_API zstr get_active_function_name(TSRMLS_D)
{
if (!zend_is_executing(TSRMLS_C)) {
- return NULL;
+ return (zstr)NULL;
}
switch (EG(function_state_ptr)->function->type) {
case ZEND_USER_FUNCTION: {
- char *function_name = ((zend_op_array *) EG(function_state_ptr)->function)->function_name;
+ zstr function_name = ((zend_op_array *) EG(function_state_ptr)->function)->function_name;
- if (function_name) {
+ if (function_name.v) {
return function_name;
} else {
- return UG(unicode)?(char*)u_main:"main";
+ return UG(unicode)?(zstr)u_main:(zstr)"main";
}
}
break;
return ((zend_internal_function *) EG(function_state_ptr)->function)->function_name;
break;
default:
- return NULL;
+ return (zstr)NULL;
}
}
p->is_ref = is_ref;
} else if (Z_TYPE_P(p) == IS_CONSTANT_ARRAY) {
zval **element, *new_val;
- char *str_index;
+ zstr str_index;
uint str_index_len;
ulong num_index;
if (UG(unicode)) {
if (Z_TYPE(const_value) == IS_UNICODE &&
Z_USTRLEN(const_value) == str_index_len-1 &&
- !u_strncmp(Z_USTRVAL(const_value), (UChar*)str_index, str_index_len)) {
+ !u_strncmp(Z_USTRVAL(const_value), str_index.u, str_index_len)) {
/* constant value is the same as its name */
zval_dtor(&const_value);
zend_hash_move_forward(Z_ARRVAL_P(p));
} else {
if (Z_TYPE(const_value) == IS_STRING &&
Z_STRLEN(const_value) == str_index_len-1 &&
- !strncmp(Z_STRVAL(const_value), str_index, str_index_len)) {
+ !strncmp(Z_STRVAL(const_value), str_index.s, str_index_len)) {
/* constant value is the same as its name */
zval_dtor(&const_value);
zend_hash_move_forward(Z_ARRVAL_P(p));
break;
case IS_BOOL:
case IS_LONG:
- zend_hash_update_current_key(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, NULL, 0, Z_LVAL(const_value));
+ zend_hash_update_current_key(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, (zstr)NULL, 0, Z_LVAL(const_value));
break;
case IS_DOUBLE:
- zend_hash_update_current_key(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, NULL, 0, (long)Z_DVAL(const_value));
+ zend_hash_update_current_key(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, (zstr)NULL, 0, (long)Z_DVAL(const_value));
break;
case IS_NULL:
- zend_hash_update_current_key(Z_ARRVAL_P(p), HASH_KEY_IS_STRING, "", 1, 0);
+ zend_hash_update_current_key(Z_ARRVAL_P(p), HASH_KEY_IS_STRING, (zstr)EMPTY_STR, 1, 0);
break;
}
zend_hash_move_forward(Z_ARRVAL_P(p));
char *old_func_name = NULL;
unsigned int clen;
int mlen, fname_len;
- char *mname, *colon, *fname, *lcname;
+ char *mname, *colon;
+ zstr fname, lcname;
if (EG(exception)) {
return FAILURE; /* we would result in an instable executor otherwise */
}
if (Z_TYPE_P(fci->function_name) == IS_UNICODE) {
- if ((colon = (char*)u_strstr((UChar*)Z_UNIVAL_P(fci->function_name), (UChar*)":\0:\0")) != NULL) {
+ if ((colon = (char*)u_strstr(Z_USTRVAL_P(fci->function_name), (UChar*)":\0:\0")) != NULL) {
mlen = u_strlen((UChar*)(colon+4));
clen = Z_UNILEN_P(fci->function_name) - mlen - 2;
mname = colon + 4;
}
if (colon != NULL) {
zend_class_entry **pce, *ce_child = NULL;
- if (zend_u_lookup_class(Z_TYPE_P(fci->function_name), Z_STRVAL_P(fci->function_name), clen, &pce TSRMLS_CC) == SUCCESS) {
+ if (zend_u_lookup_class(Z_TYPE_P(fci->function_name), Z_UNIVAL_P(fci->function_name), clen, &pce TSRMLS_CC) == SUCCESS) {
ce_child = *pce;
} else {
lcname = zend_u_str_case_fold(Z_TYPE_P(fci->function_name), Z_UNIVAL_P(fci->function_name), clen, 0, &clen);
/* caution: lcname is not '\0' terminated */
if (calling_scope) {
- if (clen == sizeof("self") - 1 && memcmp(lcname, "self", sizeof("self") - 1) == 0) {
+ /* FIXME: Unicode support??? */
+ if (clen == sizeof("self") - 1 && memcmp(lcname.s, "self", sizeof("self") - 1) == 0) {
ce_child = EG(active_op_array) ? EG(active_op_array)->scope : NULL;
- } else if (clen == sizeof("parent") - 1 && memcmp(lcname, "parent", sizeof("parent") - 1) == 0 && EG(active_op_array)->scope) {
+ } else if (clen == sizeof("parent") - 1 && memcmp(lcname.s, "parent", sizeof("parent") - 1) == 0 && EG(active_op_array)->scope) {
ce_child = EG(active_op_array) && EG(active_op_array)->scope ? EG(scope)->parent : NULL;
}
}
- efree(lcname);
+ efree(lcname.v);
}
if (!ce_child) {
zend_error(E_ERROR, "Cannot call method %R() or method does not exist", Z_TYPE_P(fci->function_name), Z_UNIVAL_P(fci->function_name));
check_scope_or_static = calling_scope;
fci->function_table = &ce_child->function_table;
calling_scope = ce_child;
- fname = colon + (Z_TYPE_P(fci->function_name) == IS_UNICODE ? 4 : 2);
+ fname.s = colon + (Z_TYPE_P(fci->function_name) == IS_UNICODE ? 4 : 2);
fname_len = mlen;
} else {
- fname = Z_STRVAL_P(fci->function_name);
+ fname.s = Z_STRVAL_P(fci->function_name);
fname_len = Z_STRLEN_P(fci->function_name);
}
EX(function_state).function =
Z_OBJ_HT_PP(fci->object_pp)->get_method(fci->object_pp, fname, fname_len TSRMLS_CC);
if (EX(function_state).function && calling_scope != EX(function_state).function->common.scope) {
- void *function_name_lc = zend_u_str_tolower_dup(Z_TYPE_P(fci->function_name), fname, fname_len);
+ zstr function_name_lc = zend_u_str_tolower_dup(Z_TYPE_P(fci->function_name), fname, fname_len);
if (zend_u_hash_find(&calling_scope->function_table, Z_TYPE_P(fci->function_name), function_name_lc, fname_len+1, (void **) &EX(function_state).function)==FAILURE) {
- efree(function_name_lc);
+ efree(function_name_lc.v);
zend_error(E_ERROR, "Cannot call method %v::%R() or method does not exist", calling_scope->name, Z_TYPE_P(fci->function_name), fname);
}
- efree(function_name_lc);
+ efree(function_name_lc.v);
}
} else if (calling_scope) {
unsigned int lcname_len;
- char *lcname = zend_u_str_case_fold(Z_TYPE_P(fci->function_name), fname, fname_len, 1, &lcname_len);
+ zstr lcname = zend_u_str_case_fold(Z_TYPE_P(fci->function_name), fname, fname_len, 1, &lcname_len);
EX(function_state).function =
zend_std_get_static_method(calling_scope, lcname, lcname_len TSRMLS_CC);
- efree(lcname);
+ efree(lcname.v);
if (check_scope_or_static && EX(function_state).function
&& !(EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC)
&& !instanceof_function(check_scope_or_static, calling_scope TSRMLS_CC)) {
}
} else {
unsigned int lcname_len;
- char *lcname = zend_u_str_case_fold(Z_TYPE_P(fci->function_name), fname, fname_len, 1, &lcname_len);
+ zstr lcname = zend_u_str_case_fold(Z_TYPE_P(fci->function_name), fname, fname_len, 1, &lcname_len);
if (zend_u_hash_find(fci->function_table, Z_TYPE_P(fci->function_name), lcname, lcname_len+1, (void **) &EX(function_state).function)==FAILURE) {
EX(function_state).function = NULL;
}
- efree(lcname);
+ efree(lcname.v);
}
if (EX(function_state).function == NULL) {
EX(function_state).function = calling_scope->__call;
/* prepare params */
ALLOC_INIT_ZVAL(method_name);
- ZVAL_STRINGL(method_name, fname, fname_len, 0);
+ ZVAL_STRINGL(method_name, fname.s, fname_len, 0);
ALLOC_INIT_ZVAL(params_array);
array_init(params_array);
}
if (EX(function_state).function->common.fn_flags & ZEND_ACC_DEPRECATED) {
zend_error(E_NOTICE, "Function %s%s%s() is deprecated",
- EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : "",
+ EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name.s : "",
EX(function_state).function->common.scope ? "::" : "",
EX(function_state).function->common.function_name);
}
}
-ZEND_API int zend_u_lookup_class_ex(zend_uchar type, void *name, int name_length, int use_autoload, zend_class_entry ***ce TSRMLS_DC)
+ZEND_API int zend_u_lookup_class_ex(zend_uchar type, zstr name, int name_length, int use_autoload, zend_class_entry ***ce TSRMLS_DC)
{
zval **args[1];
zval autoload_function;
zval *retval_ptr = NULL;
int retval;
unsigned int lc_name_len;
- char *lc_name;
+ zstr lc_name;
zval *exception;
char dummy = 1;
zend_fcall_info fcall_info;
zend_fcall_info_cache fcall_cache;
- if (name == NULL) {
+ if (name.v == NULL) {
return FAILURE;
}
lc_name = zend_u_str_case_fold(type, name, name_length, 1, &lc_name_len);
if (zend_u_hash_find(EG(class_table), type, lc_name, lc_name_len+1, (void **) ce) == SUCCESS) {
- efree(lc_name);
+ efree(lc_name.v);
return SUCCESS;
}
* (doesn't impact fuctionality of __autoload()
*/
if (!use_autoload || zend_is_compiling(TSRMLS_C)) {
- efree(lc_name);
+ efree(lc_name.v);
return FAILURE;
}
}
if (zend_u_hash_add(EG(in_autoload), type, lc_name, lc_name_len+1, (void**)&dummy, sizeof(char), NULL) == FAILURE) {
- efree(lc_name);
+ efree(lc_name.v);
return FAILURE;
}
ALLOC_ZVAL(class_name_ptr);
INIT_PZVAL(class_name_ptr);
- if (type == IS_UNICODE) {
- ZVAL_UNICODEL(class_name_ptr, name, name_length, 1);
- } else {
- ZVAL_STRINGL(class_name_ptr, name, name_length, 1);
- }
+ ZVAL_TEXTL(class_name_ptr, name, name_length, 1);
args[0] = &class_name_ptr;
if (retval == FAILURE) {
EG(exception) = exception;
- efree(lc_name);
+ efree(lc_name.v);
return FAILURE;
}
if (EG(exception) && exception) {
- efree(lc_name);
+ efree(lc_name.v);
zend_error(E_ERROR, "Function %s(%R) threw an exception of type '%v'", ZEND_AUTOLOAD_FUNC_NAME, type, name, Z_OBJCE_P(EG(exception))->name);
return FAILURE;
}
}
retval = zend_u_hash_find(EG(class_table), type, lc_name, lc_name_len + 1, (void **) ce);
- efree(lc_name);
+ efree(lc_name.v);
return retval;
}
-ZEND_API int zend_u_lookup_class(zend_uchar type, void *name, int name_length, zend_class_entry ***ce TSRMLS_DC)
+ZEND_API int zend_u_lookup_class(zend_uchar type, zstr name, int name_length, zend_class_entry ***ce TSRMLS_DC)
{
return zend_u_lookup_class_ex(type, name, name_length, 1, ce TSRMLS_CC);
}
ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***ce TSRMLS_DC)
{
- return zend_u_lookup_class(IS_STRING, 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, void *string, zval *retval_ptr, char *string_name TSRMLS_DC)
+ZEND_API int zend_u_eval_string(zend_uchar type, zstr string, zval *retval_ptr, char *string_name TSRMLS_DC)
{
zval pv;
zend_op_array *new_op_array;
int retval;
if (type == IS_UNICODE) {
- UChar *str = (UChar*)string;
+ UChar *str = string.u;
if (retval_ptr) {
Z_USTRLEN(pv) = u_strlen(str)+sizeof("return ;")-1;
Z_USTRVAL(pv) = eustrndup(str, Z_USTRLEN(pv));
}
} else {
- char *str = (char*)string;
+ char *str = string.s;
if (retval_ptr) {
Z_STRLEN(pv) = strlen(str)+sizeof("return ;")-1;
ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC)
{
- return zend_u_eval_string(IS_STRING, 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, void *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC)
+ZEND_API int zend_u_eval_string_ex(zend_uchar type, zstr str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC)
{
int result;
- result = zend_eval_string(str, retval_ptr, string_name TSRMLS_CC);
+ result = zend_u_eval_string(type, str, retval_ptr, string_name TSRMLS_CC);
if (handle_exceptions && EG(exception)) {
zend_exception_error(EG(exception) TSRMLS_CC);
result = FAILURE;
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, 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);
}
if (!CG(interactive)
|| CG(active_op_array)->backpatch_count>0
- || CG(active_op_array)->function_name
+ || CG(active_op_array)->function_name.v
|| CG(active_op_array)->type!=ZEND_USER_FUNCTION) {
return;
}
}
-ZEND_API zend_class_entry *zend_u_fetch_class(zend_uchar type, void *class_name, uint class_name_len, int fetch_type TSRMLS_DC)
+ZEND_API zend_class_entry *zend_u_fetch_class(zend_uchar type, zstr class_name, uint class_name_len, int fetch_type TSRMLS_DC)
{
zend_class_entry **pce;
int use_autoload = (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) == 0;
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, 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]) : (char*)EMPTY_STR, \
+ ai.afn[idx] ? ZEND_FN_SCOPE_NAME(ai.afn[idx]) : (zstr)EMPTY_STR, \
ai.afn[idx] ? "::" : "", \
- ai.afn[idx] ? ai.afn[idx]->common.function_name : (char*)EMPTY_STR, \
+ ai.afn[idx] ? ai.afn[idx]->common.function_name : (zstr)EMPTY_STR, \
ai.afn[idx] && ai.afn[idx+1] ? ", " : (ai.afn[idx] && ai.cnt > MAX_ABSTRACT_INFO_CNT ? ", ..." : "")
typedef struct _zend_abstract_info {
}
}
-ZEND_API int zend_u_delete_global_variable(zend_uchar type, void *name, int name_len TSRMLS_DC)
+ZEND_API int zend_u_delete_global_variable(zend_uchar type, zstr name, int name_len TSRMLS_DC)
{
zend_execute_data *ex;
ulong hash_value = zend_u_inline_hash_func(type, name, name_len+1);
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == name_len &&
- !memcmp(ex->op_array->vars[i].name, name, type==IS_UNICODE?UBYTES(name_len):name_len)) {
+ !memcmp(ex->op_array->vars[i].name.v, name.v, type==IS_UNICODE?UBYTES(name_len):name_len)) {
ex->CVs[i] = NULL;
break;
}
ZEND_API int zend_delete_global_variable(char *name, int name_len TSRMLS_DC)
{
- return zend_u_delete_global_variable(IS_STRING, name, name_len TSRMLS_CC);
+ return zend_u_delete_global_variable(IS_STRING, (zstr)name, name_len TSRMLS_CC);
}
/*
if (ht->unicode && type == IS_STRING) { \
UErrorCode status = U_ZERO_ERROR; \
UChar *u = NULL; \
- int32_t u_len; \
+ int u_len; \
TSRMLS_FETCH(); \
- zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u, &u_len, (char*)arKey, nKeyLength-1, &status); \
+ zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u, &u_len, arKey.s, nKeyLength-1, &status); \
if (U_FAILURE(status)) { \
/* UTODO: */ \
} \
type = IS_UNICODE; \
- tmp = arKey = u; \
+ tmp = arKey.u = u; \
}
static int zend_hash_do_resize(HashTable *ht);
-ZEND_API ulong zend_u_hash_func(zend_uchar type, char *arKey, uint nKeyLength)
+ZEND_API ulong zend_u_hash_func(zend_uchar type, zstr arKey, uint nKeyLength)
{
return zend_u_inline_hash_func(type, arKey, nKeyLength);
}
ZEND_API ulong zend_hash_func(char *arKey, uint nKeyLength)
{
- return zend_u_hash_func(IS_STRING, arKey, nKeyLength);
+ return zend_u_hash_func(IS_STRING, (zstr)arKey, nKeyLength);
}
#define UPDATE_DATA(ht, p, pData, nDataSize) \
-ZEND_API int _zend_u_hash_add_or_update(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)
+ZEND_API int _zend_u_hash_add_or_update(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)
{
ulong h;
uint nIndex;
if ((p->h == h) &&
(p->key.type == type) &&
(p->nKeyLength == nKeyLength) &&
- !memcmp(&p->key.u, arKey, realKeyLength)) {
+ !memcmp(p->key.arKey.s, arKey.s, realKeyLength)) {
if (flag & HASH_ADD) {
if (tmp) efree(tmp);
return FAILURE;
p = p->pNext;
}
- p = (Bucket *) pemalloc(sizeof(Bucket)-sizeof(p->key.u)+realKeyLength, ht->persistent);
+ p = (Bucket *) pemalloc(sizeof(Bucket)-sizeof(p->key.arKey)+realKeyLength, ht->persistent);
if (!p) {
if (tmp) efree(tmp);
return FAILURE;
}
p->key.type = type;
- memcpy(&p->key.u, arKey, realKeyLength);
+ memcpy(p->key.arKey.s, arKey.s, realKeyLength);
p->nKeyLength = nKeyLength;
INIT_DATA(ht, p, pData, nDataSize);
p->h = h;
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, 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, void *arKey, uint nKeyLength, ulong h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)
+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)
{
uint nIndex;
Bucket *p;
if ((p->h == h) &&
(p->key.type == type) &&
(p->nKeyLength == nKeyLength) &&
- !memcmp(&p->key.u, arKey, realKeyLength)) {
+ !memcmp(p->key.arKey.s, arKey.s, realKeyLength)) {
if (flag & HASH_ADD) {
if (tmp) efree(tmp);
return FAILURE;
p = p->pNext;
}
- p = (Bucket *) pemalloc(sizeof(Bucket)-sizeof(p->key.u)+realKeyLength, ht->persistent);
+ p = (Bucket *) pemalloc(sizeof(Bucket)-sizeof(p->key.arKey)+realKeyLength, ht->persistent);
if (!p) {
if (tmp) efree(tmp);
return FAILURE;
}
p->key.type = type;
- memcpy(&p->key.u, arKey, realKeyLength);
+ memcpy(p->key.arKey.s, arKey.s, realKeyLength);
p->nKeyLength = nKeyLength;
INIT_DATA(ht, p, pData, nDataSize);
p->h = h;
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, 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, void *arKey, uint nKeyLength)
+ZEND_API int zend_u_hash_add_empty_element(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength)
{
void *dummy = (void *) 1;
{
void *dummy = (void *) 1;
- return zend_u_hash_add(ht, IS_STRING, arKey, nKeyLength, &dummy, sizeof(void *), NULL);
+ return zend_u_hash_add(ht, IS_STRING, (zstr)arKey, nKeyLength, &dummy, sizeof(void *), NULL);
}
}
p = p->pNext;
}
- p = (Bucket *) pemalloc_rel(sizeof(Bucket) - sizeof(p->key.u), ht->persistent);
+ p = (Bucket *) pemalloc_rel(sizeof(Bucket) - sizeof(p->key.arKey), ht->persistent);
if (!p) {
return FAILURE;
}
return SUCCESS;
}
-ZEND_API int zend_u_hash_del_key_or_index(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, ulong h, int flag)
+ZEND_API int zend_u_hash_del_key_or_index(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, ulong h, int flag)
{
uint nIndex;
Bucket *p;
void *tmp = NULL;
- uint realKeyLength;
+ uint realKeyLength = 0;
IS_CONSISTENT(ht);
&& (p->nKeyLength == nKeyLength)
&& ((p->nKeyLength == 0) /* Numeric index (short circuits the memcmp()) */
|| ((p->key.type == type)
- && !memcmp(&p->key.u, arKey, realKeyLength)))) {
+ && !memcmp(p->key.arKey.s, arKey.s, realKeyLength)))) {
HANDLE_BLOCK_INTERRUPTIONS();
if (p == ht->arBuckets[nIndex]) {
ht->arBuckets[nIndex] = p->pNext;
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, 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)
hash_key.nKeyLength = p->nKeyLength;
hash_key.h = p->h;
hash_key.type = p->key.type;
- if (hash_key.type == IS_UNICODE) {
- hash_key.u.unicode = p->key.u.unicode;
- } else {
- hash_key.u.string = p->key.u.string;
- }
+ hash_key.arKey.s = p->key.arKey.s;
if (destruct(p->pData, num_args, args, &hash_key)) {
p = zend_hash_apply_deleter(ht, p);
} else {
if (q->nKeyLength==0) {
zend_hash_index_del(ht, q->h);
} else {
- zend_u_hash_del(ht, q->key.type, &q->key.u.unicode, q->nKeyLength);
+ zend_u_hash_del(ht, q->key.type, (zstr)q->key.arKey.s, q->nKeyLength);
}
}
if (result & ZEND_HASH_APPLY_STOP) {
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, &p->key.u, 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);
pCopyConstructor(t);
}
} else {
- if (_zend_u_hash_add_or_update(target, p->key.type, &p->key.u, 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);
}
}
hash_key.nKeyLength = p->nKeyLength;
hash_key.h = p->h;
hash_key.type = p->key.type;
- if (hash_key.type == IS_UNICODE) {
- hash_key.u.unicode = p->key.u.unicode;
- } else {
- hash_key.u.string = p->key.u.string;
- }
+ hash_key.arKey.s = p->key.arKey.s;
return merge_checker_func(target, source_data, &hash_key, pParam);
}
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, &p->key.u, 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);
}
}
}
-ZEND_API ulong zend_u_get_hash_value(zend_uchar type, char *arKey, uint nKeyLength)
+ZEND_API ulong zend_u_get_hash_value(zend_uchar type, zstr arKey, uint nKeyLength)
{
return zend_u_inline_hash_func(type, arKey, nKeyLength);
}
ZEND_API ulong zend_get_hash_value(char *arKey, uint nKeyLength)
{
- return zend_u_get_hash_value(IS_STRING, arKey, nKeyLength);
+ return zend_u_get_hash_value(IS_STRING, (zstr)arKey, nKeyLength);
}
* data is returned in pData. The reason is that there's no reason
* someone using the hash table might not want to have NULL data
*/
-ZEND_API int zend_u_hash_find(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, void **pData)
+ZEND_API int zend_u_hash_find(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, void **pData)
{
ulong h;
uint nIndex;
if ((p->h == h) &&
(p->key.type == type) &&
(p->nKeyLength == nKeyLength) &&
- !memcmp(&p->key.u, arKey, realKeyLength)) {
+ !memcmp(p->key.arKey.s, arKey.s, realKeyLength)) {
*pData = p->pData;
if (tmp) efree(tmp);
return SUCCESS;
ZEND_API int zend_hash_find(HashTable *ht, char *arKey, uint nKeyLength, void **pData)
{
- return zend_u_hash_find(ht, IS_STRING, arKey, nKeyLength, pData);
+ return zend_u_hash_find(ht, IS_STRING, (zstr)arKey, nKeyLength, pData);
}
-ZEND_API int zend_u_hash_quick_find(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, ulong h, void **pData)
+ZEND_API int zend_u_hash_quick_find(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, ulong h, void **pData)
{
uint nIndex;
Bucket *p;
if ((p->h == h) &&
(p->key.type == type) &&
(p->nKeyLength == nKeyLength) &&
- !memcmp(&p->key.u, arKey, realKeyLength)) {
+ !memcmp(p->key.arKey.s, arKey.s, realKeyLength)) {
*pData = p->pData;
if (tmp) efree(tmp);
return SUCCESS;
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, 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, void *arKey, uint nKeyLength)
+ZEND_API int zend_u_hash_exists(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength)
{
ulong h;
uint nIndex;
if ((p->h == h) &&
(p->key.type == type) &&
(p->nKeyLength == nKeyLength) &&
- !memcmp(&p->key.u, arKey, realKeyLength)) {
+ !memcmp(p->key.arKey.s, arKey.s, realKeyLength)) {
if (tmp) efree(tmp);
return 1;
}
ZEND_API int zend_hash_exists(HashTable *ht, char *arKey, uint nKeyLength)
{
- return zend_u_hash_exists(ht, IS_STRING, 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, void *arKey, uint nKeyLength, ulong h)
+ZEND_API int zend_u_hash_quick_exists(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, ulong h)
{
uint nIndex;
Bucket *p;
if ((p->h == h) &&
(p->key.type == type) &&
(p->nKeyLength == nKeyLength) &&
- !memcmp(&p->key.u, arKey, realKeyLength)) {
+ !memcmp(p->key.arKey.s, arKey.s, realKeyLength)) {
if (tmp) efree(tmp);
return 1;
}
ZEND_API int zend_hash_quick_exists(HashTable *ht, char *arKey, uint nKeyLength, ulong h)
{
- return zend_u_hash_quick_exists(ht, IS_STRING, 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)
/* This function should be made binary safe */
-ZEND_API int zend_hash_get_current_key_ex(HashTable *ht, char **str_index, uint *str_length, ulong *num_index, zend_bool duplicate, HashPosition *pos)
+ZEND_API int zend_hash_get_current_key_ex(HashTable *ht, zstr *str_index, uint *str_length, ulong *num_index, zend_bool duplicate, HashPosition *pos)
{
Bucket *p;
if (p->nKeyLength) {
if (p->key.type == IS_STRING) {
if (duplicate) {
- *str_index = estrndup(p->key.u.string, p->nKeyLength-1);
+ str_index->s = estrndup(p->key.arKey.s, p->nKeyLength-1);
} else {
- *str_index = p->key.u.string;
+ str_index->s = p->key.arKey.s;
}
if (str_length) {
*str_length = p->nKeyLength;
return HASH_KEY_IS_STRING;
} else if (p->key.type == IS_UNICODE) {
if (duplicate) {
- *str_index = (char*)eustrndup(p->key.u.unicode, p->nKeyLength-1);
+ str_index->u = eustrndup(p->key.arKey.u, p->nKeyLength-1);
} else {
- *str_index = p->key.u.string;
+ str_index->u = p->key.arKey.u;
}
if (str_length) {
*str_length = p->nKeyLength;
/* This function changes key of currevt element without changing elements'
* order. If element with target key already exists, it will be deleted first.
*/
-ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, char *str_index, uint str_length, ulong num_index, HashPosition *pos)
+ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, zstr str_index, uint str_length, ulong num_index, HashPosition *pos)
{
Bucket *p;
uint real_length;
real_length = str_length;
if (p->nKeyLength == str_length &&
p->key.type == IS_STRING &&
- memcmp(p->key.u.string, str_index, str_length) == 0) {
+ memcmp(p->key.arKey.s, str_index.s, str_length) == 0) {
return SUCCESS;
}
zend_u_hash_del(ht, IS_STRING, str_index, str_length);
real_length = str_length * sizeof(UChar);
if (p->nKeyLength == str_length &&
p->key.type == IS_UNICODE &&
- memcmp(p->key.u.string, str_index, real_length) == 0) {
+ memcmp(p->key.arKey.u, str_index.u, real_length) == 0) {
return SUCCESS;
}
zend_u_hash_del(ht, IS_UNICODE, str_index, str_length);
if (key_type == HASH_KEY_IS_LONG) {
p->h = num_index;
} else if (key_type == HASH_KEY_IS_UNICODE) {
- memcpy(p->key.u.unicode, str_index, real_length);
- p->key.type = IS_UNICODE;
+ memcpy(p->key.arKey.u, str_index.u, real_length);
+ p->key.type = IS_UNICODE;
p->h = zend_u_inline_hash_func(IS_UNICODE, str_index, str_length);
} else {
- memcpy(p->key.u.string, str_index, real_length);
- p->key.type = IS_STRING;
+ memcpy(p->key.arKey.s, str_index.s, real_length);
+ p->key.type = IS_STRING;
p->h = zend_u_inline_hash_func(p->key.type, str_index, str_length);
}
result = p1->nKeyLength - p2->nKeyLength;
}
if (result==0) {
- result = memcmp(&p1->key.u, &p2->key.u, REAL_KEY_SIZE(p1->key.type, p1->nKeyLength));
+ result = memcmp(p1->key.arKey.s, p2->key.arKey.s, REAL_KEY_SIZE(p1->key.type, p1->nKeyLength));
}
if (result!=0) {
HASH_UNPROTECT_RECURSION(ht1);
return 1;
}
} else { /* string, binary or unicode index */
- if (zend_u_hash_find(ht2, p1->key.type, &p1->key.u, 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;
#define HANDLE_U_NUMERIC(key, length, func) { \
register UChar *tmp=key; \
- register int32_t val; \
+ register int val; \
\
if (*tmp=='-') { \
tmp++; \
} while (0); \
}
-ZEND_API int zend_u_symtable_update(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest)
+ZEND_API int zend_u_symtable_update(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest)
{
if (type == IS_STRING) {
- HANDLE_NUMERIC((char*)arKey, nKeyLength, zend_hash_index_update(ht, idx, pData, nDataSize, pDest));
+ HANDLE_NUMERIC(arKey.s, nKeyLength, zend_hash_index_update(ht, idx, pData, nDataSize, pDest));
} else if (type == IS_UNICODE) {
- HANDLE_U_NUMERIC((UChar*)arKey, nKeyLength, zend_hash_index_update(ht, idx, pData, nDataSize, pDest));
+ HANDLE_U_NUMERIC(arKey.u, nKeyLength, zend_hash_index_update(ht, idx, pData, nDataSize, pDest));
}
return zend_u_hash_update(ht, type, arKey, nKeyLength, pData, nDataSize, pDest);
}
-ZEND_API int zend_u_symtable_del(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength)
+ZEND_API int zend_u_symtable_del(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength)
{
if (type == IS_STRING) {
- HANDLE_NUMERIC((char*)arKey, nKeyLength, zend_hash_index_del(ht, idx));
+ HANDLE_NUMERIC(arKey.s, nKeyLength, zend_hash_index_del(ht, idx));
} else if (type == IS_UNICODE) {
- HANDLE_U_NUMERIC((UChar*)arKey, nKeyLength, zend_hash_index_del(ht, idx));
+ HANDLE_U_NUMERIC(arKey.u, nKeyLength, zend_hash_index_del(ht, idx));
}
return zend_u_hash_del(ht, type, arKey, nKeyLength);
}
-ZEND_API int zend_u_symtable_find(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, void **pData)
+ZEND_API int zend_u_symtable_find(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, void **pData)
{
if (type == IS_STRING) {
- HANDLE_NUMERIC((char*)arKey, nKeyLength, zend_hash_index_find(ht, idx, pData));
+ HANDLE_NUMERIC(arKey.s, nKeyLength, zend_hash_index_find(ht, idx, pData));
} else if (type == IS_UNICODE) {
- HANDLE_U_NUMERIC((UChar*)arKey, nKeyLength, zend_hash_index_find(ht, idx, pData));
+ HANDLE_U_NUMERIC(arKey.u, nKeyLength, zend_hash_index_find(ht, idx, pData));
}
return zend_u_hash_find(ht, type, arKey, nKeyLength, pData);
}
-ZEND_API int zend_u_symtable_exists(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength)
+ZEND_API int zend_u_symtable_exists(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength)
{
if (type == IS_STRING) {
- HANDLE_NUMERIC((char*)arKey, nKeyLength, zend_hash_index_exists(ht, idx));
+ HANDLE_NUMERIC(arKey.s, nKeyLength, zend_hash_index_exists(ht, idx));
} else if (type == IS_UNICODE) {
- HANDLE_U_NUMERIC((UChar*)arKey, nKeyLength, zend_hash_index_exists(ht, idx));
+ HANDLE_U_NUMERIC(arKey.u, nKeyLength, zend_hash_index_exists(ht, idx));
}
return zend_u_hash_exists(ht, type, arKey, nKeyLength);
}
-ZEND_API int zend_u_symtable_update_current_key(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength)
+ZEND_API int zend_u_symtable_update_current_key(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength)
{
zend_uchar key_type;
if (type == IS_STRING) {
key_type = HASH_KEY_IS_STRING;
- HANDLE_NUMERIC((char*)arKey, nKeyLength, zend_hash_update_current_key(ht, HASH_KEY_IS_LONG, NULL, 0, idx));
- } else if (type == IS_UNICODE) {
+ HANDLE_NUMERIC(arKey.s, nKeyLength, zend_hash_update_current_key(ht, HASH_KEY_IS_LONG, (zstr)NULL, 0, idx));
+ } else {
key_type = HASH_KEY_IS_UNICODE;
- HANDLE_U_NUMERIC((UChar*)arKey, nKeyLength, zend_hash_update_current_key(ht, HASH_KEY_IS_LONG, NULL, 0, idx));
+ HANDLE_U_NUMERIC(arKey.u, nKeyLength, zend_hash_update_current_key(ht, HASH_KEY_IS_LONG, (zstr)NULL, 0, idx));
}
return zend_hash_update_current_key(ht, key_type, arKey, nKeyLength, 0);
}
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, NULL, 0, idx));
- return zend_hash_update_current_key(ht, HASH_KEY_IS_STRING, arKey, nKeyLength, 0);
+ 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);
}
ZEND_API void zend_hash_to_unicode(HashTable *ht, apply_func_t apply_func TSRMLS_DC)
if ((*p)->key.type == IS_STRING) {
UErrorCode status = U_ZERO_ERROR;
UChar *u = NULL;
- int32_t u_len;
+ int u_len;
Bucket *q;
- zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u, &u_len, (char*)(*p)->key.u.string, (*p)->nKeyLength-1, &status);
+ zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &u, &u_len, (*p)->key.arKey.s, (*p)->nKeyLength-1, &status);
- q = (Bucket *) pemalloc(sizeof(Bucket)-sizeof(q->key.u)+((u_len+1)*2), ht->persistent);
- memcpy(q, *p, sizeof(Bucket)-sizeof(q->key.u));
- memcpy(q->key.u.unicode, u, (u_len+1)*2);
+ q = (Bucket *) pemalloc(sizeof(Bucket)-sizeof(q->key.arKey)+((u_len+1)*2), ht->persistent);
+ memcpy(q, *p, sizeof(Bucket)-sizeof(q->key.arKey));
+ memcpy(q->key.arKey.u, u, (u_len+1)*2);
q->key.type = IS_UNICODE;
q->nKeyLength = u_len+1;
- q->h = zend_u_inline_hash_func(IS_UNICODE, (void*)q->key.u.unicode, q->nKeyLength);
+ q->h = zend_u_inline_hash_func(IS_UNICODE, q->key.arKey, q->nKeyLength);
if ((*p)->pData == &(*p)->pDataPtr) {
q->pData = &q->pDataPtr;
}
p = ht->pListTail;
while (p != NULL) {
if (p->key.type == IS_UNICODE) {
- /* TODO: ??? */
+ /* FIXME: Unicode support??? */
} else {
- zend_output_debug_string(0, "pListTail has key %s\n", p->key.u.string);
+ zend_output_debug_string(0, "pListTail has key %s\n", p->key.arKey.s);
}
p = p->pListLast;
}
p = ht->arBuckets[i];
while (p != NULL) {
if (p->key.type == IS_UNICODE) {
- /* TODO: ??? */
+ /* FIXME: Unicode support??? */
} else {
- zend_output_debug_string(0, "%s <==> 0x%lX\n", p->key.u.string, p->h);
+ zend_output_debug_string(0, "%s <==> 0x%lX\n", p->key.arKey.s, p->h);
}
p = p->pNext;
}
p = ht->pListTail;
while (p != NULL) {
if (p->key.type == IS_UNICODE) {
- /* TODO: ??? */
+ /* FIXME: Unicode support??? */
} else {
- zend_output_debug_string(0, "%s <==> 0x%lX\n", p->key.u.string, p->h);
+ zend_output_debug_string(0, "%s <==> 0x%lX\n", p->key.arKey.s, p->h);
}
p = p->pListLast;
}
typedef struct _key {
zend_uchar type;
union {
- char string[1]; /* Must be last element */
- UChar unicode[1]; /* Must be last element */
- } u;
+ char s[1]; /* Must be last element */
+ UChar u[1]; /* Must be last element */
+ } arKey;
} HashKey;
typedef struct bucket {
ulong h;
uint nKeyLength;
zend_uchar type;
- union {
- char *string;
- UChar *unicode;
- } u;
+ zstr arKey;
} zend_hash_key;
/* additions/updates/changes */
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);
-ZEND_API int _zend_u_hash_add_or_update(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC);
+ZEND_API int _zend_u_hash_add_or_update(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC);
#define zend_hash_update(ht, arKey, nKeyLength, pData, nDataSize, pDest) \
_zend_hash_add_or_update(ht, arKey, nKeyLength, pData, nDataSize, pDest, HASH_UPDATE ZEND_FILE_LINE_CC)
#define zend_u_hash_update(ht, type, arKey, nKeyLength, pData, nDataSize, pDest) \
_zend_u_hash_add_or_update(ht, type, arKey, nKeyLength, pData, nDataSize, pDest, HASH_ADD ZEND_FILE_LINE_CC)
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);
-ZEND_API int _zend_u_hash_quick_add_or_update(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, ulong h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC);
+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);
#define zend_hash_quick_update(ht, arKey, nKeyLength, h, pData, nDataSize, pDest) \
_zend_hash_quick_add_or_update(ht, arKey, nKeyLength, h, pData, nDataSize, pDest, HASH_UPDATE ZEND_FILE_LINE_CC)
#define zend_u_hash_quick_update(ht, type, arKey, nKeyLength, h, pData, nDataSize, pDest) \
_zend_hash_index_update_or_next_insert(ht, 0, pData, nDataSize, pDest, HASH_NEXT_INSERT ZEND_FILE_LINE_CC)
ZEND_API int zend_hash_add_empty_element(HashTable *ht, char *arKey, uint nKeyLength);
-ZEND_API int zend_u_hash_add_empty_element(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength);
+ZEND_API int zend_u_hash_add_empty_element(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength);
#define ZEND_HASH_APPLY_KEEP 0
/* Deletes */
ZEND_API int zend_hash_del_key_or_index(HashTable *ht, char *arKey, uint nKeyLength, ulong h, int flag);
-ZEND_API int zend_u_hash_del_key_or_index(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, ulong h, int flag);
+ZEND_API int zend_u_hash_del_key_or_index(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, ulong h, int flag);
#define zend_hash_del(ht, arKey, nKeyLength) \
zend_hash_del_key_or_index(ht, arKey, nKeyLength, 0, HASH_DEL_KEY)
#define zend_u_hash_del(ht, type, arKey, nKeyLength) \
zend_hash_del_key_or_index(ht, NULL, 0, h, HASH_DEL_INDEX)
ZEND_API ulong zend_get_hash_value(char *arKey, uint nKeyLength);
-ZEND_API ulong zend_u_get_hash_value(zend_uchar type, char *arKey, uint nKeyLength);
+ZEND_API ulong zend_u_get_hash_value(zend_uchar type, zstr arKey, uint nKeyLength);
/* Data retreival */
ZEND_API int zend_hash_find(HashTable *ht, char *arKey, uint nKeyLength, void **pData);
-ZEND_API int zend_u_hash_find(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, void **pData);
+ZEND_API int zend_u_hash_find(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, void **pData);
ZEND_API int zend_hash_quick_find(HashTable *ht, char *arKey, uint nKeyLength, ulong h, void **pData);
-ZEND_API int zend_u_hash_quick_find(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, ulong h, void **pData);
+ZEND_API int zend_u_hash_quick_find(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, ulong h, void **pData);
ZEND_API int zend_hash_index_find(HashTable *ht, ulong h, void **pData);
/* Misc */
ZEND_API int zend_hash_exists(HashTable *ht, char *arKey, uint nKeyLength);
-ZEND_API int zend_u_hash_exists(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength);
+ZEND_API int zend_u_hash_exists(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength);
ZEND_API int zend_hash_quick_exists(HashTable *ht, char *arKey, uint nKeyLength, ulong h);
-ZEND_API int zend_u_hash_quick_exists(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, ulong h);
+ZEND_API int zend_u_hash_quick_exists(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, ulong h);
ZEND_API int zend_hash_index_exists(HashTable *ht, ulong h);
ZEND_API ulong zend_hash_next_free_element(HashTable *ht);
(zend_hash_get_current_key_type_ex(ht, pos) == HASH_KEY_NON_EXISTANT ? FAILURE : SUCCESS)
ZEND_API int zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos);
ZEND_API int zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos);
-ZEND_API int zend_hash_get_current_key_ex(HashTable *ht, char **str_index, uint *str_length, ulong *num_index, zend_bool duplicate, HashPosition *pos);
+ZEND_API int zend_hash_get_current_key_ex(HashTable *ht, zstr *str_index, uint *str_length, ulong *num_index, zend_bool duplicate, HashPosition *pos);
ZEND_API int zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos);
ZEND_API int zend_hash_get_current_data_ex(HashTable *ht, void **pData, HashPosition *pos);
ZEND_API void zend_hash_internal_pointer_reset_ex(HashTable *ht, HashPosition *pos);
ZEND_API void zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos);
-ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, char *str_index, uint str_length, ulong num_index, HashPosition *pos);
+ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, zstr str_index, uint str_length, ulong num_index, HashPosition *pos);
#define zend_hash_has_more_elements(ht) \
zend_hash_has_more_elements_ex(ht, NULL)
}
#define zend_u_inline_hash_func(type, arKey, nKeyLength) \
- zend_inline_hash_func(arKey, REAL_KEY_SIZE(type, nKeyLength))
+ zend_inline_hash_func(arKey.s, REAL_KEY_SIZE(type, nKeyLength))
ZEND_API ulong zend_hash_func(char *arKey, uint nKeyLength);
-ZEND_API ulong zend_u_hash_func(zend_uchar type, char *arKey, uint nKeyLength);
+ZEND_API ulong zend_u_hash_func(zend_uchar type, zstr arKey, uint nKeyLength);
#if ZEND_DEBUG
/* debug */
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);
-ZEND_API int zend_u_symtable_update(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest);
-ZEND_API int zend_u_symtable_del(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength);
-ZEND_API int zend_u_symtable_find(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength, void **pData);
-ZEND_API int zend_u_symtable_exists(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength);
-ZEND_API int zend_u_symtable_update_current_key(HashTable *ht, zend_uchar type, void *arKey, uint nKeyLength);
+ZEND_API int zend_u_symtable_update(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest);
+ZEND_API int zend_u_symtable_del(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength);
+ZEND_API int zend_u_symtable_find(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength, void **pData);
+ZEND_API int zend_u_symtable_exists(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength);
+ZEND_API int zend_u_symtable_update_current_key(HashTable *ht, zend_uchar type, zstr arKey, uint nKeyLength);
#endif /* ZEND_HASH_H */
case T_DOC_COMMENT:
break;
default:
- efree(Z_UNIVAL(token));
+ efree(Z_UNIVAL(token).v);
break;
}
} else if (token_type == T_END_HEREDOC) {
- efree(Z_UNIVAL(token));
+ efree(Z_UNIVAL(token).v);
}
Z_TYPE(token) = 0;
}
break;
default:
- efree(Z_UNIVAL(token));
+ efree(Z_UNIVAL(token).v);
break;
}
}
return 1;
} else { /* both strings */
/*FIXME: unicode hash*/
- return zend_binary_strcasecmp(f->key.u.string, f->nKeyLength, s->key.u.string, s->nKeyLength);
+ return zend_binary_strcasecmp(f->key.arKey.s, f->nKeyLength, s->key.arKey.s, s->nKeyLength);
}
}
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 ? (void*)obj_ce->name : 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 : (zstr)EMPTY_STR, obj_ce ? "::" : "", function_name);
}
if (fn_proxy) {
*fn_proxy = fcic.function_handler;
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 ? (void*)obj_ce->name : EMPTY_STR, obj_ce ? "::" : "", function_name);
+ zend_error(E_CORE_ERROR, "Couldn't execute method %v%s%s", obj_ce ? obj_ce->name : (zstr)EMPTY_STR, obj_ce ? "::" : "", function_name);
}
if (!retval_ptr_ptr) {
if (retval) {
/* {{{ zend_user_it_get_current_key_default */
#if 0
-static int zend_user_it_get_current_key_default(zend_object_iterator *_iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
+static int zend_user_it_get_current_key_default(zend_object_iterator *_iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
{
*int_key = _iter->index;
return HASH_KEY_IS_LONG;
/* }}} */
/* {{{ zend_user_it_get_current_key */
-ZEND_API int zend_user_it_get_current_key(zend_object_iterator *_iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
+ZEND_API int zend_user_it_get_current_key(zend_object_iterator *_iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
{
zend_user_iterator *iter = (zend_user_iterator*)_iter;
zval *object = (zval*)iter->it.data;
return HASH_KEY_IS_LONG;
case IS_STRING:
- *str_key = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval));
+ str_key->s = estrndup(Z_STRVAL_P(retval), Z_STRLEN_P(retval));
*str_key_len = Z_STRLEN_P(retval)+1;
zval_ptr_dtor(&retval);
return HASH_KEY_IS_STRING;
case IS_UNICODE:
- *str_key = (char*)eustrndup(Z_USTRVAL_P(retval), Z_USTRLEN_P(retval));
+ str_key->u = eustrndup(Z_USTRVAL_P(retval), Z_USTRLEN_P(retval));
*str_key_len = Z_USTRLEN_P(retval)+1;
zval_ptr_dtor(&retval);
return HASH_KEY_IS_UNICODE;
ZEND_API void zend_user_it_rewind(zend_object_iterator *_iter TSRMLS_DC);
ZEND_API int zend_user_it_valid(zend_object_iterator *_iter TSRMLS_DC);
-ZEND_API int zend_user_it_get_current_key(zend_object_iterator *_iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC);
+ZEND_API int zend_user_it_get_current_key(zend_object_iterator *_iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC);
ZEND_API void zend_user_it_get_current_data(zend_object_iterator *_iter, zval ***data TSRMLS_DC);
ZEND_API void zend_user_it_move_forward(zend_object_iterator *_iter TSRMLS_DC);
ZEND_API void zend_user_it_invalidate_current(zend_object_iterator *_iter TSRMLS_DC);
ZEND_API void zend_register_iterator_wrapper(TSRMLS_D)
{
INIT_CLASS_ENTRY(zend_iterator_class_entry, "__iterator_wrapper", NULL);
- free(zend_iterator_class_entry.name);
- zend_iterator_class_entry.name = "__iterator_wrapper";
+ free(zend_iterator_class_entry.name.s);
+ zend_iterator_class_entry.name.s = "__iterator_wrapper";
}
static void iter_wrapper_dtor(void *object, zend_object_handle handle TSRMLS_DC)
void (*get_current_data)(zend_object_iterator *iter, zval ***data TSRMLS_DC);
/* fetch the key for the current element (return HASH_KEY_IS_STRING or HASH_KEY_IS_LONG) (optional, may be NULL) */
- int (*get_current_key)(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC);
+ int (*get_current_key)(zend_object_iterator *iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC);
/* step forwards to next element */
void (*move_forward)(zend_object_iterator *iter TSRMLS_DC);
}
}
-static inline int zend_uchar_from_uname(UChar *name, int32_t name_len, UChar32 *c)
+static inline int zend_uchar_from_uname(UChar *name, int name_len, UChar32 *c)
{
UChar32 codepoint = 0;
UErrorCode status = U_ZERO_ERROR;
static inline int zend_copy_string_value(zval *zendlval, char *str, zend_uint str_len, zend_uchar type TSRMLS_DC)
{
UErrorCode status = U_ZERO_ERROR;
- int32_t consumed = 0;
+ int consumed = 0;
if (type == IS_UNICODE) {
consumed = zend_convert_scanner_output(&Z_USTRVAL_P(zendlval), &Z_USTRLEN_P(zendlval), str, str_len, &status TSRMLS_CC);
static inline int zend_check_and_normalize_identifier(zval *zendlval)
{
UChar *norm;
- int32_t norm_len;
+ int norm_len;
if (!zend_is_valid_identifier(Z_USTRVAL_P(zendlval), Z_USTRLEN_P(zendlval))) {
zend_error(E_COMPILE_WARNING, "Invalid identifier syntax: %r", Z_USTRVAL_P(zendlval));
return zend_set_converter_encoding(&SCNG(output_conv), encoding);
}
-ZEND_API int32_t zend_convert_scanner_output(UChar **target, int32_t *target_len, const char *source, int32_t source_len, UErrorCode *status TSRMLS_DC)
+ZEND_API int zend_convert_scanner_output(UChar **target, int *target_len, const char *source, int source_len, UErrorCode *status TSRMLS_DC)
{
const char *source_consumed = NULL;
}
<ST_IN_SCRIPTING>"__CLASS__" {
- char *class_name = NULL;
+ zstr class_name = (zstr)NULL;
if (CG(active_class_entry)) {
class_name = CG(active_class_entry)->name;
}
- if (!class_name) {
+ if (!class_name.v) {
ZVAL_EMPTY_TEXT(zendlval);
} else {
ZVAL_TEXT(zendlval, class_name, 1);
}
<ST_IN_SCRIPTING>"__FUNCTION__" {
- char *func_name = NULL;
+ zstr func_name = (zstr)NULL;
if (CG(active_op_array)) {
func_name = CG(active_op_array)->function_name;
}
- if (!func_name) {
- func_name = "";
- }
- if (!func_name) {
+ if (!func_name.v) {
ZVAL_EMPTY_TEXT(zendlval);
} else {
ZVAL_TEXT(zendlval, func_name, 1);
}
<ST_IN_SCRIPTING>"__METHOD__" {
- char *class_name = CG(active_class_entry) ? CG(active_class_entry)->name : NULL;
- char *func_name = CG(active_op_array)? CG(active_op_array)->function_name : NULL;
+ 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;
size_t len = 0;
if (UG(unicode)) {
size_t len1;
- if (class_name) {
- len += len1 = u_strlen((UChar*)class_name);
+ if (class_name.u) {
+ len += len1 = u_strlen(class_name.u);
len += 2;
}
- if (func_name) {
- len += u_strlen((UChar*)func_name);
+ if (func_name.u) {
+ len += u_strlen(func_name.u);
} else {
- func_name = (char*)EMPTY_STR;
+ func_name.u = EMPTY_STR;
}
Z_USTRLEN_P(zendlval) = len;
Z_USTRVAL_P(zendlval) = eumalloc(len+1);
- if (class_name) {
- u_strcpy(Z_USTRVAL_P(zendlval), (UChar*)class_name);
+ if (class_name.u) {
+ u_strcpy(Z_USTRVAL_P(zendlval), class_name.u);
Z_USTRVAL_P(zendlval)[len1] = 0x3a; /* ':' */
Z_USTRVAL_P(zendlval)[len1+1] = 0x3a; /* ':' */
Z_USTRVAL_P(zendlval)[len1+2] = 0;
} else {
Z_USTRVAL_P(zendlval)[0] = 0;
}
- u_strcat(Z_USTRVAL_P(zendlval), (UChar*)func_name);
+ u_strcat(Z_USTRVAL_P(zendlval), func_name.u);
Z_TYPE_P(zendlval) = IS_UNICODE;
} else {
- if (class_name) {
- len += strlen(class_name) + 2;
+ if (class_name.s) {
+ len += strlen(class_name.s) + 2;
}
- if (func_name) {
- len += strlen(func_name);
+ if (func_name.s) {
+ len += strlen(func_name.s);
}
Z_STRVAL_P(zendlval) = emalloc(len+1);
Z_STRLEN_P(zendlval) = sprintf(Z_STRVAL_P(zendlval), "%s%s%s",
- class_name ? class_name : "",
- class_name && func_name ? "::" : "",
- func_name ? func_name : ""
+ class_name.s ? class_name.s : "",
+ class_name.s && func_name.s ? "::" : "",
+ func_name.s ? func_name.s : ""
);
Z_STRLEN_P(zendlval) = strlen(Z_STRVAL_P(zendlval));
Z_TYPE_P(zendlval) = IS_STRING;
va_list resource_types;
int i;
char *space;
- char *class_name;
+ zstr class_name;
if (default_id==-1) { /* use id */
if (!passed_id) {
}
-ZEND_API int zend_check_property_access(zend_object *zobj, zend_uchar utype, void *prop_info_name TSRMLS_DC)
+ZEND_API int zend_check_property_access(zend_object *zobj, zend_uchar utype, zstr prop_info_name TSRMLS_DC)
{
zend_property_info *property_info;
- char *class_name, *prop_name;
+ zstr class_name, prop_name;
zval member;
zend_u_unmangle_property_name(utype, prop_info_name, &class_name, &prop_name);
if (utype == IS_UNICODE) {
- ZVAL_UNICODE(&member, (UChar*)prop_name, 0);
+ ZVAL_UNICODE(&member, prop_name.u, 0);
} else {
- ZVAL_STRING(&member, prop_name, 0);
+ ZVAL_STRING(&member, prop_name.s, 0);
}
property_info = zend_get_property_info(zobj->ce, &member, 1 TSRMLS_CC);
if (!property_info) {
return FAILURE;
}
- if (class_name && class_name[0] != '*') {
+ if (class_name.s && class_name.s[0] != '*') {
if (!(property_info->flags & ZEND_ACC_PRIVATE)) {
/* we we're looking for a private prop but found a non private one of the same name */
return FAILURE;
- } else if (!UG(unicode) && strcmp((char*)prop_info_name+1, property_info->name+1)) {
+ } else if (!UG(unicode) && strcmp(prop_info_name.s+1, property_info->name.s+1)) {
/* we we're looking for a private prop but found a private one of the same name but another class */
return FAILURE;
- } else if (UG(unicode) && u_strcmp(((UChar*)prop_info_name)+1, ((UChar*)property_info->name)+1)) {
+ } else if (UG(unicode) && u_strcmp(prop_info_name.u+1, property_info->name.u+1)) {
/* we we're looking for a private prop but found a private one of the same name but another class */
return FAILURE;
}
property_info = &info;
info.name = Z_UNIVAL_P(member);
info.name_length = Z_UNILEN_P(member);
- info.h = zend_u_get_hash_value(Z_TYPE_P(member), Z_STRVAL_P(member), Z_STRLEN_P(member) + 1);
+ info.h = zend_u_get_hash_value(Z_TYPE_P(member), Z_UNIVAL_P(member), Z_UNILEN_P(member) + 1);
}
if (!zobj->guards) {
ALLOC_HASHTABLE(zobj->guards);
* Returns the function address that should be called, or NULL
* if no such function exists.
*/
-static inline zend_function *zend_check_private_int(zend_function *fbc, zend_class_entry *ce, char *function_name_strval, int function_name_strlen TSRMLS_DC)
+static inline zend_function *zend_check_private_int(zend_function *fbc, zend_class_entry *ce, zstr function_name_strval, int function_name_strlen TSRMLS_DC)
{
if (!ce) {
return 0;
}
-ZEND_API int zend_check_private(zend_function *fbc, zend_class_entry *ce, char *function_name_strval, int function_name_strlen TSRMLS_DC)
+ZEND_API int zend_check_private(zend_function *fbc, zend_class_entry *ce, zstr function_name_strval, int function_name_strlen TSRMLS_DC)
{
return zend_check_private_int(fbc, ce, function_name_strval, function_name_strlen TSRMLS_CC) != NULL;
}
}
-static union _zend_function *zend_std_get_method(zval **object_ptr, char *method_name, int method_len TSRMLS_DC)
+static union _zend_function *zend_std_get_method(zval **object_ptr, zstr method_name, int method_len TSRMLS_DC)
{
zend_object *zobj;
zend_function *fbc;
unsigned int lc_method_name_len;
- char *lc_method_name;
+ zstr lc_method_name;
zval *object = *object_ptr;
/* FIXME: type is default */
zobj = Z_OBJ_P(object);
if (zend_u_hash_find(&zobj->ce->function_table, type, lc_method_name, lc_method_name_len+1, (void **)&fbc) == FAILURE) {
- efree(lc_method_name);
+ efree(lc_method_name.v);
if (zobj->ce->__call) {
zend_internal_function *call_user_call = emalloc(sizeof(zend_internal_function));
call_user_call->type = ZEND_INTERNAL_FUNCTION;
call_user_call->scope = zobj->ce;
call_user_call->fn_flags = 0;
if (UG(unicode)) {
- call_user_call->function_name = (char*)eustrndup((UChar*)method_name, method_len);
+ call_user_call->function_name.u = eustrndup(method_name.u, method_len);
} else {
- call_user_call->function_name = estrndup(method_name, method_len);
+ call_user_call->function_name.s = estrndup(method_name.s, method_len);
}
call_user_call->pass_rest_by_reference = 0;
call_user_call->return_reference = ZEND_RETURN_VALUE;
*/
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 : (char*)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 : (zstr)EMPTY_STR);
}
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 : (char*)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 : (zstr)EMPTY_STR);
}
}
- efree(lc_method_name);
+ efree(lc_method_name.v);
return fbc;
}
/* This is not (yet?) in the API, but it belongs in the built-in objects callbacks */
-ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, char *function_name_strval, int function_name_strlen TSRMLS_DC)
+ZEND_API zend_function *zend_std_get_static_method(zend_class_entry *ce, zstr function_name_strval, int function_name_strlen TSRMLS_DC)
{
zend_function *fbc;
/* FIXME: type is default */
zend_uchar type = UG(unicode)?IS_UNICODE:IS_STRING;
if (zend_u_hash_find(&ce->function_table, type, function_name_strval, function_name_strlen+1, (void **) &fbc)==FAILURE) {
- char *class_name = ce->name;
+ zstr class_name = ce->name;
- if (!class_name) {
- class_name = (char*)EMPTY_STR;
+ if (!class_name.v) {
+ class_name.u = EMPTY_STR;
}
zend_error(E_ERROR, "Call to undefined method %R::%R()", type, class_name, type, function_name_strval);
}
*/
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 : (char*)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 : (zstr)EMPTY_STR);
}
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 : (char*)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 : (zstr)EMPTY_STR);
}
}
}
-ZEND_API zval **zend_std_get_static_property(zend_class_entry *ce, zend_uchar type, void *property_name, int property_name_len, zend_bool silent TSRMLS_DC)
+ZEND_API zval **zend_std_get_static_property(zend_class_entry *ce, zend_uchar type, zstr property_name, int property_name_len, zend_bool silent TSRMLS_DC)
{
zval **retval = NULL;
zend_class_entry *tmp_ce = ce;
std_property_info.flags = ZEND_ACC_PUBLIC;
std_property_info.name = property_name;
std_property_info.name_length = property_name_len;
- std_property_info.h = zend_get_hash_value(std_property_info.name, std_property_info.name_length+1);
+ std_property_info.h = zend_u_get_hash_value(UG(unicode)?IS_UNICODE:IS_STRING, std_property_info.name, std_property_info.name_length+1);
property_info = &std_property_info;
}
}
-ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_uchar type, void *property_name, int property_name_len TSRMLS_DC)
+ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_uchar type, zstr property_name, int property_name_len TSRMLS_DC)
{
zend_error(E_ERROR, "Attempt to unset static property %v::$%R", ce->name, type, property_name);
return 0;
/* 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 : (char*)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 : (zstr)EMPTY_STR);
}
} 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 : (char*)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 : (zstr)EMPTY_STR);
}
}
}
return zobj->ce;
}
-int zend_std_object_get_class_name(zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC)
+int zend_std_object_get_class_name(zval *object, zstr *class_name, zend_uint *class_name_len, int parent TSRMLS_DC)
{
zend_object *zobj;
zend_class_entry *ce;
*class_name_len = ce->name_length;
if (UG(unicode)) {
- *class_name = (char*)eustrndup((UChar*)ce->name, ce->name_length);
+ class_name->u = eustrndup(ce->name.u, ce->name_length);
} else {
- *class_name = estrndup(ce->name, ce->name_length);
+ class_name->s = estrndup(ce->name.s, ce->name_length);
}
return SUCCESS;
}
/* args on stack! */
/* Andi - EX(fbc) (function being called) needs to be initialized already in the INIT fcall opcode so that the parameters can be parsed the right way. We need to add another callback for this.
*/
-typedef int (*zend_object_call_method_t)(char *method, INTERNAL_FUNCTION_PARAMETERS);
-typedef union _zend_function *(*zend_object_get_method_t)(zval **object_ptr, char *method, int method_len TSRMLS_DC);
+typedef int (*zend_object_call_method_t)(zstr method, INTERNAL_FUNCTION_PARAMETERS);
+typedef union _zend_function *(*zend_object_get_method_t)(zval **object_ptr, zstr method, int method_len TSRMLS_DC);
typedef union _zend_function *(*zend_object_get_constructor_t)(zval *object TSRMLS_DC);
/* Object maintenance/destruction */
typedef zend_object_value (*zend_object_clone_obj_t)(zval *object TSRMLS_DC);
typedef zend_class_entry *(*zend_object_get_class_entry_t)(zval *object TSRMLS_DC);
-typedef int (*zend_object_get_class_name_t)(zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC);
+typedef int (*zend_object_get_class_name_t)(zval *object, zstr *class_name, zend_uint *class_name_len, int parent TSRMLS_DC);
typedef int (*zend_object_compare_t)(zval *object1, zval *object2 TSRMLS_DC);
/* Cast an object to some other type
extern ZEND_API zend_object_handlers std_object_handlers;
BEGIN_EXTERN_C()
-ZEND_API union _zend_function *zend_std_get_static_method(zend_class_entry *ce, char *function_name_strval, int function_name_strlen TSRMLS_DC);
-ZEND_API zval **zend_std_get_static_property(zend_class_entry *ce, zend_uchar type, void *property_name, int property_name_len, zend_bool silent TSRMLS_DC);
-ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_uchar type, void *property_name, int property_name_len TSRMLS_DC);
+ZEND_API union _zend_function *zend_std_get_static_method(zend_class_entry *ce, zstr function_name_strval, int function_name_strlen TSRMLS_DC);
+ZEND_API zval **zend_std_get_static_property(zend_class_entry *ce, zend_uchar type, zstr property_name, int property_name_len, zend_bool silent TSRMLS_DC);
+ZEND_API zend_bool zend_std_unset_static_property(zend_class_entry *ce, zend_uchar type, zstr property_name, int property_name_len TSRMLS_DC);
ZEND_API struct _zend_property_info *zend_get_property_info(zend_class_entry *ce, zval *member, int silent TSRMLS_DC);
ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int type TSRMLS_DC);
#define IS_ZEND_STD_OBJECT(z) (Z_TYPE(z) == IS_OBJECT && (Z_OBJ_HT((z))->get_class_entry != NULL))
#define HAS_CLASS_ENTRY(z) (Z_OBJ_HT(z)->get_class_entry != NULL)
-ZEND_API int zend_check_private(union _zend_function *fbc, zend_class_entry *ce, char *function_name_strval, int function_name_strlen TSRMLS_DC);
+ZEND_API int zend_check_private(union _zend_function *fbc, zend_class_entry *ce, zstr function_name_strval, int function_name_strlen TSRMLS_DC);
ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope);
-ZEND_API int zend_check_property_access(zend_object *zobj, zend_uchar utype, void *prop_info_name TSRMLS_DC);
+ZEND_API int zend_check_property_access(zend_object *zobj, zend_uchar utype, zstr prop_info_name TSRMLS_DC);
ZEND_API void zend_std_call_user_call(INTERNAL_FUNCTION_PARAMETERS);
END_EXTERN_C()
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 : (char*)EMPTY_STR,
+ EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR,
EG(in_execution) ? "" : " during shutdown ignored");
return;
}
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 : (char*)EMPTY_STR,
+ EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR,
EG(in_execution) ? "" : " during shutdown ignored");
return;
}
op_array->T = 0;
- op_array->function_name = NULL;
+ op_array->function_name.v = NULL;
op_array->filename = zend_get_compiled_filename(TSRMLS_C);
op_array->script_encoding = zend_get_compiled_script_encoding(TSRMLS_C);
op_array->doc_comment = NULL;
zend_hash_destroy(&ce->default_properties);
zend_hash_destroy(&ce->properties_info);
zend_hash_destroy(&ce->default_static_members);
- efree(ce->name);
+ efree(ce->name.v);
zend_hash_destroy(&ce->function_table);
zend_hash_destroy(&ce->constants_table);
if (ce->num_interfaces > 0 && ce->interfaces) {
zend_hash_destroy(&ce->default_properties);
zend_hash_destroy(&ce->properties_info);
zend_hash_destroy(&ce->default_static_members);
- free(ce->name);
+ free(ce->name.v);
zend_hash_destroy(&ce->function_table);
zend_hash_destroy(&ce->constants_table);
if (ce->num_interfaces > 0) {
i = op_array->last_var;
while (i > 0) {
i--;
- efree(op_array->vars[i].name);
+ efree(op_array->vars[i].name.v);
}
efree(op_array->vars);
}
}
efree(op_array->opcodes);
- if (op_array->function_name) {
- efree(op_array->function_name);
+ if (op_array->function_name.v) {
+ efree(op_array->function_name.v);
}
if (op_array->doc_comment) {
efree(op_array->doc_comment);
}
if (op_array->arg_info) {
for (i=0; i<op_array->num_args; i++) {
- efree(op_array->arg_info[i].name);
- if (op_array->arg_info[i].class_name) {
- efree(op_array->arg_info[i].class_name);
+ efree(op_array->arg_info[i].name.v);
+ if (op_array->arg_info[i].class_name.v) {
+ efree(op_array->arg_info[i].class_name.v);
}
}
efree(op_array->arg_info);
break;
case IS_RESOURCE: {
long tmp = Z_LVAL_P(op);
- TSRMLS_FETCH();
zend_list_delete(Z_LVAL_P(op));
Z_USTRVAL_P(op) = eumalloc_rel(sizeof("Resource id #")-1 + MAX_LENGTH_OF_LONG + 1);
break;
}
case IS_LONG: {
- int32_t capacity = MAX_LENGTH_OF_LONG + 1;
long lval = Z_LVAL_P(op);
- Z_USTRVAL_P(op) = eumalloc_rel(capacity);
+ Z_USTRVAL_P(op) = eumalloc_rel(MAX_LENGTH_OF_LONG + 1);
Z_USTRLEN_P(op) = u_sprintf(Z_USTRVAL_P(op), "%ld", lval);
break;
}
case IS_DOUBLE: {
- int32_t capacity;
double dval = Z_DVAL_P(op);
- TSRMLS_FETCH();
- capacity = MAX_LENGTH_OF_DOUBLE + EG(precision) + 1;
- Z_USTRVAL_P(op) = eumalloc_rel(capacity);
+ Z_USTRVAL_P(op) = eumalloc_rel(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1);
Z_USTRLEN_P(op) = u_sprintf(Z_USTRVAL_P(op), "%.*G", (int) EG(precision), dval);
break;
}
Z_USTRLEN_P(op) = sizeof("Array")-1;
break;
case IS_OBJECT: {
- TSRMLS_FETCH();
-
convert_object_to_type(op, IS_UNICODE, convert_to_unicode);
if (Z_TYPE_P(op) == IS_UNICODE) {
assert(Z_TYPE_P(op1) == Z_TYPE_P(op2));
if (Z_TYPE_P(op1) == IS_UNICODE) {
- int32_t length = Z_USTRLEN_P(op1) + Z_USTRLEN_P(op2);
+ int length = Z_USTRLEN_P(op1) + Z_USTRLEN_P(op2);
Z_USTRVAL_P(result) = eurealloc(Z_USTRVAL_P(op1), length+1);
u_memcpy(Z_USTRVAL_P(result)+Z_USTRLEN_P(op1), Z_USTRVAL_P(op2), Z_USTRLEN_P(op2));
return zend_str_tolower_copy((char *)emalloc(length+1), source, length);
}
-ZEND_API void *zend_u_str_tolower_copy(zend_uchar type, void *dest, const void *source, unsigned int length)
+ZEND_API zstr zend_u_str_tolower_copy(zend_uchar type, zstr dest, zstr source, unsigned int length)
{
if (type == IS_UNICODE) {
- register UChar *str = (UChar*)source;
- register UChar *result = (UChar*)dest;
+ register UChar *str = source.u;
+ register UChar *result = dest.u;
register UChar *end = str + length;
while (str < end) {
return dest;
} else {
- return zend_str_tolower_copy(dest, source, length);
+ return (zstr)zend_str_tolower_copy(dest.s, source.s, length);
}
}
-ZEND_API void *zend_u_str_tolower_dup(zend_uchar type, const void *source, unsigned int length)
+ZEND_API zstr zend_u_str_tolower_dup(zend_uchar type, zstr source, unsigned int length)
{
if (type == IS_UNICODE) {
- return zend_u_str_tolower_copy(IS_UNICODE, emalloc(UBYTES(length+1)), source, length);
+ return zend_u_str_tolower_copy(IS_UNICODE, (zstr)emalloc(UBYTES(length+1)), source, length);
} else {
- return zend_str_tolower_copy((char*)emalloc(length+1), (char*)source, length);
+ return (zstr)zend_str_tolower_copy((char*)emalloc(length+1), source.s, length);
}
}
}
}
-ZEND_API void zend_u_str_tolower(zend_uchar type, void *str, unsigned int length) {
+ZEND_API void zend_u_str_tolower(zend_uchar type, zstr str, unsigned int length) {
if (type == IS_UNICODE) {
- register UChar *p = (UChar*)str;
+ register UChar *p = str.u;
register UChar *end = p + length;
while (p < end) {
p++;
}
} else {
- zend_str_tolower((char*)str, length);
+ zend_str_tolower(str.s, length);
}
}
-ZEND_API void *zend_u_str_case_fold(zend_uchar type, const void *source, unsigned int length, zend_bool normalize, unsigned int *new_len)
+ZEND_API zstr zend_u_str_case_fold(zend_uchar type, zstr source, unsigned int length, zend_bool normalize, unsigned int *new_len)
{
if (type == IS_UNICODE) {
UChar *ret;
- int32_t ret_len;
+ int ret_len;
if (normalize) {
- zend_normalize_identifier(&ret, &ret_len, (UChar*)source, length, 1);
+ zend_normalize_identifier(&ret, &ret_len, source.u, length, 1);
} else {
UErrorCode status = U_ZERO_ERROR;
- zend_case_fold_string(&ret, &ret_len, (UChar*)source, length, U_FOLD_CASE_DEFAULT, &status);
+ zend_case_fold_string(&ret, &ret_len, source.u, length, U_FOLD_CASE_DEFAULT, &status);
}
*new_len = ret_len;
- return ret;
+ return (zstr)ret;
} else {
*new_len = length;
- return zend_str_tolower_dup(source, length);
+ return (zstr)zend_str_tolower_dup(source.s, length);
}
}
}
-ZEND_API int zend_u_binary_strcmp(UChar *s1, int32_t len1, UChar *s2, int32_t len2)
+ZEND_API int zend_u_binary_strcmp(UChar *s1, int len1, UChar *s2, int len2)
{
- int32_t result = u_strCompare(s1, len1, s2, len2, 1);
+ int result = u_strCompare(s1, len1, s2, len2, 1);
return ZEND_NORMALIZE_BOOL(result);
}
}
-ZEND_API int zend_u_binary_strncmp(UChar *s1, int32_t len1, UChar *s2, int32_t len2, uint length)
+ZEND_API int zend_u_binary_strncmp(UChar *s1, int len1, UChar *s2, int len2, uint length)
{
int32_t off1 = 0, off2 = 0;
UChar32 c1, c2;
- int32_t result = 0;
+ int result = 0;
for( ; length > 0; --length) {
if (off1 >= len1 || off2 >= len2) {
}
-ZEND_API int zend_u_binary_strcasecmp(UChar *s1, int32_t len1, UChar *s2, int32_t len2)
+ZEND_API int zend_u_binary_strcasecmp(UChar *s1, int len1, UChar *s2, int len2)
{
UErrorCode status = U_ZERO_ERROR;
- int32_t result = u_strCaseCompare(s1, len1, s2, len2, U_COMPARE_CODE_POINT_ORDER, &status);
+ int result = u_strCaseCompare(s1, len1, s2, len2, U_COMPARE_CODE_POINT_ORDER, &status);
return ZEND_NORMALIZE_BOOL(result);
}
* codepoints to compare, we take a hit upfront by iterating over both strings
* until we find them. Then we can simply use u_strCaseCompare().
*/
-ZEND_API int zend_u_binary_strncasecmp(UChar *s1, int32_t len1, UChar *s2, int32_t len2, uint length)
+ZEND_API int zend_u_binary_strncasecmp(UChar *s1, int len1, UChar *s2, int len2, uint length)
{
UErrorCode status = U_ZERO_ERROR;
int32_t off1 = 0, off2 = 0;
- int32_t result;
+ int result;
U16_FWD_N(s1, off1, len1, length);
U16_FWD_N(s2, off2, len2, length);
{
double dval = Z_DVAL_P(op);
UFILE *strf;
- int32_t capacity;
+ int capacity;
TSRMLS_FETCH();
{
long lval = Z_LVAL_P(op);
UFILE *strf;
- int32_t capacity;
+ int capacity;
capacity = MAX_LENGTH_OF_LONG + 1;
Z_USTRVAL_P(op) = eumalloc_rel(capacity);
return 0;
}
-static inline zend_uchar is_numeric_unicode(UChar *str, int32_t length, long *lval, double *dval, zend_bool allow_errors)
+static inline zend_uchar is_numeric_unicode(UChar *str, int length, long *lval, double *dval, zend_bool allow_errors)
{
- int32_t local_lval;
+ long local_lval;
double local_dval;
UChar *end_ptr_long, *end_ptr_double;
int conv_base=10;
}
static inline UChar*
-zend_u_memnstr(UChar *haystack, UChar *needle, int32_t needle_len, UChar *end)
+zend_u_memnstr(UChar *haystack, UChar *needle, int needle_len, UChar *end)
{
return u_strFindFirst(haystack, end - haystack, needle, needle_len);
}
ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned int length);
ZEND_API char *zend_str_tolower_dup(const char *source, unsigned int length);
-ZEND_API void zend_u_str_tolower(zend_uchar type, void *str, unsigned int length);
-ZEND_API void *zend_u_str_tolower_copy(zend_uchar type, void *dest, const void *source, unsigned int length);
-ZEND_API void *zend_u_str_tolower_dup(zend_uchar type, const void *source, unsigned int length);
+ZEND_API void zend_u_str_tolower(zend_uchar type, zstr str, unsigned int length);
+ZEND_API zstr zend_u_str_tolower_copy(zend_uchar type, zstr dest, zstr source, unsigned int length);
+ZEND_API zstr zend_u_str_tolower_dup(zend_uchar type, zstr source, unsigned int length);
-ZEND_API void *zend_u_str_case_fold(zend_uchar type, const void *source, unsigned int length, zend_bool normalize, unsigned int *new_len);
+ZEND_API zstr zend_u_str_case_fold(zend_uchar type, zstr source, unsigned int length, zend_bool normalize, unsigned int *new_len);
ZEND_API int zend_binary_zval_strcmp(zval *s1, zval *s2);
ZEND_API int zend_binary_zval_strncmp(zval *s1, zval *s2, zval *s3);
ZEND_API int zend_binary_strncasecmp(char *s1, uint len1, char *s2, uint len2, uint length);
ZEND_API int zend_u_binary_zval_strcmp(zval *s1, zval *s2);
-ZEND_API int zend_u_binary_strcmp(UChar *s1, int32_t len1, UChar *s2, int32_t len2);
-ZEND_API int zend_u_binary_strncmp(UChar *s1, int32_t len1, UChar *s2, int32_t len2, uint length);
-ZEND_API int zend_u_binary_strcasecmp(UChar *s1, int32_t len1, UChar *s2, int32_t len2);
-ZEND_API int zend_u_binary_strncasecmp(UChar *s1, int32_t len1, UChar *s2, int32_t len2, uint length);
+ZEND_API int zend_u_binary_strcmp(UChar *s1, int len1, UChar *s2, int len2);
+ZEND_API int zend_u_binary_strncmp(UChar *s1, int len1, UChar *s2, int len2, uint length);
+ZEND_API int zend_u_binary_strcasecmp(UChar *s1, int len1, UChar *s2, int len2);
+ZEND_API int zend_u_binary_strncasecmp(UChar *s1, int len1, UChar *s2, int len2, uint length);
ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2);
ZEND_API void zendi_u_smart_strcmp(zval *result, zval *s1, zval *s2);
#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) (Z_TYPE(zval)==IS_UNICODE?(char*)Z_USTRVAL(zval):Z_STRVAL(zval))
-#define Z_UNILEN(zval) (Z_TYPE(zval)==IS_UNICODE?Z_USTRLEN(zval):Z_STRLEN(zval))
+#define Z_UNIVAL(zval) ((zstr)(Z_STRVAL(zval)))
+#define Z_UNILEN(zval) Z_STRLEN(zval)
#define Z_LVAL_P(zval_p) Z_LVAL(*zval_p)
#define Z_BVAL_P(zval_p) Z_BVAL(*zval_p)
register UChar c;
register unsigned long cutoff;
register int neg = 0, any, cutlim;
- register int32_t val;
+ register int val;
/*
* Skip white space and pick up leading +/- sign if any.
ZEND_API zend_unicode_globals unicode_globals;
#endif
-static void zend_from_unicode_substitute_cb(
- const void *context,
- UConverterFromUnicodeArgs *toUArgs,
- const char *codeUnits,
- int32_t length,
- UConverterCallbackReason reason,
- UErrorCode *err
- )
-{
- if (context == NULL) {
- if (reason > UCNV_IRREGULAR)
- {
- return;
- }
-
- *err = U_ZERO_ERROR;
- //ucnv_cbFromUWriteSub(fromArgs, 0, err);
- return;
- } else if (*((char*)context)=='i') {
- if (reason != UCNV_UNASSIGNED)
- {
- /* the caller must have set
- * the error code accordingly
- */
- return;
- } else {
- *err = U_ZERO_ERROR;
- //ucnv_cbFromUWriteSub(fromArgs, 0, err);
- return;
- }
- }
-}
-
/* {{{ zend_set_converter_error_mode */
void zend_set_converter_error_mode(UConverter *conv, uint8_t error_mode)
{
/* }}} */
/* {{{ zend_convert_to_unicode */
-ZEND_API void zend_convert_to_unicode(UConverter *conv, UChar **target, int32_t *target_len, const char *source, int32_t source_len, UErrorCode *status)
+ZEND_API void zend_convert_to_unicode(UConverter *conv, UChar **target, int *target_len, const char *source, int source_len, UErrorCode *status)
{
UChar *buffer = NULL;
UChar *output;
/* }}} */
/* {{{ zend_case_fold_string */
-ZEND_API void zend_case_fold_string(UChar **dest, int32_t *dest_len, UChar *src, int32_t src_len, uint32_t options, UErrorCode *status)
+ZEND_API void zend_case_fold_string(UChar **dest, int *dest_len, UChar *src, int src_len, uint32_t options, UErrorCode *status)
{
UChar *buffer = NULL;
int32_t buffer_len;
/* }}} */
/* {{{ zend_normalize_identifier */
-ZEND_API int zend_normalize_identifier(UChar **dest, int32_t *dest_len, UChar *ident, int32_t ident_len, zend_bool fold_case)
+ZEND_API int zend_normalize_identifier(UChar **dest, int *dest_len, UChar *ident, int ident_len, zend_bool fold_case)
{
UChar *buffer = NULL;
UChar *orig_ident = ident;
/* API functions */
-ZEND_API void zend_convert_to_unicode(UConverter *conv, UChar **target, int32_t *target_len, const char *source, int32_t source_len, UErrorCode *status);
+ZEND_API void zend_convert_to_unicode(UConverter *conv, UChar **target, int *target_len, const char *source, int source_len, UErrorCode *status);
ZEND_API void zend_convert_from_unicode(UConverter *conv, char **target, int32_t *target_len, const UChar *source, int32_t source_len, UErrorCode *status);
ZEND_API void zend_convert_encodings(UConverter *target_conv, UConverter *source_conv, char **target, int32_t *target_len, const char *source, int32_t source_len, UErrorCode *status);
ZEND_API int zval_string_to_unicode_ex(zval *string, UConverter *conv);
ZEND_API int zend_cmp_unicode_and_string(UChar *ustr, char* str, uint len);
ZEND_API int zend_cmp_unicode_and_literal(UChar *ustr, int32_t ulen, char* str, int32_t slen);
-ZEND_API void zend_case_fold_string(UChar **dest, int32_t *dest_len, UChar *src, int32_t src_len, uint32_t options, UErrorCode *status);
+ZEND_API void zend_case_fold_string(UChar **dest, int *dest_len, UChar *src, int src_len, uint32_t options, UErrorCode *status);
ZEND_API int zend_is_valid_identifier(UChar *ident, int32_t ident_len);
-ZEND_API int zend_normalize_identifier(UChar **dest, int32_t *dest_len, UChar *ident, int32_t ident_len, zend_bool fold_case);
+ZEND_API int zend_normalize_identifier(UChar **dest, int *dest_len, UChar *ident, int ident_len, zend_bool fold_case);
/*
* Function to get a codepoint at position n. Iterates over codepoints starting from the
#define USTR_FREE(ustr) do { if (ustr) { efree(ustr); } } while (0);
#define UBYTES(len) ((len) * sizeof(UChar))
-#define USTR_LEN(str) (UG(unicode)?u_strlen((UChar*)(str)):strlen((char*)(str)))
+#define USTR_LEN(str) (UG(unicode)?u_strlen((str).u):strlen((str).s))
#define USTR_MAKE(cs) zend_ascii_to_unicode(cs, sizeof(cs) ZEND_FILE_LINE_CC)
#define USTR_MAKE_REL(cs) zend_ascii_to_unicode(cs, sizeof(cs) ZEND_FILE_LINE_RELAY_CC)
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
zend_free_op free_op1, free_op2;
/* FIXME: type is default */
ce = EX_T(opline->op1.u.var).class_entry;
if(OP2_TYPE != IS_UNUSED) {
- char *function_name_strval;
+ zstr function_name_strval;
unsigned int function_name_strlen;
zend_bool is_const = (OP2_TYPE == IS_CONST);
zend_free_op free_op2;
EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC);
if (!is_const) {
- efree(function_name_strval);
+ efree(function_name_strval.v);
FREE_OP2();
}
} else {
zend_op *opline = EX(opline);
zval *function_name;
zend_function *function;
- void *function_name_strval, *lcname;
+ zstr function_name_strval, lcname;
unsigned int function_name_strlen, lcname_len;
zend_free_op free_op2;
function_name_strval = Z_UNIVAL_P(function_name);
function_name_strlen = Z_UNILEN_P(function_name);
- lcname = zend_u_str_case_fold(Z_TYPE_P(function_name), Z_STRVAL_P(function_name), function_name_strlen, 1, &lcname_len);
+ lcname = zend_u_str_case_fold(Z_TYPE_P(function_name), Z_UNIVAL_P(function_name), function_name_strlen, 1, &lcname_len);
if (zend_u_hash_find(EG(function_table), Z_TYPE_P(function_name), lcname, lcname_len+1, (void **) &function)==FAILURE) {
- efree(lcname);
+ efree(lcname.v);
zend_error_noreturn(E_ERROR, "Call to undefined function %R()", Z_TYPE_P(function_name), function_name_strval);
}
- efree(lcname);
+ efree(lcname.v);
if (OP2_TYPE != IS_CONST) {
FREE_OP2();
}
ZEND_VM_NEXT_OPCODE(); /* Never reached */
}
if (EX(function_state).function->common.fn_flags & ZEND_ACC_DEPRECATED) {
- zend_error(E_NOTICE, "Function %s%s%s() is deprecated",
- EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : "",
+ zend_error(E_NOTICE, "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.function_name);
}
}
if (EX(function_state).function->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
- efree(EX(function_state).function->common.function_name);
+ efree(EX(function_state).function->common.function_name.v);
}
efree(EX(fbc));
if (EG(ze1_compatibility_mode) && Z_TYPE_P(retval_ptr) == IS_OBJECT) {
zval *ret;
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
int dup;
INIT_PZVAL_COPY(ret, retval_ptr);
dup = zend_get_object_classname(retval_ptr, &class_name, &class_name_len TSRMLS_CC);
if (Z_OBJ_HT_P(retval_ptr)->clone_obj == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", Z_OBJCE_P(retval_ptr)->name);
+ zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", class_name);
}
- zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(retval_ptr)->name);
+ zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", class_name);
Z_OBJVAL_P(ret) = Z_OBJ_HT_P(retval_ptr)->clone_obj(retval_ptr TSRMLS_CC);
*EG(return_value_ptr_ptr) = ret;
if (!dup) {
- efree(class_name);
+ efree(class_name.v);
}
} else if (!IS_OP1_TMP_FREE()) { /* Not a temp var */
if (EG(active_op_array)->return_reference == ZEND_RETURN_REF ||
if (zend_ptr_stack_get_arg(arg_num, (void **) ¶m TSRMLS_CC)==FAILURE) {
char *space;
- char *class_name = get_active_class_name(&space TSRMLS_CC);
+ zstr class_name = get_active_class_name(&space TSRMLS_CC);
zend_execute_data *ptr = EX(prev_execute_data);
zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, NULL TSRMLS_CC);
/* 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 : (char*)EMPTY_STR);
+ zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
}
} 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 : (char*)EMPTY_STR);
+ zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
}
}
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == Z_UNILEN_P(varname) &&
- !memcmp(ex->op_array->vars[i].name, Z_UNIVAL_P(varname), Z_TYPE_P(varname)==IS_UNICODE?UBYTES(Z_UNILEN_P(varname)):Z_UNILEN_P(varname))) {
+ !memcmp(ex->op_array->vars[i].name.v, Z_UNIVAL_P(varname).v, Z_TYPE_P(varname)==IS_UNICODE?UBYTES(Z_UNILEN_P(varname)):Z_UNILEN_P(varname))) {
ex->CVs[i] = NULL;
break;
}
break;
case IS_STRING:
case IS_UNICODE: {
- void *offset_key = Z_UNIVAL_P(offset);
+ zstr offset_key = Z_UNIVAL_P(offset);
int offset_len = Z_UNILEN_P(offset);
int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
- zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ offset_key.u, offset_len, 0)) {
+ zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key.u);
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == offset_len &&
- !memcmp(ex->op_array->vars[i].name, offset_key, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
+ !memcmp(ex->op_array->vars[i].name.v, offset_key.v, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
ex->CVs[i] = NULL;
break;
}
}
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
if (ce) {
zend_object *zobj = zend_objects_get_address(array_ptr TSRMLS_CC);
while (zend_hash_has_more_elements(fe_ht) == SUCCESS) {
- char *str_key;
+ zstr str_key;
uint str_key_len;
ulong int_key;
zend_uchar key_type;
zend_free_op free_op1;
zval *array = GET_OP1_ZVAL_PTR(BP_VAR_R);
zval **value;
- char *str_key;
+ zstr str_key;
uint str_key_len;
ulong int_key;
HashTable *fe_ht;
ZEND_VM_JMP(EX(op_array)->opcodes+opline->op2.u.opline_num);
case ZEND_ITER_PLAIN_OBJECT: {
- char *class_name, *prop_name;
+ zstr class_name, prop_name;
zend_object *zobj = zend_objects_get_address(array TSRMLS_CC);
fe_ht = HASH_OF(array);
if (use_key) {
zend_u_unmangle_property_name(key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key, &class_name, &prop_name);
if (key_type == HASH_KEY_IS_UNICODE) {
- str_key_len = u_strlen((UChar*)prop_name);
- str_key = (char*)eustrndup((UChar*)prop_name, str_key_len);
+ str_key_len = u_strlen(prop_name.u);
+ str_key.u = eustrndup(prop_name.u, str_key_len);
} else {
- str_key_len = strlen(prop_name);
- str_key = estrndup(prop_name, str_key_len);
+ str_key_len = strlen(prop_name.s);
+ str_key.s = estrndup(prop_name.s, str_key_len);
}
str_key_len++;
}
switch (key_type) {
case HASH_KEY_IS_STRING:
- Z_STRVAL_P(key) = str_key;
+ Z_STRVAL_P(key) = str_key.s;
Z_STRLEN_P(key) = str_key_len-1;
Z_TYPE_P(key) = IS_STRING;
break;
case HASH_KEY_IS_UNICODE:
- Z_USTRVAL_P(key) = (UChar*)str_key;
+ Z_USTRVAL_P(key) = str_key.u;
Z_USTRLEN_P(key) = str_key_len-1;
Z_TYPE_P(key) = IS_UNICODE;
break;
break;
case IS_STRING:
case IS_UNICODE: {
- char *offset_key = Z_UNIVAL_P(offset);
- int offset_len = Z_UNILEN_P(offset);
- int free_offset = 0;
+ zstr offset_key = Z_UNIVAL_P(offset);
+ int offset_len = Z_UNILEN_P(offset);
+ int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
- if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
+ if (!zend_normalize_identifier(&norm, &norm_len, offset_key.u, offset_len, 0)) {
zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
isset = 1;
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
zval var_copy;
int use_copy;
UChar *norm;
- int32_t norm_len;
+ int norm_len;
zend_make_unicode_zval(result, &var_copy, &use_copy);
if (use_copy) {
ZEND_VM_NEXT_OPCODE(); /* Never reached */
}
if (EX(function_state).function->common.fn_flags & ZEND_ACC_DEPRECATED) {
- zend_error(E_NOTICE, "Function %s%s%s() is deprecated",
- EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : "",
+ zend_error(E_NOTICE, "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.function_name);
}
}
if (EX(function_state).function->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
- efree(EX(function_state).function->common.function_name);
+ efree(EX(function_state).function->common.function_name.v);
}
efree(EX(fbc));
if (zend_ptr_stack_get_arg(arg_num, (void **) ¶m TSRMLS_CC)==FAILURE) {
char *space;
- char *class_name = get_active_class_name(&space TSRMLS_CC);
+ zstr class_name = get_active_class_name(&space TSRMLS_CC);
zend_execute_data *ptr = EX(prev_execute_data);
zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, NULL TSRMLS_CC);
ce = EX_T(opline->op1.u.var).class_entry;
if(IS_CONST != IS_UNUSED) {
- char *function_name_strval;
+ zstr function_name_strval;
unsigned int function_name_strlen;
zend_bool is_const = (IS_CONST == IS_CONST);
EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC);
if (!is_const) {
- efree(function_name_strval);
+ efree(function_name_strval.v);
}
} else {
zend_op *opline = EX(opline);
zval *function_name;
zend_function *function;
- void *function_name_strval, *lcname;
+ zstr function_name_strval, lcname;
unsigned int function_name_strlen, lcname_len;
function_name_strval = Z_UNIVAL_P(function_name);
function_name_strlen = Z_UNILEN_P(function_name);
- lcname = zend_u_str_case_fold(Z_TYPE_P(function_name), Z_STRVAL_P(function_name), function_name_strlen, 1, &lcname_len);
+ lcname = zend_u_str_case_fold(Z_TYPE_P(function_name), Z_UNIVAL_P(function_name), function_name_strlen, 1, &lcname_len);
if (zend_u_hash_find(EG(function_table), Z_TYPE_P(function_name), lcname, lcname_len+1, (void **) &function)==FAILURE) {
- efree(lcname);
+ efree(lcname.v);
zend_error_noreturn(E_ERROR, "Call to undefined function %R()", Z_TYPE_P(function_name), function_name_strval);
}
- efree(lcname);
+ efree(lcname.v);
if (IS_CONST != IS_CONST) {
}
ce = EX_T(opline->op1.u.var).class_entry;
if(IS_TMP_VAR != IS_UNUSED) {
- char *function_name_strval;
+ zstr function_name_strval;
unsigned int function_name_strlen;
zend_bool is_const = (IS_TMP_VAR == IS_CONST);
zend_free_op free_op2;
EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC);
if (!is_const) {
- efree(function_name_strval);
+ efree(function_name_strval.v);
zval_dtor(free_op2.var);
}
} else {
zend_op *opline = EX(opline);
zval *function_name;
zend_function *function;
- void *function_name_strval, *lcname;
+ zstr function_name_strval, lcname;
unsigned int function_name_strlen, lcname_len;
zend_free_op free_op2;
function_name_strval = Z_UNIVAL_P(function_name);
function_name_strlen = Z_UNILEN_P(function_name);
- lcname = zend_u_str_case_fold(Z_TYPE_P(function_name), Z_STRVAL_P(function_name), function_name_strlen, 1, &lcname_len);
+ lcname = zend_u_str_case_fold(Z_TYPE_P(function_name), Z_UNIVAL_P(function_name), function_name_strlen, 1, &lcname_len);
if (zend_u_hash_find(EG(function_table), Z_TYPE_P(function_name), lcname, lcname_len+1, (void **) &function)==FAILURE) {
- efree(lcname);
+ efree(lcname.v);
zend_error_noreturn(E_ERROR, "Call to undefined function %R()", Z_TYPE_P(function_name), function_name_strval);
}
- efree(lcname);
+ efree(lcname.v);
if (IS_TMP_VAR != IS_CONST) {
zval_dtor(free_op2.var);
}
ce = EX_T(opline->op1.u.var).class_entry;
if(IS_VAR != IS_UNUSED) {
- char *function_name_strval;
+ zstr function_name_strval;
unsigned int function_name_strlen;
zend_bool is_const = (IS_VAR == IS_CONST);
zend_free_op free_op2;
EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC);
if (!is_const) {
- efree(function_name_strval);
+ efree(function_name_strval.v);
if (free_op2.var) {zval_ptr_dtor(&free_op2.var);};
}
} else {
zend_op *opline = EX(opline);
zval *function_name;
zend_function *function;
- void *function_name_strval, *lcname;
+ zstr function_name_strval, lcname;
unsigned int function_name_strlen, lcname_len;
zend_free_op free_op2;
function_name_strval = Z_UNIVAL_P(function_name);
function_name_strlen = Z_UNILEN_P(function_name);
- lcname = zend_u_str_case_fold(Z_TYPE_P(function_name), Z_STRVAL_P(function_name), function_name_strlen, 1, &lcname_len);
+ lcname = zend_u_str_case_fold(Z_TYPE_P(function_name), Z_UNIVAL_P(function_name), function_name_strlen, 1, &lcname_len);
if (zend_u_hash_find(EG(function_table), Z_TYPE_P(function_name), lcname, lcname_len+1, (void **) &function)==FAILURE) {
- efree(lcname);
+ efree(lcname.v);
zend_error_noreturn(E_ERROR, "Call to undefined function %R()", Z_TYPE_P(function_name), function_name_strval);
}
- efree(lcname);
+ efree(lcname.v);
if (IS_VAR != IS_CONST) {
if (free_op2.var) {zval_ptr_dtor(&free_op2.var);};
}
ce = EX_T(opline->op1.u.var).class_entry;
if(IS_UNUSED != IS_UNUSED) {
- char *function_name_strval;
+ zstr function_name_strval;
unsigned int function_name_strlen;
zend_bool is_const = (IS_UNUSED == IS_CONST);
EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC);
if (!is_const) {
- efree(function_name_strval);
+ efree(function_name_strval.v);
}
} else {
ce = EX_T(opline->op1.u.var).class_entry;
if(IS_CV != IS_UNUSED) {
- char *function_name_strval;
+ zstr function_name_strval;
unsigned int function_name_strlen;
zend_bool is_const = (IS_CV == IS_CONST);
EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC);
if (!is_const) {
- efree(function_name_strval);
+ efree(function_name_strval.v);
}
} else {
zend_op *opline = EX(opline);
zval *function_name;
zend_function *function;
- void *function_name_strval, *lcname;
+ zstr function_name_strval, lcname;
unsigned int function_name_strlen, lcname_len;
function_name_strval = Z_UNIVAL_P(function_name);
function_name_strlen = Z_UNILEN_P(function_name);
- lcname = zend_u_str_case_fold(Z_TYPE_P(function_name), Z_STRVAL_P(function_name), function_name_strlen, 1, &lcname_len);
+ lcname = zend_u_str_case_fold(Z_TYPE_P(function_name), Z_UNIVAL_P(function_name), function_name_strlen, 1, &lcname_len);
if (zend_u_hash_find(EG(function_table), Z_TYPE_P(function_name), lcname, lcname_len+1, (void **) &function)==FAILURE) {
- efree(lcname);
+ efree(lcname.v);
zend_error_noreturn(E_ERROR, "Call to undefined function %R()", Z_TYPE_P(function_name), function_name_strval);
}
- efree(lcname);
+ efree(lcname.v);
if (IS_CV != IS_CONST) {
}
if (EG(ze1_compatibility_mode) && Z_TYPE_P(retval_ptr) == IS_OBJECT) {
zval *ret;
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
int dup;
INIT_PZVAL_COPY(ret, retval_ptr);
dup = zend_get_object_classname(retval_ptr, &class_name, &class_name_len TSRMLS_CC);
if (Z_OBJ_HT_P(retval_ptr)->clone_obj == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", Z_OBJCE_P(retval_ptr)->name);
+ zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", class_name);
}
- zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(retval_ptr)->name);
+ zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", class_name);
Z_OBJVAL_P(ret) = Z_OBJ_HT_P(retval_ptr)->clone_obj(retval_ptr TSRMLS_CC);
*EG(return_value_ptr_ptr) = ret;
if (!dup) {
- efree(class_name);
+ efree(class_name.v);
}
} else if (!0) { /* Not a temp var */
if (EG(active_op_array)->return_reference == ZEND_RETURN_REF ||
/* 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 : (char*)EMPTY_STR);
+ zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
}
} 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 : (char*)EMPTY_STR);
+ zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
}
}
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == Z_UNILEN_P(varname) &&
- !memcmp(ex->op_array->vars[i].name, Z_UNIVAL_P(varname), Z_TYPE_P(varname)==IS_UNICODE?UBYTES(Z_UNILEN_P(varname)):Z_UNILEN_P(varname))) {
+ !memcmp(ex->op_array->vars[i].name.v, Z_UNIVAL_P(varname).v, Z_TYPE_P(varname)==IS_UNICODE?UBYTES(Z_UNILEN_P(varname)):Z_UNILEN_P(varname))) {
ex->CVs[i] = NULL;
break;
}
if (ce) {
zend_object *zobj = zend_objects_get_address(array_ptr TSRMLS_CC);
while (zend_hash_has_more_elements(fe_ht) == SUCCESS) {
- char *str_key;
+ zstr str_key;
uint str_key_len;
ulong int_key;
zend_uchar key_type;
zval var_copy;
int use_copy;
UChar *norm;
- int32_t norm_len;
+ int norm_len;
zend_make_unicode_zval(result, &var_copy, &use_copy);
if (use_copy) {
if (EG(ze1_compatibility_mode) && Z_TYPE_P(retval_ptr) == IS_OBJECT) {
zval *ret;
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
int dup;
INIT_PZVAL_COPY(ret, retval_ptr);
dup = zend_get_object_classname(retval_ptr, &class_name, &class_name_len TSRMLS_CC);
if (Z_OBJ_HT_P(retval_ptr)->clone_obj == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", Z_OBJCE_P(retval_ptr)->name);
+ zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", class_name);
}
- zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(retval_ptr)->name);
+ zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", class_name);
Z_OBJVAL_P(ret) = Z_OBJ_HT_P(retval_ptr)->clone_obj(retval_ptr TSRMLS_CC);
*EG(return_value_ptr_ptr) = ret;
if (!dup) {
- efree(class_name);
+ efree(class_name.v);
}
} else if (!1) { /* Not a temp var */
if (EG(active_op_array)->return_reference == ZEND_RETURN_REF ||
/* 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 : (char*)EMPTY_STR);
+ zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
}
} 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 : (char*)EMPTY_STR);
+ zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
}
}
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == Z_UNILEN_P(varname) &&
- !memcmp(ex->op_array->vars[i].name, Z_UNIVAL_P(varname), Z_TYPE_P(varname)==IS_UNICODE?UBYTES(Z_UNILEN_P(varname)):Z_UNILEN_P(varname))) {
+ !memcmp(ex->op_array->vars[i].name.v, Z_UNIVAL_P(varname).v, Z_TYPE_P(varname)==IS_UNICODE?UBYTES(Z_UNILEN_P(varname)):Z_UNILEN_P(varname))) {
ex->CVs[i] = NULL;
break;
}
if (ce) {
zend_object *zobj = zend_objects_get_address(array_ptr TSRMLS_CC);
while (zend_hash_has_more_elements(fe_ht) == SUCCESS) {
- char *str_key;
+ zstr str_key;
uint str_key_len;
ulong int_key;
zend_uchar key_type;
zval var_copy;
int use_copy;
UChar *norm;
- int32_t norm_len;
+ int norm_len;
zend_make_unicode_zval(result, &var_copy, &use_copy);
if (use_copy) {
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
zend_free_op free_op1;
/* FIXME: type is default */
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
zend_free_op free_op1, free_op2;
/* FIXME: type is default */
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
zend_free_op free_op1, free_op2;
/* FIXME: type is default */
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
zend_free_op free_op1;
/* FIXME: type is default */
if (EG(ze1_compatibility_mode) && Z_TYPE_P(retval_ptr) == IS_OBJECT) {
zval *ret;
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
int dup;
INIT_PZVAL_COPY(ret, retval_ptr);
dup = zend_get_object_classname(retval_ptr, &class_name, &class_name_len TSRMLS_CC);
if (Z_OBJ_HT_P(retval_ptr)->clone_obj == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", Z_OBJCE_P(retval_ptr)->name);
+ zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", class_name);
}
- zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(retval_ptr)->name);
+ zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", class_name);
Z_OBJVAL_P(ret) = Z_OBJ_HT_P(retval_ptr)->clone_obj(retval_ptr TSRMLS_CC);
*EG(return_value_ptr_ptr) = ret;
if (!dup) {
- efree(class_name);
+ efree(class_name.v);
}
} else if (!0) { /* Not a temp var */
if (EG(active_op_array)->return_reference == ZEND_RETURN_REF ||
/* 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 : (char*)EMPTY_STR);
+ zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
}
} 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 : (char*)EMPTY_STR);
+ zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
}
}
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == Z_UNILEN_P(varname) &&
- !memcmp(ex->op_array->vars[i].name, Z_UNIVAL_P(varname), Z_TYPE_P(varname)==IS_UNICODE?UBYTES(Z_UNILEN_P(varname)):Z_UNILEN_P(varname))) {
+ !memcmp(ex->op_array->vars[i].name.v, Z_UNIVAL_P(varname).v, Z_TYPE_P(varname)==IS_UNICODE?UBYTES(Z_UNILEN_P(varname)):Z_UNILEN_P(varname))) {
ex->CVs[i] = NULL;
break;
}
if (ce) {
zend_object *zobj = zend_objects_get_address(array_ptr TSRMLS_CC);
while (zend_hash_has_more_elements(fe_ht) == SUCCESS) {
- char *str_key;
+ zstr str_key;
uint str_key_len;
ulong int_key;
zend_uchar key_type;
zend_free_op free_op1;
zval *array = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC);
zval **value;
- char *str_key;
+ zstr str_key;
uint str_key_len;
ulong int_key;
HashTable *fe_ht;
ZEND_VM_JMP(EX(op_array)->opcodes+opline->op2.u.opline_num);
case ZEND_ITER_PLAIN_OBJECT: {
- char *class_name, *prop_name;
+ zstr class_name, prop_name;
zend_object *zobj = zend_objects_get_address(array TSRMLS_CC);
fe_ht = HASH_OF(array);
if (use_key) {
zend_u_unmangle_property_name(key_type == HASH_KEY_IS_UNICODE?IS_UNICODE:IS_STRING, str_key, &class_name, &prop_name);
if (key_type == HASH_KEY_IS_UNICODE) {
- str_key_len = u_strlen((UChar*)prop_name);
- str_key = (char*)eustrndup((UChar*)prop_name, str_key_len);
+ str_key_len = u_strlen(prop_name.u);
+ str_key.u = eustrndup(prop_name.u, str_key_len);
} else {
- str_key_len = strlen(prop_name);
- str_key = estrndup(prop_name, str_key_len);
+ str_key_len = strlen(prop_name.s);
+ str_key.s = estrndup(prop_name.s, str_key_len);
}
str_key_len++;
}
switch (key_type) {
case HASH_KEY_IS_STRING:
- Z_STRVAL_P(key) = str_key;
+ Z_STRVAL_P(key) = str_key.s;
Z_STRLEN_P(key) = str_key_len-1;
Z_TYPE_P(key) = IS_STRING;
break;
case HASH_KEY_IS_UNICODE:
- Z_USTRVAL_P(key) = (UChar*)str_key;
+ Z_USTRVAL_P(key) = str_key.u;
Z_USTRLEN_P(key) = str_key_len-1;
Z_TYPE_P(key) = IS_UNICODE;
break;
zval var_copy;
int use_copy;
UChar *norm;
- int32_t norm_len;
+ int norm_len;
zend_make_unicode_zval(result, &var_copy, &use_copy);
if (use_copy) {
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
zend_free_op free_op1;
/* FIXME: type is default */
break;
case IS_STRING:
case IS_UNICODE: {
- void *offset_key = Z_UNIVAL_P(offset);
+ zstr offset_key = Z_UNIVAL_P(offset);
int offset_len = Z_UNILEN_P(offset);
int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
- zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ offset_key.u, offset_len, 0)) {
+ zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key.u);
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == offset_len &&
- !memcmp(ex->op_array->vars[i].name, offset_key, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
+ !memcmp(ex->op_array->vars[i].name.v, offset_key.v, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
ex->CVs[i] = NULL;
break;
}
}
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
break;
case IS_STRING:
case IS_UNICODE: {
- char *offset_key = Z_UNIVAL_P(offset);
- int offset_len = Z_UNILEN_P(offset);
- int free_offset = 0;
+ zstr offset_key = Z_UNIVAL_P(offset);
+ int offset_len = Z_UNILEN_P(offset);
+ int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
- if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
+ if (!zend_normalize_identifier(&norm, &norm_len, offset_key.u, offset_len, 0)) {
zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
isset = 1;
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
zend_free_op free_op1, free_op2;
/* FIXME: type is default */
break;
case IS_STRING:
case IS_UNICODE: {
- void *offset_key = Z_UNIVAL_P(offset);
+ zstr offset_key = Z_UNIVAL_P(offset);
int offset_len = Z_UNILEN_P(offset);
int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
- zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ offset_key.u, offset_len, 0)) {
+ zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key.u);
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == offset_len &&
- !memcmp(ex->op_array->vars[i].name, offset_key, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
+ !memcmp(ex->op_array->vars[i].name.v, offset_key.v, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
ex->CVs[i] = NULL;
break;
}
}
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
break;
case IS_STRING:
case IS_UNICODE: {
- char *offset_key = Z_UNIVAL_P(offset);
- int offset_len = Z_UNILEN_P(offset);
- int free_offset = 0;
+ zstr offset_key = Z_UNIVAL_P(offset);
+ int offset_len = Z_UNILEN_P(offset);
+ int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
- if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
+ if (!zend_normalize_identifier(&norm, &norm_len, offset_key.u, offset_len, 0)) {
zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
isset = 1;
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
zend_free_op free_op1, free_op2;
/* FIXME: type is default */
break;
case IS_STRING:
case IS_UNICODE: {
- void *offset_key = Z_UNIVAL_P(offset);
+ zstr offset_key = Z_UNIVAL_P(offset);
int offset_len = Z_UNILEN_P(offset);
int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
- zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ offset_key.u, offset_len, 0)) {
+ zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key.u);
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == offset_len &&
- !memcmp(ex->op_array->vars[i].name, offset_key, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
+ !memcmp(ex->op_array->vars[i].name.v, offset_key.v, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
ex->CVs[i] = NULL;
break;
}
}
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
break;
case IS_STRING:
case IS_UNICODE: {
- char *offset_key = Z_UNIVAL_P(offset);
- int offset_len = Z_UNILEN_P(offset);
- int free_offset = 0;
+ zstr offset_key = Z_UNIVAL_P(offset);
+ int offset_len = Z_UNILEN_P(offset);
+ int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
- if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
+ if (!zend_normalize_identifier(&norm, &norm_len, offset_key.u, offset_len, 0)) {
zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
isset = 1;
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
zend_free_op free_op1;
/* FIXME: type is default */
break;
case IS_STRING:
case IS_UNICODE: {
- void *offset_key = Z_UNIVAL_P(offset);
+ zstr offset_key = Z_UNIVAL_P(offset);
int offset_len = Z_UNILEN_P(offset);
int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
- zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ offset_key.u, offset_len, 0)) {
+ zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key.u);
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == offset_len &&
- !memcmp(ex->op_array->vars[i].name, offset_key, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
+ !memcmp(ex->op_array->vars[i].name.v, offset_key.v, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
ex->CVs[i] = NULL;
break;
}
}
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
break;
case IS_STRING:
case IS_UNICODE: {
- char *offset_key = Z_UNIVAL_P(offset);
- int offset_len = Z_UNILEN_P(offset);
- int free_offset = 0;
+ zstr offset_key = Z_UNIVAL_P(offset);
+ int offset_len = Z_UNILEN_P(offset);
+ int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
- if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
+ if (!zend_normalize_identifier(&norm, &norm_len, offset_key.u, offset_len, 0)) {
zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
isset = 1;
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
/* 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 : (char*)EMPTY_STR);
+ zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
}
} 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 : (char*)EMPTY_STR);
+ zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
}
}
}
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
/* FIXME: type is default */
break;
case IS_STRING:
case IS_UNICODE: {
- void *offset_key = Z_UNIVAL_P(offset);
+ zstr offset_key = Z_UNIVAL_P(offset);
int offset_len = Z_UNILEN_P(offset);
int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
- zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ offset_key.u, offset_len, 0)) {
+ zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key.u);
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == offset_len &&
- !memcmp(ex->op_array->vars[i].name, offset_key, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
+ !memcmp(ex->op_array->vars[i].name.v, offset_key.v, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
ex->CVs[i] = NULL;
break;
}
}
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
break;
case IS_STRING:
case IS_UNICODE: {
- char *offset_key = Z_UNIVAL_P(offset);
- int offset_len = Z_UNILEN_P(offset);
- int free_offset = 0;
+ zstr offset_key = Z_UNIVAL_P(offset);
+ int offset_len = Z_UNILEN_P(offset);
+ int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
- if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
+ if (!zend_normalize_identifier(&norm, &norm_len, offset_key.u, offset_len, 0)) {
zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
isset = 1;
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
zend_free_op free_op2;
/* FIXME: type is default */
break;
case IS_STRING:
case IS_UNICODE: {
- void *offset_key = Z_UNIVAL_P(offset);
+ zstr offset_key = Z_UNIVAL_P(offset);
int offset_len = Z_UNILEN_P(offset);
int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
- zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ offset_key.u, offset_len, 0)) {
+ zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key.u);
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == offset_len &&
- !memcmp(ex->op_array->vars[i].name, offset_key, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
+ !memcmp(ex->op_array->vars[i].name.v, offset_key.v, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
ex->CVs[i] = NULL;
break;
}
}
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
break;
case IS_STRING:
case IS_UNICODE: {
- char *offset_key = Z_UNIVAL_P(offset);
- int offset_len = Z_UNILEN_P(offset);
- int free_offset = 0;
+ zstr offset_key = Z_UNIVAL_P(offset);
+ int offset_len = Z_UNILEN_P(offset);
+ int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
- if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
+ if (!zend_normalize_identifier(&norm, &norm_len, offset_key.u, offset_len, 0)) {
zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
isset = 1;
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
zend_free_op free_op2;
/* FIXME: type is default */
break;
case IS_STRING:
case IS_UNICODE: {
- void *offset_key = Z_UNIVAL_P(offset);
+ zstr offset_key = Z_UNIVAL_P(offset);
int offset_len = Z_UNILEN_P(offset);
int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
- zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ offset_key.u, offset_len, 0)) {
+ zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key.u);
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == offset_len &&
- !memcmp(ex->op_array->vars[i].name, offset_key, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
+ !memcmp(ex->op_array->vars[i].name.v, offset_key.v, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
ex->CVs[i] = NULL;
break;
}
}
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
break;
case IS_STRING:
case IS_UNICODE: {
- char *offset_key = Z_UNIVAL_P(offset);
- int offset_len = Z_UNILEN_P(offset);
- int free_offset = 0;
+ zstr offset_key = Z_UNIVAL_P(offset);
+ int offset_len = Z_UNILEN_P(offset);
+ int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
- if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
+ if (!zend_normalize_identifier(&norm, &norm_len, offset_key.u, offset_len, 0)) {
zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
isset = 1;
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
/* FIXME: type is default */
break;
case IS_STRING:
case IS_UNICODE: {
- void *offset_key = Z_UNIVAL_P(offset);
+ zstr offset_key = Z_UNIVAL_P(offset);
int offset_len = Z_UNILEN_P(offset);
int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
- zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ offset_key.u, offset_len, 0)) {
+ zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key.u);
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == offset_len &&
- !memcmp(ex->op_array->vars[i].name, offset_key, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
+ !memcmp(ex->op_array->vars[i].name.v, offset_key.v, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
ex->CVs[i] = NULL;
break;
}
}
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
break;
case IS_STRING:
case IS_UNICODE: {
- char *offset_key = Z_UNIVAL_P(offset);
- int offset_len = Z_UNILEN_P(offset);
- int free_offset = 0;
+ zstr offset_key = Z_UNIVAL_P(offset);
+ int offset_len = Z_UNILEN_P(offset);
+ int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
- if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
+ if (!zend_normalize_identifier(&norm, &norm_len, offset_key.u, offset_len, 0)) {
zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
isset = 1;
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
if (EG(ze1_compatibility_mode) && Z_TYPE_P(retval_ptr) == IS_OBJECT) {
zval *ret;
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
int dup;
INIT_PZVAL_COPY(ret, retval_ptr);
dup = zend_get_object_classname(retval_ptr, &class_name, &class_name_len TSRMLS_CC);
if (Z_OBJ_HT_P(retval_ptr)->clone_obj == NULL) {
- zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", Z_OBJCE_P(retval_ptr)->name);
+ zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %v", class_name);
}
- zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(retval_ptr)->name);
+ zend_error(E_STRICT, "Implicit cloning object of class '%v' because of 'zend.ze1_compatibility_mode'", class_name);
Z_OBJVAL_P(ret) = Z_OBJ_HT_P(retval_ptr)->clone_obj(retval_ptr TSRMLS_CC);
*EG(return_value_ptr_ptr) = ret;
if (!dup) {
- efree(class_name);
+ efree(class_name.v);
}
} else if (!0) { /* Not a temp var */
if (EG(active_op_array)->return_reference == ZEND_RETURN_REF ||
/* 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 : (char*)EMPTY_STR);
+ zend_error_noreturn(E_ERROR, "Call to private %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
}
} 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 : (char*)EMPTY_STR);
+ zend_error_noreturn(E_ERROR, "Call to protected %v::__clone() from context '%v'", ce->name, EG(scope) ? EG(scope)->name : (zstr)EMPTY_STR);
}
}
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == Z_UNILEN_P(varname) &&
- !memcmp(ex->op_array->vars[i].name, Z_UNIVAL_P(varname), Z_TYPE_P(varname)==IS_UNICODE?UBYTES(Z_UNILEN_P(varname)):Z_UNILEN_P(varname))) {
+ !memcmp(ex->op_array->vars[i].name.v, Z_UNIVAL_P(varname).v, Z_TYPE_P(varname)==IS_UNICODE?UBYTES(Z_UNILEN_P(varname)):Z_UNILEN_P(varname))) {
ex->CVs[i] = NULL;
break;
}
if (ce) {
zend_object *zobj = zend_objects_get_address(array_ptr TSRMLS_CC);
while (zend_hash_has_more_elements(fe_ht) == SUCCESS) {
- char *str_key;
+ zstr str_key;
uint str_key_len;
ulong int_key;
zend_uchar key_type;
zval var_copy;
int use_copy;
UChar *norm;
- int32_t norm_len;
+ int norm_len;
zend_make_unicode_zval(result, &var_copy, &use_copy);
if (use_copy) {
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
/* FIXME: type is default */
break;
case IS_STRING:
case IS_UNICODE: {
- void *offset_key = Z_UNIVAL_P(offset);
+ zstr offset_key = Z_UNIVAL_P(offset);
int offset_len = Z_UNILEN_P(offset);
int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
- zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ offset_key.u, offset_len, 0)) {
+ zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key.u);
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == offset_len &&
- !memcmp(ex->op_array->vars[i].name, offset_key, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
+ !memcmp(ex->op_array->vars[i].name.v, offset_key.v, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
ex->CVs[i] = NULL;
break;
}
}
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
break;
case IS_STRING:
case IS_UNICODE: {
- char *offset_key = Z_UNIVAL_P(offset);
- int offset_len = Z_UNILEN_P(offset);
- int free_offset = 0;
+ zstr offset_key = Z_UNIVAL_P(offset);
+ int offset_len = Z_UNILEN_P(offset);
+ int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
- if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
+ if (!zend_normalize_identifier(&norm, &norm_len, offset_key.u, offset_len, 0)) {
zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
isset = 1;
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
zend_free_op free_op2;
/* FIXME: type is default */
break;
case IS_STRING:
case IS_UNICODE: {
- void *offset_key = Z_UNIVAL_P(offset);
+ zstr offset_key = Z_UNIVAL_P(offset);
int offset_len = Z_UNILEN_P(offset);
int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
- zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ offset_key.u, offset_len, 0)) {
+ zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key.u);
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == offset_len &&
- !memcmp(ex->op_array->vars[i].name, offset_key, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
+ !memcmp(ex->op_array->vars[i].name.v, offset_key.v, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
ex->CVs[i] = NULL;
break;
}
}
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
break;
case IS_STRING:
case IS_UNICODE: {
- char *offset_key = Z_UNIVAL_P(offset);
- int offset_len = Z_UNILEN_P(offset);
- int free_offset = 0;
+ zstr offset_key = Z_UNIVAL_P(offset);
+ int offset_len = Z_UNILEN_P(offset);
+ int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
- if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
+ if (!zend_normalize_identifier(&norm, &norm_len, offset_key.u, offset_len, 0)) {
zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
isset = 1;
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
zend_free_op free_op2;
/* FIXME: type is default */
break;
case IS_STRING:
case IS_UNICODE: {
- void *offset_key = Z_UNIVAL_P(offset);
+ zstr offset_key = Z_UNIVAL_P(offset);
int offset_len = Z_UNILEN_P(offset);
int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
- zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ offset_key.u, offset_len, 0)) {
+ zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key.u);
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == offset_len &&
- !memcmp(ex->op_array->vars[i].name, offset_key, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
+ !memcmp(ex->op_array->vars[i].name.v, offset_key.v, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
ex->CVs[i] = NULL;
break;
}
}
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
break;
case IS_STRING:
case IS_UNICODE: {
- char *offset_key = Z_UNIVAL_P(offset);
- int offset_len = Z_UNILEN_P(offset);
- int free_offset = 0;
+ zstr offset_key = Z_UNIVAL_P(offset);
+ int offset_len = Z_UNILEN_P(offset);
+ int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
- if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
+ if (!zend_normalize_identifier(&norm, &norm_len, offset_key.u, offset_len, 0)) {
zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
isset = 1;
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
{
zend_op *opline = EX(opline);
zval *function_name;
- char *function_name_strval;
+ zstr function_name_strval;
int function_name_strlen;
/* FIXME: type is default */
break;
case IS_STRING:
case IS_UNICODE: {
- void *offset_key = Z_UNIVAL_P(offset);
+ zstr offset_key = Z_UNIVAL_P(offset);
int offset_len = Z_UNILEN_P(offset);
int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
- zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ offset_key.u, offset_len, 0)) {
+ zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key.u);
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
for (i = 0; i < ex->op_array->last_var; i++) {
if (ex->op_array->vars[i].hash_value == hash_value &&
ex->op_array->vars[i].name_len == offset_len &&
- !memcmp(ex->op_array->vars[i].name, offset_key, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
+ !memcmp(ex->op_array->vars[i].name.v, offset_key.v, Z_TYPE_P(offset)==IS_UNICODE?UBYTES(offset_len):offset_len)) {
ex->CVs[i] = NULL;
break;
}
}
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
break;
case IS_STRING:
case IS_UNICODE: {
- char *offset_key = Z_UNIVAL_P(offset);
- int offset_len = Z_UNILEN_P(offset);
- int free_offset = 0;
+ zstr offset_key = Z_UNIVAL_P(offset);
+ int offset_len = Z_UNILEN_P(offset);
+ int free_offset = 0;
if (UG(unicode) && ht == &EG(symbol_table) && Z_TYPE_P(offset) == IS_UNICODE) {
/* Identifier normalization */
UChar *norm;
- int32_t norm_len;
+ int norm_len;
- if (!zend_normalize_identifier(&norm, &norm_len,
- (UChar*)offset_key, offset_len, 0)) {
+ if (!zend_normalize_identifier(&norm, &norm_len, offset_key.u, offset_len, 0)) {
zend_error(E_WARNING, "Could not normalize identifier: %r", offset_key);
- } else if ((char*)norm != offset_key) {
- offset_key = (char*)norm;
+ } else if (norm != offset_key.u) {
+ offset_key.u = norm;
offset_len = norm_len;
free_offset = 1;
}
isset = 1;
}
if (free_offset) {
- efree(offset_key);
+ efree(offset_key.v);
}
break;
}
*data = &iterator->curobj;
}
-static int php_dom_iterator_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
+static int php_dom_iterator_current_key(zend_object_iterator *iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
{
zval *curobj;
xmlNodePtr curnode = NULL;
}
namelen = xmlStrlen(curnode->name);
- *str_key = estrndup(curnode->name, namelen);
+ str_key->s = estrndup(curnode->name, namelen);
*str_key_len = namelen + 1;
return HASH_KEY_IS_STRING;
}
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, ce.name_length + 1, &dom_domstringlist_prop_handlers, sizeof(dom_domstringlist_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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, ce.name_length + 1, &dom_namelist_prop_handlers, sizeof(dom_namelist_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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, ce.name_length + 1, &dom_domimplementationlist_prop_handlers, sizeof(dom_domimplementationlist_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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);
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, ce.name_length + 1, &dom_node_prop_handlers, sizeof(dom_node_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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);
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, ce.name_length + 1, &dom_namespace_node_prop_handlers, sizeof(dom_namespace_node_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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, ce.name_length + 1, &dom_document_fragment_prop_handlers, sizeof(dom_node_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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);
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, ce.name_length + 1, &dom_document_prop_handlers, sizeof(dom_document_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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;
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, ce.name_length + 1, &dom_nodelist_prop_handlers, sizeof(dom_nodelist_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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;
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, ce.name_length + 1, &dom_namednodemap_prop_handlers, sizeof(dom_namednodemap_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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);
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, ce.name_length + 1, &dom_characterdata_prop_handlers, sizeof(dom_characterdata_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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);
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, ce.name_length + 1, &dom_attr_prop_handlers, sizeof(dom_attr_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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);
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, ce.name_length + 1, &dom_element_prop_handlers, sizeof(dom_element_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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, ce.name_length + 1, &dom_text_prop_handlers, sizeof(dom_text_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler));
- zend_hash_add(&classes, ce.name, ce.name_length + 1, &dom_comment_prop_handlers, sizeof(dom_typeinfo_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, ce.name_length + 1, &dom_comment_prop_handlers, sizeof(dom_typeinfo_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, ce.name_length + 1, &dom_typeinfo_prop_handlers, sizeof(dom_typeinfo_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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);
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, ce.name_length + 1, &dom_domerror_prop_handlers, sizeof(dom_domerror_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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);
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, ce.name_length + 1, &dom_domlocator_prop_handlers, sizeof(dom_domlocator_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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, ce.name_length + 1, &dom_cdata_prop_handlers, sizeof(dom_documenttype_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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);
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, ce.name_length + 1, &dom_documenttype_prop_handlers, sizeof(dom_documenttype_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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);
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, ce.name_length + 1, &dom_notation_prop_handlers, sizeof(dom_notation_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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);
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, ce.name_length + 1, &dom_entity_prop_handlers, sizeof(dom_entity_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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, ce.name_length + 1, &dom_entity_reference_prop_handlers, sizeof(dom_entity_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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);
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, ce.name_length + 1, &dom_processinginstruction_prop_handlers, sizeof(dom_processinginstruction_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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);
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, ce.name_length + 1, &dom_xpath_prop_handlers, sizeof(dom_xpath_prop_handlers), NULL);
+ zend_hash_add(&classes, ce.name.s, 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);
PHP_FUNCTION(hash_algos)
{
HashPosition pos;
- char *str;
+ zstr str;
int str_len;
long idx, type;
for(zend_hash_internal_pointer_reset_ex(&php_hash_hashtable, &pos);
(type = zend_hash_get_current_key_ex(&php_hash_hashtable, &str, &str_len, &idx, 0, &pos)) != HASH_KEY_NON_EXISTANT;
zend_hash_move_forward_ex(&php_hash_hashtable, &pos)) {
- add_next_index_stringl(return_value, str, str_len-1, 1);
+ add_next_index_stringl(return_value, str.s, str_len-1, 1);
}
}
/* }}} */
{
HashPosition pos;
char buffer[2048];
- char *s = buffer, *e = s + sizeof(buffer), *str;
+ char *s = buffer, *e = s + sizeof(buffer);
+ zstr str;
long idx, type;
for(zend_hash_internal_pointer_reset_ex(&php_hash_hashtable, &pos);
(type = zend_hash_get_current_key_ex(&php_hash_hashtable, &str, NULL, &idx, 0, &pos)) != HASH_KEY_NON_EXISTANT;
zend_hash_move_forward_ex(&php_hash_hashtable, &pos)) {
- s += snprintf(s, e - s, "%s ", str);
+ s += snprintf(s, e - s, "%s ", str.s);
}
*s = 0;
php_libxml_initialize();
export_hnd.export_func = export_function;
- if (zend_hash_add(&php_libxml_exports, ce->name, ce->name_length + 1, &export_hnd, sizeof(export_hnd), NULL) == SUCCESS) {
+ 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;
uname = malloc(UBYTES(ce->name_length+1));
- u_charsToUChars(ce->name, uname, ce->name_length+1);
- ret = zend_u_hash_add(&php_libxml_exports, IS_UNICODE, uname, ce->name_length + 1, &export_hnd, sizeof(export_hnd), NULL);
- free(uname);
- return ret;
- }
- return FAILURE;
+ 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);
+ return ret;
+ }
+ return FAILURE;
}
PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object TSRMLS_DC)
WRONG_PARAM_COUNT;
break;
}
-
- if (MySG(trace_mode) || !strcasecmp(get_active_function_name(TSRMLS_C), "mysql")) {
+
+ /* FIXME: Unicode support??? */
+ if (MySG(trace_mode) || !strcasecmp(get_active_function_name(TSRMLS_C).s, "mysql")) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "This function is deprecated; use mysql_query() instead.");
}
/* apply values from the dn hash */
zend_hash_internal_pointer_reset_ex(HASH_OF(dn), &hpos);
while(zend_hash_get_current_data_ex(HASH_OF(dn), (void**)&item, &hpos) == SUCCESS) {
- char * strindex; int strindexlen;
+ zstr strindex;
+ int strindexlen;
long intindex;
zend_hash_get_current_key_ex(HASH_OF(dn), &strindex, &strindexlen, &intindex, 0, &hpos);
convert_to_string_ex(item);
- if (strindex) {
+ if (strindex.s) {
int nid;
- nid = OBJ_txt2nid(strindex);
+ nid = OBJ_txt2nid(strindex.s);
if (nid != NID_undef) {
if (!X509_NAME_add_entry_by_NID(subj, nid, MBSTRING_ASC,
(unsigned char*)Z_STRVAL_PP(item), -1, -1, 0))
return FAILURE;
}
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "dn: %s is not a recognized name", strindex);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "dn: %s is not a recognized name", strindex.s);
}
}
zend_hash_move_forward_ex(HASH_OF(dn), &hpos);
if (attribs) {
zend_hash_internal_pointer_reset_ex(HASH_OF(attribs), &hpos);
while(zend_hash_get_current_data_ex(HASH_OF(attribs), (void**)&item, &hpos) == SUCCESS) {
- char * strindex; int strindexlen;
+ zstr strindex;
+ int strindexlen;
long intindex;
zend_hash_get_current_key_ex(HASH_OF(attribs), &strindex, &strindexlen, &intindex, 0, &hpos);
convert_to_string_ex(item);
- if (strindex) {
+ if (strindex.s) {
int nid;
- nid = OBJ_txt2nid(strindex);
+ nid = OBJ_txt2nid(strindex.s);
if (nid != NID_undef) {
if (!X509_NAME_add_entry_by_NID(subj, nid, MBSTRING_ASC, (unsigned char*)Z_STRVAL_PP(item), -1, -1, 0)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "attribs: add_entry_by_NID %d -> %s (failed)", nid, Z_STRVAL_PP(item));
return FAILURE;
}
} else {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "dn: %s is not a recognized name", strindex);
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "dn: %s is not a recognized name", strindex.s);
}
}
zend_hash_move_forward_ex(HASH_OF(attribs), &hpos);
long cipherid = PHP_OPENSSL_CIPHER_DEFAULT;
uint strindexlen;
ulong intindex;
- char * strindex;
+ zstr strindex;
char * infilename = NULL; int infilename_len;
char * outfilename = NULL; int outfilename_len;
convert_to_string_ex(zcertval);
- if (strindex) {
- BIO_printf(outfile, "%s: %s\n", strindex, Z_STRVAL_PP(zcertval));
+ if (strindex.s) {
+ BIO_printf(outfile, "%s: %s\n", strindex.s, Z_STRVAL_PP(zcertval));
} else {
BIO_printf(outfile, "%s\n", Z_STRVAL_PP(zcertval));
}
ulong intindex;
uint strindexlen;
HashPosition hpos;
- char * strindex;
+ zstr strindex;
char * infilename; int infilename_len;
char * outfilename; int outfilename_len;
char * extracertsfilename = NULL; int extracertsfilename_len;
convert_to_string_ex(hval);
- if (strindex) {
- BIO_printf(outfile, "%s: %s\n", strindex, Z_STRVAL_PP(hval));
+ if (strindex.s) {
+ BIO_printf(outfile, "%s: %s\n", strindex.s, Z_STRVAL_PP(hval));
} else {
BIO_printf(outfile, "%s\n", Z_STRVAL_PP(hval));
}
char *result;
int result_len;
int limit_val = -1;
- char *string_key;
+ zstr string_key;
ulong num_key;
zval callback_name;
int replace_count=0;
switch(zend_hash_get_current_key(Z_ARRVAL_PP(subject), &string_key, &num_key, 0))
{
case HASH_KEY_IS_STRING:
- add_assoc_stringl(return_value, string_key, result, result_len, 0);
+ add_assoc_stringl(return_value, string_key.s, result, result_len, 0);
break;
case HASH_KEY_IS_LONG:
int *offsets; /* Array of subpattern offsets */
int size_offsets; /* Size of the offsets array */
int count = 0; /* Count of matched subpatterns */
- char *string_key;
+ zstr string_key;
ulong num_key;
zend_bool invert = 0; /* Whether to return non-matching
entries */
switch(zend_hash_get_current_key(Z_ARRVAL_PP(input), &string_key, &num_key, 0))
{
case HASH_KEY_IS_STRING:
- zend_hash_update(Z_ARRVAL_P(return_value), string_key,
- strlen(string_key)+1, entry, sizeof(zval *), NULL);
+ zend_hash_update(Z_ARRVAL_P(return_value), string_key.s,
+ strlen(string_key.s)+1, entry, sizeof(zval *), NULL);
break;
case HASH_KEY_IS_LONG:
while (funcs->fname) {
ifunc->type = ZEND_INTERNAL_FUNCTION;
ifunc->handler = funcs->handler;
- ifunc->function_name = funcs->fname;
+ ifunc->function_name.s = funcs->fname;
ifunc->scope = dbh->ce;
ifunc->prototype = NULL;
if (funcs->arg_info) {
#else
zval *object,
#endif
- char *method_name, int method_len TSRMLS_DC)
+ zstr method_name, int method_len TSRMLS_DC)
{
zend_function *fbc = NULL;
- char *lc_method_name;
+ zstr lc_method_name;
#if PHP_API_VERSION >= 20041225
zval *object = *object_pp;
#endif
}
out:
- efree(lc_method_name);
+ efree(lc_method_name.v);
return fbc;
}
zend_hash_internal_pointer_reset(Z_ARRVAL_P(input_params));
while (SUCCESS == zend_hash_get_current_data(Z_ARRVAL_P(input_params), (void*)&tmp)) {
+ zstr tmp_str;
+
memset(¶m, 0, sizeof(param));
if (HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(Z_ARRVAL_P(input_params),
- ¶m.name, &str_length, &num_index, 0, NULL)) {
+ &tmp_str, &str_length, &num_index, 0, NULL)) {
/* yes this is correct. we don't want to count the null byte. ask wez */
+ param.name = tmp_str.s;
param.namelen = str_length - 1;
param.paramno = -1;
} else {
zval **object = NULL, **method;
zend_class_entry * ce = NULL, **pce;
zend_function *function_handler;
- char *lcname;
+ zstr lcname;
unsigned int lcname_len;
if (Z_TYPE_P(callable) == IS_ARRAY) {
fci->function_table = ce ? &ce->function_table : EG(function_table);
if (zend_u_hash_find(fci->function_table, Z_TYPE_PP(method), lcname, lcname_len+1, (void **)&function_handler) == FAILURE) {
- efree(lcname);
+ efree(lcname.v);
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "user-supplied function does not exist" TSRMLS_CC);
return 0;
}
- efree(lcname);
+ efree(lcname.v);
fci->size = sizeof(zend_fcall_info);
fci->function_name = NULL;
error = 1;
break;
} else {
- stmt->fetch.cls.ce = zend_u_fetch_class(Z_TYPE_P(arg2), Z_STRVAL_P(arg2), Z_STRLEN_P(arg2), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
+ stmt->fetch.cls.ce = zend_u_fetch_class(Z_TYPE_P(arg2), Z_UNIVAL_P(arg2), Z_UNILEN_P(arg2), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
if (!stmt->fetch.cls.ce) {
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not find user-specified class" TSRMLS_CC);
error = 1;
zend_hash_internal_pointer_reset_ex(stmt->bound_params, &pos);
while (SUCCESS == zend_hash_get_current_data_ex(stmt->bound_params,
(void**)¶m, &pos)) {
- char *str;
+ zstr str;
uint len;
ulong num;
#else
zval *object,
#endif
- char *method_name, int method_len TSRMLS_DC)
+ zstr method_name, int method_len TSRMLS_DC)
{
zend_function *fbc = NULL;
- char *lc_method_name;
+ zstr lc_method_name;
#if PHP_API_VERSION >= 20041225
zval *object = *object_pp;
#endif
}
out:
- efree(lc_method_name);
+ efree(lc_method_name.v);
return fbc;
}
*data = &I->fetch_ahead;
}
-static int pdo_stmt_iter_get_key(zend_object_iterator *iter, char **str_key, uint *str_key_len,
+static int pdo_stmt_iter_get_key(zend_object_iterator *iter, zstr *str_key, uint *str_key_len,
ulong *int_key TSRMLS_DC)
{
struct php_pdo_iterator *I = (struct php_pdo_iterator*)iter->data;
#else
zval *object,
#endif
- char *method_name, int method_len TSRMLS_DC)
+ zstr method_name, int method_len TSRMLS_DC)
{
zend_function *fbc;
- char *lc_method_name;
+ zstr lc_method_name;
- lc_method_name = emalloc(method_len + 1);
- zend_str_tolower_copy(lc_method_name, method_name, method_len);
+ lc_method_name = zend_u_str_tolower_dup(UG(unicode)?IS_UNICODE:IS_STRING, method_name, method_len);
- if (zend_hash_find(&pdo_row_ce->function_table, lc_method_name, method_len+1, (void**)&fbc) == FAILURE) {
- efree(lc_method_name);
+ if (zend_u_hash_find(&pdo_row_ce->function_table, UG(unicode)?IS_UNICODE:IS_STRING, lc_method_name, method_len+1, (void**)&fbc) == FAILURE) {
+ efree(lc_method_name.v);
return NULL;
}
- efree(lc_method_name);
+ efree(lc_method_name.v);
return fbc;
}
-static int row_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS)
+static int row_call_method(zstr method, INTERNAL_FUNCTION_PARAMETERS)
{
return FAILURE;
}
static zend_internal_function ctor = {0};
ctor.type = ZEND_INTERNAL_FUNCTION;
- ctor.function_name = "__construct";
+ ctor.function_name.s = "__construct";
ctor.scope = pdo_row_ce;
ctor.handler = ZEND_FN(dbstmt_constructor);
return pdo_dbstmt_ce;
}
-static int row_get_classname(zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC)
+static int row_get_classname(zval *object, zstr *class_name, zend_uint *class_name_len, int parent TSRMLS_DC)
{
- *class_name = estrndup("PDORow", sizeof("PDORow")-1);
+ class_name->s = estrndup("PDORow", sizeof("PDORow")-1);
*class_name_len = sizeof("PDORow")-1;
return 0;
}
if (count > 0) {
HashPosition pos;
zval **value;
- char *key;
+ zstr key;
uint key_len;
ulong num_index;
while (zend_hash_get_current_data_ex(&ce->constants_table, (void **) &value, &pos) == SUCCESS) {
zend_hash_get_current_key_ex(&ce->constants_table, &key, &key_len, &num_index, 0, &pos);
- _const_string(str, key, *value, indent TSRMLS_CC);
+ _const_string(str, key.s, *value, indent TSRMLS_CC);
zend_hash_move_forward_ex(&ce->constants_table, &pos);
}
}
zend_hash_internal_pointer_reset_ex(properties, &pos);
while (zend_hash_get_current_data_ex(properties, (void **) &prop, &pos) == SUCCESS) {
- char *prop_name;
+ zstr prop_name;
uint prop_name_size;
ulong index;
if (zend_hash_get_current_key_ex(properties, &prop_name, &prop_name_size, &index, 1, &pos) == HASH_KEY_IS_STRING) {
- if (prop_name_size && prop_name[0]) { /* skip all private and protected properties */
- if (!zend_hash_quick_exists(&ce->properties_info, prop_name, prop_name_size, zend_get_hash_value(prop_name, prop_name_size))) {
+ if (prop_name_size && prop_name.s[0]) { /* skip all private and protected properties */
+ if (!zend_hash_quick_exists(&ce->properties_info, prop_name.s, prop_name_size, zend_get_hash_value(prop_name.s, prop_name_size))) {
count++;
- _property_string(&dyn, NULL, prop_name, sub_indent.string TSRMLS_CC);
+ _property_string(&dyn, NULL, prop_name.s, sub_indent.string TSRMLS_CC);
}
}
- efree(prop_name);
+ efree(prop_name.s);
}
zend_hash_move_forward_ex(properties, &pos);
}
} else {
string_printf(str, "<required> ");
}
- if (arg_info->class_name) {
+ if (arg_info->class_name.v) {
string_printf(str, "%v ", arg_info->class_name);
if (arg_info->allow_null) {
string_printf(str, "or NULL ");
if (arg_info->pass_by_reference) {
string_write(str, "&", sizeof("&")-1);
}
- if (arg_info->name) {
+ if (arg_info->name.v) {
string_printf(str, "$%v", arg_info->name);
} else {
string_printf(str, "$param%d", offset);
{
string param_indent;
zend_function *overwrites;
- char *lc_name;
+ zstr lc_name;
unsigned int lc_name_len;
/* TBD: Repair indenting of doc comment (or is this to be done in the parser?)
if (fptr->common.scope != scope) {
string_printf(str, ", inherits %v", fptr->common.scope->name);
} else if (fptr->common.scope->parent) {
- lc_name = zend_u_str_case_fold(IS_STRING, fptr->common.function_name, strlen(fptr->common.function_name), 1, &lc_name_len);
+ /* FIXME: Unicode support??? */
+ lc_name = zend_u_str_case_fold(IS_STRING, fptr->common.function_name, strlen(fptr->common.function_name.s), 1, &lc_name_len);
if (zend_u_hash_find(&fptr->common.scope->parent->function_table, IS_STRING, lc_name, lc_name_len + 1, (void**) &overwrites) == SUCCESS) {
if (fptr->common.scope != overwrites->common.scope) {
string_printf(str, ", overwrites %v", overwrites->common.scope->name);
}
}
- efree(lc_name);
+ efree(lc_name.v);
}
}
if (fptr->common.prototype && fptr->common.prototype->common.scope) {
/* {{{ _property_string */
static void _property_string(string *str, zend_property_info *prop, char *prop_name, char* indent TSRMLS_DC)
{
- char *class_name;
+ zstr class_name;
string_printf(str, "%sProperty [ ", indent);
if (!prop) {
if (constant->module_number == module->module_number) {
TSRMLS_FETCH();
- _const_string(str, constant->name, &constant->value, indent TSRMLS_CC);
+ /* FIXME: Unicode support??? */
+ _const_string(str, constant->name.s, &constant->value, indent TSRMLS_CC);
(*num_classes)++;
}
return ZEND_HASH_APPLY_KEEP;
zval *name;
MAKE_STD_ZVAL(name);
- if (arg_info->name) {
+ if (arg_info->name.v) {
ZVAL_TEXTL(name, arg_info->name, arg_info->name_len, 1);
} else {
ZVAL_NULL(name);
zval *name;
zval *classname;
property_reference *reference;
- char *class_name, *prop_name;
+ zstr class_name, prop_name;
zend_uchar utype = UG(unicode) ? IS_UNICODE : IS_STRING;
zend_u_unmangle_property_name(utype, prop->name, &class_name, &prop_name);
/* we have to seach the class hierarchy for this (implicit) public or protected property */
zend_class_entry *tmp_ce = ce;
zend_property_info *tmp_info;
- int prop_name_len = UG(unicode) ? u_strlen((UChar*)prop_name) : strlen(prop_name);
+ int prop_name_len = UG(unicode) ? u_strlen(prop_name.u) : strlen(prop_name.s);
while (tmp_ce && zend_u_hash_find(&tmp_ce->properties_info, utype, prop_name, prop_name_len + 1, (void **) &tmp_info) != SUCCESS) {
ce = tmp_ce;
zval *name;
zval *object;
unsigned int lcname_len;
- char *lcname;
+ zstr lcname;
reflection_object *intern;
zend_function *fptr;
- char *name_str;
+ zstr name_str;
int name_len;
zend_uchar type;
}
lcname = zend_u_str_case_fold(type, name_str, name_len, 1, &lcname_len);
if (zend_u_hash_find(EG(function_table), type, lcname, lcname_len + 1, (void **)&fptr) == FAILURE) {
- efree(lcname);
+ efree(lcname.v);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Function %R() does not exist", type, name_str);
return;
}
- efree(lcname);
+ efree(lcname.v);
MAKE_STD_ZVAL(name);
ZVAL_TEXT(name, fptr->common.function_name, 1);
zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) &name, sizeof(zval *), NULL);
case IS_UNICODE:
case IS_STRING: {
unsigned int lcname_len;
- char *lcname;
+ zstr lcname;
convert_to_text_ex(&reference);
lcname = zend_u_str_case_fold(Z_TYPE_P(reference), Z_UNIVAL_P(reference), Z_UNILEN_P(reference), 1, &lcname_len);
if (zend_u_hash_find(EG(function_table), Z_TYPE_P(reference), lcname, lcname_len + 1, (void**) &fptr) == FAILURE) {
- efree(lcname);
+ efree(lcname.v);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Function %R() does not exist", Z_TYPE_P(reference), Z_UNIVAL_P(reference));
return;
}
- efree(lcname);
+ efree(lcname.v);
}
break;
zval **method;
zend_class_entry **pce;
unsigned int lcname_len;
- char *lcname;
+ zstr lcname;
if ((zend_hash_index_find(Z_ARRVAL_P(reference), 0, (void **) &classref) == FAILURE)
|| (zend_hash_index_find(Z_ARRVAL_P(reference), 1, (void **) &method) == FAILURE)) {
convert_to_text_ex(method);
lcname = zend_u_str_case_fold(Z_TYPE_PP(method), Z_UNIVAL_PP(method), Z_UNILEN_PP(method), 1, &lcname_len);
if (zend_u_hash_find(&ce->function_table, Z_TYPE_PP(method), lcname, lcname_len + 1, (void **) &fptr) == FAILURE) {
- efree(lcname);
+ efree(lcname.v);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Method %R::%R() does not exist", Z_TYPE_PP(classref), Z_UNIVAL_PP(classref), Z_TYPE_PP(method), Z_UNIVAL_PP(method));
return;
}
- efree(lcname);
+ efree(lcname.v);
}
break;
position= -1;
convert_to_string_ex(¶meter);
for (i = 0; i < fptr->common.num_args; i++) {
- if (arg_info[i].name && strcmp(arg_info[i].name, Z_STRVAL_P(parameter)) == 0) {
+ /* FIXME: Unicode support??? */
+ if (arg_info[i].name.s && strcmp(arg_info[i].name.s, Z_STRVAL_P(parameter)) == 0) {
position= i;
break;
}
}
MAKE_STD_ZVAL(name);
- if (arg_info[position].name) {
+ if (arg_info[position].name.v) {
ZVAL_TEXTL(name, arg_info[position].name, arg_info[position].name_len, 1);
} else {
ZVAL_NULL(name);
METHOD_NOTSTATIC_NUMPARAMS(reflection_parameter_ptr, 0);
GET_REFLECTION_OBJECT_PTR(param);
- if (!param->arg_info->class_name) {
+ if (!param->arg_info->class_name.v) {
RETURN_NULL();
} else {
zend_class_entry **pce;
zval *object;
reflection_object *intern;
unsigned int lcname_len;
- char *lcname;
+ zstr lcname;
zend_class_entry **pce;
zend_class_entry *ce;
zend_function *mptr;
- char *name_str, *tmp;
+ zstr name_str;
+ char *tmp;
int name_len, tmp_len;
zval ztmp;
zend_uchar type;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name_str, &name_len) == FAILURE) {
return;
}
- if ((tmp = strstr(name_str, "::")) == NULL) {
+ /* FIXME: Unicode support??? */
+ if ((tmp = strstr(name_str.s, "::")) == NULL) {
return;
}
type = IS_STRING;
classname = &ztmp;
- tmp_len = tmp - name_str;
- ZVAL_STRINGL(classname, name_str, tmp_len, 1);
+ tmp_len = tmp - name_str.s;
+ ZVAL_STRINGL(classname, name_str.s, tmp_len, 1);
name_len = name_len - (tmp_len + 2);
- name_str = tmp + 2;
+ name_str.s = tmp + 2;
}
object = getThis();
lcname = zend_u_str_case_fold(type, name_str, name_len, 1, &lcname_len);
if (zend_u_hash_find(&ce->function_table, type, lcname, lcname_len + 1, (void **) &mptr) == FAILURE) {
- efree(lcname);
+ efree(lcname.v);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Method %v::%R() does not exist", ce->name, type, name_str);
return;
}
- efree(lcname);
+ efree(lcname.v);
MAKE_STD_ZVAL(name);
ZVAL_TEXT(name, mptr->common.function_name, 1);
zval *classname;
reflection_object *intern;
zend_class_entry **ce;
- char *name;
+ zstr name;
int name_len;
zend_uchar name_type;
{
reflection_object *intern;
zend_class_entry *ce;
- char *name;
+ zstr name;
int name_len;
zval **prop, *def_value = NULL;
zend_uchar name_type;
{
reflection_object *intern;
zend_class_entry *ce;
- char *name;
+ zstr name;
int name_len;
zval **variable_ptr, *value;
int refcount;
zend_hash_internal_pointer_reset_ex(&ce->default_properties, &pos);
while (zend_hash_get_current_data_ex(&ce->default_properties, (void **) &prop, &pos) == SUCCESS) {
- char *key, *class_name, *prop_name;
+ zstr key, class_name, prop_name;
uint key_len;
ulong num_index;
zval *prop_copy;
zend_hash_get_current_key_ex(&ce->default_properties, &key, &key_len, &num_index, 0, &pos);
zend_hash_move_forward_ex(&ce->default_properties, &pos);
- zend_unmangle_property_name(key, &class_name, &prop_name);
- if (class_name && class_name[0] != '*' && strcmp(class_name, ce->name)) {
+ zend_u_unmangle_property_name(UG(unicode)?IS_UNICODE:IS_STRING, key, &class_name, &prop_name);
+ /* FIXME: Unicode support??? */
+ if (class_name.s && class_name.s[0] != '*' && strcmp(class_name.s, ce->name.s)) {
/* filter privates from base classes */
continue;
}
zval_copy_ctor(prop_copy);
INIT_PZVAL(prop_copy);
- add_assoc_zval(return_value, prop_name, prop_copy);
+ add_assoc_zval(return_value, prop_name.s, prop_copy);
}
}
}
reflection_object *intern;
zend_class_entry *ce;
unsigned int lc_name_len;
- char *name, *lc_name;
+ zstr name, lc_name;
int name_len;
zend_uchar type;
GET_REFLECTION_OBJECT_PTR(ce);
lc_name = zend_u_str_case_fold(type, name, name_len, 1, &lc_name_len);
if (zend_u_hash_exists(&ce->function_table, type, lc_name, lc_name_len + 1)) {
- efree(lc_name);
+ efree(lc_name.v);
RETURN_TRUE;
} else {
- efree(lc_name);
+ efree(lc_name.v);
RETURN_FALSE;
}
}
zend_class_entry *ce;
zend_function *mptr;
unsigned int lc_name_len;
- char *name, *lc_name;
+ zstr name, lc_name;
int name_len;
zend_uchar type;
lc_name = zend_u_str_case_fold(type, name, name_len, 1, &lc_name_len);
if (zend_u_hash_find(&ce->function_table, type, lc_name, lc_name_len + 1, (void**) &mptr) == SUCCESS) {
reflection_method_factory(ce, mptr, return_value TSRMLS_CC);
- efree(lc_name);
+ efree(lc_name.v);
} else {
- efree(lc_name);
+ efree(lc_name.v);
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Method %R does not exist", type, name);
return;
reflection_object *intern;
zend_class_entry *ce, **pce;
zend_property_info *property_info;
- char *name, *tmp, *classname;
+ zstr name, classname;
+ char *tmp;
int name_len, classname_len;
zend_uchar name_type;
reflection_property_factory(ce, property_info, return_value TSRMLS_CC);
return;
}
- if ((tmp = strstr(name, "::")) != NULL) {
- classname_len = tmp - name;
- classname = zend_str_tolower_dup(name, classname_len);
- classname[classname_len] = '\0';
+ /* FIXME: Unicode support??? */
+ if ((tmp = strstr(name.s, "::")) != NULL) {
+ classname_len = tmp - name.s;
+ classname.s = zend_str_tolower_dup(name.s, classname_len);
+ classname.s[classname_len] = '\0';
name_len = name_len - (classname_len + 2);
- name = tmp + 2;
+ name.s = tmp + 2;
if (zend_u_lookup_class(name_type, classname, classname_len, &pce TSRMLS_CC) == FAILURE) {
if (!EG(exception)) {
zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Class %R does not exist", name_type, classname);
}
- efree(classname);
+ efree(classname.v);
return;
}
- efree(classname);
+ efree(classname.v);
if (!instanceof_function(ce, *pce TSRMLS_CC)) {
zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Fully qualified property name %v::%R does not specify a base class of %v", (*pce)->name, name_type, name, ce->name);
zval *interface;
ALLOC_ZVAL(interface);
zend_reflection_class_factory(ce->interfaces[i], interface TSRMLS_CC);
- add_assoc_zval_ex(return_value, ce->interfaces[i]->name, ce->interfaces[i]->name_length + 1, interface);
+ /* FIXME: Unicode support??? */
+ add_assoc_zval_ex(return_value, ce->interfaces[i]->name.s, ce->interfaces[i]->name_length + 1, interface);
}
}
}
ZEND_METHOD(reflection_property, __construct)
{
zval *propname, *classname;
- char *name_str, *class_name, *prop_name;
+ zstr name_str, class_name, prop_name;
int name_len;
zval *object;
reflection_object *intern;
GET_REFLECTION_OBJECT_PTR(ref);
ce = tmp_ce = ref->ce;
- while (tmp_ce && zend_hash_find(&tmp_ce->properties_info, ref->prop->name, ref->prop->name_length + 1, (void **) &tmp_info) == SUCCESS) {
+ while (tmp_ce && zend_u_hash_find(&tmp_ce->properties_info, UG(unicode)?IS_UNICODE:IS_STRING, ref->prop->name, ref->prop->name_length + 1, (void **) &tmp_info) == SUCCESS) {
ce = tmp_ce;
- tmp_ce = tmp_ce->parent;
+ tmp_ce = tmp_ce->parent;
}
zend_reflection_class_factory(ce, return_value TSRMLS_CC);
*const_val = constant->value;
zval_copy_ctor(const_val);
INIT_PZVAL(const_val);
- add_assoc_zval_ex(retval, constant->name, constant->name_len, const_val);
+ /* FIXME: Unicode support???*/
+ add_assoc_zval_ex(retval, constant->name.s, constant->name_len, const_val);
}
return 0;
}
if (add_reflection_class) {
ALLOC_ZVAL(zclass);
zend_reflection_class_factory(*pce, zclass TSRMLS_CC);
- add_assoc_zval_ex(class_array, (*pce)->name, (*pce)->name_length + 1, zclass);
+ /* FIXME: Unicode support??? */
+ add_assoc_zval_ex(class_array, (*pce)->name.s, (*pce)->name_length + 1, zclass);
} else {
- add_next_index_stringl(class_array, (*pce)->name, (*pce)->name_length, 1);
+ /* FIXME: Unicode support??? */
+ add_next_index_stringl(class_array, (*pce)->name.s, (*pce)->name_length, 1);
}
}
return ZEND_HASH_APPLY_KEEP;
#define PS_ENCODE_VARS \
- char *key; \
+ zstr key; \
uint key_length; \
ulong num_key; \
zval **struc;
zend_hash_get_current_key_ex(_ht, &key, &key_length, &num_key, 0, NULL) == HASH_KEY_IS_STRING; \
zend_hash_move_forward(_ht)) { \
key_length--; \
- if (php_get_session_var(key, key_length, &struc TSRMLS_CC) == SUCCESS) { \
+ if (php_get_session_var(key.s, key_length, &struc TSRMLS_CC) == SUCCESS) { \
code; \
} \
} \
PS_ENCODE_LOOP(
if (key_length > PS_BIN_MAX) continue;
smart_str_appendc(&buf, (unsigned char) key_length);
- smart_str_appendl(&buf, key, key_length);
+ smart_str_appendl(&buf, key.s, key_length);
php_var_serialize(&buf, struc, &var_hash TSRMLS_CC);
} else {
if (key_length > PS_BIN_MAX) continue;
smart_str_appendc(&buf, (unsigned char) (key_length & PS_BIN_UNDEF));
- smart_str_appendl(&buf, key, key_length);
+ smart_str_appendl(&buf, key.s, key_length);
);
if (newlen) *newlen = buf.len;
PHP_VAR_SERIALIZE_INIT(var_hash);
PS_ENCODE_LOOP(
- smart_str_appendl(&buf, key, (unsigned char) key_length);
- if (memchr(key, PS_DELIMITER, key_length)) {
+ smart_str_appendl(&buf, key.s, (unsigned char) key_length);
+ if (memchr(key.s, PS_DELIMITER, key_length)) {
PHP_VAR_SERIALIZE_DESTROY(var_hash);
smart_str_free(&buf);
return FAILURE;
php_var_serialize(&buf, struc, &var_hash TSRMLS_CC);
} else {
smart_str_appendc(&buf, PS_UNDEF_MARKER);
- smart_str_appendl(&buf, key, key_length);
+ smart_str_appendl(&buf, key.s, key_length);
smart_str_appendc(&buf, PS_DELIMITER);
);
static int migrate_global(HashTable *ht, HashPosition *pos TSRMLS_DC)
{
- char *str;
+ zstr str;
uint str_len;
ulong num_key;
int n;
switch (n) {
case HASH_KEY_IS_STRING:
- if (zend_hash_find(&EG(symbol_table), str, str_len,
+ case HASH_KEY_IS_UNICODE:
+ if (zend_u_hash_find(&EG(symbol_table), n, str, str_len,
(void **) &val) == SUCCESS
&& val && Z_TYPE_PP(val) != IS_NULL) {
- ZEND_SET_SYMBOL_WITH_LENGTH(ht, str, str_len, *val,
+ /* FIXME: Unicode support??? */
+ ZEND_SET_SYMBOL_WITH_LENGTH(ht, str.s, str_len, *val,
(*val)->refcount + 1 , 1);
ret = 1;
}
if (PG(register_globals)) {
uint str_len;
- char *str;
+ zstr str;
ulong num_key;
HashPosition pos;
while (zend_hash_get_current_key_ex(ht, &str, &str_len, &num_key,
0, &pos) == HASH_KEY_IS_STRING) {
- zend_delete_global_variable(str, str_len-1 TSRMLS_CC);
+ zend_delete_global_variable(str.s, str_len-1 TSRMLS_CC);
zend_hash_move_forward_ex(ht, &pos);
}
}
static void php_sxe_iterator_dtor(zend_object_iterator *iter TSRMLS_DC);
static int php_sxe_iterator_valid(zend_object_iterator *iter TSRMLS_DC);
static void php_sxe_iterator_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC);
-static int php_sxe_iterator_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC);
+static int php_sxe_iterator_current_key(zend_object_iterator *iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC);
static void php_sxe_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC);
static void php_sxe_iterator_rewind(zend_object_iterator *iter TSRMLS_DC);
*data = &iterator->sxe->iter.data;
}
-static int php_sxe_iterator_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
+static int php_sxe_iterator_current_key(zend_object_iterator *iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
{
zval *curobj;
xmlNodePtr curnode = NULL;
int32_t u_len;
namelen = xmlStrlen(curnode->name);
- zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), (UChar**)str_key, &u_len, (char*)curnode->name, namelen, &status);
+ zend_convert_to_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &str_key->u, &u_len, (char*)curnode->name, namelen, &status);
*str_key_len = u_len + 1;
return HASH_KEY_IS_UNICODE;
} else {
namelen = xmlStrlen(curnode->name);
- *str_key = estrndup(curnode->name, namelen);
+ str_key->s = estrndup(curnode->name, namelen);
*str_key_len = namelen + 1;
return HASH_KEY_IS_STRING;
}
zend_hash_move_forward_ex(SOAP_GLOBAL(class_map), &pos)) {
if (Z_TYPE_PP(tmp) == IS_STRING &&
ce->name_length == Z_STRLEN_PP(tmp) &&
- zend_binary_strncasecmp(ce->name, ce->name_length, Z_STRVAL_PP(tmp), ce->name_length, ce->name_length) == 0 &&
+ /* FIXME: Unicode support??? */
+ zend_binary_strncasecmp(ce->name.s, ce->name_length, Z_STRVAL_PP(tmp), ce->name_length, ce->name_length) == 0 &&
zend_hash_get_current_key_ex(SOAP_GLOBAL(class_map), &type_name, &type_len, &idx, 0, &pos) == HASH_KEY_IS_STRING) {
/* TODO: namespace isn't stored */
property_info = zend_get_property_info(Z_OBJCE_P(object), &member, 1 TSRMLS_CC);
EG(scope) = old_scope;
- if (property_info && zend_hash_quick_exists(Z_OBJPROP_P(object), property_info->name, property_info->name_length+1, property_info->h)) {
+ /* FIXME: Unicode support??? */
+ if (property_info && zend_hash_quick_exists(Z_OBJPROP_P(object), property_info->name.s, property_info->name_length+1, property_info->h)) {
return data;
}
return NULL;
fe.type = ZEND_INTERNAL_FUNCTION;
fe.handler = ZEND_FN(SoapClient___call);
- fe.function_name = NULL;
+ fe.function_name.v = NULL;
fe.scope = NULL;
fe.fn_flags = 0;
fe.prototype = NULL;
zend_hash_internal_pointer_reset_ex(ft, &pos);
while (zend_hash_get_current_data_ex(ft, (void **)&f, &pos) != FAILURE) {
if ((service->type != SOAP_CLASS) || (f->common.fn_flags & ZEND_ACC_PUBLIC)) {
- add_next_index_string(return_value, f->common.function_name, 1);
+ /* FIXME: Unicode support??? */
+ add_next_index_string(return_value, f->common.function_name.s, 1);
}
zend_hash_move_forward_ex(ft, &pos);
}
}
MAKE_STD_ZVAL(function_copy);
- ZVAL_STRING(function_copy, f->common.function_name, 1);
+ ZVAL_TEXT(function_copy, f->common.function_name, 1);
zend_hash_update(service->soap_functions.ft, key, key_len+1, &function_copy, sizeof(zval *), NULL);
efree(key);
}
MAKE_STD_ZVAL(function_copy);
- ZVAL_STRING(function_copy, f->common.function_name, 1);
+ ZVAL_TEXT(function_copy, f->common.function_name, 1);
zend_hash_update(service->soap_functions.ft, key, key_len+1, &function_copy, sizeof(zval *), NULL);
efree(key);
} else if (function_name->type == IS_LONG) {
#else
{
#endif
- int class_name_len = strlen(service->soap_class.ce->name);
+ /* FIXME: Unicode support??? */
+ int class_name_len = strlen(service->soap_class.ce->name.s);
char *class_name = emalloc(class_name_len+1);
- memcpy(class_name, service->soap_class.ce->name,class_name_len+1);
+ memcpy(class_name, service->soap_class.ce->name.s, class_name_len+1);
if (zend_hash_exists(&Z_OBJCE_P(tmp_soap)->function_table, php_strtolower(class_name, class_name_len), class_name_len+1)) {
zval c_ret, constructor;
INIT_ZVAL(c_ret);
INIT_ZVAL(constructor);
- ZVAL_STRING(&constructor, service->soap_class.ce->name, 1);
+ ZVAL_TEXT(&constructor, service->soap_class.ce->name, 1);
if (call_user_function(NULL, &tmp_soap, &constructor, &c_ret, service->soap_class.argc, service->soap_class.argv TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error calling constructor");
}
}
/* }}} */
-static zend_class_entry * spl_find_ce_by_name(zend_uchar ztype, void *name, int len, zend_bool autoload TSRMLS_DC)
+static zend_class_entry * spl_find_ce_by_name(zend_uchar ztype, zstr name, int len, zend_bool autoload TSRMLS_DC)
{
zend_class_entry **ce;
int found;
if (!autoload) {
- char *lc_name;
+ zstr lc_name;
lc_name = zend_u_str_tolower_dup(ztype, name, len);
found = zend_u_hash_find(EG(class_table), ztype, lc_name, len +1, (void **) &ce);
- efree(lc_name);
+ efree(lc_name.v);
} else {
found = zend_u_lookup_class(ztype, name, len, &ce TSRMLS_CC);
}
{
zval *class_name, *retval = NULL;
int class_name_len, class_name_type;
- char *func_name, *lc_name;
+ zstr func_name, lc_name;
uint func_name_len;
ulong dummy;
HashPosition function_pos;
while(zend_hash_has_more_elements_ex(SPL_G(autoload_functions), &function_pos) == SUCCESS && !EG(exception)) {
zend_hash_get_current_key_ex(SPL_G(autoload_functions), &func_name, &func_name_len, &dummy, 0, &function_pos);
zend_hash_get_current_data_ex(SPL_G(autoload_functions), (void **) &alfi, &function_pos);
- zend_call_method(alfi->obj ? &alfi->obj : NULL, alfi->ce, &alfi->func_ptr, func_name, func_name_len, &retval, 1, class_name, NULL TSRMLS_CC);
+ /* TODO: Unicode support??? */
+ zend_call_method(alfi->obj ? &alfi->obj : NULL, alfi->ce, &alfi->func_ptr, func_name.s, func_name_len, &retval, 1, class_name, NULL TSRMLS_CC);
if (retval) {
zval_ptr_dtor(&retval);
}
}
zend_hash_move_forward_ex(SPL_G(autoload_functions), &function_pos);
}
- efree(lc_name);
+ efree(lc_name.v);
} else {
/* do not use or overwrite &EG(autoload_func) here */
zend_call_method_with_1_params(NULL, NULL, NULL, "spl_autoload", NULL, class_name);
Unregister given function as __autoload() implementation */
PHP_FUNCTION(spl_autoload_unregister)
{
- char *func_name, *lc_name;
+ zstr func_name, lc_name;
int func_name_len, success = FAILURE;
zend_function *spl_func_ptr;
zend_uchar func_name_type;
}
}
- efree(lc_name);
+ efree(lc_name.v);
RETURN_BOOL(success == SUCCESS);
} /* }}} */
switch(Z_TYPE_P(offset)) {
case IS_STRING:
case IS_UNICODE:
- if (*(char*)Z_UNIVAL_P(offset) == '\0') {
+ /* FIXME: Unicode support??? */
+ if (Z_STRVAL_P(offset)[0] == '\0') {
zend_throw_exception(spl_ce_InvalidArgumentException, "An offset must not begin with \\0 or be empty", 0 TSRMLS_CC);
return;
}
static int spl_array_skip_protected(spl_array_object *intern TSRMLS_DC) /* {{{ */
{
- char *string_key;
+ zstr string_key;
uint string_length;
ulong num_key;
HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
do {
if (zend_hash_get_current_key_ex(aht, &string_key, &string_length, &num_key, 0, &intern->pos) == (UG(unicode)?HASH_KEY_IS_UNICODE:HASH_KEY_IS_STRING)) {
if (!string_length ||
- ((UG(unicode) && ((UChar*)string_key)[0]) ||
- (!UG(unicode) && string_key[0]))) {
+ ((UG(unicode) && string_key.u[0]) ||
+ (!UG(unicode) && string_key.s[0]))) {
return SUCCESS;
}
} else {
}
/* }}} */
-static int spl_array_it_get_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC) /* {{{ */
+static int spl_array_it_get_current_key(zend_object_iterator *iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC) /* {{{ */
{
spl_array_it *iterator = (spl_array_it *)iter;
spl_array_object *object = iterator->object;
void spl_array_iterator_key(zval *object, zval *return_value TSRMLS_DC) /* {{{ */
{
spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
- char *string_key;
+ zstr string_key;
uint string_length;
ulong num_key;
HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
switch (zend_hash_get_current_key_ex(aht, &string_key, &string_length, &num_key, 1, &intern->pos)) {
case HASH_KEY_IS_STRING:
- RETVAL_STRINGL(string_key, string_length - 1, 0);
+ RETVAL_STRINGL(string_key.s, string_length - 1, 0);
break;
case HASH_KEY_IS_UNICODE:
- RETVAL_UNICODEL((UChar*)string_key, string_length - 1, 0);
+ RETVAL_UNICODEL(string_key.u, string_length - 1, 0);
break;
case HASH_KEY_IS_LONG:
RETVAL_LONG(num_key);
static void spl_filesystem_dir_it_dtor(zend_object_iterator *iter TSRMLS_DC);
static int spl_filesystem_dir_it_valid(zend_object_iterator *iter TSRMLS_DC);
static void spl_filesystem_dir_it_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC);
-static int spl_filesystem_dir_it_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC);
+static int spl_filesystem_dir_it_current_key(zend_object_iterator *iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC);
static void spl_filesystem_dir_it_move_forward(zend_object_iterator *iter TSRMLS_DC);
static void spl_filesystem_dir_it_rewind(zend_object_iterator *iter TSRMLS_DC);
/* }}} */
/* {{{ spl_filesystem_dir_it_current_key */
-static int spl_filesystem_dir_it_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
+static int spl_filesystem_dir_it_current_key(zend_object_iterator *iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
{
spl_filesystem_dir_it *iterator = (spl_filesystem_dir_it *)iter;
spl_filesystem_object *object = iterator->object;
/* }}} */
/* {{{ spl_filesystem_tree_it_current_key */
-static int spl_filesystem_tree_it_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
+static int spl_filesystem_tree_it_current_key(zend_object_iterator *iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
{
spl_filesystem_dir_it *iterator = (spl_filesystem_dir_it *)iter;
spl_filesystem_object *object = iterator->object;
if (object->flags & SPL_FILE_DIR_KEY_AS_FILENAME) {
*str_key_len = strlen(object->u.dir.entry.d_name) + 1;
- *str_key = estrndup(object->u.dir.entry.d_name, *str_key_len - 1);
+ str_key->s = estrndup(object->u.dir.entry.d_name, *str_key_len - 1);
} else {
spl_filesystem_object_get_file_name(object TSRMLS_CC);
*str_key_len = object->file_name_len + 1;
- *str_key = estrndup(object->file_name, object->file_name_len);
+ str_key->s = estrndup(object->file_name, object->file_name_len);
}
return HASH_KEY_IS_STRING;
}
zend_get_parameters_array_ex(ZEND_NUM_ARGS(), params+(arg2 ? 2 : 1));
- ZVAL_STRING(&z_fname, func_ptr->common.function_name, 0);
+ ZVAL_STRING(&z_fname, func_ptr->common.function_name.s, 0);
fci.size = sizeof(fci);
fci.function_table = EG(function_table);
static inline int spl_instantiate_arg_ex1(zend_class_entry *pce, zval **retval, int alloc, zval *arg1 TSRMLS_DC)
{
spl_instantiate(pce, retval, alloc TSRMLS_CC);
-
- zend_call_method(retval, pce, &pce->constructor, pce->constructor->common.function_name, strlen(pce->constructor->common.function_name), NULL, 1, arg1, NULL TSRMLS_CC);
+
+ /* FIXME: Unicode support??? */
+ zend_call_method(retval, pce, &pce->constructor, pce->constructor->common.function_name.s, strlen(pce->constructor->common.function_name.s), NULL, 1, arg1, NULL TSRMLS_CC);
return 0;
}
/* }}} */
{
spl_instantiate(pce, retval, alloc TSRMLS_CC);
- zend_call_method(retval, pce, &pce->constructor, pce->constructor->common.function_name, strlen(pce->constructor->common.function_name), NULL, 2, arg1, arg2 TSRMLS_CC);
+ /* FIXME: Unicode support??? */
+ zend_call_method(retval, pce, &pce->constructor, pce->constructor->common.function_name.s, strlen(pce->constructor->common.function_name.s), NULL, 2, arg1, arg2 TSRMLS_CC);
return 0;
}
/* }}} */
sub_iter->funcs->get_current_data(sub_iter, data TSRMLS_CC);
}
-static int spl_recursive_it_get_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
+static int spl_recursive_it_get_current_key(zend_object_iterator *iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
{
spl_recursive_it_object *object = (spl_recursive_it_object*)iter->data;
zend_object_iterator *sub_iter = object->iterators[object->level].iterator;
zend_object_iterator *iterator = object->iterators[object->level].iterator;
if (iterator->funcs->get_current_key) {
- char *str_key;
+ zstr str_key;
uint str_key_len;
ulong int_key;
RETURN_LONG(int_key);
break;
case HASH_KEY_IS_STRING:
- RETURN_STRINGL(str_key, str_key_len-1, 0);
+ RETURN_STRINGL(str_key.s, str_key_len-1, 0);
break;
case HASH_KEY_IS_UNICODE:
- RETURN_UNICODEL((void*)str_key, str_key_len-1, 0);
+ RETURN_UNICODEL(str_key.u, str_key_len-1, 0);
break;
default:
RETURN_NULL();
}
} /* }}} */
-static union _zend_function *spl_recursive_it_get_method(zval **object_ptr, char *method, int method_len TSRMLS_DC)
+static union _zend_function *spl_recursive_it_get_method(zval **object_ptr, zstr method, int method_len TSRMLS_DC)
{
union _zend_function *function_handler;
spl_recursive_it_object *object = (spl_recursive_it_object*)zend_object_store_get_object(*object_ptr TSRMLS_CC);
function_handler = std_object_handlers.get_method(object_ptr, method, method_len TSRMLS_CC);
if (!function_handler) {
- if (zend_hash_find(&Z_OBJCE_P(zobj)->function_table, method, method_len+1, (void **) &function_handler) == FAILURE) {
+ if (zend_u_hash_find(&Z_OBJCE_P(zobj)->function_table, UG(unicode)?IS_UNICODE:IS_STRING, method, method_len+1, (void **) &function_handler) == FAILURE) {
if (Z_OBJ_HT_P(zobj)->get_method) {
*object_ptr = zobj;
function_handler = Z_OBJ_HT_P(*object_ptr)->get_method(object_ptr, method, method_len TSRMLS_CC);
}
#endif
-static union _zend_function *spl_dual_it_get_method(zval **object_ptr, char *method, int method_len TSRMLS_DC)
+static union _zend_function *spl_dual_it_get_method(zval **object_ptr, zstr method, int method_len TSRMLS_DC)
{
union _zend_function *function_handler;
spl_dual_it_object *intern;
function_handler = std_object_handlers.get_method(object_ptr, method, method_len TSRMLS_CC);
if (!function_handler) {
- if (zend_hash_find(&intern->inner.ce->function_table, method, method_len+1, (void **) &function_handler) == FAILURE) {
+ if (zend_u_hash_find(&intern->inner.ce->function_table, UG(unicode)?IS_UNICODE:IS_STRING, method, method_len+1, (void **) &function_handler) == FAILURE) {
if (Z_OBJ_HT_P(intern->inner.zobject)->get_method) {
*object_ptr = intern->inner.zobject;
function_handler = Z_OBJ_HT_P(*object_ptr)->get_method(object_ptr, method, method_len TSRMLS_CC);
zval_ptr_dtor(&intern->current.data);
intern->current.data = NULL;
}
- if (intern->current.str_key) {
- efree(intern->current.str_key);
- intern->current.str_key = NULL;
+ if (intern->current.str_key.v) {
+ efree(intern->current.str_key.v);
+ intern->current.str_key.v = NULL;
}
if (intern->dit_type == DIT_CachingIterator || intern->dit_type == DIT_RecursiveCachingIterator) {
if (intern->u.caching.zstr) {
if (intern->current.data) {
if (intern->current.key_type == HASH_KEY_IS_STRING) {
- RETURN_STRINGL(intern->current.str_key, intern->current.str_key_len-1, 1);
+ RETURN_STRINGL(intern->current.str_key.s, intern->current.str_key_len-1, 1);
} else if (intern->current.key_type == HASH_KEY_IS_UNICODE) {
- RETURN_UNICODEL((UChar *)intern->current.str_key, intern->current.str_key_len-1, 1);
+ RETURN_UNICODEL(intern->current.str_key.u, intern->current.str_key_len-1, 1);
} else {
RETURN_LONG(intern->current.int_key);
}
subject = &tmp[0];
} else {
subject_len = intern->current.str_key_len;
- subject = intern->current.str_key;
+ /* FIXME: Unicode support??? */
+ subject = intern->current.str_key.s;
}
} else {
zend_make_printable_zval(intern->current.data, &subject_copy, &use_copy);
}
if (intern->u.caching.flags & CIT_TOSTRING_USE_KEY) {
if (intern->current.key_type == HASH_KEY_IS_STRING) {
- RETURN_STRINGL(intern->current.str_key, intern->current.str_key_len, 1);
+ RETURN_STRINGL(intern->current.str_key.s, intern->current.str_key_len, 1);
} else if (intern->current.key_type == HASH_KEY_IS_UNICODE) {
- RETURN_UNICODEL((void*)intern->current.str_key, intern->current.str_key_len, 1);
+ RETURN_UNICODEL(intern->current.str_key.u, intern->current.str_key_len, 1);
} else {
RETVAL_LONG(intern->current.int_key);
convert_to_string(return_value);
SPL_METHOD(CachingIterator, offsetSet)
{
spl_dual_it_object *intern;
- void *arKey;
+ zstr arKey;
uint nKeyLength;
zend_uchar type;
zval *value;
SPL_METHOD(CachingIterator, offsetGet)
{
spl_dual_it_object *intern;
- void *arKey;
+ zstr arKey;
uint nKeyLength;
zend_uchar type;
zval **value;
SPL_METHOD(CachingIterator, offsetUnset)
{
spl_dual_it_object *intern;
- void *arKey;
+ zstr arKey;
uint nKeyLength;
zend_uchar type;
SPL_METHOD(CachingIterator, offsetExists)
{
spl_dual_it_object *intern;
- void *arKey;
+ zstr arKey;
uint nKeyLength;
zend_uchar type;
intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (intern->inner.iterator->funcs->get_current_key) {
- char *str_key;
+ zstr str_key;
uint str_key_len;
ulong int_key;
switch (intern->inner.iterator->funcs->get_current_key(intern->inner.iterator, &str_key, &str_key_len, &int_key TSRMLS_CC)) {
RETURN_LONG(int_key);
break;
case HASH_KEY_IS_STRING:
- RETURN_STRINGL(str_key, str_key_len-1, 0);
+ RETURN_STRINGL(str_key.s, str_key_len-1, 0);
break;
case HASH_KEY_IS_UNICODE:
- RETURN_UNICODEL((void*)str_key, str_key_len-1, 0);
+ RETURN_UNICODEL(str_key.u, str_key_len-1, 0);
break;
default:
RETURN_NULL();
{
zval *obj, **data;
zend_object_iterator *iter;
- char *str_key;
+ zstr str_key;
uint str_key_len;
ulong int_key;
int key_type;
key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC);
switch(key_type) {
case HASH_KEY_IS_STRING:
- add_assoc_zval_ex(return_value, str_key, str_key_len, *data);
- efree(str_key);
+ add_assoc_zval_ex(return_value, str_key.s, str_key_len, *data);
+ efree(str_key.s);
break;
case HASH_KEY_IS_UNICODE:
add_u_assoc_zval_ex(return_value, IS_UNICODE, str_key, str_key_len, *data);
- efree(str_key);
+ efree(str_key.u);
break;
case HASH_KEY_IS_LONG:
add_index_zval(return_value, int_key, *data);
} inner;
struct {
zval *data;
- char *str_key;
+ zstr str_key;
uint str_key_len;
ulong int_key;
int key_type; /* HASH_KEY_IS_STRING or HASH_KEY_IS_LONG */
}
-int sqlite_iterator_get_current_key(zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
+int sqlite_iterator_get_current_key(zend_object_iterator *iter, zstr *str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
{
struct php_sqlite_result *res = ((sqlite_object_iterator*)iter)->res;
- *str_key = NULL;
+ str_key->v = NULL;
*str_key_len = 0;
*int_key = res ? res->curr_row : 0;
return HASH_KEY_IS_LONG;
zend_bool decode_binary = 1;
struct php_sqlite_result *res;
zval *object = getThis();
- char *class_name;
+ zstr class_name;
int class_name_len;
zend_class_entry *ce;
zval dataset;
Z_LVAL(first) = f->h;
} else if (f->key.type == IS_UNICODE) {
Z_TYPE(first) = IS_UNICODE;
- Z_USTRVAL(first) = f->key.u.unicode;
+ Z_USTRVAL(first) = f->key.arKey.u;
Z_USTRLEN(first) = f->nKeyLength-1;
} else {
Z_TYPE(first) = f->key.type;
- Z_STRVAL(first) = f->key.u.string;
+ Z_STRVAL(first) = f->key.arKey.s;
Z_STRLEN(first) = f->nKeyLength-1;
}
Z_LVAL(second) = s->h;
} else if (s->key.type == IS_UNICODE) {
Z_TYPE(second) = IS_UNICODE;
- Z_USTRVAL(second) = s->key.u.unicode;
+ Z_USTRVAL(second) = s->key.arKey.u;
Z_USTRLEN(second) = s->nKeyLength-1;
} else {
Z_TYPE(second) = s->key.type;
- Z_STRVAL(second) = s->key.u.string;
+ Z_STRVAL(second) = s->key.arKey.s;
Z_STRLEN(second) = s->nKeyLength-1;
}
Z_LVAL(key1) = f->h;
Z_TYPE(key1) = IS_LONG;
} else if (f->key.type == IS_UNICODE) {
- Z_USTRVAL(key1) = eustrndup(f->key.u.unicode, f->nKeyLength-1);
+ Z_USTRVAL(key1) = eustrndup(f->key.arKey.u, f->nKeyLength-1);
Z_USTRLEN(key1) = f->nKeyLength-1;
Z_TYPE(key1) = IS_UNICODE;
} else {
- Z_STRVAL(key1) = estrndup(f->key.u.string, f->nKeyLength-1);
+ Z_STRVAL(key1) = estrndup(f->key.arKey.s, f->nKeyLength-1);
Z_STRLEN(key1) = f->nKeyLength-1;
Z_TYPE(key1) = f->key.type;
}
Z_LVAL(key2) = s->h;
Z_TYPE(key2) = IS_LONG;
} else if (s->key.type == IS_UNICODE) {
- Z_USTRVAL(key2) = eustrndup(s->key.u.unicode, s->nKeyLength-1);
+ Z_USTRVAL(key2) = eustrndup(s->key.arKey.u, s->nKeyLength-1);
Z_USTRLEN(key2) = s->nKeyLength-1;
Z_TYPE(key2) = IS_UNICODE;
} else {
- Z_STRVAL(key2) = estrndup(s->key.u.string, s->nKeyLength-1);
+ Z_STRVAL(key2) = estrndup(s->key.arKey.s, s->nKeyLength-1);
Z_STRLEN(key2) = s->nKeyLength-1;
Z_TYPE(key2) = s->key.type;
}
PHP_FUNCTION(key)
{
zval **array;
- char *string_key;
+ zstr string_key;
uint string_length;
ulong num_key;
HashTable *target_hash;
}
switch (zend_hash_get_current_key_ex(target_hash, &string_key, &string_length, &num_key, 0, NULL)) {
case HASH_KEY_IS_STRING:
- RETVAL_STRINGL(string_key, string_length - 1, 1);
+ RETVAL_STRINGL(string_key.s, string_length - 1, 1);
break;
case HASH_KEY_IS_UNICODE:
- RETVAL_UNICODEL((UChar*)string_key, string_length - 1, 1);
+ RETVAL_UNICODEL(string_key.u, string_length - 1, 1);
break;
case HASH_KEY_IS_LONG:
RETVAL_LONG(num_key);
zval **args[3], /* Arguments to userland function */
*retval_ptr, /* Return value - unused */
*key=NULL; /* Entry key */
- char *string_key;
+ zstr string_key;
uint string_key_len;
ulong num_key;
HashPosition pos;
Z_LVAL_P(key) = num_key;
break;
case HASH_KEY_IS_STRING:
- ZVAL_STRINGL(key, string_key, string_key_len-1, 1);
+ ZVAL_STRINGL(key, string_key.s, string_key_len-1, 1);
break;
case HASH_KEY_IS_UNICODE:
- ZVAL_UNICODEL(key, (UChar*)string_key, string_key_len-1, 1);
+ ZVAL_UNICODEL(key, string_key.u, string_key_len-1, 1);
break;
}
HashPosition pos; /* hash iterator */
ulong num_key;
uint str_key_len;
- char *string_key;
+ zstr string_key;
int (*is_equal_func)(zval *, zval *, zval * TSRMLS_DC) = is_equal_function;
if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > 3 ||
/* Return current key */
switch (zend_hash_get_current_key_ex(target_hash, &string_key, &str_key_len, &num_key, 0, &pos)) {
case HASH_KEY_IS_STRING:
- RETURN_STRINGL(string_key, str_key_len-1, 1);
+ RETURN_STRINGL(string_key.s, str_key_len-1, 1);
break;
case HASH_KEY_IS_UNICODE:
- RETURN_UNICODEL((UChar*)string_key, str_key_len-1, 1);
+ RETURN_UNICODEL(string_key.u, str_key_len-1, 1);
break;
case HASH_KEY_IS_LONG:
RETURN_LONG(num_key);
{
zval **var_array, **z_extract_type, **prefix;
zval **entry, *data;
- void *var_name;
+ zstr var_name;
ulong num_key;
uint var_name_len;
int var_exists, extract_type, key_type, count = 0;
ZVAL_NULL(&final_name);
- key_type = zend_hash_get_current_key_ex(Z_ARRVAL_PP(var_array), (char **)&var_name, &var_name_len, &num_key, 0, &pos);
+ key_type = zend_hash_get_current_key_ex(Z_ARRVAL_PP(var_array), &var_name, &var_name_len, &num_key, 0, &pos);
var_exists = 0;
if (key_type == HASH_KEY_IS_STRING ||
/* break omitted intentionally */
case EXTR_OVERWRITE:
- if (var_exists && !strcmp(var_name, "GLOBALS")) {
+ /* FIXME: Unicode support??? */
+ if (var_exists && !strcmp(var_name.s, "GLOBALS")) {
break;
}
Z_USTRVAL(final_name) = eumalloc(Z_USTRLEN(final_name)+1);
memcpy(Z_USTRVAL(final_name), Z_USTRVAL_PP(prefix), UBYTES(Z_USTRLEN_PP(prefix)));
Z_USTRVAL(final_name)[Z_USTRLEN_PP(prefix)] = '_';
- memcpy(Z_USTRVAL(final_name)+Z_USTRLEN_PP(prefix)+1, var_name, UBYTES(var_name_len+1));
+ memcpy(Z_USTRVAL(final_name)+Z_USTRLEN_PP(prefix)+1, var_name.u, UBYTES(var_name_len+1));
} else {
Z_TYPE(final_name) = IS_STRING;
Z_STRVAL(final_name) = emalloc(Z_STRLEN(final_name)+1);
memcpy(Z_STRVAL(final_name), Z_STRVAL_PP(prefix), Z_STRLEN_PP(prefix));
Z_STRVAL(final_name)[Z_STRLEN_PP(prefix)] = '_';
- memcpy(Z_STRVAL(final_name)+Z_STRLEN_PP(prefix)+1, var_name, var_name_len+1);
+ memcpy(Z_STRVAL(final_name)+Z_STRLEN_PP(prefix)+1, var_name.s, var_name_len+1);
}
}
break;
Z_USTRVAL(final_name) = eumalloc(Z_USTRLEN(final_name)+1);
memcpy(Z_USTRVAL(final_name), Z_USTRVAL_PP(prefix), UBYTES(Z_USTRLEN_PP(prefix)));
Z_USTRVAL(final_name)[Z_USTRLEN_PP(prefix)] = '_';
- memcpy(Z_USTRVAL(final_name)+Z_USTRLEN_PP(prefix)+1, var_name, UBYTES(var_name_len+1));
+ memcpy(Z_USTRVAL(final_name)+Z_USTRLEN_PP(prefix)+1, var_name.u, UBYTES(var_name_len+1));
} else {
Z_TYPE(final_name) = IS_STRING;
Z_STRVAL(final_name) = emalloc(Z_STRLEN(final_name)+1);
memcpy(Z_STRVAL(final_name), Z_STRVAL_PP(prefix), Z_STRLEN_PP(prefix));
Z_STRVAL(final_name)[Z_STRLEN_PP(prefix)] = '_';
- memcpy(Z_STRVAL(final_name)+Z_STRLEN_PP(prefix)+1, var_name, var_name_len+1);
+ memcpy(Z_STRVAL(final_name)+Z_STRLEN_PP(prefix)+1, var_name.s, var_name_len+1);
}
}
break;
case EXTR_PREFIX_INVALID:
if (Z_TYPE(final_name) == IS_NULL) {
- if (!php_valid_var_name(var_name)) {
+ /* FIXME: Unicode support??? */
+ if (!php_valid_var_name(var_name.s)) {
Z_STRLEN(final_name) = Z_UNILEN_PP(prefix) + 1 + var_name_len;
if (UG(unicode)) {
Z_TYPE(final_name) = IS_UNICODE;
Z_USTRVAL(final_name) = eumalloc(Z_USTRLEN(final_name)+1);
memcpy(Z_USTRVAL(final_name), Z_USTRVAL_PP(prefix), UBYTES(Z_USTRLEN_PP(prefix)));
Z_USTRVAL(final_name)[Z_USTRLEN_PP(prefix)] = '_';
- memcpy(Z_USTRVAL(final_name)+Z_USTRLEN_PP(prefix)+1, var_name, UBYTES(var_name_len+1));
+ memcpy(Z_USTRVAL(final_name)+Z_USTRLEN_PP(prefix)+1, var_name.u, UBYTES(var_name_len+1));
} else {
Z_TYPE(final_name) = IS_STRING;
Z_STRVAL(final_name) = emalloc(Z_STRLEN(final_name)+1);
memcpy(Z_STRVAL(final_name), Z_STRVAL_PP(prefix), Z_STRLEN_PP(prefix));
Z_STRVAL(final_name)[Z_STRLEN_PP(prefix)] = '_';
- memcpy(Z_STRVAL(final_name)+Z_STRLEN_PP(prefix)+1, var_name, var_name_len+1);
+ memcpy(Z_STRVAL(final_name)+Z_STRLEN_PP(prefix)+1, var_name.s, var_name_len+1);
}
} else {
ZVAL_TEXTL(&final_name, var_name, var_name_len, 1);
}
if (Z_TYPE(final_name) != IS_NULL) {
- if (php_valid_var_name(Z_UNIVAL(final_name))) {
+ /* FIXME: Unicode support??? */
+ if (php_valid_var_name(Z_STRVAL(final_name))) {
if (extract_refs) {
zval **orig_var;
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, &p->key.u, 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);
}
}
if (p->nKeyLength == 0) {
zend_hash_next_index_insert(*removed, &entry, sizeof(zval *), NULL);
} else {
- zend_u_hash_update(*removed, p->key.type, &p->key.u, 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 */
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, &p->key.u, 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);
}
}
{
zval **stack, /* Input stack */
**val; /* Value to be popped */
- char *key = NULL;
+ zstr key = (zstr)NULL;
int key_len = 0;
ulong index;
zend_uchar key_type;
/* Delete the first or last value */
key_type = zend_hash_get_current_key_ex(Z_ARRVAL_PP(stack), &key, &key_len, &index, 0, NULL);
- if (key && Z_ARRVAL_PP(stack) == &EG(symbol_table)) {
+ if (key.v && Z_ARRVAL_PP(stack) == &EG(symbol_table)) {
if (key_type == HASH_KEY_IS_UNICODE) key_type = IS_UNICODE;
else key_type = IS_STRING;
zend_u_delete_global_variable(key_type, key, key_len-1 TSRMLS_CC);
} else {
- zend_hash_del_key_or_index(Z_ARRVAL_PP(stack), key, key_len, index, (key) ? HASH_DEL_KEY : HASH_DEL_INDEX);
+ zend_u_hash_del_key_or_index(Z_ARRVAL_PP(stack), key_type, key, key_len, index, (key.v) ? HASH_DEL_KEY : HASH_DEL_INDEX);
}
/* If we did a shift... re-index like it did before */
pos, /* Current position in the array */
argc; /* Number of function arguments */
- char *string_key;
+ zstr string_key;
uint string_key_len;
ulong num_key;
HashPosition hpos;
PHPAPI int php_array_merge(HashTable *dest, HashTable *src, int recursive TSRMLS_DC)
{
zval **src_entry, **dest_entry;
- char *string_key;
+ zstr string_key;
uint string_key_len;
ulong num_key;
HashPosition pos;
**strict, /* be strict */
*new_val; /* New value */
int add_key; /* Flag to indicate whether a key should be added */
- char *string_key; /* String key */
+ zstr string_key; /* String key */
uint string_key_len;
ulong num_key; /* Numeric key */
HashPosition pos;
switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(input), &string_key, &string_key_len, &num_key, 1, &pos)) {
case HASH_KEY_IS_STRING:
- ZVAL_STRINGL(new_val, string_key, string_key_len-1, 0);
+ ZVAL_STRINGL(new_val, string_key.s, string_key_len-1, 0);
goto ukey;
case HASH_KEY_IS_UNICODE:
- ZVAL_UNICODEL(new_val, (UChar*)string_key, string_key_len-1, 0);
+ ZVAL_UNICODEL(new_val, string_key.u, string_key_len-1, 0);
ukey:
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &new_val,
sizeof(zval *), NULL);
zval **input, /* Input array */
**z_preserve_keys, /* Flag: whether to preserve keys */
**entry; /* An entry in the input array */
- char *string_key;
+ zstr string_key;
uint string_key_len;
ulong num_key;
zend_bool preserve_keys = 0;
{
zval **array, **entry, *data;
HashTable *target_hash;
- char *string_key;
+ zstr string_key;
uint str_key_len;
ulong num_key;
HashPosition pos;
MAKE_STD_ZVAL(data);
switch (zend_hash_get_current_key_ex(target_hash, &string_key, &str_key_len, &num_key, 1, &pos)) {
case HASH_KEY_IS_STRING:
- ZVAL_STRINGL(data, string_key, str_key_len-1, 0);
+ ZVAL_STRINGL(data, string_key.s, str_key_len-1, 0);
break;
case HASH_KEY_IS_UNICODE:
- ZVAL_UNICODEL(data, (UChar *)string_key, str_key_len-1, 0);
+ ZVAL_UNICODEL(data, string_key.u, str_key_len-1, 0);
break;
case HASH_KEY_IS_LONG:
Z_TYPE_P(data) = IS_LONG;
PHP_FUNCTION(array_change_key_case)
{
zval **array, **entry, **to_upper;
- char *string_key;
- char *new_key;
+ zstr string_key;
+ zstr new_key;
uint str_key_len;
ulong num_key;
ulong change_to_upper=0;
zend_hash_index_update(Z_ARRVAL_P(return_value), num_key, entry, sizeof(entry), NULL);
break;
case HASH_KEY_IS_STRING:
- new_key = estrndup(string_key,str_key_len - 1);
+ new_key.s = estrndup(string_key.s, str_key_len - 1);
if (change_to_upper)
- php_strtoupper(new_key, str_key_len - 1);
+ php_strtoupper(new_key.s, str_key_len - 1);
else
- php_strtolower(new_key, str_key_len - 1);
+ php_strtolower(new_key.s, str_key_len - 1);
zend_u_hash_update(Z_ARRVAL_P(return_value), IS_STRING, new_key, str_key_len, entry, sizeof(entry), NULL);
- efree(new_key);
+ efree(new_key.s);
break;
case HASH_KEY_IS_UNICODE:
- {
- UChar *new_key_u;
-
- new_key_u = eustrndup((UChar *)string_key,str_key_len - 1);
- str_key_len--;
- if (change_to_upper)
- new_key_u = php_u_strtoupper(&new_key_u, &str_key_len, UG(default_locale));
- else
- new_key_u = php_u_strtolower(&new_key_u, &str_key_len, UG(default_locale));
- str_key_len++;
- zend_u_hash_update(Z_ARRVAL_P(return_value), IS_UNICODE, new_key_u, str_key_len, entry, sizeof(entry), NULL);
- efree(new_key_u);
- }
+ new_key.u = eustrndup(string_key.u, str_key_len - 1);
+ str_key_len--;
+ if (change_to_upper)
+ new_key.u = php_u_strtoupper(&new_key.u, &str_key_len, UG(default_locale));
+ else
+ new_key.u = php_u_strtolower(&new_key.u, &str_key_len, UG(default_locale));
+ str_key_len++;
+ zend_u_hash_update(Z_ARRVAL_P(return_value), IS_UNICODE, new_key, str_key_len, entry, sizeof(entry), NULL);
+ efree(new_key.u);
break;
}
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, &p->key.u, 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, &p->key.u, p->nKeyLength);
+ zend_u_hash_del(Z_ARRVAL_P(return_value), p->key.type, (zstr)p->key.arKey.s, p->nKeyLength);
}
}
}
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, &p->key.u, p->nKeyLength);
+ zend_u_hash_del(Z_ARRVAL_P(return_value), p->key.type, (zstr)p->key.arKey.s, p->nKeyLength);
}
}
}
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, &p->key.u, 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;
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, &p->key.u, 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;
zval **input, **num_req;
long randval;
int num_req_val, num_avail, key_type;
- char *string_key;
+ zstr string_key;
uint string_key_len;
ulong num_key;
HashPosition pos;
/* If we are returning a single result, just do it. */
if (Z_TYPE_P(return_value) != IS_ARRAY) {
if (key_type == HASH_KEY_IS_STRING) {
- RETURN_STRINGL(string_key, string_key_len-1, 1);
+ RETURN_STRINGL(string_key.s, string_key_len-1, 1);
} else if (key_type == HASH_KEY_IS_UNICODE) {
- RETURN_UNICODEL((UChar *)string_key, string_key_len-1, 1);
+ RETURN_UNICODEL(string_key.u, string_key_len-1, 1);
} else {
RETURN_LONG(num_key);
}
} else {
/* Append the result to the return value. */
if (key_type == HASH_KEY_IS_STRING)
- add_next_index_stringl(return_value, string_key, string_key_len-1, 1);
+ add_next_index_stringl(return_value, string_key.s, string_key_len-1, 1);
else if (key_type == HASH_KEY_IS_UNICODE)
- add_next_index_unicodel(return_value, (UChar *)string_key, string_key_len-1, 1);
+ add_next_index_unicodel(return_value, string_key.u, string_key_len-1, 1);
else
add_next_index_long(return_value, num_key);
}
zval **args[1];
zval *retval = NULL;
zval callback_name;
- char *string_key;
+ zstr string_key;
zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
uint string_key_len;
ulong num_key;
for (k = 0; k < maxlen; k++) {
uint str_key_len;
ulong num_key;
- char *str_key;
+ zstr str_key;
int key_type = 0;
/*
{
int argc = ZEND_NUM_ARGS(), key_type;
long size, current = 0;
- char *str_key;
+ zstr str_key;
uint str_key_len;
ulong num_key;
zend_bool preserve_keys = 0;
}
convert_to_string_ex(const_name);
- if (!zend_u_get_constant(Z_TYPE_PP(const_name), Z_STRVAL_PP(const_name), Z_STRLEN_PP(const_name), return_value TSRMLS_CC)) {
+ if (!zend_u_get_constant(Z_TYPE_PP(const_name), Z_UNIVAL_PP(const_name), Z_UNILEN_PP(const_name), return_value TSRMLS_CC)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't find constant %s", Z_STRVAL_PP(const_name));
RETURN_NULL();
}
}
if (hash_key->nKeyLength == 0 ||
- hash_key->type != IS_STRING ||
- hash_key->u.string[0] != 0) {
+ hash_key->type != IS_STRING ||
+ hash_key->arKey.s[0] != 0) {
MAKE_STD_ZVAL(option);
array_init(option);
if (!hash_key->nKeyLength) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Numeric key detected - possible security hazard.");
return 0;
- } else if (!strcmp(hash_key->u.string, "GLOBALS")) {
+ /* FIXME: Unicode support??? */
+ } else if (!strcmp(hash_key->arKey.s, "GLOBALS")) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempted GLOBALS variable overwrite.");
return 0;
}
new_key = (char *) emalloc(new_key_len);
memcpy(new_key, prefix, prefix_len);
- memcpy(new_key+prefix_len, hash_key->u.string, hash_key->nKeyLength);
+ /* FIXME: Unicode support??? */
+ memcpy(new_key+prefix_len, hash_key->arKey.s, hash_key->nKeyLength);
} else {
new_key_len = spprintf(&new_key, 0, "%s%ld", prefix, hash_key->h);
}
const char *key_suffix, int key_suffix_len,
zval *type, char *arg_sep TSRMLS_DC)
{
- char *key = NULL, *ekey, *newprefix, *p;
+ zstr key;
+ char *ekey, *newprefix, *p;
int arg_sep_len, key_len, ekey_len, key_type, newprefix_len;
ulong idx;
zval **zdata = NULL, *copyzval;
(key_type = zend_hash_get_current_key_ex(ht, &key, &key_len, &idx, 0, NULL)) != HASH_KEY_NON_EXISTANT;
zend_hash_move_forward(ht)
) {
- if (key_type == HASH_KEY_IS_STRING && key_len && key[key_len-1] == '\0') {
+ if (key_type == HASH_KEY_IS_STRING && key_len && key.s[key_len-1] == '\0') {
/* We don't want that trailing NULL */
key_len -= 1;
}
/* handling for private & protected object properties */
- if (key && *key == '\0' && type != NULL) {
- char *tmp;
+ /* FIXME: Unicode support??? */
+ if (key.s && key.s[0] == '\0' && type != NULL) {
+ zstr tmp;
zend_object *zobj = zend_objects_get_address(type TSRMLS_CC);
if (zend_check_property_access(zobj, IS_STRING, key TSRMLS_CC) != SUCCESS) {
/* private or protected property access outside of the class */
continue;
}
- zend_unmangle_property_name(key, &tmp, &key);
- key_len = strlen(key);
+ zend_u_unmangle_property_name(key_type, key, &tmp, &key);
+ key_len = strlen(key.s);
}
if (zend_hash_get_current_data_ex(ht, (void **)&zdata, NULL) == FAILURE || !zdata || !(*zdata)) {
}
if (Z_TYPE_PP(zdata) == IS_ARRAY || Z_TYPE_PP(zdata) == IS_OBJECT) {
if (key_type == HASH_KEY_IS_STRING) {
- ekey = php_url_encode(key, key_len, &ekey_len);
+ ekey = php_url_encode(key.s, key_len, &ekey_len);
newprefix_len = key_suffix_len + ekey_len + key_prefix_len + 1;
newprefix = emalloc(newprefix_len + 1);
p = newprefix;
/* Simple key=value */
smart_str_appendl(formstr, key_prefix, key_prefix_len);
if (key_type == HASH_KEY_IS_STRING) {
- ekey = php_url_encode(key, key_len, &ekey_len);
+ ekey = php_url_encode(key.s, key_len, &ekey_len);
smart_str_appendl(formstr, ekey, ekey_len);
efree(ekey);
} else {
*/
static void incomplete_class_message(zval *object, int error_type TSRMLS_DC)
{
- char *class_name;
+ zstr class_name;
class_name = php_lookup_class_name(object, NULL);
- if (!class_name) {
- class_name = "unknown";
+ /* FIXME: Unicode support??? */
+ if (!class_name.s) {
+ class_name.s = "unknown";
}
php_error_docref(NULL TSRMLS_CC, error_type, INCOMPLETE_CLASS_MSG, class_name);
return 0;
}
-static union _zend_function *incomplete_class_get_method(zval **object, char *method, int method_len TSRMLS_DC) {
+static union _zend_function *incomplete_class_get_method(zval **object, zstr method, int method_len TSRMLS_DC) {
incomplete_class_message(*object, E_ERROR TSRMLS_CC);
return NULL;
}
/* {{{ php_lookup_class_name
*/
-PHPAPI char *php_lookup_class_name(zval *object, zend_uint *nlen)
+PHPAPI zstr php_lookup_class_name(zval *object, zend_uint *nlen)
{
zval **val;
- char *retval = NULL;
+ zstr retval = (zstr)NULL;
HashTable *object_properties;
TSRMLS_FETCH();
object_properties = Z_OBJPROP_P(object);
if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS) {
- retval = estrndup(Z_STRVAL_PP(val), Z_STRLEN_PP(val));
+ retval.s = estrndup(Z_STRVAL_PP(val), Z_STRLEN_PP(val));
if (nlen)
*nlen = Z_STRLEN_PP(val);
}
- return (retval);
+ return retval;
}
/* }}} */
static void php_print_gpcse_array(char *name, uint name_length TSRMLS_DC)
{
zval **data, **tmp, tmp2;
- char *string_key;
+ zstr string_key;
uint string_len;
ulong num_key;
char *elem_esc = NULL;
switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(data), &string_key, &string_len, &num_key, 0, NULL)) {
case HASH_KEY_IS_STRING:
if (!sapi_module.phpinfo_as_text) {
- elem_esc = php_info_html_esc(string_key TSRMLS_CC);
+ elem_esc = php_info_html_esc(string_key.s TSRMLS_CC);
PUTS(elem_esc);
efree(elem_esc);
} else {
- PUTS(string_key);
+ PUTS(string_key.s);
}
break;
case HASH_KEY_IS_LONG:
#endif
{
HashTable *url_stream_wrappers_hash;
- char *stream_protocol, *stream_protocols_buf = NULL;
+ zstr stream_protocol;
+ char *stream_protocols_buf = NULL;
int stream_protocol_len, stream_protocols_buf_len = 0;
ulong num_key;
zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING;
zend_hash_move_forward(url_stream_wrappers_hash)) {
stream_protocols_buf = erealloc(stream_protocols_buf, stream_protocols_buf_len + stream_protocol_len + 2 + 1);
- memcpy(stream_protocols_buf + stream_protocols_buf_len, stream_protocol, stream_protocol_len);
+ memcpy(stream_protocols_buf + stream_protocols_buf_len, stream_protocol.s, stream_protocol_len);
stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len] = ',';
stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len + 1] = ' ';
stream_protocols_buf_len += stream_protocol_len + 2;
{
HashTable *stream_xport_hash;
- char *xport_name, *xport_buf = NULL;
+ zstr xport_name;
+ char *xport_buf = NULL;
int xport_name_len, xport_buf_len = 0, xport_buf_size = 0;
ulong num_key;
xport_buf[xport_buf_len++] = ',';
xport_buf[xport_buf_len++] = ' ';
}
- memcpy(xport_buf + xport_buf_len, xport_name, xport_name_len);
+ memcpy(xport_buf + xport_buf_len, xport_name.s, xport_name_len);
xport_buf_len += xport_name_len;
xport_buf[xport_buf_len] = '\0';
}
{
HashTable *stream_filter_hash;
- char *filter_name, *filter_buf = NULL;
+ zstr filter_name;
+ char *filter_buf = NULL;
int filter_name_len, filter_buf_len = 0, filter_buf_size = 0;
ulong num_key;
filter_buf[filter_buf_len++] = ',';
filter_buf[filter_buf_len++] = ' ';
}
- memcpy(filter_buf + filter_buf_len, filter_name, filter_name_len);
+ memcpy(filter_buf + filter_buf_len, filter_name.s, filter_name_len);
filter_buf_len += filter_name_len;
filter_buf[filter_buf_len] = '\0';
}
}
#define PHP_CLEANUP_CLASS_ATTRIBUTES() \
- if (free_class_name) efree(class_name)
+ if (free_class_name) efree(class_name.v)
#define PHP_CLASS_ATTRIBUTES \
- char *class_name; \
+ zstr class_name; \
zend_uint name_len; \
zend_bool free_class_name = 0; \
zend_bool incomplete_class = 0
zend_class_entry *php_create_incomplete_class(TSRMLS_D);
-PHPAPI char *php_lookup_class_name(zval *object, zend_uint *nlen);
+PHPAPI zstr php_lookup_class_name(zval *object, zend_uint *nlen);
PHPAPI void php_store_class_name(zval *object, const char *name, zend_uint len);
#ifdef __cplusplus
{
zval **element;
php_process_env_t env;
- char *string_key, *data;
+ zstr string_key;
+ char *data;
#ifndef PHP_WIN32
char **ep;
#endif
continue;
}
l = string_length + el_len + 1;
- memcpy(p, string_key, string_length);
+ memcpy(p, string_key.s, string_length);
strcat(p, "=");
strcat(p, data);
/* walk the descriptor spec and set up files/pipes */
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(descriptorspec), &pos);
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(descriptorspec), (void **)&descitem, &pos) == SUCCESS) {
- char *str_index;
+ zstr str_index;
ulong nindex;
zval **ztype;
- str_index = NULL;
+ str_index.v = NULL;
zend_hash_get_current_key_ex(Z_ARRVAL_P(descriptorspec), &str_index, NULL, &nindex, 0, &pos);
- if (str_index) {
+ if (str_index.v) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "descriptor spec must be an integer indexed array");
goto exit_fail;
}
PHP_FUNCTION(stream_get_transports)
{
HashTable *stream_xport_hash;
- char *stream_xport;
+ zstr stream_xport;
int stream_xport_len;
ulong num_key;
while (zend_hash_get_current_key_ex(stream_xport_hash,
&stream_xport, &stream_xport_len,
&num_key, 0, NULL) == HASH_KEY_IS_STRING) {
- add_next_index_stringl(return_value, stream_xport, stream_xport_len, 1);
+ add_next_index_stringl(return_value, stream_xport.s, stream_xport_len, 1);
zend_hash_move_forward(stream_xport_hash);
}
} else {
PHP_FUNCTION(stream_get_wrappers)
{
HashTable *url_stream_wrappers_hash;
- char *stream_protocol;
+ zstr stream_protocol;
int key_flags, stream_protocol_len = 0;
ulong num_key;
(key_flags = zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTANT;
zend_hash_move_forward(url_stream_wrappers_hash)) {
if (key_flags == HASH_KEY_IS_STRING) {
- add_next_index_stringl(return_value, stream_protocol, stream_protocol_len, 1);
+ add_next_index_stringl(return_value, stream_protocol.s, stream_protocol_len, 1);
}
}
} else {
{
HashPosition pos, opos;
zval **wval, **oval;
- char *wkey, *okey;
+ zstr wkey, okey;
int wkey_len, okey_len;
int ret = SUCCESS;
ulong num_key;
/* fold to string */
UErrorCode errCode = 0;
- zend_convert_from_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &wkey, &wkey_len, (UChar*)wkey, wkey_len, &errCode);
+ zend_convert_from_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &wkey.s, &wkey_len, wkey.u, wkey_len, &errCode);
}
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(wval), &opos);
/* fold to string */
UErrorCode errCode = 0;
- zend_convert_from_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &okey, &okey_len, (UChar*)okey, okey_len, &errCode);
- php_stream_context_set_option(context, wkey, okey, *oval);
- efree(okey);
+ zend_convert_from_unicode(ZEND_U_CONVERTER(UG(runtime_encoding_conv)), &okey.s, &okey_len, okey.u, okey_len, &errCode);
+ php_stream_context_set_option(context, wkey.s, okey.s, *oval);
+ efree(okey.v);
}
if (HASH_KEY_IS_STRING == otype) {
- php_stream_context_set_option(context, wkey, okey, *oval);
+ php_stream_context_set_option(context, wkey.s, okey.s, *oval);
}
zend_hash_move_forward_ex(Z_ARRVAL_PP(wval), &opos);
}
if (wtype == HASH_KEY_IS_UNICODE) {
- efree(wkey);
+ efree(wkey.v);
}
} else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "options should have the form [\"wrappername\"][\"optionname\"] = $value");
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, u_notification, sizeof("notification"), (void**)&tmp)) {
+ SUCCESS == zend_u_hash_find(Z_ARRVAL_P(params), IS_UNICODE, (zstr)u_notification, sizeof("notification"), (void**)&tmp)) {
if (context->notifier) {
php_stream_notification_free(context->notifier);
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, u_options, sizeof("options"), (void**)&tmp)) {
+ SUCCESS == zend_u_hash_find(Z_ARRVAL_P(params), IS_UNICODE, (zstr)u_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, u_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)) {
zval strval = **tmp;
if (context->input_encoding) {
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, u_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)) {
zval strval = **tmp;
if (context->output_encoding) {
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, u_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)) {
zval longval = **tmp;
zval_copy_ctor(&longval);
UChar u_needle_char[3];
int32_t needle_len;
char *haystack_copy;
- void *target;
+ zstr target;
void *found = NULL;
int found_offset;
void *start, *end;
u_needle_char[needle_len++] = (UChar)U16_TRAIL(Z_LVAL_P(needle));
u_needle_char[needle_len] = 0;
}
- target = u_needle_char;
+ target.u = u_needle_char;
} else {
needle_char[needle_len++] = (char)Z_LVAL_P(needle);
needle_char[needle_len] = 0;
- target = needle_char;
+ target.s = needle_char;
}
}
}
if (Z_TYPE_P(haystack) == IS_UNICODE) {
- found = php_u_stristr(Z_USTRVAL_P(haystack), (UChar *)target,
+ found = php_u_stristr(Z_USTRVAL_P(haystack), target.u,
Z_USTRLEN_P(haystack), needle_len);
} else {
haystack_copy = estrndup(Z_STRVAL_P(haystack), Z_STRLEN_P(haystack));
- found = php_stristr(Z_STRVAL_P(haystack), (char *)target,
+ found = php_stristr(Z_STRVAL_P(haystack), target.s,
Z_STRLEN_P(haystack), needle_len);
}
if (Z_TYPE_P(haystack) == IS_UNICODE) {
haystack_dup = eustrndup(Z_USTRVAL_P(haystack), haystack_len);
php_u_strtolower((UChar **)&haystack_dup, &haystack_len, UG(default_locale));
- needle_dup = eustrndup(Z_STRVAL_P(needle), needle_len);
+ needle_dup = eustrndup(Z_USTRVAL_P(needle), needle_len);
php_u_strtolower((UChar **)&needle_dup, &needle_len, UG(default_locale));
found = zend_u_memnstr((UChar *)haystack_dup + offset,
(UChar *)needle_dup, needle_len,
PHP_FUNCTION(strrpos)
{
zval *zhaystack, *zneedle;
- void *haystack, *needle;
+ zstr haystack, needle;
int32_t haystack_len, needle_len = 0;
zend_uchar str_type;
long offset = 0;
u_ord_needle[needle_len++] = (UChar)U16_TRAIL(Z_LVAL_P(zneedle));
u_ord_needle[needle_len] = 0;
}
- needle = u_ord_needle;
+ needle.u = u_ord_needle;
} else {
convert_to_long(zneedle);
ord_needle[0] = (char)(Z_LVAL_P(zneedle) & 0xFF);
ord_needle[1] = '\0';
- needle = ord_needle;
+ needle.s = ord_needle;
needle_len = 1;
}
}
if (Z_TYPE_P(zhaystack) == IS_UNICODE) {
if (offset >= 0) {
- u_p = (UChar *)haystack + offset;
- u_e = (UChar *)haystack + haystack_len - needle_len;
+ u_p = haystack.u + offset;
+ u_e = haystack.u + haystack_len - needle_len;
} else {
- u_p = haystack;
+ u_p = haystack.u;
if (-offset > haystack_len) {
- u_e = (UChar *)haystack - needle_len;
+ u_e = haystack.u - needle_len;
} else if (needle_len > -offset) {
- u_e = (UChar *)haystack + haystack_len - needle_len;
+ u_e = haystack.u + haystack_len - needle_len;
} else {
- u_e = (UChar *)haystack + haystack_len + offset;
+ u_e = haystack.u + haystack_len + offset;
}
}
- pos = u_strFindLast(u_p, u_e-u_p+needle_len, (UChar *)needle, needle_len);
+ pos = u_strFindLast(u_p, u_e-u_p+needle_len, needle.u, needle_len);
if (pos) {
- RETURN_LONG(pos - (UChar *)haystack);
+ RETURN_LONG(pos - haystack.u);
} else {
RETURN_FALSE;
}
} else {
if (offset >= 0) {
- p = (char *)haystack + offset;
- e = (char *)haystack + haystack_len - needle_len;
+ p = haystack.s + offset;
+ e = haystack.s + haystack_len - needle_len;
} else {
- p = haystack;
+ p = haystack.s;
if (-offset > haystack_len) {
- e = (char *)haystack - needle_len;
+ e = haystack.s - needle_len;
} else if (needle_len > -offset) {
- e = (char *)haystack + haystack_len - needle_len;
+ e = haystack.s + haystack_len - needle_len;
} else {
- e = (char *)haystack + haystack_len + offset;
+ e = haystack.s + haystack_len + offset;
}
}
if (needle_len == 1) {
/* Single character search can shortcut memcmps */
while (e >= p) {
- if (*e == *(char *)needle) {
+ if (*e == *needle.s) {
RETURN_LONG(e - p + (offset > 0 ? offset : 0));
}
e--;
}
while (e >= p) {
- if (memcmp(e, needle, needle_len) == 0) {
+ if (memcmp(e, needle.s, needle_len) == 0) {
RETURN_LONG(e - p + (offset > 0 ? offset : 0));
}
e--;
static void php_strtr_array(zval *return_value, char *str, int slen, HashTable *hash)
{
zval **entry;
- char *string_key;
+ zstr string_key;
uint string_key_len;
zval **trans;
zval ctmp;
zend_hash_destroy(&tmp_hash);
RETURN_FALSE;
}
- zend_hash_add(&tmp_hash, string_key, string_key_len, entry, sizeof(zval*), NULL);
+ zend_u_hash_add(&tmp_hash, IS_STRING, string_key, string_key_len, entry, sizeof(zval*), NULL);
if (len > maxlen) {
maxlen = len;
}
{
zval **subject, **search, **replace, **subject_entry, **zcount;
zval *result;
- char *string_key;
+ zstr string_key;
uint string_key_len;
ulong num_key;
int count = 0;
switch (zend_hash_get_current_key_ex(Z_ARRVAL_PP(subject), &string_key,
&string_key_len, &num_key, 0, NULL)) {
case HASH_KEY_IS_STRING:
- add_assoc_zval_ex(return_value, string_key, string_key_len, result);
+ add_assoc_zval_ex(return_value, string_key.s, string_key_len, result);
break;
case HASH_KEY_IS_LONG:
RETURN_TRUE;
}
ce = Z_OBJCE_PP(arg);
- if (!strcmp(ce->name, INCOMPLETE_CLASS)) {
+ /* FIXME: Unicode support??? */
+ if (!strcmp(ce->name.s, INCOMPLETE_CLASS)) {
RETURN_FALSE;
}
}
Returns a list of registered filters */
PHP_FUNCTION(stream_get_filters)
{
- char *filter_name;
+ zstr filter_name;
int key_flags, filter_name_len = 0;
HashTable *filters_hash;
ulong num_key;
(key_flags = zend_hash_get_current_key_ex(filters_hash, &filter_name, &filter_name_len, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTANT;
zend_hash_move_forward(filters_hash))
if (key_flags == HASH_KEY_IS_STRING)
- add_next_index_stringl(return_value, filter_name, filter_name_len, 1);
+ add_next_index_stringl(return_value, filter_name.s, filter_name_len, 1);
}
/* It's okay to return an empty array if no filters are registered */
}
php_printf("%*c[%ld]=>\n", level + 1, ' ', hash_key->h);
} else { /* string key */
if (va_arg(args, int) &&
- ((hash_key->type == IS_STRING && hash_key->u.string[0] == 0) ||
- (hash_key->type == IS_UNICODE && hash_key->u.unicode[0] == '\0'))) {
+ ((hash_key->type == IS_STRING && hash_key->arKey.s[0] == 0) ||
+ (hash_key->type == IS_UNICODE && hash_key->arKey.u[0] == 0))) {
/* XXX: perhaps when we are inside the class we should permit access to
* private & protected values
*/
php_printf("%*c[", level + 1, ' ');
if (hash_key->type == IS_STRING) {
php_printf("\"");
- PHPWRITE(hash_key->u.string, hash_key->nKeyLength - 1);
+ PHPWRITE(hash_key->arKey.s, hash_key->nKeyLength - 1);
php_printf("\"");
} else if (hash_key->type == IS_UNICODE) {
php_printf("u");
- php_var_dump_unicode(hash_key->u.unicode, hash_key->nKeyLength-1, verbose, "\"", 0 TSRMLS_CC);
+ php_var_dump_unicode(hash_key->arKey.u, hash_key->nKeyLength-1, verbose, "\"", 0 TSRMLS_CC);
}
php_printf("]=>\n");
}
static int php_object_property_dump(zval **zv, int num_args, va_list args, zend_hash_key *hash_key)
{
int level;
- char *prop_name, *class_name;
+ zstr prop_name, class_name;
int verbose;
TSRMLS_FETCH();
} else { /* string key */
int is_unicode = hash_key->type == IS_UNICODE;
- zend_u_unmangle_property_name(hash_key->type, hash_key->u.string, &class_name, &prop_name);
+ zend_u_unmangle_property_name(hash_key->type, hash_key->arKey, &class_name, &prop_name);
php_printf("%*c[", level + 1, ' ');
- if (class_name) {
- if (class_name[0]=='*') {
+ if (class_name.s) {
+ if (class_name.s[0]=='*') {
php_printf("%s\"%R\":protected", is_unicode ? "u" : "", hash_key->type, prop_name);
} else {
php_printf("%s\"%R\":%s\"%R\":private", is_unicode ? "u" : "", hash_key->type, prop_name, is_unicode ? "u" : "", hash_key->type, class_name);
PHPAPI void php_var_dump(zval **struc, int level, int verbose TSRMLS_DC)
{
HashTable *myht = NULL;
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
int (*php_element_dump_func)(zval**, int, va_list, zend_hash_key*);
Z_OBJ_HANDLER(**struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC);
php_printf("%sobject(%v)#%d (%d) {\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0);
- efree(class_name);
+ efree(class_name.v);
php_element_dump_func = php_object_property_dump;
head_done:
if (myht) {
* private & protected values
*/
if (va_arg(args, int) &&
- ((hash_key->type == IS_STRING && hash_key->u.string[0] == 0) ||
- (hash_key->type == IS_UNICODE && hash_key->u.unicode[0] == '\0'))) {
+ ((hash_key->type == IS_STRING && hash_key->arKey.s[0] == 0) ||
+ (hash_key->type == IS_UNICODE && hash_key->arKey.u[0] == 0))) {
return 0;
}
php_printf("%*c[", level + 1, ' ');
if (hash_key->type == IS_STRING) {
php_printf("\"");
- PHPWRITE(hash_key->u.string, hash_key->nKeyLength - 1);
+ PHPWRITE(hash_key->arKey.s, hash_key->nKeyLength - 1);
php_printf("\"");
} else if (hash_key->type == IS_UNICODE) {
php_printf("u");
- php_var_dump_unicode(hash_key->u.unicode, hash_key->nKeyLength-1, 1, "\"", 0 TSRMLS_CC);
+ php_var_dump_unicode(hash_key->arKey.u, hash_key->nKeyLength-1, 1, "\"", 0 TSRMLS_CC);
}
php_printf("]=>\n");
}
PHPAPI void php_debug_zval_dump(zval **struc, int level, int verbose TSRMLS_DC)
{
HashTable *myht = NULL;
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
zend_class_entry *ce;
ce = Z_OBJCE(**struc);
Z_OBJ_HANDLER(**struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC);
php_printf("%sobject(%v)#%d (%d) refcount(%u){\n", COMMON, class_name, Z_OBJ_HANDLE_PP(struc), myht ? zend_hash_num_elements(myht) : 0, Z_REFCOUNT_PP(struc));
- efree(class_name);
+ efree(class_name.v);
head_done:
if (myht) {
zend_hash_apply_with_arguments(myht, (apply_func_args_t) zval_array_element_dump, 1, level, (Z_TYPE_PP(struc) == IS_ARRAY ? 0 : 1));
} else { /* string key */
php_printf("%*c'", level + 1, ' ');
if (hash_key->type == IS_UNICODE) {
- php_var_dump_unicode(hash_key->u.unicode, hash_key->nKeyLength-1, 0, "", 1 TSRMLS_CC);
+ php_var_dump_unicode(hash_key->arKey.u, hash_key->nKeyLength-1, 0, "", 1 TSRMLS_CC);
} else {
char *key;
int key_len;
- key = php_addcslashes(hash_key->u.string, hash_key->nKeyLength - 1, &key_len, 0, "'\\", 2 TSRMLS_CC);
+ key = php_addcslashes(hash_key->arKey.s, hash_key->nKeyLength - 1, &key_len, 0, "'\\", 2 TSRMLS_CC);
PHPWRITE(key, key_len);
efree(key);
}
static int php_object_element_export(zval **zv, int num_args, va_list args, zend_hash_key *hash_key)
{
int level;
- char *prop_name, *class_name;
+ zstr prop_name, class_name;
TSRMLS_FETCH();
level = va_arg(args, int);
if (hash_key->nKeyLength != 0) {
php_printf("%*c", level + 1, ' ');
- zend_u_unmangle_property_name(hash_key->type, hash_key->u.string, &class_name, &prop_name);
+ zend_u_unmangle_property_name(hash_key->type, hash_key->arKey, &class_name, &prop_name);
php_printf(" '%R' => ", hash_key->type, prop_name);
php_var_export(zv, level + 2 TSRMLS_CC);
PUTS (",\n");
HashTable *myht;
char* tmp_str;
int tmp_len;
- char *class_name;
+ zstr class_name;
zend_uint class_name_len;
switch (Z_TYPE_PP(struc)) {
}
Z_OBJ_HANDLER(**struc, get_class_name)(*struc, &class_name, &class_name_len, 0 TSRMLS_CC);
php_printf ("%v::__set_state(array(\n", class_name);
- efree(class_name);
+ efree(class_name.v);
if (myht) {
zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_object_element_export, 1, level);
}
smart_str_append_long(buf, name_len);
smart_str_appendl(buf, ":\"", 2);
if (UG(unicode)) {
- php_var_serialize_ustr(buf, (UChar*)class_name, name_len);
+ php_var_serialize_ustr(buf, class_name.u, name_len);
} else {
- smart_str_appendl(buf, class_name, name_len);
+ smart_str_appendl(buf, class_name.s, name_len);
}
smart_str_appendl(buf, "\":", 2);
PHP_CLEANUP_CLASS_ATTRIBUTES();
smart_str_appendl(buf, ":{", 2);
if (count > 0) {
- char *key;
+ zstr key;
zval **d, **name;
ulong index;
HashPosition pos;
if (i == HASH_KEY_NON_EXISTANT)
break;
- if (incomplete_class && strcmp(key, MAGIC_MEMBER) == 0) {
+ /* FIXME: Unicode support??? */
+ if (incomplete_class && strcmp(key.s, MAGIC_MEMBER) == 0) {
continue;
}
zend_hash_get_current_data_ex(HASH_OF(retval_ptr),
zend_class_entry *ce;
ce = zend_get_class_entry(*struc TSRMLS_CC);
if (ce) {
- char *prot_name, *priv_name;
+ zstr prot_name, priv_name;
int prop_name_length;
do {
zend_u_mangle_property_name(&priv_name, &prop_name_length, Z_TYPE_PP(name), ce->name, ce->name_length,
- Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce->type & ZEND_INTERNAL_CLASS);
+ 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), priv_name, prop_name_length+1, (void *) &d) == SUCCESS) {
if (Z_TYPE_PP(name) == IS_UNICODE) {
- php_var_serialize_unicode(buf, (UChar *)priv_name, prop_name_length);
+ php_var_serialize_unicode(buf, priv_name.u, prop_name_length);
} else {
- php_var_serialize_string(buf, priv_name, prop_name_length);
+ php_var_serialize_string(buf, priv_name.s, prop_name_length);
}
- efree(priv_name);
+ efree(priv_name.v);
php_var_serialize_intern(buf, d, var_hash TSRMLS_CC);
break;
}
- efree(priv_name);
- zend_u_mangle_property_name(&prot_name, &prop_name_length, Z_TYPE_PP(name), "*", 1,
- Z_STRVAL_PP(name), Z_STRLEN_PP(name), ce->type & ZEND_INTERNAL_CLASS);
+ efree(priv_name.v);
+ zend_u_mangle_property_name(&prot_name, &prop_name_length, Z_TYPE_PP(name), (zstr)"*", 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) {
- php_var_serialize_unicode(buf, (UChar *)prot_name, prop_name_length);
+ php_var_serialize_unicode(buf, prot_name.u, prop_name_length);
} else {
- php_var_serialize_string(buf, prot_name, prop_name_length);
+ php_var_serialize_string(buf, prot_name.s, prop_name_length);
}
- efree(prot_name);
+ efree(prot_name.v);
php_var_serialize_intern(buf, d, var_hash TSRMLS_CC);
break;
}
- efree(prot_name);
+ efree(prot_name.v);
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "\"%R\" returned as member variable from __sleep() but does not exist", Z_TYPE_PP(name), Z_UNIVAL_PP(name));
if (Z_TYPE_PP(name) == IS_UNICODE) {
php_var_serialize_unicode(buf, Z_USTRVAL_PP(name), Z_USTRLEN_PP(name));
smart_str_appendl(buf, "C:", 2);
smart_str_append_long(buf, Z_OBJCE_PP(struc)->name_length);
smart_str_appendl(buf, ":\"", 2);
- smart_str_appendl(buf, Z_OBJCE_PP(struc)->name, Z_OBJCE_PP(struc)->name_length);
+ /* FIXME: Unicode support??? */
+ smart_str_appendl(buf, Z_OBJCE_PP(struc)->name.s, Z_OBJCE_PP(struc)->name_length);
smart_str_appendl(buf, "\":", 2);
smart_str_append_long(buf, serialized_length);
smart_str_append_long(buf, i);
smart_str_appendl(buf, ":{", 2);
if (i > 0) {
- char *key;
+ zstr key;
zval **data;
ulong index;
uint key_len;
if (i == HASH_KEY_NON_EXISTANT)
break;
- if (incomplete_class && strcmp(key, MAGIC_MEMBER) == 0) {
+ /* FIXME: Unicode support??? */
+ if (incomplete_class && strcmp(key.s, MAGIC_MEMBER) == 0) {
continue;
}
php_var_serialize_long(buf, index);
break;
case HASH_KEY_IS_STRING:
- php_var_serialize_string(buf, key, key_len - 1);
+ php_var_serialize_string(buf, key.s, key_len - 1);
break;
case HASH_KEY_IS_UNICODE:
- php_var_serialize_unicode(buf, (UChar*)key, key_len - 1);
+ php_var_serialize_unicode(buf, key.u, key_len - 1);
break;
}
char *p;
int buffer_len = 0;
char *space;
- char *class_name = get_active_class_name(&space TSRMLS_CC);
+ zstr class_name = get_active_class_name(&space TSRMLS_CC);
int origin_len;
- char *function = NULL;
+ zstr function = (zstr)NULL;
char *origin;
char *message;
char *stage;
EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL) {
switch (EG(current_execute_data)->opline->op2.u.constant.value.lval) {
case ZEND_EVAL:
- function = "eval";
+ function.s = "eval";
break;
case ZEND_INCLUDE:
- function = "include";
+ function.s = "include";
break;
case ZEND_INCLUDE_ONCE:
- function = "include_once";
+ function.s = "include_once";
break;
case ZEND_REQUIRE:
- function = "require";
+ function.s = "require";
break;
case ZEND_REQUIRE_ONCE:
- function = "require_once";
+ function.s = "require_once";
break;
default:
stage = "Unknown";
} else {
function_name_is_string = 0;
function = get_active_function_name(TSRMLS_C);
- if (!function || !USTR_LEN(function)) {
+ if (!function.v || !USTR_LEN(function)) {
stage = "Unknown";
- function = NULL;
+ function.v = NULL;
}
}
/* if we still have memory then format the origin */
- if (function) {
+ if (function.v) {
if (function_name_is_string) {
- origin_len = spprintf(&origin, 0, "%v%s%s(%s)", class_name, space, function, params);
+ origin_len = spprintf(&origin, 0, "%v%s%s(%s)", class_name, space, function.s, params);
} else {
origin_len = spprintf(&origin, 0, "%v%s%v(%s)", class_name, space, function, params);
}
}
/* no docref given but function is known (the default) */
- if (!docref && function) {
+ if (!docref && function.v) {
if (function_name_is_string) {
- spprintf(&docref_buf, 0, "function.%s", function);
+ spprintf(&docref_buf, 0, "function.%s", function.s);
} else {
spprintf(&docref_buf, 0, "function.%v", function);
}
* - we show erroes in html mode OR
* - the user wants to see the links anyway
*/
- if (docref && function && (PG(html_errors) || strlen(PG(docref_root)))) {
+ if (docref && function.v && (PG(html_errors) || strlen(PG(docref_root)))) {
if (strncmp(docref, "http://", 7)) {
/* We don't have 'http://' so we use docref_root */
/* {{{ php_ob_init_named
*/
-static int php_ob_init_named(uint initial_size, uint block_size, zend_uchar type, char *handler_name, zval *output_handler, uint chunk_size, zend_bool erase TSRMLS_DC)
+static int php_ob_init_named(uint initial_size, uint block_size, zend_uchar type, zstr handler_name, zval *output_handler, uint chunk_size, zend_bool erase TSRMLS_DC)
{
int handler_len;
return FAILURE;
}
if (type == IS_UNICODE) {
- handler_len = u_strlen(handler_name);
+ handler_len = u_strlen(handler_name.u);
} else {
- handler_len = strlen(handler_name);
+ handler_len = strlen(handler_name.s);
}
if (OG(ob_nesting_level)>0) {
#if HAVE_ZLIB && !defined(COMPILE_DL_ZLIB)
OG(active_ob_buffer).status = 0;
OG(active_ob_buffer).internal_output_handler = NULL;
if (type == IS_UNICODE) {
- OG(active_ob_buffer).handler_name = eustrdup(handler_name&&handler_name[0]?handler_name:OB_DEFAULT_HANDLER_NAME);
+ /* FIXME: Unicode support??? */
+ OG(active_ob_buffer).handler_name = eustrdup((handler_name.u && handler_name.u[0])?handler_name.u:(UChar*)OB_DEFAULT_HANDLER_NAME);
} else {
- OG(active_ob_buffer).handler_name = estrdup(handler_name&&handler_name[0]?handler_name:OB_DEFAULT_HANDLER_NAME);
+ OG(active_ob_buffer).handler_name = estrdup((handler_name.s && handler_name.s[0])?handler_name.s:OB_DEFAULT_HANDLER_NAME);
}
OG(active_ob_buffer).erase = erase;
OG(php_body_write) = php_b_body_write;
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, next_handler_name, handler_zval, chunk_size, erase 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 (result != SUCCESS) {
zval_dtor(handler_zval);
FREE_ZVAL(handler_zval);
}
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, handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
+ result = php_ob_init_named(initial_size, block_size, IS_STRING, (zstr)handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
if (result != SUCCESS) {
zval_dtor(handler_zval);
FREE_ZVAL(handler_zval);
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, next_handler_name, handler_zval, chunk_size, erase 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 (result != SUCCESS) {
zval_dtor(handler_zval);
FREE_ZVAL(handler_zval);
}
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, handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
+ result = php_ob_init_named(initial_size, block_size, IS_UNICODE, (zstr)handler_name, handler_zval, chunk_size, erase TSRMLS_CC);
if (result != SUCCESS) {
zval_dtor(handler_zval);
FREE_ZVAL(handler_zval);
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, OB_DEFAULT_HANDLER_NAME, NULL, chunk_size, erase TSRMLS_CC);
+ result = php_ob_init_named(initial_size, block_size, IS_STRING, (zstr)OB_DEFAULT_HANDLER_NAME, NULL, chunk_size, erase TSRMLS_CC);
}
return result;
}
} else {
escaped_index = index;
}
- if (zend_u_symtable_find(symtable1, IS_UNICODE, escaped_index, index_len+1, (void **) &gpc_element_p)==FAILURE
+ if (zend_u_symtable_find(symtable1, IS_UNICODE, (zstr)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, escaped_index, index_len+1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
+ zend_u_symtable_update(symtable1, IS_UNICODE, (zstr)escaped_index, index_len+1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
}
if (index!=escaped_index) {
efree(escaped_index);
/* 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, escaped_index, index_len+1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
+ zend_u_symtable_update(symtable1, IS_UNICODE, (zstr)escaped_index, index_len+1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
//efree(escaped_index);
}
break;
static void php_autoglobal_merge(HashTable *dest, HashTable *src TSRMLS_DC)
{
zval **src_entry, **dest_entry;
- char *string_key;
+ zstr string_key;
uint string_key_len;
ulong num_key;
HashPosition pos;
zend_hash_internal_pointer_reset_ex(src, &pos);
while (zend_hash_get_current_data_ex(src, (void **)&src_entry, &pos) == SUCCESS) {
key_type = zend_hash_get_current_key_ex(src, &string_key, &string_key_len, &num_key, 0, &pos);
+ /* FIXME: Unicode support??? */
if (Z_TYPE_PP(src_entry) != IS_ARRAY
- || (key_type == HASH_KEY_IS_STRING && zend_hash_find(dest, string_key, string_key_len, (void **) &dest_entry) != SUCCESS)
+ || (key_type == HASH_KEY_IS_STRING && zend_u_hash_find(dest, key_type, string_key, string_key_len, (void **) &dest_entry) != SUCCESS)
|| (key_type == HASH_KEY_IS_LONG && zend_hash_index_find(dest, num_key, (void **)&dest_entry) != SUCCESS)
|| Z_TYPE_PP(dest_entry) != IS_ARRAY
) {
(*src_entry)->refcount++;
if (key_type == HASH_KEY_IS_STRING) {
/* if register_globals is on and working with main symbol table, prevent overwriting of GLOBALS */
- if (!globals_check || string_key_len != sizeof("GLOBALS") || memcmp(string_key, "GLOBALS", sizeof("GLOBALS") - 1)) {
- zend_hash_update(dest, string_key, string_key_len, src_entry, sizeof(zval *), NULL);
+ if (!globals_check || string_key_len != sizeof("GLOBALS") || memcmp(string_key.s, "GLOBALS", sizeof("GLOBALS") - 1)) {
+ zend_u_hash_update(dest, key_type, string_key, string_key_len, src_entry, sizeof(zval *), NULL);
} else {
(*src_entry)->refcount--;
}
int dummy=1;
normalize_u_protected_variable(varname TSRMLS_CC);
- zend_u_hash_add(&PG(rfc1867_protected_variables), IS_UNICODE, 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);
}
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, varname, u_strlen(varname)+1);
+ return zend_u_hash_exists(&PG(rfc1867_protected_variables), IS_UNICODE, (zstr)varname, u_strlen(varname)+1);
}
}
temp_filename = EMPTY_STR;
} else {
- zend_u_hash_add(SG(rfc1867_uploaded_files), IS_UNICODE, 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
php_stream *stream)
{
php_stream **pstream;
- char *hostent;
+ zend_uchar type;
+ zstr hostent;
+ unsigned int hostent_len;
int ret = SUCCESS;
if (!context || !context->links || !stream) {
SUCCESS == zend_hash_get_current_data(Z_ARRVAL_P(context->links), (void**)&pstream);
zend_hash_move_forward(Z_ARRVAL_P(context->links))) {
if (*pstream == stream) {
- if (SUCCESS == zend_hash_get_current_key(Z_ARRVAL_P(context->links), &hostent, NULL, 0)) {
- if (FAILURE == zend_hash_del(Z_ARRVAL_P(context->links), (char*)hostent, strlen(hostent)+1)) {
+ type = zend_hash_get_current_key_ex(Z_ARRVAL_P(context->links), &hostent, &hostent_len, NULL, 0, NULL);
+ if (type == HASH_KEY_IS_STRING || type == HASH_KEY_IS_UNICODE) {
+ if (FAILURE == zend_u_hash_del(Z_ARRVAL_P(context->links), type, hostent, hostent_len)) {
ret = FAILURE;
}
} else {
ic.value = *zin;
ic.flags = CONST_CS;
- ic.name = zend_strndup(ZEND_STRL("STDIN"));
+ ic.name.s = zend_strndup(ZEND_STRL("STDIN"));
ic.name_len = sizeof("STDIN");
ic.module_number = 0;
zend_register_constant(&ic TSRMLS_CC);
oc.value = *zout;
oc.flags = CONST_CS;
- oc.name = zend_strndup(ZEND_STRL("STDOUT"));
+ oc.name.s = zend_strndup(ZEND_STRL("STDOUT"));
oc.name_len = sizeof("STDOUT");
oc.module_number = 0;
zend_register_constant(&oc TSRMLS_CC);
ec.value = *zerr;
ec.flags = CONST_CS;
- ec.name = zend_strndup(ZEND_STRL("STDERR"));
+ ec.name.s = zend_strndup(ZEND_STRL("STDERR"));
ec.name_len = sizeof("STDERR");
ec.module_number = 0;
zend_register_constant(&ec TSRMLS_CC);