andrei Mon Jul 17 20:52:12 2006 UTC Modified files: /ZendEngine2 zend_API.c zend_API.h zend_execute_API.c /php-src/ext/standard array.c basic_functions.c basic_functions.h Log: - Upgrade usort() to support Unicode (including valid Unicode callbacks). - Make usort() use 'f' specifier for function call info/cache.
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.378&r2=1.379&diff_format=u Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.378 ZendEngine2/zend_API.c:1.379 --- ZendEngine2/zend_API.c:1.378 Thu Jul 13 21:27:48 2006 +++ ZendEngine2/zend_API.c Mon Jul 17 20:52:12 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.c,v 1.378 2006/07/13 21:27:48 andrei Exp $ */ +/* $Id: zend_API.c,v 1.379 2006/07/17 20:52:12 andrei Exp $ */ #include "zend.h" #include "zend_execute.h" @@ -763,7 +763,7 @@ fcc->initialized = 0; break; } else { - return "function"; + return "valid callback"; } } http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.h?r1=1.247&r2=1.248&diff_format=u Index: ZendEngine2/zend_API.h diff -u ZendEngine2/zend_API.h:1.247 ZendEngine2/zend_API.h:1.248 --- ZendEngine2/zend_API.h:1.247 Tue Jun 13 13:11:42 2006 +++ ZendEngine2/zend_API.h Mon Jul 17 20:52:12 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_API.h,v 1.247 2006/06/13 13:11:42 dmitry Exp $ */ +/* $Id: zend_API.h,v 1.248 2006/07/17 20:52:12 andrei Exp $ */ #ifndef ZEND_API_H #define ZEND_API_H @@ -655,6 +655,7 @@ } zend_fcall_info_cache; BEGIN_EXTERN_C() +ZEND_API extern zend_fcall_info empty_fcall_info; ZEND_API extern zend_fcall_info_cache empty_fcall_info_cache; /** Build zend_call_info/cache from a zval* http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute_API.c?r1=1.375&r2=1.376&diff_format=u Index: ZendEngine2/zend_execute_API.c diff -u ZendEngine2/zend_execute_API.c:1.375 ZendEngine2/zend_execute_API.c:1.376 --- ZendEngine2/zend_execute_API.c:1.375 Wed Jul 12 07:54:18 2006 +++ ZendEngine2/zend_execute_API.c Mon Jul 17 20:52:12 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute_API.c,v 1.375 2006/07/12 07:54:18 dmitry Exp $ */ +/* $Id: zend_execute_API.c,v 1.376 2006/07/17 20:52:12 andrei Exp $ */ #include <stdio.h> #include <signal.h> @@ -39,6 +39,7 @@ ZEND_API void (*zend_execute_internal)(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC); /* true globals */ +ZEND_API zend_fcall_info empty_fcall_info = { sizeof(zend_fcall_info), NULL, NULL, NULL, 0, NULL, NULL, 0 }; ZEND_API zend_fcall_info_cache empty_fcall_info_cache = { 0, NULL, NULL, NULL }; #ifdef ZEND_WIN32 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.365&r2=1.366&diff_format=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.365 php-src/ext/standard/array.c:1.366 --- php-src/ext/standard/array.c:1.365 Sat Jul 15 12:09:13 2006 +++ php-src/ext/standard/array.c Mon Jul 17 20:52:12 2006 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c,v 1.365 2006/07/15 12:09:13 helly Exp $ */ +/* $Id: array.c,v 1.366 2006/07/17 20:52:12 andrei Exp $ */ #include "php.h" #include "php_ini.h" @@ -571,8 +571,7 @@ Bucket *f; Bucket *s; zval **args[2]; - zval *retval_ptr; - zend_fcall_info fci; + zval *retval_ptr = NULL; f = *((Bucket **) a); s = *((Bucket **) b); @@ -580,17 +579,11 @@ args[0] = (zval **) f->pData; args[1] = (zval **) s->pData; - fci.size = sizeof(fci); - fci.function_table = EG(function_table); - fci.function_name = *BG(user_compare_func_name); - fci.symbol_table = NULL; - fci.object_pp = NULL; - fci.retval_ptr_ptr = &retval_ptr; - fci.param_count = 2; - fci.params = args; - fci.no_separation = 0; - - if (zend_call_function(&fci, &BG(user_compare_fci_cache) TSRMLS_CC)== SUCCESS + 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) { long retval; @@ -607,6 +600,7 @@ #define PHP_ARRAY_CMP_FUNC_CHECK(func_name) \ if (!zend_is_callable(*func_name, 0, NULL)) { \ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid comparison function."); \ + BG(user_compare_fci) = old_user_compare_fci; \ BG(user_compare_fci_cache) = old_user_compare_fci_cache; \ BG(user_compare_func_name) = old_compare_func; \ RETURN_FALSE; \ @@ -622,41 +616,38 @@ #define PHP_ARRAY_CMP_FUNC_VARS \ zval **old_compare_func; \ + zend_fcall_info old_user_compare_fci; \ zend_fcall_info_cache old_user_compare_fci_cache \ #define PHP_ARRAY_CMP_FUNC_BACKUP() \ old_compare_func = BG(user_compare_func_name); \ + old_user_compare_fci = BG(user_compare_fci); \ old_user_compare_fci_cache = BG(user_compare_fci_cache); \ BG(user_compare_fci_cache) = empty_fcall_info_cache; \ #define PHP_ARRAY_CMP_FUNC_RESTORE() \ + BG(user_compare_fci) = old_user_compare_fci; \ BG(user_compare_fci_cache) = old_user_compare_fci_cache; \ BG(user_compare_func_name) = old_compare_func; \ -/* {{{ proto bool usort(array array_arg, string cmp_function) +/* {{{ proto bool usort(array array_arg, mixed comparator) U Sort an array by values using a user-defined comparison function */ PHP_FUNCTION(usort) { - 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) { + 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(); - 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"); - 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, 1 TSRMLS_CC) == FAILURE) { PHP_ARRAY_CMP_FUNC_RESTORE(); http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.791&r2=1.792&diff_format=u Index: php-src/ext/standard/basic_functions.c diff -u php-src/ext/standard/basic_functions.c:1.791 php-src/ext/standard/basic_functions.c:1.792 --- php-src/ext/standard/basic_functions.c:1.791 Mon Jul 17 19:32:10 2006 +++ php-src/ext/standard/basic_functions.c Mon Jul 17 20:52:12 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.791 2006/07/17 19:32:10 andrei Exp $ */ +/* $Id: basic_functions.c,v 1.792 2006/07/17 20:52:12 andrei Exp $ */ #include "php.h" #include "php_streams.h" @@ -3858,6 +3858,7 @@ BG(left) = -1; BG(user_tick_functions) = NULL; BG(user_filter_map) = NULL; + BG(user_compare_fci) = empty_fcall_info; BG(user_compare_fci_cache) = empty_fcall_info_cache; zend_hash_init(&BG(sm_protected_env_vars), 5, NULL, NULL, 1); BG(sm_allowed_env_vars) = NULL; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.h?r1=1.146&r2=1.147&diff_format=u Index: php-src/ext/standard/basic_functions.h diff -u php-src/ext/standard/basic_functions.h:1.146 php-src/ext/standard/basic_functions.h:1.147 --- php-src/ext/standard/basic_functions.h:1.146 Mon Jun 26 20:28:30 2006 +++ php-src/ext/standard/basic_functions.h Mon Jul 17 20:52:12 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.h,v 1.146 2006/06/26 20:28:30 bjori Exp $ */ +/* $Id: basic_functions.h,v 1.147 2006/07/17 20:52:12 andrei Exp $ */ #ifndef BASIC_FUNCTIONS_H #define BASIC_FUNCTIONS_H @@ -165,6 +165,7 @@ char str_ebuf[40]; zval **array_walk_func_name; zval **user_compare_func_name; + zend_fcall_info user_compare_fci; zend_fcall_info_cache user_compare_fci_cache; zend_llist *user_tick_functions;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php