]> granicus.if.org Git - php/commitdiff
- Updated array functions to use high-performance API
authorAndrey Hristov <andrey@php.net>
Fri, 24 Sep 1999 22:44:41 +0000 (22:44 +0000)
committerAndrey Hristov <andrey@php.net>
Fri, 24 Sep 1999 22:44:41 +0000 (22:44 +0000)
- Updated preg_split() to allow returning only non-empty pieces

ChangeLog
ext/pcre/php_pcre.c
ext/standard/basic_functions.c

index add669485fbf034dedfe95515637b081face6a80..0f7e78af0e02954bac3230b332c063e1d3f44239 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,11 +2,12 @@ PHP 4.0 CHANGE LOG                                                    ChangeLog
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 
 ?? ?? 1999, Version 4.0 Beta 3
-- Updated PCRE to use the new high-performance Zend function API (Andrey)
+- Updated preg_split() to allow returning only non-empty pieces (Andrei)
+- Updated PCRE to use the new high-performance Zend function API (Andrei)
 - Updated session, dba, mhash, mcrypt, sysvshm, sysvsem, gettext modules to use
   the new high-performance Zend function API (Sascha)
-- Extended var_dump to handle resource type somewhat (Andrey)
-- Updated WDDX to use the new high-performance Zend function API (Andrey)
+- Extended var_dump to handle resource type somewhat (Andrei)
+- Updated WDDX to use the new high-performance Zend function API (Andrei)
 - Updated XML to use the new high-performance Zend function API. (Thies)
 - Updated Oracle to use the new high-performance Zend function API. (Thies)
 - Improved the performance of the MySQL module significantly by using the new
@@ -20,7 +21,7 @@ PHP 4.0 CHANGE LOG                                                    ChangeLog
   typo in mcal_list_alarms() (Andrew Skalski)
 - Fixed Ora_PLogon (Thies)
 - Resourcified Oracle (Thies)
-- Implemented object serialization/deserialization in WDDX (Andrey)
+- Implemented object serialization/deserialization in WDDX (Andrei)
 - Added krsort() function (Thies)
 - Added func_num_args(), func_get_arg() and func_get_args() for standard
   access to variable number of arguments functions (Zeev)
@@ -28,7 +29,7 @@ PHP 4.0 CHANGE LOG                                                    ChangeLog
 - Added optional allowable_tags arguments to strip_tags(), gzgetss() and
   fgetss() to allow you to specify a string of tags that are not to be
   stripped  (Rasmus)
-- Upgraded var_dump() to take multiple arguments (Andrey)
+- Upgraded var_dump() to take multiple arguments (Andrei)
 - Resourcified XML (Thies)
 - Fixed a memory leak in the Apache per-directory directives handler (Zeev)
 - Added array_count_values() function. (Thies)
@@ -45,9 +46,9 @@ PHP 4.0 CHANGE LOG                                                    ChangeLog
 - Made serialize/unserialize work on classes. If the class is known at 
   unserialize() time, you'll get back a fully working object! (Thies)
 - Reworked preg_* functions according to the new PCRE API, which also made
-  them behave much more like Perl ones (Andrey)
-- Made it possible to specify external location of PCRE library (Andrey)
-- Updated bundled PCRE library to version 2.08 (Andrey)
+  them behave much more like Perl ones (Andrei)
+- Made it possible to specify external location of PCRE library (Andrei)
+- Updated bundled PCRE library to version 2.08 (Andrei)
 - count()/is_array/is_object... speedups. (Thies)
 - OCI8 supports appending and positioning when saving LOBs (Thies)
 - Added metaphone support (Thies)
@@ -60,12 +61,12 @@ PHP 4.0 CHANGE LOG                                                    ChangeLog
   tells PHP whether it may expose its existence to the outside world, e.g.
   by adding itself to the Web server header (Zeev)
 - Added support for transparent session id propagation (Sascha)
-- Made WDDX serialize object properties properly (Andrey)
+- Made WDDX serialize object properties properly (Andrei)
 - Fixed WDDX mem leak when undefined variable is passed in
-  for serialization (Andrey)
-- Added session_unset() function (Andrey)
-- Fixed double session globals shutdown crash (Andrey)
-- Fixed crash related to ignore_user_abort ini entry (Andrey)
+  for serialization (Andrei)
+- Added session_unset() function (Andrei)
+- Fixed double session globals shutdown crash (Andrei)
+- Fixed crash related to ignore_user_abort ini entry (Andrei)
 - Added support for external entropy sources for session id creation 
   (on Unices /dev/random and /dev/urandom) (Sascha)
 - Added gpc_globals variable directive to php.ini.  By default it is On, but
