andrei Mon Jul 17 21:20:02 2006 UTC Modified files: /php-src unicode-progress.txt /php-src/ext/standard array.c Log: Upgrade uasort() and uksort() to use params API with FCI cache and mark them with U. http://cvs.php.net/viewvc.cgi/php-src/unicode-progress.txt?r1=1.24&r2=1.25&diff_format=u Index: php-src/unicode-progress.txt diff -u php-src/unicode-progress.txt:1.24 php-src/unicode-progress.txt:1.25 --- php-src/unicode-progress.txt:1.24 Fri Jul 14 22:41:22 2006 +++ php-src/unicode-progress.txt Mon Jul 17 21:20:02 2006 @@ -47,9 +47,6 @@ Params API Either port strnatcmp() to support Unicode or maybe use ICU's numeric collation - usort(), uasort(), uksort() - Params API, callback name normalization, FCI cache - Completed ========= @@ -90,6 +87,7 @@ sort(), rsort() asort(), arsort() ksort(), krsort() + usort(), uasort(), uksort() string.c http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.366&r2=1.367&diff_format=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.366 php-src/ext/standard/array.c:1.367 --- php-src/ext/standard/array.c:1.366 Mon Jul 17 20:52:12 2006 +++ php-src/ext/standard/array.c Mon Jul 17 21:20:02 2006 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c,v 1.366 2006/07/17 20:52:12 andrei Exp $ */ +/* $Id: array.c,v 1.367 2006/07/17 21:20:02 andrei Exp $ */ #include "php.h" #include "php_ini.h" @@ -658,35 +658,29 @@ } /* }}} */ -/* {{{ proto bool uasort(array array_arg, string cmp_function) +/* {{{ proto bool uasort(array array_arg, mixed comparator) U Sort an array with a user-defined comparison function and maintain index association */ PHP_FUNCTION(uasort) { - zval **array; + zval *array; HashTable *target_hash; PHP_ARRAY_CMP_FUNC_VARS; PHP_ARRAY_CMP_FUNC_BACKUP(); - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &array, &BG(user_compare_func_name)) == FAILURE) { - PHP_ARRAY_CMP_FUNC_RESTORE(); - WRONG_PARAM_COUNT; - } - target_hash = HASH_OF(*array); - if (!target_hash) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The argument should be an array"); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "af", &array, + &BG(user_compare_fci), &BG(user_compare_fci_cache)) == FAILURE) { PHP_ARRAY_CMP_FUNC_RESTORE(); - RETURN_FALSE; + return; } - PHP_ARRAY_CMP_FUNC_CHECK(BG(user_compare_func_name)) + target_hash = HASH_OF(array); if (zend_hash_sort(target_hash, zend_qsort, array_user_compare, 0 TSRMLS_CC) == FAILURE) { PHP_ARRAY_CMP_FUNC_RESTORE(); RETURN_FALSE; } PHP_ARRAY_CMP_FUNC_RESTORE(); - RETURN_TRUE; } /* }}} */ @@ -696,12 +690,13 @@ Bucket *f; Bucket *s; zval key1, key2; - zval *args[2]; - zval retval; - int status; + zval *key1_ptr = &key1, *key2_ptr = &key2; + zval **args[2]; + zval *retval_ptr = NULL; + long result; - args[0] = &key1; - args[1] = &key2; + args[0] = &key1_ptr; + args[1] = &key2_ptr; INIT_PZVAL(&key1); INIT_PZVAL(&key2); @@ -733,43 +728,43 @@ Z_TYPE(key2) = s->key.type; } - status = call_user_function(EG(function_table), NULL, *BG(user_compare_func_name), &retval, 2, args TSRMLS_CC); + BG(user_compare_fci).param_count = 2; + BG(user_compare_fci).params = args; + BG(user_compare_fci).retval_ptr_ptr = &retval_ptr; + BG(user_compare_fci).no_separation = 0; + if (zend_call_function(&BG(user_compare_fci), &BG(user_compare_fci_cache) TSRMLS_CC)== SUCCESS + && retval_ptr) { + + convert_to_long_ex(&retval_ptr); + result = Z_LVAL_P(retval_ptr); + zval_ptr_dtor(&retval_ptr); + } else { + result = 0; + } zval_dtor(&key1); zval_dtor(&key2); - if (status == SUCCESS) { - convert_to_long(&retval); - return Z_LVAL(retval); - } else { - return 0; - } + return result; } -/* {{{ proto bool uksort(array array_arg, string cmp_function) +/* {{{ proto bool uksort(array array_arg, mixed comparator) U Sort an array by keys using a user-defined comparison function */ PHP_FUNCTION(uksort) { - zval **array; + zval *array; HashTable *target_hash; PHP_ARRAY_CMP_FUNC_VARS; - PHP_ARRAY_CMP_FUNC_BACKUP(); - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &array, &BG(user_compare_func_name)) == FAILURE) { - PHP_ARRAY_CMP_FUNC_RESTORE(); - WRONG_PARAM_COUNT; - } - target_hash = HASH_OF(*array); - if (!target_hash) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The argument should be an array"); + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "af", &array, + &BG(user_compare_fci), &BG(user_compare_fci_cache)) == FAILURE) { PHP_ARRAY_CMP_FUNC_RESTORE(); - - RETURN_FALSE; + return; } - PHP_ARRAY_CMP_FUNC_CHECK(BG(user_compare_func_name)) + target_hash = HASH_OF(array); if (zend_hash_sort(target_hash, zend_qsort, array_user_key_compare, 0 TSRMLS_CC) == FAILURE) { PHP_ARRAY_CMP_FUNC_RESTORE();
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php