[PHP-CVS] cvs: php-src /ext/standard array.c basic_functions.c basic_functions.h
tony2001Wed Dec 6 17:42:47 2006 UTC Modified files: /php-src/ext/standard array.c basic_functions.c basic_functions.h Log: fix import_request_variables() http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.396r2=1.397diff_format=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.396 php-src/ext/standard/array.c:1.397 --- php-src/ext/standard/array.c:1.396 Tue Dec 5 23:17:06 2006 +++ php-src/ext/standard/array.cWed Dec 6 17:42:47 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: array.c,v 1.396 2006/12/05 23:17:06 andrei Exp $ */ +/* $Id: array.c,v 1.397 2006/12/06 17:42:47 tony2001 Exp $ */ #include php.h #include php_ini.h @@ -1280,16 +1280,21 @@ } PHPAPI int php_prefix_varname(zval *result, zval *prefix, zstr var_name, - int var_name_len, int var_name_type TSRMLS_DC) + int var_name_len, int var_name_type, zend_bool add_underscore TSRMLS_DC) { - Z_UNILEN_P(result) = Z_UNILEN_P(prefix) + 1 + var_name_len; + Z_UNILEN_P(result) = Z_UNILEN_P(prefix) + (add_underscore ? 1 : 0) + var_name_len; + if (UG(unicode)) { Z_TYPE_P(result) = IS_UNICODE; Z_USTRVAL_P(result) = eumalloc(Z_USTRLEN_P(result)+1); u_memcpy(Z_USTRVAL_P(result), Z_USTRVAL_P(prefix), Z_USTRLEN_P(prefix)); - Z_USTRVAL_P(result)[Z_USTRLEN_P(prefix)] = (UChar) 0x5f /*'_'*/; + + if (add_underscore) { + Z_USTRVAL_P(result)[Z_USTRLEN_P(prefix)] = (UChar) 0x5f /*'_'*/; + } + if (var_name_type == IS_UNICODE) { - u_memcpy(Z_USTRVAL_P(result)+Z_USTRLEN_P(prefix)+1, var_name.u, var_name_len+1); + u_memcpy(Z_USTRVAL_P(result)+Z_USTRLEN_P(prefix) + (add_underscore ? 1 : 0), var_name.u, var_name_len+1); } else { UChar *buf; int buf_len; @@ -1304,19 +1309,23 @@ return FAILURE; } if (buf_len var_name_len) { - Z_USTRLEN_P(result) = Z_USTRLEN_P(prefix) + 1 + buf_len; - Z_USTRVAL_P(result) = eurealloc(Z_USTRVAL_P(result), Z_USTRLEN_P(result)+1); + Z_USTRLEN_P(result) = Z_USTRLEN_P(prefix) + (add_underscore ? 1 : 0) + buf_len; + Z_USTRVAL_P(result) = eurealloc(Z_USTRVAL_P(result), Z_USTRLEN_P(result) + 1); } - u_memcpy(Z_USTRVAL_P(result)+Z_USTRLEN_P(prefix)+1, buf, buf_len+1); + u_memcpy(Z_USTRVAL_P(result)+Z_USTRLEN_P(prefix) + (add_underscore ? 1 : 0), buf, buf_len+1); efree(buf); } } else { Z_TYPE_P(result) = IS_STRING; Z_STRVAL_P(result) = emalloc(Z_STRLEN_P(result)+1); memcpy(Z_STRVAL_P(result), Z_STRVAL_P(prefix), Z_STRLEN_P(prefix)); - Z_STRVAL_P(result)[Z_STRLEN_P(prefix)] = '_'; + + if (add_underscore) { + Z_STRVAL_P(result)[Z_STRLEN_P(prefix)] = '_'; + } + if (var_name_type == IS_STRING) { - memcpy(Z_STRVAL_P(result)+Z_STRLEN_P(prefix)+1, var_name.s, var_name_len+1); + memcpy(Z_STRVAL_P(result)+Z_STRLEN_P(prefix) + (add_underscore ? 1 : 0), var_name.s, var_name_len+1); } else { char *buf; int buf_len; @@ -1331,10 +1340,10 @@ return FAILURE; } if (buf_len var_name_len) { - Z_STRLEN_P(result) = Z_STRLEN_P(prefix) + 1 + buf_len; - Z_STRVAL_P(result) = erealloc(Z_STRVAL_P(result), Z_STRLEN_P(result)+1); + Z_STRLEN_P(result) = Z_STRLEN_P(prefix) + (add_underscore ? 1 : 0) + buf_len; + Z_STRVAL_P(result) = erealloc(Z_STRVAL_P(result), Z_STRLEN_P(result) + 1); } - memcpy(Z_STRVAL_P(result)+Z_STRLEN_P(prefix)+1, buf, buf_len+1); + memcpy(Z_STRVAL_P(result)+Z_STRLEN_P(prefix) + (add_underscore ? 1 : 0), buf, buf_len+1); efree(buf); } } @@ -1408,7 +1417,7 @@ ZVAL_LONG(num, num_key); convert_to_text(num); - php_prefix_varname(final_name, prefix, Z_UNIVAL(num), Z_UNILEN(num), Z_TYPE(num) TSRMLS_CC); +
[PHP-CVS] cvs: php-src /ext/standard array.c basic_functions.c basic_functions.h
andrei Fri Jul 21 23:29:25 2006 UTC Modified files: /php-src/ext/standard array.c basic_functions.c basic_functions.h Log: Remove references to BG(user_compare_fnnc_name). # Less bickering, more coding! http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.373r2=1.374diff_format=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.373 php-src/ext/standard/array.c:1.374 --- php-src/ext/standard/array.c:1.373 Fri Jul 21 23:25:08 2006 +++ php-src/ext/standard/array.cFri Jul 21 23:29:25 2006 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: array.c,v 1.373 2006/07/21 23:25:08 andrei Exp $ */ +/* $Id: array.c,v 1.374 2006/07/21 23:29:25 andrei Exp $ */ #include php.h #include php_ini.h @@ -602,7 +602,6 @@ 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; \ } \ @@ -615,12 +614,10 @@ */ #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; \ @@ -628,7 +625,6 @@ #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, mixed comparator) U @@ -3106,11 +3102,6 @@ return_value-value.ht = ht; } - if ((behavior INTERSECT_NORMAL) data_compare_type == INTERSECT_COMP_DATA_USER) { - /* array_uintersect() */ - BG(user_compare_func_name) = args[arr_argc]; - } - /* go through the lists and look for common values */ while (*ptrs[0]) { if ((behavior INTERSECT_ASSOC) /* triggered also when INTERSECT_KEY */ http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.794r2=1.795diff_format=u Index: php-src/ext/standard/basic_functions.c diff -u php-src/ext/standard/basic_functions.c:1.794 php-src/ext/standard/basic_functions.c:1.795 --- php-src/ext/standard/basic_functions.c:1.794Thu Jul 20 23:21:32 2006 +++ php-src/ext/standard/basic_functions.c Fri Jul 21 23:29:25 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: basic_functions.c,v 1.794 2006/07/20 23:21:32 andrei Exp $ */ +/* $Id: basic_functions.c,v 1.795 2006/07/21 23:29:25 andrei Exp $ */ #include php.h #include php_streams.h @@ -4080,7 +4080,6 @@ BG(strtok_string) = NULL; BG(strtok_zval) = NULL; BG(locale_string) = NULL; - BG(user_compare_func_name) = NULL; BG(array_walk_fci) = empty_fcall_info; BG(array_walk_fci_cache) = empty_fcall_info_cache; BG(user_compare_fci) = empty_fcall_info; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.h?r1=1.149r2=1.150diff_format=u Index: php-src/ext/standard/basic_functions.h diff -u php-src/ext/standard/basic_functions.h:1.149 php-src/ext/standard/basic_functions.h:1.150 --- php-src/ext/standard/basic_functions.h:1.149Thu Jul 20 23:21:32 2006 +++ php-src/ext/standard/basic_functions.h Fri Jul 21 23:29:25 2006 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: basic_functions.h,v 1.149 2006/07/20 23:21:32 andrei Exp $ */ +/* $Id: basic_functions.h,v 1.150 2006/07/21 23:29:25 andrei Exp $ */ #ifndef BASIC_FUNCTIONS_H #define BASIC_FUNCTIONS_H @@ -166,7 +166,6 @@ char str_ebuf[40]; zend_fcall_info array_walk_fci; zend_fcall_info_cache array_walk_fci_cache; - 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
[PHP-CVS] cvs: php-src /ext/standard array.c basic_functions.c basic_functions.h ZendEngine2 zend_API.c zend_API.h zend_execute_API.c
andrei Mon Jul 17 20:52:12 2006 UTC Modified files: /ZendEngine2zend_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.378r2=1.379diff_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.378Thu 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.247r2=1.248diff_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.247Tue 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.375r2=1.376diff_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.375Wed 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.365r2=1.366diff_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.cMon 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
Re: [PHP-CVS] cvs: php-src /ext/standard array.c basic_functions.c basic_functions.h
Close the bug? Add a NEWS entry ? :) --Jani On Wed, 15 Jun 2005, Andrei Zmievski wrote: andrei Wed Jun 15 16:51:37 2005 EDT Modified files: /php-src/ext/standardbasic_functions.c basic_functions.h array.c Log: Fix FCI cache for array_walk and user array compare functions. Bug #33286. (Patch from [EMAIL PROTECTED]) -- Donate @ http://pecl.php.net/wishlist.php/sniper -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/standard array.c basic_functions.c basic_functions.h
andrei Wed Jun 15 16:51:37 2005 EDT Modified files: /php-src/ext/standard basic_functions.c basic_functions.h array.c Log: Fix FCI cache for array_walk and user array compare functions. Bug #33286. (Patch from [EMAIL PROTECTED]) http://cvs.php.net/diff.php/php-src/ext/standard/basic_functions.c?r1=1.719r2=1.720ty=u Index: php-src/ext/standard/basic_functions.c diff -u php-src/ext/standard/basic_functions.c:1.719 php-src/ext/standard/basic_functions.c:1.720 --- php-src/ext/standard/basic_functions.c:1.719Tue Jun 14 17:32:27 2005 +++ php-src/ext/standard/basic_functions.c Wed Jun 15 16:51:31 2005 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: basic_functions.c,v 1.719 2005/06/14 21:32:27 derick Exp $ */ +/* $Id: basic_functions.c,v 1.720 2005/06/15 20:51:31 andrei Exp $ */ #include php.h #include php_streams.h @@ -955,7 +955,6 @@ BG(user_tick_functions) = NULL; BG(user_filter_map) = NULL; BG(user_compare_fci_cache) = empty_fcall_info_cache; - /*BG(array_walk_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/diff.php/php-src/ext/standard/basic_functions.h?r1=1.137r2=1.138ty=u Index: php-src/ext/standard/basic_functions.h diff -u php-src/ext/standard/basic_functions.h:1.137 php-src/ext/standard/basic_functions.h:1.138 --- php-src/ext/standard/basic_functions.h:1.137Sun Apr 10 12:25:11 2005 +++ php-src/ext/standard/basic_functions.h Wed Jun 15 16:51:33 2005 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: basic_functions.h,v 1.137 2005/04/10 16:25:11 iliaa Exp $ */ +/* $Id: basic_functions.h,v 1.138 2005/06/15 20:51:33 andrei Exp $ */ #ifndef BASIC_FUNCTIONS_H #define BASIC_FUNCTIONS_H @@ -160,7 +160,6 @@ ulong strtok_len; char str_ebuf[40]; zval **array_walk_func_name; - zend_fcall_info_cache array_walk_fci_cache; zval **user_compare_func_name; zend_fcall_info_cache user_compare_fci_cache; zend_llist *user_tick_functions; http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.300r2=1.301ty=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.300 php-src/ext/standard/array.c:1.301 --- php-src/ext/standard/array.c:1.300 Wed Jun 8 15:54:24 2005 +++ php-src/ext/standard/array.cWed Jun 15 16:51:33 2005 @@ -21,7 +21,7 @@ +--+ */ -/* $Id: array.c,v 1.300 2005/06/08 19:54:24 dmitry Exp $ */ +/* $Id: array.c,v 1.301 2005/06/15 20:51:33 andrei Exp $ */ #include php.h #include php_ini.h @@ -610,43 +610,66 @@ } } -/* check is comparison function is valid */ +/* check if comparison function is valid */ #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_cache) = old_user_compare_fci_cache; \ BG(user_compare_func_name) = old_compare_func; \ RETURN_FALSE; \ } \ +/* clear FCI cache otherwise : for example the same or other array with + (partly) the same key values has been sorted with uasort() or + other sorting function the comparison is cached, however the the name + of the function for comparison is not respected. see bug #28739 AND #33295 + + following defines will assist in backup / restore values. +*/ + +#define PHP_ARRAY_CMP_FUNC_VARS \ +zval **old_compare_func; \ +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_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_cache) = old_user_compare_fci_cache; \ +BG(user_compare_func_name) = old_compare_func; \ + + /* {{{ proto bool usort(array array_arg, string cmp_function) Sort an array by values using a user-defined comparison function */ PHP_FUNCTION(usort) { zval **array; - zval **old_compare_func; HashTable *target_hash; +PHP_ARRAY_CMP_FUNC_VARS; + + PHP_ARRAY_CMP_FUNC_BACKUP(); - old_compare_func = BG(user_compare_func_name); - BG(user_compare_fci_cache) = empty_fcall_info_cache; if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, array, BG(user_compare_func_name)) == FAILURE) { - BG(user_compare_func_name) = old_compare_func; +PHP_ARRAY_CMP_FUNC_RESTORE(); WRONG_PARAM_COUNT; } target_hash =
Re: [PHP-CVS] cvs: php-src /ext/standard array.c basic_functions.c basic_functions.h
On Wed, 15 Jun 2005 20:51:37 - Andrei Zmievski [EMAIL PROTECTED] wrote: andreiWed Jun 15 16:51:37 2005 EDT Modified files: /php-src/ext/standard basic_functions.c basic_functions.h array.c Log: Fix FCI cache for array_walk and user array compare functions. Bug #33286. (Patch from [EMAIL PROTECTED]) Andrei, could you plz also fix whitespaces/tabs there ? - zval **old_compare_func; +PHP_ARRAY_CMP_FUNC_VARS; + - BG(user_compare_func_name) = old_compare_func; +PHP_ARRAY_CMP_FUNC_RESTORE(); + etc. Thanks. -- Wbr, Antony Dovgal aka tony2001 -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php