@@ -75,7 +76,7 @@ PHP 4.0 CHANGE LOG                                                    ChangeLog
   This allows concurrent use of PHP 3.0 and PHP 4.0 as Apache modules. See
   the end of the INSTALL file for more information.
 - Added second parameter to array_keys which specifies search value
-  for which the key should be returned (Andrey)
+  for which the key should be returned (Andrei)
 - Resourcified Informix driver (Danny)
 - New resource handling for odbc, renamed to php_odbc.[ch]
 - Make set_time_limit() work on Unix (Rasmus)
@@ -97,7 +98,7 @@ PHP 4.0 CHANGE LOG                                                    ChangeLog
 - Added -d switch to the CGI binary that allows overriding php.ini values
   from the command line (Zeev)
 - Fixed a crash that would occur if wddx_deserialize did not receive
-  a valid packet (Andrey)
+  a valid packet (Andrei)
 - Fixed a bugglet when redefining a class at run-time (Andi, Zend library)
 - Fixed sem_get() on AIX (Sascha)
 - Fixed fopen() to work with URL's in Win32 (Andi & Zeev)
@@ -114,7 +115,7 @@ PHP 4.0 CHANGE LOG                                                    ChangeLog
 - Improved speed of uniqid() by using the combined LCG and removing
   the extra usleep() (Sascha)
 - Introduced general combined linear congruential generator (Sascha)
-- Made ldap_close back into an alias for ldap_unbind (Andrey)
+- Made ldap_close back into an alias for ldap_unbind (Andrei)
 - OciFetchInto now resets the returned array in all cases (Thies)
 - Fixed mysql_errno() to work with recent versions of MySQL (Zeev)
 - Fixed a problem with define() and boolean values (Zeev)
@@ -123,7 +124,7 @@ PHP 4.0 CHANGE LOG                                                    ChangeLog
 - Oracle is now ZTS-Safe (Thies)
 - Fixed flushing of cached information to disk in DBA's DB2 module (Sascha)
 - OCI8 is now ZTS-Safe (Thies)
-- Fixed is_writeable/is_writable problem; they are both defined now (Andrey)
+- Fixed is_writeable/is_writable problem; they are both defined now (Andrei)
 - Imported PHP 3.0 diskfreespace() function (Thies)
 - Fixed thread-safety issues in the MySQL module (Zeev)
 - Fixed thread-safe support for dynamic modules (Zeev)
@@ -140,7 +141,7 @@ August 9 1999, Version 4.0 Beta 2
   on using the allow_builtin_links INI directive (Zeev)
 - Changed phpinfo() to list modules that have no info function (Zeev)
 - Modified array_walk() function so that the userland callback is passed
-  a key and possible user data in addition to the value (Andrey)
+  a key and possible user data in addition to the value (Andrei)
 - Fixed ldap_search(), ldap_read() and ldap_list() (Zeev)
 - Fixed Apache information in phpinfo() (sam@breakfree.com)
 - Improved register_shutdown_function() - you may now supply arguments that
@@ -165,7 +166,7 @@ August 9 1999, Version 4.0 Beta 2
 - Fixed runtime inheritance of classes (parent methods/properties were
   overriding their children) (Zeev, Zend library)
 - Fixed backwards incompatibility with the "new" operator (Andi, Zend library)
-- Fixed bugs in uksort() and ksort() sort ordering (Andrey)
+- Fixed bugs in uksort() and ksort() sort ordering (Andrei)
 - Fixed a memory leak when using assignment-op operators with lvalue of type
   string (Zeev, Zend library)
 - Fixed a problem in inheritance from classes that are defined in include()d
@@ -179,18 +180,18 @@ August 9 1999, Version 4.0 Beta 2
 - Fixed a crash problem in switch statements that had a string offset
   as a conditional (Andi & Zeev, Zend library)
 - Imported PHP 3.0 fixes for rand() and mt_rand() (Rasmus)
-- Added function entries for strip_tags() and similar_text() (Andrey)
+- Added function entries for strip_tags() and similar_text() (Andrei)
 - Fixed a bug in WDDX that would cause a crash if a number was passed in
