summaryrefslogtreecommitdiff
path: root/Zend/zend_builtin_functions.c
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/zend_builtin_functions.c')
-rw-r--r--Zend/zend_builtin_functions.c104
1 files changed, 38 insertions, 66 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 4a0a71fd04..91ab77e6c5 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -381,7 +381,7 @@ ZEND_FUNCTION(gc_enabled)
ZEND_FUNCTION(gc_enable)
{
zend_string *key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
- zend_alter_ini_entry(key, "1", sizeof("1")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
+ zend_alter_ini_entry_chars(key, "1", sizeof("1")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
zend_string_release(key);
}
/* }}} */
@@ -391,7 +391,7 @@ ZEND_FUNCTION(gc_enable)
ZEND_FUNCTION(gc_disable)
{
zend_string *key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
- zend_alter_ini_entry(key, "0", sizeof("0")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
+ zend_alter_ini_entry_chars(key, "0", sizeof("0")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
zend_string_release(key);
}
/* }}} */
@@ -415,7 +415,7 @@ ZEND_FUNCTION(func_num_args)
Get the $arg_num'th argument that was passed to the function */
ZEND_FUNCTION(func_get_arg)
{
- int arg_count, first_extra_arg;
+ uint32_t arg_count, first_extra_arg;
zval *arg;
zend_long requested_offset;
zend_execute_data *ex;
@@ -460,8 +460,8 @@ ZEND_FUNCTION(func_get_arg)
ZEND_FUNCTION(func_get_args)
{
zval *p;
- int arg_count, first_extra_arg;
- int i;
+ uint32_t arg_count, first_extra_arg;
+ uint32_t i;
zend_execute_data *ex = EG(current_execute_data)->prev_execute_data;
if (ex->frame_kind != VM_FRAME_NESTED_FUNCTION && ex->frame_kind != VM_FRAME_TOP_FUNCTION) {
@@ -539,7 +539,6 @@ ZEND_FUNCTION(strlen)
}
/* }}} */
-
/* {{{ proto int strcmp(string str1, string str2)
Binary safe string comparison */
ZEND_FUNCTION(strcmp)
@@ -554,7 +553,6 @@ ZEND_FUNCTION(strcmp)
}
/* }}} */
-
/* {{{ proto int strncmp(string str1, string str2, int len)
Binary safe string comparison */
ZEND_FUNCTION(strncmp)
@@ -575,7 +573,6 @@ ZEND_FUNCTION(strncmp)
}
/* }}} */
-
/* {{{ proto int strcasecmp(string str1, string str2)
Binary safe case-insensitive string comparison */
ZEND_FUNCTION(strcasecmp)
@@ -590,7 +587,6 @@ ZEND_FUNCTION(strcasecmp)
}
/* }}} */
-
/* {{{ proto int strncasecmp(string str1, string str2, int len)
Binary safe string comparison */
ZEND_FUNCTION(strncasecmp)
@@ -611,7 +607,6 @@ ZEND_FUNCTION(strncasecmp)
}
/* }}} */
-
/* {{{ proto array each(array arr)
Return the currently pointed key..value pair in the passed array, and advance the pointer to the next element */
ZEND_FUNCTION(each)
@@ -660,7 +655,7 @@ ZEND_FUNCTION(each)
/* add the key elements */
if (zend_hash_get_current_key(target_hash, &key, &num_key, 0) == HASH_KEY_IS_STRING) {
- ZVAL_STR(&tmp, zend_string_copy(key));
+ ZVAL_STR_COPY(&tmp, key);
if (Z_REFCOUNTED(tmp)) Z_ADDREF(tmp);
} else {
ZVAL_LONG(&tmp, num_key);
@@ -671,23 +666,21 @@ ZEND_FUNCTION(each)
}
/* }}} */
-
/* {{{ proto int error_reporting([int new_error_level])
Return the current error_reporting level, and if an argument was passed - change to the new level */
ZEND_FUNCTION(error_reporting)
{
- char *err;
- size_t err_len;
+ zend_string *err;
int old_error_reporting;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &err, &err_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|S", &err) == FAILURE) {
return;
}
old_error_reporting = EG(error_reporting);
if(ZEND_NUM_ARGS() != 0) {
zend_string *key = zend_string_init("error_reporting", sizeof("error_reporting")-1, 0);
- zend_alter_ini_entry(key, err, err_len, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
+ zend_alter_ini_entry(key, err, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
zend_string_release(key);
}
@@ -695,7 +688,6 @@ ZEND_FUNCTION(error_reporting)
}
/* }}} */
-
/* {{{ proto bool define(string constant_name, mixed value, boolean case_insensitive=false)
Define a new constant */
ZEND_FUNCTION(define)
@@ -775,7 +767,6 @@ repeat:
}
/* }}} */
-
/* {{{ proto bool defined(string constant_name)
Check whether a constant exists
Warning: This function is special-cased by zend_compile.c and so is usually bypassed */
@@ -801,7 +792,6 @@ ZEND_FUNCTION(defined)
}
/* }}} */
-
/* {{{ proto string get_class([object object])
Retrieves the class name */
ZEND_FUNCTION(get_class)
@@ -825,7 +815,6 @@ ZEND_FUNCTION(get_class)
}
/* }}} */
-
/* {{{ proto string get_called_class()
Retrieves the "Late Static Binding" class name */
ZEND_FUNCTION(get_called_class)
@@ -843,7 +832,6 @@ ZEND_FUNCTION(get_called_class)
}
/* }}} */
-
/* {{{ proto string get_parent_class([mixed object])
Retrieves the parent class name for object or class or current scope. */
ZEND_FUNCTION(get_parent_class)
@@ -884,8 +872,7 @@ ZEND_FUNCTION(get_parent_class)
}
/* }}} */
-
-static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass)
+static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass) /* {{{ */
{
zval *obj;
zend_string *class_name;
@@ -937,7 +924,7 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass)
RETURN_BOOL(retval);
}
-
+/* }}} */
/* {{{ proto bool is_subclass_of(mixed object_or_string, string class_name [, bool allow_string=true])
Returns true if the object has this class as one of its parents */
@@ -947,7 +934,6 @@ ZEND_FUNCTION(is_subclass_of)
}
/* }}} */
-
/* {{{ proto bool is_a(mixed object_or_string, string class_name [, bool allow_string=false])
Returns true if the first argument is an object and is this class or has this class as one of its parents, */
ZEND_FUNCTION(is_a)
@@ -956,7 +942,6 @@ ZEND_FUNCTION(is_a)
}
/* }}} */
-
/* {{{ add_class_vars */
static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value TSRMLS_DC)
{
@@ -1004,7 +989,6 @@ static void add_class_vars(zend_class_entry *ce, int statics, zval *return_value
}
/* }}} */
-
/* {{{ proto array get_class_vars(string class_name)
Returns an array of default properties of the class. */
ZEND_FUNCTION(get_class_vars)
@@ -1028,7 +1012,6 @@ ZEND_FUNCTION(get_class_vars)
}
/* }}} */
-
/* {{{ proto array get_object_vars(object obj)
Returns an array of object properties */
ZEND_FUNCTION(get_object_vars)
@@ -1037,8 +1020,6 @@ ZEND_FUNCTION(get_object_vars)
zval *value;
HashTable *properties;
zend_string *key;
- const char *prop_name, *class_name;
- uint prop_len;
zend_object *zobj;
#ifndef FAST_ZPP
@@ -1063,7 +1044,7 @@ ZEND_FUNCTION(get_object_vars)
zobj = Z_OBJ_P(obj);
- array_init(return_value);
+ array_init_size(return_value, zend_hash_num_elements(properties));
ZEND_HASH_FOREACH_STR_KEY_VAL_IND(properties, key, value) {
if (key) {
@@ -1071,7 +1052,9 @@ ZEND_FUNCTION(get_object_vars)
/* Not separating references */
if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value);
if (key->val[0] == 0) {
- zend_unmangle_property_name_ex(key->val, key->len, &class_name, &prop_name, (int*) &prop_len);
+ const char *prop_name, *class_name;
+ size_t prop_len;
+ zend_unmangle_property_name_ex(key, &class_name, &prop_name, &prop_len);
zend_hash_str_add_new(Z_ARRVAL_P(return_value), prop_name, prop_len, value);
} else {
zend_hash_add_new(Z_ARRVAL_P(return_value), key, value);
@@ -1082,13 +1065,14 @@ ZEND_FUNCTION(get_object_vars)
}
/* }}} */
-static int same_name(const char *key, const char *name, uint32_t name_len)
+static int same_name(const char *key, const char *name, uint32_t name_len) /* {{{ */
{
char *lcname = zend_str_tolower_dup(name, name_len);
int ret = memcmp(lcname, key, name_len) == 0;
efree(lcname);
return ret;
}
+/* }}} */
/* {{{ proto array get_class_methods(mixed class)
Returns an array of method names for class or class instance. */
@@ -1132,7 +1116,7 @@ ZEND_FUNCTION(get_class_methods)
/* Do not display old-style inherited constructors */
if (!key) {
- ZVAL_STR(&method_name, zend_string_copy(mptr->common.function_name));
+ ZVAL_STR_COPY(&method_name, mptr->common.function_name);
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
} else if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 ||
mptr->common.scope == ce ||
@@ -1142,10 +1126,10 @@ ZEND_FUNCTION(get_class_methods)
*mptr->op_array.refcount > 1 &&
(len != key->len ||
!same_name(key->val, mptr->common.function_name->val, len))) {
- ZVAL_STR(&method_name, zend_string_copy(zend_find_alias_name(mptr->common.scope, key)));
+ ZVAL_STR_COPY(&method_name, zend_find_alias_name(mptr->common.scope, key));
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
} else {
- ZVAL_STR(&method_name, zend_string_copy(mptr->common.function_name));
+ ZVAL_STR_COPY(&method_name, mptr->common.function_name);
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
}
}
@@ -1154,7 +1138,6 @@ ZEND_FUNCTION(get_class_methods)
}
/* }}} */
-
/* {{{ proto bool method_exists(object object, string method)
Checks if the class method exists */
ZEND_FUNCTION(method_exists)
@@ -1263,7 +1246,6 @@ ZEND_FUNCTION(property_exists)
}
/* }}} */
-
/* {{{ proto bool class_exists(string classname [, bool autoload])
Checks if the class exists */
ZEND_FUNCTION(class_exists)
@@ -1394,7 +1376,6 @@ ZEND_FUNCTION(trait_exists)
}
/* }}} */
-
/* {{{ proto bool function_exists(string function_name)
Checks if the function exists */
ZEND_FUNCTION(function_exists)
@@ -1538,7 +1519,6 @@ ZEND_FUNCTION(get_included_files)
}
/* }}} */
-
/* {{{ proto void trigger_error(string message [, int error_type])
Generates a user-level error/warning/notice message */
ZEND_FUNCTION(trigger_error)
@@ -1568,7 +1548,6 @@ ZEND_FUNCTION(trigger_error)
}
/* }}} */
-
/* {{{ proto string set_error_handler(string error_handler [, int error_types])
Sets a user-defined error handler function. Returns the previously defined error handler, or false on error */
ZEND_FUNCTION(set_error_handler)
@@ -1608,7 +1587,6 @@ ZEND_FUNCTION(set_error_handler)
}
/* }}} */
-
/* {{{ proto void restore_error_handler(void)
Restores the previously defined error handler function */
ZEND_FUNCTION(restore_error_handler)
@@ -1635,7 +1613,6 @@ ZEND_FUNCTION(restore_error_handler)
}
/* }}} */
-
/* {{{ proto string set_exception_handler(callable exception_handler)
Sets a user-defined exception handler function. Returns the previously defined exception handler, or false on error */
ZEND_FUNCTION(set_exception_handler)
@@ -1672,7 +1649,6 @@ ZEND_FUNCTION(set_exception_handler)
}
/* }}} */
-
/* {{{ proto void restore_exception_handler(void)
Restores the previously defined exception handler function */
ZEND_FUNCTION(restore_exception_handler)
@@ -1691,7 +1667,7 @@ ZEND_FUNCTION(restore_exception_handler)
}
/* }}} */
-static int copy_class_or_interface_name(zval *el TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
+static int copy_class_or_interface_name(zval *el TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
{
zend_class_entry *ce = (zend_class_entry *)Z_PTR_P(el);
zval *array = va_arg(args, zval *);
@@ -1711,6 +1687,7 @@ static int copy_class_or_interface_name(zval *el TSRMLS_DC, int num_args, va_lis
}
return ZEND_HASH_APPLY_KEEP;
}
+/* }}} */
/* {{{ proto array get_declared_traits()
Returns an array of all declared traits. */
@@ -1728,7 +1705,6 @@ ZEND_FUNCTION(get_declared_traits)
}
/* }}} */
-
/* {{{ proto array get_declared_classes()
Returns an array of all declared classes. */
ZEND_FUNCTION(get_declared_classes)
@@ -1761,8 +1737,7 @@ ZEND_FUNCTION(get_declared_interfaces)
}
/* }}} */
-
-static int copy_function_name(zval *zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
+static int copy_function_name(zval *zv TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
{
zend_function *func = Z_PTR_P(zv);
zval *internal_ar = va_arg(args, zval *),
@@ -1780,7 +1755,7 @@ static int copy_function_name(zval *zv TSRMLS_DC, int num_args, va_list args, ze
return 0;
}
-
+/* }}} */
/* {{{ proto array get_defined_functions(void)
Returns an array of all defined functions */
@@ -1818,7 +1793,6 @@ ZEND_FUNCTION(get_defined_functions)
}
/* }}} */
-
/* {{{ proto array get_defined_vars(void)
Returns an associative array of names and values of all currently defined variable names (variables in the current scope) */
ZEND_FUNCTION(get_defined_vars)
@@ -1830,7 +1804,6 @@ ZEND_FUNCTION(get_defined_vars)
}
/* }}} */
-
#define LAMBDA_TEMP_FUNCNAME "__lambda_func"
/* {{{ proto string create_function(string args, string code)
Creates an anonymous function, and returns its name (funny, eh?) */
@@ -1901,7 +1874,6 @@ ZEND_FUNCTION(create_function)
}
/* }}} */
-
#if ZEND_DEBUG
ZEND_FUNCTION(zend_test_func)
{
@@ -1987,22 +1959,24 @@ ZEND_FUNCTION(get_resources)
}
/* }}} */
-static int add_extension_info(zval *item, void *arg TSRMLS_DC)
+static int add_extension_info(zval *item, void *arg TSRMLS_DC) /* {{{ */
{
zval *name_array = (zval *)arg;
zend_module_entry *module = (zend_module_entry*)Z_PTR_P(item);
add_next_index_string(name_array, module->name);
return 0;
}
+/* }}} */
-static int add_zendext_info(zend_extension *ext, void *arg TSRMLS_DC)
+static int add_zendext_info(zend_extension *ext, void *arg TSRMLS_DC) /* {{{ */
{
zval *name_array = (zval *)arg;
add_next_index_string(name_array, ext->name);
return 0;
}
+/* }}} */
-static int add_constant_info(zval *item, void *arg TSRMLS_DC)
+static int add_constant_info(zval *item, void *arg TSRMLS_DC) /* {{{ */
{
zval *name_array = (zval *)arg;
zend_constant *constant = (zend_constant*)Z_PTR_P(item);
@@ -2017,7 +1991,7 @@ static int add_constant_info(zval *item, void *arg TSRMLS_DC)
zend_hash_add_new(Z_ARRVAL_P(name_array), constant->name, &const_val);
return 0;
}
-
+/* }}} */
/* {{{ proto array get_loaded_extensions([bool zend_extensions]) U
Return an array containing names of loaded extensions */
@@ -2039,7 +2013,6 @@ ZEND_FUNCTION(get_loaded_extensions)
}
/* }}} */
-
/* {{{ proto array get_defined_constants([bool categorize])
Return an array containing the names and values of all defined constants */
ZEND_FUNCTION(get_defined_constants)
@@ -2102,18 +2075,17 @@ ZEND_FUNCTION(get_defined_constants)
}
/* }}} */
-
-static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array TSRMLS_DC)
+static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array TSRMLS_DC) /* {{{ */
{
- int num_args = call->num_args;
+ uint32_t num_args = call->num_args;
array_init_size(arg_array, num_args);
if (num_args) {
- int i = 0;
+ uint32_t i = 0;
zval *p = ZEND_CALL_ARG(call, 1);
if (call->func->type == ZEND_USER_FUNCTION) {
- int first_extra_arg = call->func->op_array.num_args;
+ uint32_t first_extra_arg = call->func->op_array.num_args;
if (call->func->op_array.fn_flags & ZEND_ACC_VARIADIC) {
first_extra_arg--;
@@ -2137,8 +2109,9 @@ static void debug_backtrace_get_args(zend_execute_data *call, zval *arg_array TS
}
}
}
+/* }}} */
-void debug_print_backtrace_args(zval *arg_array TSRMLS_DC)
+void debug_print_backtrace_args(zval *arg_array TSRMLS_DC) /* {{{ */
{
zval *tmp;
int i = 0;
@@ -2150,6 +2123,7 @@ void debug_print_backtrace_args(zval *arg_array TSRMLS_DC)
zend_print_flat_zval_r(tmp TSRMLS_CC);
} ZEND_HASH_FOREACH_END();
}
+/* }}} */
/* {{{ proto void debug_print_backtrace([int options[, int limit]]) */
ZEND_FUNCTION(debug_print_backtrace)
@@ -2340,7 +2314,7 @@ ZEND_FUNCTION(debug_print_backtrace)
/* }}} */
-ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit TSRMLS_DC)
+ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int options, int limit TSRMLS_DC) /* {{{ */
{
zend_execute_data *call, *ptr, *skip;
zend_object *object;
@@ -2548,7 +2522,6 @@ ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, int
}
/* }}} */
-
/* {{{ proto array debug_backtrace([int options[, int limit]])
Return backtrace as array */
ZEND_FUNCTION(debug_backtrace)
@@ -2587,7 +2560,6 @@ ZEND_FUNCTION(extension_loaded)
}
/* }}} */
-
/* {{{ proto array get_extension_funcs(string extension_name)
Returns an array with the names of functions belonging to the named extension */
ZEND_FUNCTION(get_extension_funcs)