Re: cvs: php-src /ext/standard array.c ZendEngine2 zend_operators.c zend_operators.h
| From: | Marcus Boerger | Date: | Sat, 11 Sep 2004 14:48:04 +0000 |
| Subject: | Re: cvs: php-src /ext/standard array.c ZendEngine2 zend_operators.c zend_operators.h | ||
| References: | 1 | Groups: | php.cvs |
| Request: | Send a blank email to php-cvs+get-28645@lists.php.net to get a copy of this message | ||
Hello Derick,
why not define the const only if it is usefull (strcoll available)?
regards
marcus
Saturday, September 11, 2004, 4:22:36 PM, you wrote:
> derick Sat Sep 11 10:22:36 2004 EDT
> Modified files:
> /ZendEngine2 zend_operators.c zend_operators.h
> /php-src/ext/standard array.c
> Log:
> - MFB: Added the sorting flag SORT_LOCALE_STRING to the sort() functions which
> makes them sort based on the current locale. (Derick)
>
> http://cvs.php.net/diff.php/ZendEngine2/zend_operators.c?r1=1.195&r2=1.196&ty=u
> Index: ZendEngine2/zend_operators.c
> diff -u ZendEngine2/zend_operators.c:1.195 ZendEngine2/zend_operators.c:1.196
> --- ZendEngine2/zend_operators.c:1.195 Fri Sep 10 20:23:20 2004
> +++ ZendEngine2/zend_operators.c Sat Sep 11 10:22:35 2004
> @@ -17,7 +17,7 @@
>
> +----------------------------------------------------------------------+
> */
> -/* $Id: zend_operators.c,v 1.195 2004/09/11 00:23:20 andi Exp $ */
> +/* $Id: zend_operators.c,v 1.196 2004/09/11 14:22:35 derick Exp $ */
> #include <ctype.h>
> @@ -1221,6 +1221,35 @@
> }
> return SUCCESS;
> }
> +
> +#if HAVE_STRCOLL
> +ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
> +{
> + zval op1_copy, op2_copy;
> + int use_copy1, use_copy2;
> +
> + zend_make_printable_zval(op1, &op1_copy, &use_copy1);
> + zend_make_printable_zval(op2, &op2_copy, &use_copy2);
> +
> + if (use_copy1) {
> + op1 = &op1_copy;
> + }
> + if (use_copy2) {
> + op2 = &op2_copy;
> + }
> +
> + result->value.lval = strcoll(op1->value.str.val, op2->value.str.val);
> + result->type = IS_LONG;
> +
> + if (use_copy1) {
> + zval_dtor(op1);
> + }
> + if (use_copy2) {
> + zval_dtor(op2);
> + }
> + return SUCCESS;
> +}
> +#endif
> ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
> {
>
> http://cvs.php.net/diff.php/ZendEngine2/zend_operators.h?r1=1.89&r2=1.90&ty=u
> Index: ZendEngine2/zend_operators.h
> diff -u ZendEngine2/zend_operators.h:1.89 ZendEngine2/zend_operators.h:1.90
> --- ZendEngine2/zend_operators.h:1.89 Thu Jul 15 22:03:25 2004
> +++ ZendEngine2/zend_operators.h Sat Sep 11 10:22:35 2004
> @@ -17,7 +17,7 @@
>
> +----------------------------------------------------------------------+
> */
> -/* $Id: zend_operators.h,v 1.89 2004/07/16 02:03:25 iliaa Exp $ */
> +/* $Id: zend_operators.h,v 1.90 2004/09/11 14:22:35 derick Exp $ */
> #ifndef ZEND_OPERATORS_H
> #define ZEND_OPERATORS_H
> @@ -179,6 +179,9 @@
> ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
> ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
> ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
> +#if HAVE_STRCOLL
> +ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
> +#endif
> ZEND_API void zend_str_tolower(char *str, unsigned int length);
> ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned int length);
>
> http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.273&r2=1.274&ty=u
> Index: php-src/ext/standard/array.c
> diff -u php-src/ext/standard/array.c:1.273 php-src/ext/standard/array.c:1.274
> --- php-src/ext/standard/array.c:1.273 Wed Aug 25 20:26:19 2004
> +++ php-src/ext/standard/array.c Sat Sep 11 10:22:35 2004
> @@ -21,7 +21,7 @@
>
> +----------------------------------------------------------------------+
> */
> -/* $Id: array.c,v 1.273 2004/08/26 00:26:19 iliaa Exp $ */
> +/* $Id: array.c,v 1.274 2004/09/11 14:22:35 derick Exp $ */
> #include "php.h"
> #include "php_ini.h"
> @@ -65,6 +65,7 @@
> #define SORT_REGULAR 0
> #define SORT_NUMERIC 1
> #define SORT_STRING 2
> +#define SORT_LOCALE_STRING 5
> #define SORT_DESC 3
> #define SORT_ASC 4
> @@ -114,6 +115,8 @@
> REGISTER_LONG_CONSTANT("SORT_REGULAR", SORT_REGULAR, CONST_CS | CONST_PERSISTENT);
> REGISTER_LONG_CONSTANT("SORT_NUMERIC", SORT_NUMERIC, CONST_CS | CONST_PERSISTENT);
> REGISTER_LONG_CONSTANT("SORT_STRING", SORT_STRING, CONST_CS | CONST_PERSISTENT);
> + REGISTER_LONG_CONSTANT("SORT_LOCALE_STRING", SORT_LOCALE_STRING, CONST_CS |
> CONST_PERSISTENT);
> +
> REGISTER_LONG_CONSTANT("CASE_LOWER", CASE_LOWER, CONST_CS | CONST_PERSISTENT);
> REGISTER_LONG_CONSTANT("CASE_UPPER", CASE_UPPER, CONST_CS | CONST_PERSISTENT);
> @@ -142,6 +145,12 @@
> case SORT_STRING:
> ARRAYG(compare_func) = string_compare_function;
> break;
> +
> +#if HAVE_STRCOLL
> + case SORT_LOCALE_STRING:
> + ARRAYG(compare_func) = string_locale_compare_function;
> + break;
> +#endif
> case SORT_REGULAR:
> default:
--
Best regards,
Marcus mailto:helly@php.net