-  instead of a variable name (Andrey)
-- Ported strtotime() function from PHP 3.0 (Andrey)
+  instead of a variable name (Andrei)
+- Ported strtotime() function from PHP 3.0 (Andrei)
 - Merged in gdttf stuff from PHP 3.0 (Sascha)
 - buildconf now checks your installation (Stig)
 - XML module now built dynamically with --with-xml=shared (Stig)
 - Added a check for freetype.h - fixed build on RedHat 6.0 (Zeev)
-- Fixed array_walk() to work in PHP 4.0 (Andrey)
-- Ported all remaining date() format options from PHP 3.0 (Andrey)
-- $php_errormsg now works (Andrey)
-- Added locale support for Perl Compatible Regexp functions (Andrey)
+- Fixed array_walk() to work in PHP 4.0 (Andrei)
+- Ported all remaining date() format options from PHP 3.0 (Andrei)
+- $php_errormsg now works (Andrei)
+- Added locale support for Perl Compatible Regexp functions (Andrei)
 - Informix module ported (Danny)
 - Removed --with-shared-apache (Sascha)
 - Added patch for reverse lookup table in base64_decode (Sascha)
index df7a737b9f8714d2c6f53d4385e5f845f41490ec..ada3360a35c6edfd9a8d13dfd7855c7f1b7df976 100644 (file)
@@ -35,6 +35,8 @@
 #define PREG_PATTERN_ORDER     0
 #define PREG_SET_ORDER         1
 
+#define        PREG_SPLIT_NO_EMPTY     (1<<0)
+
 #define PREG_REPLACE_EVAL      (1<<0)
 
 #ifdef ZTS
