Patch func-get-args-with-offset for *General Issues Bug #50945
Patch version 2010-03-06 11:50 UTC
Return to Bug #50945 |
Download this patch
Patch Revisions:
Developer: kalle@php.net
Index: zend_builtin_functions.c
===================================================================
--- zend_builtin_functions.c (revision 295888)
+++ zend_builtin_functions.c (working copy)
@@ -222,7 +222,7 @@
ZEND_FE(zend_version, arginfo_zend__void)
ZEND_FE(func_num_args, arginfo_zend__void)
ZEND_FE(func_get_arg, arginfo_func_get_arg)
- ZEND_FE(func_get_args, arginfo_zend__void)
+ ZEND_FE(func_get_args, arginfo_func_get_arg)
ZEND_FE(strlen, arginfo_strlen)
ZEND_FE(strcmp, arginfo_strcmp)
ZEND_FE(strncmp, arginfo_strncmp)
@@ -422,20 +422,28 @@
ZEND_FUNCTION(func_get_args)
{
void **p;
- int arg_count;
- int i;
+ long arg_count, i, offset = 0;
zend_execute_data *ex = EG(current_execute_data)->prev_execute_data;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &offset) == FAILURE) {
+ return;
+ }
+
if (!ex || !ex->function_state.arguments) {
zend_error(E_WARNING, "func_get_args(): Called from the global scope - no function context");
RETURN_FALSE;
}
p = ex->function_state.arguments;
- arg_count = (int)(zend_uintptr_t) *p; /* this is the amount of arguments passed to func_get_args(); */
+ arg_count = (long)(zend_uintptr_t) *p; /* this is the amount of arguments passed to the current function */
- array_init_size(return_value, arg_count);
- for (i=0; i<arg_count; i++) {
+ if ((arg_count - offset) < 1) {
+ array_init(return_value);
+ } else {
+ array_init_size(return_value, arg_count - offset);
+ }
+
+ for (i = offset; i < arg_count; i++) {
zval *element;
ALLOC_ZVAL(element);
|