diff options
Diffstat (limited to 'Zend/zend_API.c')
-rw-r--r-- | Zend/zend_API.c | 315 |
1 files changed, 127 insertions, 188 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c index 348737bddc..02d6484afd 100644 --- a/Zend/zend_API.c +++ b/Zend/zend_API.c @@ -166,7 +166,7 @@ ZEND_API char *zend_get_type_by_const(int type) /* {{{ */ case IS_FALSE: case IS_TRUE: return "boolean"; - case IS_INT: + case IS_LONG: return "integer"; case IS_DOUBLE: return "double"; @@ -228,7 +228,7 @@ static int parse_arg_object_to_string(zval *arg, char **p, int *pl, int type TSR if (Z_OBJ_HANDLER_P(arg, cast_object)(arg, &obj, type TSRMLS_CC) == SUCCESS) { zval_ptr_dtor(arg); ZVAL_COPY_VALUE(arg, &obj); - *pl = Z_STRSIZE_P(arg); + *pl = Z_STRLEN_P(arg); *p = Z_STRVAL_P(arg); return SUCCESS; } @@ -237,7 +237,7 @@ static int parse_arg_object_to_string(zval *arg, char **p, int *pl, int type TSR if (Z_OBJ_HT_P(arg) == &std_object_handlers || !Z_OBJ_HANDLER_P(arg, cast_object)) { SEPARATE_ZVAL_NOREF(arg); if (zend_std_cast_object_tostring(arg, arg, type TSRMLS_CC) == SUCCESS) { - *pl = Z_STRSIZE_P(arg); + *pl = Z_STRLEN_P(arg); *p = Z_STRVAL_P(arg); return SUCCESS; } @@ -252,7 +252,7 @@ static int parse_arg_object_to_string(zval *arg, char **p, int *pl, int type TSR if (!zend_make_printable_zval(z, arg TSRMLS_CC)) { ZVAL_ZVAL(arg, z, 1, 1); } - *pl = Z_STRSIZE_P(arg); + *pl = Z_STRLEN_P(arg); *p = Z_STRVAL_P(arg); return SUCCESS; } @@ -413,7 +413,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons case 'l': case 'L': { - long *p = va_arg(*va, long *); + zend_long *p = va_arg(*va, zend_long *); if (check_null) { zend_bool *p = va_arg(*va, zend_bool *); @@ -426,71 +426,10 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons double d; int type; - if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRSIZE_P(arg), (zend_int_t *)p, &d, -1)) == 0) { + if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), p, &d, -1)) == 0) { return "long"; } else if (type == IS_DOUBLE) { if (c == 'L') { - if (d > LONG_MAX) { - *p = LONG_MAX; - break; - } else if (d < LONG_MIN) { - *p = LONG_MIN; - break; - } - } - - *p = zend_dval_to_ival(d); - } - } - break; - - case IS_DOUBLE: - if (c == 'L') { - if (Z_DVAL_P(arg) > LONG_MAX) { - *p = LONG_MAX; - break; - } else if (Z_DVAL_P(arg) < LONG_MIN) { - *p = LONG_MIN; - break; - } - } - case IS_NULL: - case IS_FALSE: - case IS_TRUE: - case IS_INT: - convert_to_int_ex(arg); - *p = Z_IVAL_P(arg); - break; - - case IS_ARRAY: - case IS_OBJECT: - case IS_RESOURCE: - default: - return "long"; - } - } - break; - - case 'i': - case 'I': - { - zend_int_t *p = va_arg(*va, zend_int_t *); - - if (check_null) { - zend_bool *p = va_arg(*va, zend_bool *); - *p = (Z_TYPE_P(arg) == IS_NULL); - } - - switch (Z_TYPE_P(arg)) { - case IS_STRING: - { - double d; - int type; - - if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRSIZE_P(arg), p, &d, -1)) == 0) { - return "long"; - } else if (type == IS_DOUBLE) { - if (c == 'I') { if (d > ZEND_INT_MAX) { *p = ZEND_INT_MAX; break; @@ -500,13 +439,13 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons } } - *p = zend_dval_to_ival(d); + *p = zend_dval_to_lval(d); } } break; case IS_DOUBLE: - if (c == 'I') { + if (c == 'L') { if (Z_DVAL_P(arg) > ZEND_INT_MAX) { *p = ZEND_INT_MAX; break; @@ -518,9 +457,9 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons case IS_NULL: case IS_FALSE: case IS_TRUE: - case IS_INT: + case IS_LONG: convert_to_int_ex(arg); - *p = Z_IVAL_P(arg); + *p = Z_LVAL_P(arg); break; case IS_ARRAY: @@ -544,12 +483,12 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons switch (Z_TYPE_P(arg)) { case IS_STRING: { - zend_int_t l; + zend_long l; int type; - if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRSIZE_P(arg), &l, p, -1)) == 0) { + if ((type = is_numeric_string(Z_STRVAL_P(arg), Z_STRLEN_P(arg), &l, p, -1)) == 0) { return "double"; - } else if (type == IS_INT) { + } else if (type == IS_LONG) { *p = (double) l; } } @@ -558,7 +497,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons case IS_NULL: case IS_FALSE: case IS_TRUE: - case IS_INT: + case IS_LONG: case IS_DOUBLE: convert_to_double_ex(arg); *p = Z_DVAL_P(arg); @@ -587,14 +526,14 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons } /* break omitted intentionally */ - case IS_INT: + case IS_LONG: case IS_DOUBLE: case IS_FALSE: case IS_TRUE: convert_to_string_ex(arg); case IS_STRING: *p = Z_STRVAL_P(arg); - *pl = Z_STRSIZE_P(arg); + *pl = Z_STRLEN_P(arg); if (c == 'p' && CHECK_ZVAL_NULL_PATH(arg)) { return "a valid path"; } @@ -628,7 +567,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons } /* break omitted intentionally */ - case IS_INT: + case IS_LONG: case IS_DOUBLE: case IS_FALSE: case IS_TRUE: @@ -668,7 +607,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons switch (Z_TYPE_P(arg)) { case IS_NULL: case IS_STRING: - case IS_INT: + case IS_LONG: case IS_DOUBLE: case IS_FALSE: case IS_TRUE: @@ -932,7 +871,7 @@ static int zend_parse_va_args(int num_args, const char *type_spec, va_list *va, case 'f': case 'A': case 'H': case 'p': case 'S': case 'P': - case 'i': + case 'L': max_num_args++; break; @@ -1205,7 +1144,7 @@ ZEND_API void zend_merge_properties(zval *obj, HashTable *properties TSRMLS_DC) if (key) { zval member; - ZVAL_STR(&member, STR_COPY(key)); + ZVAL_STR(&member, zend_string_copy(key)); obj_ht->write_property(obj, &member, value, NULL TSRMLS_CC); zval_ptr_dtor(&member); } @@ -1425,11 +1364,11 @@ ZEND_API int add_assoc_function(zval *arg, const char *key, void (*function_ptr) } /* }}} */ -ZEND_API int add_assoc_int_ex(zval *arg, const char *key, uint key_len, zend_int_t n) /* {{{ */ +ZEND_API int add_assoc_long_ex(zval *arg, const char *key, uint key_len, zend_long n) /* {{{ */ { zval *ret, tmp; - ZVAL_INT(&tmp, n); + ZVAL_LONG(&tmp, n); ret = zend_symtable_str_update(Z_ARRVAL_P(arg), key, key_len, &tmp); return ret ? SUCCESS : FAILURE; } @@ -1514,16 +1453,16 @@ ZEND_API int add_assoc_zval_ex(zval *arg, const char *key, uint key_len, zval *v } /* }}} */ -ZEND_API int add_index_int(zval *arg, zend_uint_t index, zend_int_t n) /* {{{ */ +ZEND_API int add_index_long(zval *arg, zend_ulong index, zend_long n) /* {{{ */ { zval tmp; - ZVAL_INT(&tmp, n); + ZVAL_LONG(&tmp, n); return zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp) ? SUCCESS : FAILURE; } /* }}} */ -ZEND_API int add_index_null(zval *arg, zend_uint_t index) /* {{{ */ +ZEND_API int add_index_null(zval *arg, zend_ulong index) /* {{{ */ { zval tmp; @@ -1532,7 +1471,7 @@ ZEND_API int add_index_null(zval *arg, zend_uint_t index) /* {{{ */ } /* }}} */ -ZEND_API int add_index_bool(zval *arg, zend_uint_t index, int b) /* {{{ */ +ZEND_API int add_index_bool(zval *arg, zend_ulong index, int b) /* {{{ */ { zval tmp; @@ -1541,7 +1480,7 @@ ZEND_API int add_index_bool(zval *arg, zend_uint_t index, int b) /* {{{ */ } /* }}} */ -ZEND_API int add_index_resource(zval *arg, zend_uint_t index, zend_resource *r) /* {{{ */ +ZEND_API int add_index_resource(zval *arg, zend_ulong index, zend_resource *r) /* {{{ */ { zval tmp; @@ -1550,7 +1489,7 @@ ZEND_API int add_index_resource(zval *arg, zend_uint_t index, zend_resource *r) } /* }}} */ -ZEND_API int add_index_double(zval *arg, zend_uint_t index, double d) /* {{{ */ +ZEND_API int add_index_double(zval *arg, zend_ulong index, double d) /* {{{ */ { zval tmp; @@ -1559,7 +1498,7 @@ ZEND_API int add_index_double(zval *arg, zend_uint_t index, double d) /* {{{ */ } /* }}} */ -ZEND_API int add_index_str(zval *arg, zend_uint_t index, zend_string *str) /* {{{ */ +ZEND_API int add_index_str(zval *arg, zend_ulong index, zend_string *str) /* {{{ */ { zval tmp; @@ -1568,7 +1507,7 @@ ZEND_API int add_index_str(zval *arg, zend_uint_t index, zend_string *str) /* {{ } /* }}} */ -ZEND_API int add_index_string(zval *arg, zend_uint_t index, const char *str) /* {{{ */ +ZEND_API int add_index_string(zval *arg, zend_ulong index, const char *str) /* {{{ */ { zval tmp; @@ -1577,7 +1516,7 @@ ZEND_API int add_index_string(zval *arg, zend_uint_t index, const char *str) /* } /* }}} */ -ZEND_API int add_index_stringl(zval *arg, zend_uint_t index, const char *str, uint length) /* {{{ */ +ZEND_API int add_index_stringl(zval *arg, zend_ulong index, const char *str, uint length) /* {{{ */ { zval tmp; @@ -1586,17 +1525,17 @@ ZEND_API int add_index_stringl(zval *arg, zend_uint_t index, const char *str, ui } /* }}} */ -ZEND_API int add_index_zval(zval *arg, zend_uint_t index, zval *value) /* {{{ */ +ZEND_API int add_index_zval(zval *arg, zend_ulong index, zval *value) /* {{{ */ { return zend_hash_index_update(Z_ARRVAL_P(arg), index, value) ? SUCCESS : FAILURE; } /* }}} */ -ZEND_API int add_next_index_int(zval *arg, zend_int_t n) /* {{{ */ +ZEND_API int add_next_index_long(zval *arg, zend_long n) /* {{{ */ { zval tmp; - ZVAL_INT(&tmp, n); + ZVAL_LONG(&tmp, n); return zend_hash_next_index_insert(Z_ARRVAL_P(arg), &tmp) ? SUCCESS : FAILURE; } /* }}} */ @@ -1690,16 +1629,16 @@ ZEND_API zval *add_get_assoc_stringl_ex(zval *arg, const char *key, uint key_len } /* }}} */ -ZEND_API zval *add_get_index_int(zval *arg, zend_uint_t index, zend_int_t l) /* {{{ */ +ZEND_API zval *add_get_index_long(zval *arg, zend_ulong index, zend_long l) /* {{{ */ { zval tmp; - ZVAL_INT(&tmp, l); + ZVAL_LONG(&tmp, l); return zend_hash_index_update(Z_ARRVAL_P(arg), index, &tmp); } /* }}} */ -ZEND_API zval *add_get_index_double(zval *arg, zend_uint_t index, double d) /* {{{ */ +ZEND_API zval *add_get_index_double(zval *arg, zend_ulong index, double d) /* {{{ */ { zval tmp; @@ -1708,7 +1647,7 @@ ZEND_API zval *add_get_index_double(zval *arg, zend_uint_t index, double d) /* { } /* }}} */ -ZEND_API zval *add_get_index_str(zval *arg, zend_uint_t index, zend_string *str) /* {{{ */ +ZEND_API zval *add_get_index_str(zval *arg, zend_ulong index, zend_string *str) /* {{{ */ { zval tmp; @@ -1717,7 +1656,7 @@ ZEND_API zval *add_get_index_str(zval *arg, zend_uint_t index, zend_string *str) } /* }}} */ -ZEND_API zval *add_get_index_string(zval *arg, zend_uint_t index, const char *str) /* {{{ */ +ZEND_API zval *add_get_index_string(zval *arg, zend_ulong index, const char *str) /* {{{ */ { zval tmp; @@ -1726,7 +1665,7 @@ ZEND_API zval *add_get_index_string(zval *arg, zend_uint_t index, const char *st } /* }}} */ -ZEND_API zval *add_get_index_stringl(zval *arg, zend_uint_t index, const char *str, uint length) /* {{{ */ +ZEND_API zval *add_get_index_stringl(zval *arg, zend_ulong index, const char *str, uint length) /* {{{ */ { zval tmp; @@ -1756,11 +1695,11 @@ ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value TSRMLS_DC) case IS_TRUE: result = zend_hash_index_update(ht, 1, value); break; - case IS_INT: - result = zend_hash_index_update(ht, Z_IVAL_P(key), value); + case IS_LONG: + result = zend_hash_index_update(ht, Z_LVAL_P(key), value); break; case IS_DOUBLE: - result = zend_hash_index_update(ht, zend_dval_to_ival(Z_DVAL_P(key)), value); + result = zend_hash_index_update(ht, zend_dval_to_lval(Z_DVAL_P(key)), value); break; default: zend_error(E_WARNING, "Illegal offset type"); @@ -1778,12 +1717,12 @@ ZEND_API int array_set_zval_key(HashTable *ht, zval *key, zval *value TSRMLS_DC) } /* }}} */ -ZEND_API int add_property_int_ex(zval *arg, const char *key, uint key_len, zend_int_t n TSRMLS_DC) /* {{{ */ +ZEND_API int add_property_long_ex(zval *arg, const char *key, uint key_len, zend_long n TSRMLS_DC) /* {{{ */ { zval tmp; zval z_key; - ZVAL_INT(&tmp, n); + ZVAL_LONG(&tmp, n); ZVAL_STRINGL(&z_key, key, key_len); Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, NULL TSRMLS_CC); zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */ @@ -1792,7 +1731,7 @@ ZEND_API int add_property_int_ex(zval *arg, const char *key, uint key_len, zend_ } /* }}} */ -ZEND_API int add_property_bool_ex(zval *arg, const char *key, uint key_len, zend_int_t b TSRMLS_DC) /* {{{ */ +ZEND_API int add_property_bool_ex(zval *arg, const char *key, uint key_len, zend_long b TSRMLS_DC) /* {{{ */ { zval tmp; zval z_key; @@ -1920,17 +1859,17 @@ ZEND_API int zend_startup_module_ex(zend_module_entry *module TSRMLS_DC) /* {{{ zend_module_entry *req_mod; name_len = strlen(dep->name); - lcname = STR_ALLOC(name_len, 0); + lcname = zend_string_alloc(name_len, 0); zend_str_tolower_copy(lcname->val, dep->name, name_len); if ((req_mod = zend_hash_find_ptr(&module_registry, lcname)) == NULL || !req_mod->module_started) { - STR_FREE(lcname); + zend_string_free(lcname); /* TODO: Check version relationship */ zend_error(E_CORE_WARNING, "Cannot load module '%s' because required module '%s' is not loaded", module->name, dep->name); module->module_started = 0; return FAILURE; } - STR_FREE(lcname); + zend_string_free(lcname); } ++dep; } @@ -2109,31 +2048,31 @@ ZEND_API zend_module_entry* zend_register_module_ex(zend_module_entry *module TS while (dep->name) { if (dep->type == MODULE_DEP_CONFLICTS) { name_len = strlen(dep->name); - lcname = STR_ALLOC(name_len, 0); + lcname = zend_string_alloc(name_len, 0); zend_str_tolower_copy(lcname->val, dep->name, name_len); if (zend_hash_exists(&module_registry, lcname)) { - STR_FREE(lcname); + zend_string_free(lcname); /* TODO: Check version relationship */ zend_error(E_CORE_WARNING, "Cannot load module '%s' because conflicting module '%s' is already loaded", module->name, dep->name); return NULL; } - STR_FREE(lcname); + zend_string_free(lcname); } ++dep; } } name_len = strlen(module->name); - lcname = STR_ALLOC(name_len, 1); + lcname = zend_string_alloc(name_len, 1); zend_str_tolower_copy(lcname->val, module->name, name_len); if ((module_ptr = zend_hash_add_mem(&module_registry, lcname, module, sizeof(zend_module_entry))) == NULL) { zend_error(E_CORE_WARNING, "Module '%s' already loaded", module->name); - STR_RELEASE(lcname); + zend_string_release(lcname); return NULL; } - STR_RELEASE(lcname); + zend_string_release(lcname); module = module_ptr; EG(current_module) = module; @@ -2261,7 +2200,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio while (ptr->fname) { fname_len = strlen(ptr->fname); internal_function->handler = ptr->handler; - internal_function->function_name = zend_new_interned_string(STR_INIT(ptr->fname, fname_len, 1) TSRMLS_CC); + internal_function->function_name = zend_new_interned_string(zend_string_init(ptr->fname, fname_len, 1) TSRMLS_CC); internal_function->scope = scope; internal_function->prototype = NULL; if (ptr->flags) { @@ -2327,7 +2266,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio return FAILURE; } } - lowercase_name = STR_ALLOC(fname_len, 1); + lowercase_name = zend_string_alloc(fname_len, 1); zend_str_tolower_copy(lowercase_name->val, ptr->fname, fname_len); lowercase_name = zend_new_interned_string(lowercase_name TSRMLS_CC); reg_function = malloc(sizeof(zend_internal_function)); @@ -2335,7 +2274,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio if (zend_hash_add_ptr(target_function_table, lowercase_name, reg_function) == NULL) { unload=1; free(reg_function); - STR_RELEASE(lowercase_name); + zend_string_release(lowercase_name); break; } @@ -2392,7 +2331,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio } ptr++; count++; - STR_RELEASE(lowercase_name); + zend_string_release(lowercase_name); } if (unload) { /* before unloading, display all remaining bad function in the module */ if (scope) { @@ -2400,12 +2339,12 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio } while (ptr->fname) { fname_len = strlen(ptr->fname); - lowercase_name = STR_ALLOC(fname_len, 0); + lowercase_name = zend_string_alloc(fname_len, 0); zend_str_tolower_copy(lowercase_name->val, ptr->fname, fname_len); if (zend_hash_exists(target_function_table, lowercase_name)) { zend_error(error_type, "Function registration failed - duplicate name - %s%s%s", scope ? scope->name->val : "", scope ? "::" : "", ptr->fname); } - STR_FREE(lowercase_name); + zend_string_free(lowercase_name); ptr++; } zend_unregister_functions(functions, count, target_function_table TSRMLS_CC); @@ -2516,10 +2455,10 @@ ZEND_API void zend_unregister_functions(const zend_function_entry *functions, in break; } fname_len = strlen(ptr->fname); - lowercase_name = STR_ALLOC(fname_len, 0); + lowercase_name = zend_string_alloc(fname_len, 0); zend_str_tolower_copy(lowercase_name->val, ptr->fname, fname_len); zend_hash_del(target_function_table, lowercase_name); - STR_FREE(lowercase_name); + zend_string_free(lowercase_name); ptr++; i++; } @@ -2721,7 +2660,7 @@ int zend_next_free_module(void) /* {{{ */ static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class_entry, zend_uint ce_flags TSRMLS_DC) /* {{{ */ { zend_class_entry *class_entry = malloc(sizeof(zend_class_entry)); - zend_string *lowercase_name = STR_ALLOC(orig_class_entry->name->len, 1); + zend_string *lowercase_name = zend_string_alloc(orig_class_entry->name->len, 1); *class_entry = *orig_class_entry; class_entry->type = ZEND_INTERNAL_CLASS; @@ -2736,7 +2675,7 @@ static zend_class_entry *do_register_internal_class(zend_class_entry *orig_class zend_str_tolower_copy(lowercase_name->val, orig_class_entry->name->val, class_entry->name->len); lowercase_name = zend_new_interned_string(lowercase_name TSRMLS_CC); zend_hash_update_ptr(CG(class_table), lowercase_name, class_entry); - STR_RELEASE(lowercase_name); + zend_string_release(lowercase_name); return class_entry; } /* }}} */ @@ -2793,14 +2732,14 @@ ZEND_API int zend_register_class_alias_ex(const char *name, int name_len, zend_c zend_string *lcname; if (name[0] == '\\') { - lcname = STR_ALLOC(name_len-1, 1); + lcname = zend_string_alloc(name_len-1, 1); zend_str_tolower_copy(lcname->val, name+1, name_len-1); } else { - lcname = STR_ALLOC(name_len, 1); + lcname = zend_string_alloc(name_len, 1); zend_str_tolower_copy(lcname->val, name, name_len); } ce = zend_hash_add_ptr(CG(class_table), lcname, ce); - STR_RELEASE(lcname); + zend_string_release(lcname); if (ce) { ce->refcount++; return SUCCESS; @@ -2886,7 +2825,7 @@ ZEND_API int zend_disable_class(char *class_name, uint class_name_length TSRMLS_ zend_class_entry *disabled_class; zend_string *key; - key = STR_ALLOC(class_name_length, 0); + key = zend_string_alloc(class_name_length, 0); zend_str_tolower_copy(key->val, class_name, class_name_length); disabled_class = zend_hash_find_ptr(CG(class_table), key); if (!disabled_class) { @@ -3003,7 +2942,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca /* Skip leading \ */ if (UNEXPECTED(Z_STRVAL_P(callable)[0] == '\\')) { - STR_ALLOCA_INIT(lmname, Z_STRVAL_P(callable) + 1, Z_STRSIZE_P(callable) - 1, use_heap); + STR_ALLOCA_INIT(lmname, Z_STRVAL_P(callable) + 1, Z_STRLEN_P(callable) - 1, use_heap); } else { lmname = Z_STR_P(callable); } @@ -3016,9 +2955,9 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca return 1; } else { if (lmname == Z_STR_P(callable)) { - STR_ALLOCA_INIT(lmname, Z_STRVAL_P(callable), Z_STRSIZE_P(callable), use_heap); + STR_ALLOCA_INIT(lmname, Z_STRVAL_P(callable), Z_STRLEN_P(callable), use_heap); } else { - STR_FORGET_HASH_VAL(lmname); + zend_string_forget_hash_val(lmname); } zend_str_tolower(lmname->val, lmname->len); if ((fcc->function_handler = zend_hash_find_ptr(EG(function_table), lmname)) != NULL) { @@ -3032,13 +2971,13 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca } /* Split name into class/namespace and method/function names */ - if ((colon = zend_memrchr(Z_STRVAL_P(callable), ':', Z_STRSIZE_P(callable))) != NULL && + if ((colon = zend_memrchr(Z_STRVAL_P(callable), ':', Z_STRLEN_P(callable))) != NULL && colon > Z_STRVAL_P(callable) && *(colon-1) == ':' ) { colon--; clen = colon - Z_STRVAL_P(callable); - mlen = Z_STRSIZE_P(callable) - clen - 2; + mlen = Z_STRLEN_P(callable) - clen - 2; if (colon == Z_STRVAL_P(callable)) { if (error) zend_spprintf(error, 0, "invalid function name"); @@ -3052,13 +2991,13 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca EG(scope) = ce_org; } - cname = STR_INIT(Z_STRVAL_P(callable), clen, 0); + cname = zend_string_init(Z_STRVAL_P(callable), clen, 0); if (!zend_is_callable_check_class(cname, fcc, &strict_class, error TSRMLS_CC)) { - STR_RELEASE(cname); + zend_string_release(cname); EG(scope) = last_scope; return 0; } - STR_RELEASE(cname); + zend_string_release(cname); EG(scope) = last_scope; ftable = &fcc->calling_scope->function_table; @@ -3066,12 +3005,12 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca if (error) zend_spprintf(error, 0, "class '%s' is not a subclass of '%s'", ce_org->name->val, fcc->calling_scope->name->val); return 0; } - mname = STR_INIT(Z_STRVAL_P(callable) + clen + 2, mlen, 0); + mname = zend_string_init(Z_STRVAL_P(callable) + clen + 2, mlen, 0); } else if (ce_org) { /* Try to fetch find static method of given class. */ - mlen = Z_STRSIZE_P(callable); + mlen = Z_STRLEN_P(callable); mname = Z_STR_P(callable); - STR_ADDREF(mname); + zend_string_addref(mname); ftable = &ce_org->function_table; fcc->calling_scope = ce_org; } else { @@ -3082,7 +3021,7 @@ static int zend_is_callable_check_func(int check_flags, zval *callable, zend_fca return 0; } - lmname = STR_ALLOC(mlen, 0); + lmname = zend_string_alloc(mlen, 0); zend_str_tolower_copy(lmname->val, mname->val, mlen); if (strict_class && fcc->calling_scope && @@ -3136,7 +3075,7 @@ get_function_via_handler: fcc->function_handler->internal_function.scope = ce_org; fcc->function_handler->internal_function.fn_flags = ZEND_ACC_CALL_VIA_HANDLER; fcc->function_handler->internal_function.function_name = mname; - STR_ADDREF(mname); + zend_string_addref(mname); call_via_handler = 1; retval = 1; } else if (fcc->object->handlers->get_method) { @@ -3147,7 +3086,7 @@ get_function_via_handler: !instanceof_function(ce_org, fcc->function_handler->common.scope TSRMLS_CC))) { if ((fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) { if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) { - STR_RELEASE(fcc->function_handler->common.function_name); + zend_string_release(fcc->function_handler->common.function_name); } efree(fcc->function_handler); } @@ -3250,8 +3189,8 @@ get_function_via_handler: if (error) zend_spprintf(error, 0, "function '%s' does not exist", mname->val); } } - STR_FREE(lmname); - STR_RELEASE(mname); + zend_string_free(lmname); + zend_string_release(mname); if (fcc->object) { fcc->called_scope = zend_get_class_entry(fcc->object TSRMLS_CC); @@ -3299,16 +3238,16 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint if (callable_name) { char *ptr; - *callable_name = STR_ALLOC(fcc->calling_scope->name->len + Z_STRSIZE_P(callable) + sizeof("::") - 1, 0); + *callable_name = zend_string_alloc(fcc->calling_scope->name->len + Z_STRLEN_P(callable) + sizeof("::") - 1, 0); ptr = (*callable_name)->val; memcpy(ptr, fcc->calling_scope->name->val, fcc->calling_scope->name->len); ptr += fcc->calling_scope->name->len; memcpy(ptr, "::", sizeof("::") - 1); ptr += sizeof("::") - 1; - memcpy(ptr, Z_STRVAL_P(callable), Z_STRSIZE_P(callable) + 1); + memcpy(ptr, Z_STRVAL_P(callable), Z_STRLEN_P(callable) + 1); } } else if (callable_name) { - *callable_name = STR_COPY(Z_STR_P(callable)); + *callable_name = zend_string_copy(Z_STR_P(callable)); } if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) { fcc->called_scope = fcc->calling_scope; @@ -3323,7 +3262,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) { if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) { - STR_RELEASE(fcc->function_handler->common.function_name); + zend_string_release(fcc->function_handler->common.function_name); } efree(fcc->function_handler); } @@ -3356,13 +3295,13 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint char *ptr; - *callable_name = STR_ALLOC(Z_STRSIZE_P(obj) + Z_STRSIZE_P(method) + sizeof("::") - 1, 0); + *callable_name = zend_string_alloc(Z_STRLEN_P(obj) + Z_STRLEN_P(method) + sizeof("::") - 1, 0); ptr = (*callable_name)->val; - memcpy(ptr, Z_STRVAL_P(obj), Z_STRSIZE_P(obj)); - ptr += Z_STRSIZE_P(obj); + memcpy(ptr, Z_STRVAL_P(obj), Z_STRLEN_P(obj)); + ptr += Z_STRLEN_P(obj); memcpy(ptr, "::", sizeof("::") - 1); ptr += sizeof("::") - 1; - memcpy(ptr, Z_STRVAL_P(method), Z_STRSIZE_P(method) + 1); + memcpy(ptr, Z_STRVAL_P(method), Z_STRLEN_P(method) + 1); } if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) { @@ -3386,13 +3325,13 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint if (callable_name) { char *ptr; - *callable_name = STR_ALLOC(fcc->calling_scope->name->len + Z_STRSIZE_P(method) + sizeof("::") - 1, 0); + *callable_name = zend_string_alloc(fcc->calling_scope->name->len + Z_STRLEN_P(method) + sizeof("::") - 1, 0); ptr = (*callable_name)->val; memcpy(ptr, fcc->calling_scope->name->val, fcc->calling_scope->name->len); ptr += fcc->calling_scope->name->len; memcpy(ptr, "::", sizeof("::") - 1); ptr += sizeof("::") - 1; - memcpy(ptr, Z_STRVAL_P(method), Z_STRSIZE_P(method) + 1); + memcpy(ptr, Z_STRVAL_P(method), Z_STRLEN_P(method) + 1); } if (check_flags & IS_CALLABLE_CHECK_SYNTAX_ONLY) { @@ -3411,7 +3350,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY || fcc->function_handler->type == ZEND_OVERLOADED_FUNCTION)) { if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION) { - STR_RELEASE(fcc->function_handler->common.function_name); + zend_string_release(fcc->function_handler->common.function_name); } efree(fcc->function_handler); } @@ -3430,7 +3369,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint if (error) zend_spprintf(error, 0, "array must have exactly two members"); } if (callable_name) { - *callable_name = STR_INIT("Array", sizeof("Array")-1, 0); + *callable_name = zend_string_init("Array", sizeof("Array")-1, 0); } } return 0; @@ -3441,7 +3380,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint if (callable_name) { zend_class_entry *ce = Z_OBJCE_P(callable); /* TBFixed: what if it's overloaded? */ - *callable_name = STR_ALLOC(ce->name->len + sizeof("::__invoke") - 1, 0); + *callable_name = zend_string_alloc(ce->name->len + sizeof("::__invoke") - 1, 0); memcpy((*callable_name)->val, ce->name->val, ce->name->len); memcpy((*callable_name)->val + ce->name->len, "::__invoke", sizeof("::__invoke")); } @@ -3473,8 +3412,8 @@ ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_nam if (Z_TYPE_P(callable) == IS_STRING && fcc.calling_scope) { zval_dtor(callable); array_init(callable); - add_next_index_str(callable, STR_COPY(fcc.calling_scope->name)); - add_next_index_str(callable, STR_COPY(fcc.function_handler->common.function_name)); + add_next_index_str(callable, zend_string_copy(fcc.calling_scope->name)); + add_next_index_str(callable, zend_string_copy(fcc.function_handler->common.function_name)); } if (fcc.function_handler && ((fcc.function_handler->type == ZEND_INTERNAL_FUNCTION && @@ -3482,7 +3421,7 @@ ZEND_API zend_bool zend_make_callable(zval *callable, zend_string **callable_nam fcc.function_handler->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY || fcc.function_handler->type == ZEND_OVERLOADED_FUNCTION)) { if (fcc.function_handler->type != ZEND_OVERLOADED_FUNCTION) { - STR_RELEASE(fcc.function_handler->common.function_name); + zend_string_release(fcc.function_handler->common.function_name); } efree(fcc.function_handler); } @@ -3676,10 +3615,10 @@ ZEND_API const char *zend_get_module_version(const char *module_name) /* {{{ */ int name_len = strlen(module_name); zend_module_entry *module; - lname = STR_ALLOC(name_len, 0); + lname = zend_string_alloc(name_len, 0); zend_str_tolower_copy(lname->val, module_name, name_len); module = zend_hash_find_ptr(&module_registry, lname); - STR_FREE(lname); + zend_string_free(lname); return module ? module->version : NULL; } /* }}} */ @@ -3747,7 +3686,7 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, z } break; case ZEND_ACC_PUBLIC: - property_info->name = STR_COPY(name); + property_info->name = zend_string_copy(name); break; } @@ -3763,9 +3702,9 @@ ZEND_API int zend_declare_property_ex(zend_class_entry *ce, zend_string *name, z ZEND_API int zend_declare_property(zend_class_entry *ce, const char *name, int name_length, zval *property, int access_type TSRMLS_DC) /* {{{ */ { - zend_string *key = STR_INIT(name, name_length, ce->type & ZEND_INTERNAL_CLASS); + zend_string *key = zend_string_init(name, name_length, ce->type & ZEND_INTERNAL_CLASS); int ret = zend_declare_property_ex(ce, key, property, access_type, NULL TSRMLS_CC); - STR_RELEASE(key); + zend_string_release(key); return ret; } /* }}} */ @@ -3779,7 +3718,7 @@ ZEND_API int zend_declare_property_null(zend_class_entry *ce, const char *name, } /* }}} */ -ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, int name_length, zend_int_t value, int access_type TSRMLS_DC) /* {{{ */ +ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, int name_length, zend_long value, int access_type TSRMLS_DC) /* {{{ */ { zval property; @@ -3788,11 +3727,11 @@ ZEND_API int zend_declare_property_bool(zend_class_entry *ce, const char *name, } /* }}} */ -ZEND_API int zend_declare_property_int(zend_class_entry *ce, const char *name, int name_length, zend_int_t value, int access_type TSRMLS_DC) /* {{{ */ +ZEND_API int zend_declare_property_long(zend_class_entry *ce, const char *name, int name_length, zend_long value, int access_type TSRMLS_DC) /* {{{ */ { zval property; - ZVAL_INT(&property, value); + ZVAL_LONG(&property, value); return zend_declare_property(ce, name, name_length, &property, access_type TSRMLS_CC); } /* }}} */ @@ -3810,7 +3749,7 @@ ZEND_API int zend_declare_property_string(zend_class_entry *ce, const char *name { zval property; - ZVAL_NEW_STR(&property, STR_INIT(value, strlen(value), ce->type & ZEND_INTERNAL_CLASS)); + ZVAL_NEW_STR(&property, zend_string_init(value, strlen(value), ce->type & ZEND_INTERNAL_CLASS)); return zend_declare_property(ce, name, name_length, &property, access_type TSRMLS_CC); } /* }}} */ @@ -3819,7 +3758,7 @@ ZEND_API int zend_declare_property_stringl(zend_class_entry *ce, const char *nam { zval property; - ZVAL_NEW_STR(&property, STR_INIT(value, value_len, ce->type & ZEND_INTERNAL_CLASS)); + ZVAL_NEW_STR(&property, zend_string_init(value, value_len, ce->type & ZEND_INTERNAL_CLASS)); return zend_declare_property(ce, name, name_length, &property, access_type TSRMLS_CC); } /* }}} */ @@ -3843,11 +3782,11 @@ ZEND_API int zend_declare_class_constant_null(zend_class_entry *ce, const char * } /* }}} */ -ZEND_API int zend_declare_class_constant_int(zend_class_entry *ce, const char *name, size_t name_length, zend_int_t value TSRMLS_DC) /* {{{ */ +ZEND_API int zend_declare_class_constant_long(zend_class_entry *ce, const char *name, size_t name_length, zend_long value TSRMLS_DC) /* {{{ */ { zval constant; - ZVAL_INT(&constant, value); + ZVAL_LONG(&constant, value); return zend_declare_class_constant(ce, name, name_length, &constant TSRMLS_CC); } /* }}} */ @@ -3874,7 +3813,7 @@ ZEND_API int zend_declare_class_constant_stringl(zend_class_entry *ce, const cha { zval constant; - ZVAL_NEW_STR(&constant, STR_INIT(value, value_length, ce->type & ZEND_INTERNAL_CLASS)); + ZVAL_NEW_STR(&constant, zend_string_init(value, value_length, ce->type & ZEND_INTERNAL_CLASS)); return zend_declare_class_constant(ce, name, name_length, &constant TSRMLS_CC); } /* }}} */ @@ -3913,7 +3852,7 @@ ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, c } /* }}} */ -ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_int_t value TSRMLS_DC) /* {{{ */ +ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_long value TSRMLS_DC) /* {{{ */ { zval tmp; @@ -3922,11 +3861,11 @@ ZEND_API void zend_update_property_bool(zend_class_entry *scope, zval *object, c } /* }}} */ -ZEND_API void zend_update_property_int(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_int_t value TSRMLS_DC) /* {{{ */ +ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, const char *name, int name_length, zend_long value TSRMLS_DC) /* {{{ */ { zval tmp; - ZVAL_INT(&tmp, value); + ZVAL_LONG(&tmp, value); zend_update_property(scope, object, name, name_length, &tmp TSRMLS_CC); } /* }}} */ @@ -3973,12 +3912,12 @@ ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *na { zval *property; zend_class_entry *old_scope = EG(scope); - zend_string *key = STR_INIT(name, name_length, 0); + zend_string *key = zend_string_init(name, name_length, 0); EG(scope) = scope; property = zend_std_get_static_property(scope, key, 0, NULL TSRMLS_CC); EG(scope) = old_scope; - STR_FREE(key); + zend_string_free(key); if (!property) { return FAILURE; } else { @@ -4015,7 +3954,7 @@ ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const cha } /* }}} */ -ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, int name_length, zend_int_t value TSRMLS_DC) /* {{{ */ +ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const char *name, int name_length, zend_long value TSRMLS_DC) /* {{{ */ { zval tmp; @@ -4024,11 +3963,11 @@ ZEND_API int zend_update_static_property_bool(zend_class_entry *scope, const cha } /* }}} */ -ZEND_API int zend_update_static_property_int(zend_class_entry *scope, const char *name, int name_length, zend_int_t value TSRMLS_DC) /* {{{ */ +ZEND_API int zend_update_static_property_long(zend_class_entry *scope, const char *name, int name_length, zend_long value TSRMLS_DC) /* {{{ */ { zval tmp; - ZVAL_INT(&tmp, value); + ZVAL_LONG(&tmp, value); return zend_update_static_property(scope, name, name_length, &tmp TSRMLS_CC); } /* }}} */ @@ -4088,12 +4027,12 @@ ZEND_API zval *zend_read_static_property(zend_class_entry *scope, const char *na { zval *property; zend_class_entry *old_scope = EG(scope); - zend_string *key = STR_INIT(name, name_length, 0); + zend_string *key = zend_string_init(name, name_length, 0); EG(scope) = scope; property = zend_std_get_static_property(scope, key, silent, NULL TSRMLS_CC); EG(scope) = old_scope; - STR_FREE(key); + zend_string_free(key); return property; } @@ -4132,10 +4071,10 @@ static int same_zval(zval *zv1, zval *zv2) /* {{{ */ case IS_FALSE: case IS_TRUE: return 1; - case IS_INT: - return Z_IVAL_P(zv1) == Z_IVAL_P(zv2); + case IS_LONG: + return Z_LVAL_P(zv1) == Z_LVAL_P(zv2); case IS_DOUBLE: - return Z_IVAL_P(zv1) == Z_IVAL_P(zv2); + return Z_LVAL_P(zv1) == Z_LVAL_P(zv2); case IS_STRING: case IS_ARRAY: case IS_OBJECT: |