@@ -109,6 +111,7 @@ static PHP_MINIT_FUNCTION(pcre)
        
        REGISTER_LONG_CONSTANT("PREG_PATTERN_ORDER", PREG_PATTERN_ORDER, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("PREG_SET_ORDER", PREG_SET_ORDER, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("PREG_SPLIT_NO_EMPTY", PREG_SPLIT_NO_EMPTY, CONST_CS | CONST_PERSISTENT);
        return SUCCESS;
 }
 /* }}} */
@@ -886,13 +889,14 @@ PHP_FUNCTION(preg_replace)
 /* }}} */
 
 
-/* {{{ proto array preg_split(string pattern, string subject [, int limit ]) 
+/* {{{ proto array preg_split(string pattern, string subject [, int limit [, int flags]]) 
     split string into an array using a perl-style regular expression as a delimiter */
 PHP_FUNCTION(preg_split)
 {
        zval               **regex,                             /* Regular expression to split by */
                                   **subject,                   /* Subject string to split */
-                                  **limit;                             /* Number of pieces to return */
+                                  **limit,                             /* Number of pieces to return */
+                                  **flags;
        pcre                    *re = NULL;                     /* Compiled regular expression */
        pcre_extra              *extra = NULL;          /* Holds results of studying */
        int                             *offsets;                       /* Array of subpattern offsets */
@@ -901,6 +905,7 @@ PHP_FUNCTION(preg_split)
        int                              preg_options = 0;      /* Custom preg options */
        int                              argc;                          /* Argument count */
        int                              limit_val;                     /* Integer value of limit */
+       int                              no_empty = 0;          /* If NO_EMPTY flag is set */
        int                              count = 0;                     /* Count of matched subpatterns */
        int                              start_offset;          /* Where the new search starts */
        int                              g_notempty = 0;        /* If the match should not be empty */
@@ -909,7 +914,7 @@ PHP_FUNCTION(preg_split)
 
        /* Get function parameters and do error checking */     
        argc = ARG_COUNT(ht);
-       if (argc < 1 || argc > 3 || getParametersEx(argc, &regex, &subject, &limit) == FAILURE) {
+       if (argc < 1 || argc > 4 || getParametersEx(argc, &regex, &subject, &limit, &flags) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
        
@@ -920,6 +925,11 @@ PHP_FUNCTION(preg_split)
        else
                limit_val = -1;
        
+       if (argc == 4) {
+               convert_to_long_ex(flags);
+               no_empty = (*flags)->value.lval & PREG_SPLIT_NO_EMPTY;
+       }
+       
        /* Make sure we're dealing with strings */
        convert_to_string_ex(regex);
        convert_to_string_ex(subject);
@@ -956,10 +966,11 @@ PHP_FUNCTION(preg_split)
                /* If something matched */
                if (count > 0) {
                        match = (*subject)->value.str.val + offsets[0];
-               
-                       /* Add the piece to the return value */
-                       add_next_index_stringl(return_value, last_match,
-                                                                  &(*subject)->value.str.val[offsets[0]]-last_match, 1);
+
+                       if (!no_empty || &(*subject)->value.str.val[offsets[0]] != last_match)
+                               /* Add the piece to the return value */
+                               add_next_index_stringl(return_value, last_match,
+                                                                          &(*subject)->value.str.val[offsets[0]]-last_match, 1);
                        
                        last_match = &(*subject)->value.str.val[offsets[1]];
                        
@@ -988,9 +999,10 @@ PHP_FUNCTION(preg_split)
                start_offset = offsets[1];
        }
        
-       /* Add the last piece to the return value */
-       add_next_index_string(return_value,
-                                                 &(*subject)->value.str.val[start_offset], 1);
+       if (!no_empty || start_offset != (*subject)->value.str.len)
+               /* Add the last piece to the return value */
+               add_next_index_string(return_value,
+                                                         &(*subject)->value.str.val[start_offset], 1);
        
        /* Clean up */
        efree(offsets);
index 85a53596aed94a5060677912c058f1eccdbc3f8c..54e20914958e1a9b50d2135c2f73359daede501a 100644 (file)
@@ -1402,7 +1402,7 @@ PHP_FUNCTION(max)
        }
 }
 
-static pval *php_array_walk_func_name;
+static zval **php_array_walk_func_name;
 
 static int php_array_walk(HashTable *target_hash, zval **userdata)
 {
@@ -1433,8 +1433,8 @@ static int php_array_walk(HashTable *target_hash, zval **userdata)
                }
                
                /* Call the userland function */
-               call_user_function_ex(CG(function_table), NULL, php_array_walk_func_name,
-                                                  &retval, (*userdata) ? 3 : 2, args, 0);
+               call_user_function_ex(CG(function_table), NULL, *php_array_walk_func_name,
+                                                  &retval, userdata ? 3 : 2, args, 0);
                
                /* Clean up the key */
                if (zend_hash_get_current_key_type(target_hash) == HASH_KEY_IS_STRING)
@@ -1450,27 +1450,27 @@ static int php_array_walk(HashTable *target_hash, zval **userdata)
 /* {{{ proto array_walk(array input, string funcname [, mixed userdata])
    Apply a user function to every member of an array */
 PHP_FUNCTION(array_walk) {
-       int   argc;
-       zval *array,
-                *userdata = NULL,
-                *old_walk_func_name;
+       int    argc;
+       zval **array,
+                **userdata = NULL,
+                **old_walk_func_name;
        HashTable *target_hash;
 
        argc = ARG_COUNT(ht);
        old_walk_func_name = php_array_walk_func_name;
        if (argc < 2 || argc > 3 ||
-               getParameters(ht, argc, &array, &php_array_walk_func_name, &userdata) == FAILURE) {
+               getParametersEx(argc, &array, &php_array_walk_func_name, &userdata) == FAILURE) {
                php_array_walk_func_name = old_walk_func_name;
                WRONG_PARAM_COUNT;
        }
-       target_hash = HASH_OF(array);
+       target_hash = HASH_OF(*array);
        if (!target_hash) {
                php_error(E_WARNING, "Wrong datatype in array_walk() call");
                php_array_walk_func_name = old_walk_func_name;
                return;
        }
-       convert_to_string(php_array_walk_func_name);
-       php_array_walk(target_hash, &userdata);
+       convert_to_string_ex(php_array_walk_func_name);
+       php_array_walk(target_hash, userdata);
        php_array_walk_func_name = old_walk_func_name;
        RETURN_TRUE;
 }
@@ -2472,9 +2472,9 @@ PHP_FUNCTION(compact)
 
 
 /* HashTable* _phpi_splice(HashTable *in_hash, int offset, int length,
-                                                  zval **list, int list_count, HashTable **removed) */
+                                                  zval ***list, int list_count, HashTable **removed) */
 HashTable* _phpi_splice(HashTable *in_hash, int offset, int length,
-                                               zval **list, int list_count, HashTable **removed)
+                                               zval ***list, int list_count, HashTable **removed)
 {
        HashTable       *out_hash = NULL;       /* Output hashtable */
        int                      num_in,                        /* Number of entries in the input hashtable */
@@ -2539,7 +2539,7 @@ HashTable* _phpi_splice(HashTable *in_hash, int offset, int length,
                /* ..for each one, create a new zval, copy entry into it
                   and copy it into the output hash */
                for (i=0; i<list_count; i++) {
-                       entry = list[i];
+                       entry = *list[i];
                        entry->refcount++;
                        zend_hash_next_index_insert(out_hash, &entry, sizeof(zval *), NULL);
                }
@@ -2565,9 +2565,9 @@ HashTable* _phpi_splice(HashTable *in_hash, int offset, int length,
    Pushes elements onto the end of the array */
 PHP_FUNCTION(array_push)
 {
-       zval       **args,              /* Function arguments array */
-                               *stack,         /* Input array */
-                               *new_var;       /* Variable to be pushed */
+       zval      ***args,              /* Function arguments array */
+                           *stack,             /* Input array */
+                           *new_var;   /* Variable to be pushed */
        int                      i,                     /* Loop counter */
                                 argc;          /* Number of function arguments */
 
@@ -2578,23 +2578,23 @@ PHP_FUNCTION(array_push)
        }
        
        /* Allocate arguments array and get the arguments, checking for errors. */
-       args = (zval **)emalloc(argc * sizeof(zval *));
-       if (getParametersArray(ht, argc, args) == FAILURE) {
+       args = (zval ***)emalloc(argc * sizeof(zval **));
+       if (getParametersArrayEx(argc, args) == FAILURE) {
                efree(args);
                WRONG_PARAM_COUNT;
        }
 
        /* Get first argument and check that it's an array */   
-       stack = args[0];
+       stack = *args[0];
        if (stack->type != IS_ARRAY) {
-               zend_error(E_WARNING, "First argument to push() needs to be an array");
+               zend_error(E_WARNING, "First argument to array_push() needs to be an array");
                RETURN_FALSE;
        }
 
        /* For each subsequent argument, make it a reference, increase refcount,
           and add it to the end of the array */
        for (i=1; i<argc; i++) {
-               new_var = args[i];
+               new_var = *args[i];
                new_var->refcount++;
        
                zend_hash_next_index_insert(stack->value.ht, &new_var, sizeof(zval *), NULL);
@@ -2610,39 +2610,39 @@ PHP_FUNCTION(array_push)
 /* {{{ void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int which_end) */
 static void _phpi_pop(INTERNAL_FUNCTION_PARAMETERS, int off_the_end)
 {
-       zval            *stack,                 /* Input stack */
+       zval       **stack,                     /* Input stack */
                           **val;                       /* Value to be popped */
        HashTable       *new_hash;              /* New stack */
        
        /* Get the arguments and do error-checking */
-       if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &stack) == FAILURE) {
+       if (ARG_COUNT(ht) != 1 || getParametersEx(1, &stack) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
        
-       if (stack->type != IS_ARRAY) {
+       if ((*stack)->type != IS_ARRAY) {
                zend_error(E_WARNING, "The argument needs to be an array");
                return;
        }
 
-       if (zend_hash_num_elements(stack->value.ht) == 0) {
+       if (zend_hash_num_elements((*stack)->value.ht) == 0) {
                return;
        }
                
        /* Get the first or last value and copy it into the return value */
        if (off_the_end)
-               zend_hash_internal_pointer_end(stack->value.ht);
+               zend_hash_internal_pointer_end((*stack)->value.ht);
        else
-               zend_hash_internal_pointer_reset(stack->value.ht);
-       zend_hash_get_current_data(stack->value.ht, (void **)&val);
+               zend_hash_internal_pointer_reset((*stack)->value.ht);
+       zend_hash_get_current_data((*stack)->value.ht, (void **)&val);
        *return_value = **val;
        zval_copy_ctor(return_value);
        INIT_PZVAL(return_value);
        
        /* Delete the first or last value */
-       new_hash = _phpi_splice(stack->value.ht, (off_the_end) ? -1 : 0, 1, NULL, 0, NULL);
-       zend_hash_destroy(stack->value.ht);
-       efree(stack->value.ht);
-       stack->value.ht = new_hash;
+       new_hash = _phpi_splice((*stack)->value.ht, (off_the_end) ? -1 : 0, 1, NULL, 0, NULL);
+       zend_hash_destroy((*stack)->value.ht);
+       efree((*stack)->value.ht);
+       (*stack)->value.ht = new_hash;
 }
 /* }}} */
 
@@ -2669,7 +2669,7 @@ PHP_FUNCTION(array_shift)
    Pushes elements onto the beginning of the array */
 PHP_FUNCTION(array_unshift)
 {
-       zval       **args,              /* Function arguments array */
+       zval      ***args,              /* Function arguments array */
                                *stack;         /* Input stack */
        HashTable       *new_hash;      /* New hashtable for the stack */
        int                      argc;          /* Number of function arguments */
@@ -2682,16 +2682,16 @@ PHP_FUNCTION(array_unshift)
        }
        
        /* Allocate arguments array and get the arguments, checking for errors. */
-       args = (zval **)emalloc(argc * sizeof(zval *));
-       if (getParametersArray(ht, argc, args) == FAILURE) {
+       args = (zval ***)emalloc(argc * sizeof(zval **));
+       if (getParametersArrayEx(argc, args) == FAILURE) {
                efree(args);
                WRONG_PARAM_COUNT;
        }
        
        /* Get first argument and check that it's an array */
-       stack = args[0];
+       stack = *args[0];
        if (stack->type != IS_ARRAY) {
-               zend_error(E_WARNING, "First argument to push() needs to be an array");
+               zend_error(E_WARNING, "First argument to array_unshift() needs to be an array");
                RETURN_FALSE;
        }
 
@@ -2709,14 +2709,14 @@ PHP_FUNCTION(array_unshift)
 /* }}} */
 
 
-/* {{{ proto array array_splice(array input, int offset [, int length, mixed var [, ...] ])
+/* {{{ proto array array_splice(array input, int offset [, int length [, array replacement]])
    Removes the elements designated by offset and length and replace them with
-   var's if supplied */
+   supplied array */
 PHP_FUNCTION(array_splice)
 {
-       zval       **args,                              /* Function arguments array */
+       zval      ***args,                              /* Function arguments array */
                                *array,                         /* Input array */
-                          **repl = NULL;               /* Replacement elements */
+                         ***repl = NULL;               /* Replacement elements */
        HashTable       *new_hash = NULL;       /* Output array's hash */
        Bucket          *p;                                     /* Bucket used for traversing hash */
        int                      argc,                          /* Number of function arguments */
@@ -2732,39 +2732,39 @@ PHP_FUNCTION(array_splice)
        }
        
        /* Allocate arguments array and get the arguments, checking for errors. */
-       args = (zval **)emalloc(argc * sizeof(zval *));
-       if (getParametersArray(ht, argc, args) == FAILURE) {
+       args = (zval ***)emalloc(argc * sizeof(zval **));
+       if (getParametersArrayEx(argc, args) == FAILURE) {
                efree(args);
                WRONG_PARAM_COUNT;
        }       
 
        /* Get first argument and check that it's an array */
-       array = args[0];
+       array = *args[0];
        if (array->type != IS_ARRAY) {
-               zend_error(E_WARNING, "First argument to splice() should be an array");
+               zend_error(E_WARNING, "First argument to array_splice() should be an array");
                efree(args);
                return;
        }
        
        /* Get the next two arguments.  If length is omitted,
           it's assumed to be until the end of the array */
-       convert_to_long(args[1]);
-       offset = args[1]->value.lval;
+       convert_to_long_ex(args[1]);
+       offset = (*args[1])->value.lval;
        if (argc > 2) {
-               convert_to_long(args[2]);
-               length = args[2]->value.lval;
+               convert_to_long_ex(args[2]);
+               length = (*args[2])->value.lval;
        } else
                length = zend_hash_num_elements(array->value.ht);
 
        if (argc == 4) {
                /* Make sure the last argument, if passed, is an array */
-               convert_to_array(args[3]);
+               convert_to_array_ex(args[3]);
                
                /* Create the array of replacement elements */
-               repl_num = zend_hash_num_elements(args[3]->value.ht);
-               repl = (zval **)emalloc(repl_num * sizeof(zval *));
-               for (p=args[3]->value.ht->pListHead, i=0; p; p=p->pListNext, i++) {
-                       repl[i] = *((zval **)p->pData);
+               repl_num = zend_hash_num_elements((*args[3])->value.ht);
+               repl = (zval ***)emalloc(repl_num * sizeof(zval **));
+               for (p=(*args[3])->value.ht->pListHead, i=0; p; p=p->pListNext, i++) {
+                       repl[i] = ((zval **)p->pData);
                }
        }
        
@@ -2793,9 +2793,9 @@ PHP_FUNCTION(array_splice)
    Returns elements specified by offset and length */
 PHP_FUNCTION(array_slice)
 {
-       zval            *input,                 /* Input array */
-                               *offset,                /* Offset to get elements from */
-                               *length,                /* How many elements to get */
+       zval       **input,                     /* Input array */
+                          **offset,            /* Offset to get elements from */
+                          **length,            /* How many elements to get */
                           **entry;                     /* An array entry */
        int                      offset_val,    /* Value of the offset argument */
                                 length_val,    /* Value of the length argument */
@@ -2809,31 +2809,31 @@ PHP_FUNCTION(array_slice)
 
        /* Get the arguments and do error-checking */   
        argc = ARG_COUNT(ht);
-       if (argc < 2 || argc > 3 || getParameters(ht, argc, &input, &offset, &length)) {
+       if (argc < 2 || argc > 3 || getParametersEx(argc, &input, &offset, &length)) {
                WRONG_PARAM_COUNT;
        }
        
-       if (input->type != IS_ARRAY) {
-               zend_error(E_WARNING, "First argument to slice() should be an array");
+       if ((*input)->type != IS_ARRAY) {
+               zend_error(E_WARNING, "First argument to array_slice() should be an array");
                return;
        }
        
        /* Make sure offset and length are integers and assume
           we want all entries from offset to the end if length
           is not passed */
-       convert_to_long(offset);
-       offset_val = offset->value.lval;
+       convert_to_long_ex(offset);
+       offset_val = (*offset)->value.lval;
        if (argc == 3) {
-               convert_to_long(length);
-               length_val = length->value.lval;
+               convert_to_long_ex(length);
+               length_val = (*length)->value.lval;
        } else
-               length_val = zend_hash_num_elements(input->value.ht);
+               length_val = zend_hash_num_elements((*input)->value.ht);
        
        /* Initialize returned array */
        array_init(return_value);
        
        /* Get number of entries in the input hash */
-       num_in = zend_hash_num_elements(input->value.ht);
+       num_in = zend_hash_num_elements((*input)->value.ht);
        
        /* Clamp the offset.. */
        if (offset_val > num_in)
@@ -2852,20 +2852,20 @@ PHP_FUNCTION(array_slice)
        
        /* Start at the beginning and go until we hit offset */
        pos = 0;
-       zend_hash_internal_pointer_reset(input->value.ht);
+       zend_hash_internal_pointer_reset((*input)->value.ht);
        while(pos < offset_val &&
-                 zend_hash_get_current_data(input->value.ht, (void **)&entry) == SUCCESS) {
+                 zend_hash_get_current_data((*input)->value.ht, (void **)&entry) == SUCCESS) {
                pos++;
-               zend_hash_move_forward(input->value.ht);
+               zend_hash_move_forward((*input)->value.ht);
        }
        
        /* Copy elements from input array to the one that's returned */
        while(pos < offset_val+length_val &&
-                 zend_hash_get_current_data(input->value.ht, (void **)&entry) == SUCCESS) {
+                 zend_hash_get_current_data((*input)->value.ht, (void **)&entry) == SUCCESS) {
                
                (*entry)->refcount++;
 
-               switch (zend_hash_get_current_key(input->value.ht, &string_key, &num_key)) {
+               switch (zend_hash_get_current_key((*input)->value.ht, &string_key, &num_key)) {
                        case HASH_KEY_IS_STRING:
                                zend_hash_update(return_value->value.ht, string_key, strlen(string_key)+1,
                                                                 entry, sizeof(zval *), NULL);
@@ -2878,7 +2878,7 @@ PHP_FUNCTION(array_slice)
                                break;
                }
                pos++;
-               zend_hash_move_forward(input->value.ht);
+               zend_hash_move_forward((*input)->value.ht);
        }
 }
 /* }}} */
@@ -2888,7 +2888,7 @@ PHP_FUNCTION(array_slice)
    Merges elements from passed arrays into one array */
 PHP_FUNCTION(array_merge)
 {
-       zval       **args = NULL,
+       zval      ***args = NULL,
                           **entry;
        HashTable       *hash;
        int                      argc,
@@ -2903,8 +2903,8 @@ PHP_FUNCTION(array_merge)
        }
        
        /* Allocate arguments array and get the arguments, checking for errors. */
-       args = (zval **)emalloc(argc * sizeof(zval *));
-       if (getParametersArray(ht, argc, args) == FAILURE) {
+       args = (zval ***)emalloc(argc * sizeof(zval **));
+       if (getParametersArrayEx(argc, args) == FAILURE) {
                efree(args);
                WRONG_PARAM_COUNT;
        }
@@ -2912,11 +2912,11 @@ PHP_FUNCTION(array_merge)
        array_init(return_value);
        
        for (i=0; i<argc; i++) {
-               if (args[i]->type != IS_ARRAY) {
+               if ((*args[i])->type != IS_ARRAY) {
                        zend_error(E_WARNING, "Skipping argument #%d to array_merge(), since it's not an array", i+1);
                        continue;
                }
-               hash = args[i]->value.ht;
+               hash = (*args[i])->value.ht;
                
                zend_hash_internal_pointer_reset(hash);
                while(zend_hash_get_current_data(hash, (void **)&entry) == SUCCESS) {
@@ -2949,8 +2949,8 @@ PHP_FUNCTION(array_merge)
    for the specified search_value */
 PHP_FUNCTION(array_keys)
 {
-       zval            *input,                 /* Input array */
-                               *search_value,  /* Value to search for */
+       zval       **input,                     /* Input array */
+                          **search_value,      /* Value to search for */
                           **entry,                     /* An entry in the input array */
                                 res,                   /* Result of comparison */
                                *new_val;               /* New value */
@@ -2962,11 +2962,11 @@ PHP_FUNCTION(array_keys)
        
        /* Get arguments and do error-checking */
        if (ARG_COUNT(ht) < 1 || ARG_COUNT(ht) > 2 ||
-               getParameters(ht, ARG_COUNT(ht), &input, &search_value) == FAILURE) {
+               getParametersEx(ARG_COUNT(ht), &input, &search_value) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
        
-       if (input->type != IS_ARRAY) {
+       if ((*input)->type != IS_ARRAY) {
                zend_error(E_WARNING, "First argument to array_keys() should be an array");
                return;
        }
@@ -2976,18 +2976,17 @@ PHP_FUNCTION(array_keys)
        add_key = 1;
        
        /* Go through input array and add keys to the return array */
-       zend_hash_internal_pointer_reset(input->value.ht);
-       while(zend_hash_get_current_data(input->value.ht, (void **)&entry) == SUCCESS) {
+       zend_hash_internal_pointer_reset((*input)->value.ht);
+       while(zend_hash_get_current_data((*input)->value.ht, (void **)&entry) == SUCCESS) {
                if (search_value != NULL) {
-               is_equal_function(&res, search_value, *entry);
+               is_equal_function(&res, *search_value, *entry);
                        add_key = zval_is_true(&res);
                }
        
                if (add_key) {  
-                       new_val = (zval *)emalloc(sizeof(zval));
-                       INIT_PZVAL(new_val);
+                       MAKE_STD_ZVAL(new_val);
 
-                       switch (zend_hash_get_current_key(input->value.ht, &string_key, &num_key)) {
+                       switch (zend_hash_get_current_key((*input)->value.ht, &string_key, &num_key)) {
                                case HASH_KEY_IS_STRING:
                                        new_val->type = IS_STRING;
                                        new_val->value.str.val = string_key;
@@ -3005,7 +3004,7 @@ PHP_FUNCTION(array_keys)
                        }
                }
 
-               zend_hash_move_forward(input->value.ht);
+               zend_hash_move_forward((*input)->value.ht);
        }
 }
 /* }}} */
@@ -3015,15 +3014,15 @@ PHP_FUNCTION(array_keys)
    Return just the values from the input array */
 PHP_FUNCTION(array_values)
 {
-       zval            *input,         /* Input array */
+       zval       **input,             /* Input array */
                           **entry;             /* An entry in the input array */
        
        /* Get arguments and do error-checking */
-       if (ARG_COUNT(ht) != 1 || getParameters(ht, ARG_COUNT(ht), &input) == FAILURE) {
+       if (ARG_COUNT(ht) != 1 || getParametersEx(ARG_COUNT(ht), &input) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
        
-       if (input->type != IS_ARRAY) {
+       if ((*input)->type != IS_ARRAY) {
                zend_error(E_WARNING, "Argument to array_values() should be an array");
                return;
        }
@@ -3032,14 +3031,14 @@ PHP_FUNCTION(array_values)
        array_init(return_value);
 
        /* Go through input array and add values to the return array */ 
-       zend_hash_internal_pointer_reset(input->value.ht);
-       while(zend_hash_get_current_data(input->value.ht, (void **)&entry) == SUCCESS) {
+       zend_hash_internal_pointer_reset((*input)->value.ht);
+       while(zend_hash_get_current_data((*input)->value.ht, (void **)&entry) == SUCCESS) {
                
                (*entry)->refcount++;
                zend_hash_next_index_insert(return_value->value.ht, entry,
                                                                                        sizeof(zval *), NULL);
 
-               zend_hash_move_forward(input->value.ht);
+               zend_hash_move_forward((*input)->value.ht);
        }
 }
 /* }}} */