derick Sun Mar 26 11:06:24 2006 UTC
Added files:
/php-src/ext/unicodecollator.c
Modified files:
/php-src/ext/standard array.c php_array.h
/php-src/ext/unicodeconfig.m4 config.w32 php_unicode.h unicode.c
Log:
- Implemented basic collation support. For some reason new Collator gives
segfaults when the object's collation resource is used.
- The following example shows what is implemented:
?php
$orig = $strings = array(
'côte',
'cote',
'côté',
'coté',
'fluÃe',
'flüÃe',
);
echo German phonebook:\n;
$c = collator_create( [EMAIL PROTECTED] );
foreach($c-sort($strings) as $string) {
echo $string, \n;
}
echo $c-getAttribute(Collator::FRENCH_COLLATION) == Collator::ON
? With : Without, french accent sorting order\n;
echo \nFrench with options:\n;
$c = collator_create( fr );
$c-setAttribute(Collator::CASE_FIRST, Collator::UPPER_FIRST);
$c-setAttribute(Collator::CASE_LEVEL, Collator::ON);
$c-setStrength(Collator::SECONDARY);
foreach($c-sort($strings) as $string) {
echo $string, \n;
}
echo $c-getAttribute(Collator::FRENCH_COLLATION) == Collator::ON
? With : Without, french accent sorting order\n;
?
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/array.c?r1=1.346r2=1.347diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.346 php-src/ext/standard/array.c:1.347
--- php-src/ext/standard/array.c:1.346 Wed Mar 22 22:06:08 2006
+++ php-src/ext/standard/array.cSun Mar 26 11:06:24 2006
@@ -21,7 +21,7 @@
+--+
*/
-/* $Id: array.c,v 1.346 2006/03/22 22:06:08 tony2001 Exp $ */
+/* $Id: array.c,v 1.347 2006/03/26 11:06:24 derick Exp $ */
#include php.h
#include php_ini.h
@@ -60,11 +60,6 @@
#define EXTR_REFS 0x100
-#define SORT_REGULAR 0
-#define SORT_NUMERIC 1
-#defineSORT_STRING 2
-#defineSORT_LOCALE_STRING 5
-
#define SORT_DESC 3
#define SORT_ASC 4
@@ -139,7 +134,7 @@
return SUCCESS;
}
-static void set_compare_func(int sort_type TSRMLS_DC)
+PHPAPI void php_set_compare_func(int sort_type TSRMLS_DC)
{
switch (sort_type) {
case SORT_NUMERIC:
@@ -241,7 +236,7 @@
}
target_hash = HASH_OF(array);
- set_compare_func(sort_type TSRMLS_CC);
+ php_set_compare_func(sort_type TSRMLS_CC);
if (zend_hash_sort(target_hash, zend_qsort, array_reverse_key_compare,
0 TSRMLS_CC) == FAILURE) {
RETURN_FALSE;
@@ -263,7 +258,7 @@
}
target_hash = HASH_OF(array);
- set_compare_func(sort_type TSRMLS_CC);
+ php_set_compare_func(sort_type TSRMLS_CC);
if (zend_hash_sort(target_hash, zend_qsort, array_key_compare, 0
TSRMLS_CC) == FAILURE) {
RETURN_FALSE;
@@ -346,7 +341,7 @@
*
* This is not correct any more, depends on what compare_func is set to.
*/
-static int array_data_compare(const void *a, const void *b TSRMLS_DC)
+PHPAPI int php_array_data_compare(const void *a, const void *b TSRMLS_DC)
{
Bucket *f;
Bucket *s;
@@ -387,7 +382,7 @@
static int array_reverse_data_compare(const void *a, const void *b TSRMLS_DC)
{
- return array_data_compare(a, b TSRMLS_CC)*-1;
+ return php_array_data_compare(a, b TSRMLS_CC)*-1;
}
static int array_natural_general_compare(const void *a, const void *b, int
fold_case)
@@ -493,9 +488,9 @@
}
target_hash = HASH_OF(array);
- set_compare_func(sort_type TSRMLS_CC);
+ php_set_compare_func(sort_type TSRMLS_CC);
- if (zend_hash_sort(target_hash, zend_qsort, array_data_compare, 0
TSRMLS_CC) == FAILURE) {
+ if (zend_hash_sort(target_hash, zend_qsort, php_array_data_compare, 0
TSRMLS_CC) == FAILURE) {
RETURN_FALSE;
}
RETURN_TRUE;
@@ -515,7 +510,7 @@
}
target_hash = HASH_OF(array);
- set_compare_func(sort_type TSRMLS_CC);
+ php_set_compare_func(sort_type TSRMLS_CC);
if (zend_hash_sort(target_hash, zend_qsort, array_reverse_data_compare,
0 TSRMLS_CC) == FAILURE) {
RETURN_FALSE;
@@ -537,9 +532,9 @@
}
target_hash = HASH_OF(array);
- set_compare_func(sort_type TSRMLS_CC);
+ php_set_compare_func(sort_type TSRMLS_CC);
- if (zend_hash_sort(target_hash, zend_qsort, array_data_compare, 1
TSRMLS_CC) == FAILURE) {
+ if (zend_hash_sort(target_hash, zend_qsort, php_array_data_compare, 1
TSRMLS_CC) == FAILURE) {
RETURN_FALSE;
}
RETURN_TRUE;
@@ -559,7 +554,7 @@
}