]> granicus.if.org Git - php/commitdiff
Update array_sum() and array_product() (U).
authorAndrei Zmievski <andrei@php.net>
Thu, 13 Jul 2006 22:26:42 +0000 (22:26 +0000)
committerAndrei Zmievski <andrei@php.net>
Thu, 13 Jul 2006 22:26:42 +0000 (22:26 +0000)
ext/standard/array.c
unicode-progress.txt

index 8fce763e7b401e7ff411f7631e12a56767b0a55f..dc6f619ad798836b93682d0f4f95ec89b3780976 100644 (file)
@@ -4142,31 +4142,25 @@ PHP_FUNCTION(array_rand)
 }
 /* }}} */
 
-/* {{{ proto mixed array_sum(array input)
+/* {{{ proto mixed array_sum(array input) U
    Returns the sum of the array entries */
 PHP_FUNCTION(array_sum)
 {
-       zval **input,
+       zval *input,
                 **entry,
                 entry_n;
-       int argc = ZEND_NUM_ARGS();
        HashPosition pos;
        double dval;
        
-       if (argc != 1 || zend_get_parameters_ex(argc, &input) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-
-       if (Z_TYPE_PP(input) != IS_ARRAY) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "The argument should be an array");
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &input) == FAILURE) {
                return;
        }
 
        ZVAL_LONG(return_value, 0);
 
-       for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(input), &pos);
-                zend_hash_get_current_data_ex(Z_ARRVAL_PP(input), (void **)&entry, &pos) == SUCCESS;
-                zend_hash_move_forward_ex(Z_ARRVAL_PP(input), &pos)) {
+       for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(input), &pos);
+                zend_hash_get_current_data_ex(Z_ARRVAL_P(input), (void **)&entry, &pos) == SUCCESS;
+                zend_hash_move_forward_ex(Z_ARRVAL_P(input), &pos)) {
                
                if (Z_TYPE_PP(entry) == IS_ARRAY || Z_TYPE_PP(entry) == IS_OBJECT)
                        continue;
@@ -4189,34 +4183,28 @@ PHP_FUNCTION(array_sum)
 }
 /* }}} */
 
-/* {{{ proto mixed array_product(array input)
+/* {{{ proto mixed array_product(array input) U
    Returns the product of the array entries */
 PHP_FUNCTION(array_product)
 {
-       zval **input,
+       zval *input,
                 **entry,
                 entry_n;
-       int argc = ZEND_NUM_ARGS();
        HashPosition pos;
        double dval;
        
-       if (argc != 1 || zend_get_parameters_ex(argc, &input) == FAILURE) {
-               WRONG_PARAM_COUNT;
-       }
-
-       if (Z_TYPE_PP(input) != IS_ARRAY) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "The argument should be an array");
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &input) == FAILURE) {
                return;
        }
 
-       if (!zend_hash_num_elements(Z_ARRVAL_PP(input))) {
+       if (!zend_hash_num_elements(Z_ARRVAL_P(input))) {
                RETURN_LONG(0);
        }
        ZVAL_LONG(return_value, 1);
 
-       for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(input), &pos);
-                zend_hash_get_current_data_ex(Z_ARRVAL_PP(input), (void **)&entry, &pos) == SUCCESS;
-                zend_hash_move_forward_ex(Z_ARRVAL_PP(input), &pos)) {
+       for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(input), &pos);
+                zend_hash_get_current_data_ex(Z_ARRVAL_P(input), (void **)&entry, &pos) == SUCCESS;
+                zend_hash_move_forward_ex(Z_ARRVAL_P(input), &pos)) {
                
                if (Z_TYPE_PP(entry) == IS_ARRAY || Z_TYPE_PP(entry) == IS_OBJECT)
                        continue;
index b56cb16ffe4debb9c95fc61dd18d81776f2a7ddf..ee5bd8ff695efd452cc28fe817b78330cb4c2426 100644 (file)
@@ -55,9 +55,6 @@ ext/standard
     array_pad()
         Params API, test
 
-    array_product()
-        Params API, test
-
     array_push(), array_pop(), array_shift(), array_unshift()
         Params API, test
 
@@ -79,9 +76,6 @@ ext/standard
     array_slice()
         Params API, test
 
-    array_sum()
-        Params API, test
-
     array_unique()
         Params API, test
 
@@ -105,7 +99,7 @@ ext/standard
         Either port strnatcmp() to support Unicode or maybe use ICU's numeric collation
 
     usort(), uasort(), uksort()
-        function name normalization, FCI cache
+        Params API, callback name normalization, FCI cache
 
 
   Completed
@@ -116,6 +110,8 @@ ext/standard
     array_chunk() 
     array_merge()
     array_merge_recursive()
+    array_product()
+    array_sum()
     compact()
     count()
     min()