]> granicus.if.org Git - php/commitdiff
- Added the sorting flag SORT_LOCALE_STRING to the sort() functions which makes
authorDerick Rethans <derick@php.net>
Sat, 11 Sep 2004 14:20:55 +0000 (14:20 +0000)
committerDerick Rethans <derick@php.net>
Sat, 11 Sep 2004 14:20:55 +0000 (14:20 +0000)
  them sort based on the current locale. (Derick)

NEWS
Zend/zend_operators.c
Zend/zend_operators.h
ext/standard/array.c

diff --git a/NEWS b/NEWS
index 36c5e66705d9f408d298250e599f866d18d4c5d2..a1b82253404f0843065ccc19d5d90868c13271da 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,13 +1,15 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2004, PHP 5.0.2
-- SoapClient->__call() is renamed to SoapClinet->__soap_call(). (Dmitry)
-- Add interface_exists() and make class_exists() only return true for real
+- Added the sorting flag SORT_LOCALE_STRING to the sort() functions which makes
+  them sort based on the current locale. (Derick)
+- Added interface_exists() and make class_exists() only return true for real
   classes. (Andrey)
-- Implemented periodic PCRE compiled regexp cache cleanup, to avoid memory
-  exhaustion. (Andrei)
 - Added PHP_EOL constant that contains the OS way of representing newlines.
   (Paul Hudson, Derick)
+- Implemented periodic PCRE compiled regexp cache cleanup, to avoid memory
+  exhaustion. (Andrei)
+- Renamed SoapClient->__call() to SoapClinet->__soap_call(). (Dmitry)
 - Fixed bug with raw_post_data not getting set (Brian)
 - Fixed a file-descriptor leak with phpinfo() and other 'special' URLs (Zeev)
 - Fixed bug #29985 (unserialize()/ __PHP_Incomplete_class does not report 
index 3a49d12876ab4c94f85199c15f616ec6194ae58c..9c046f30f481a3bbc0601000d422d55c5282e9a5 100644 (file)
@@ -1229,6 +1229,35 @@ ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_D
        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)
 {
        zval op1_copy, op2_copy;
index b6b845ae76b958bb33bbbaa769ea0e4f63fd5443..67ee246592c6593dbbb40d1fb31022f0ae5eba07 100644 (file)
@@ -179,6 +179,9 @@ ZEND_API int zval_is_true(zval *op);
 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);
index 3aff9c3352c748aef3bf3f078efa2ddc694f2d7a..088ff2b367472b0151885e8cf970b9a0b65b3359 100644 (file)
@@ -65,6 +65,7 @@ php_array_globals array_globals;
 #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
@@ -112,6 +113,8 @@ PHP_MINIT_FUNCTION(array)
        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);
 
@@ -141,6 +144,12 @@ static void set_compare_func(int sort_type TSRMLS_DC)
                        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:
                        ARRAYG(compare_func) = compare_function;