]> granicus.if.org Git - php/commitdiff
- Zend engine part for bug #55158: Add SORT_NATURAL type to array_multisort
authorDerick Rethans <derick@php.net>
Mon, 29 Aug 2011 20:24:09 +0000 (20:24 +0000)
committerDerick Rethans <derick@php.net>
Mon, 29 Aug 2011 20:24:09 +0000 (20:24 +0000)
  (patch by Arpad Ray).

Zend/zend_operators.c
Zend/zend_operators.h

index 2f4905324c15714af7ea3d8c27ae33d9b2fbb53f..35a545145cdc73effd081ee9ad44eab566525fc8 100644 (file)
@@ -1288,7 +1288,7 @@ ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{
 }
 /* }}} */
 
-ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
+ZEND_API int string_compare_function_ex(zval *result, zval *op1, zval *op2, zend_bool case_insensitive TSRMLS_DC) /* {{{ */
 {
        zval op1_copy, op2_copy;
        int use_copy1 = 0, use_copy2 = 0;
@@ -1307,7 +1307,11 @@ ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_D
                op2 = &op2_copy;
        }
 
-       ZVAL_LONG(result, zend_binary_zval_strcmp(op1, op2));
+       if (case_insensitive) {
+               ZVAL_LONG(result, zend_binary_zval_strcasecmp(op1, op2));
+       } else {
+               ZVAL_LONG(result, zend_binary_zval_strcmp(op1, op2));
+       }
 
        if (use_copy1) {
                zval_dtor(op1);
@@ -1319,6 +1323,18 @@ ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_D
 }
 /* }}} */
 
+ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
+{
+       return string_compare_function_ex(result, op1, op2, 0);
+}
+/* }}} */
+
+ZEND_API int string_case_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
+{
+       return string_compare_function_ex(result, op1, op2, 1);
+}
+/* }}} */
+
 #if HAVE_STRCOLL
 ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC) /* {{{ */
 {
index 9b0c790f8a1b1b0b73c61cd87eafd10bdd3b7dc4..fb0c39abc5b264843ed1c3b640c8c66721a7049f 100644 (file)
@@ -301,7 +301,9 @@ ZEND_API double zend_string_to_double(const char *number, zend_uint length);
 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_ex(zval *result, zval *op1, zval *op2, zend_bool case_insensitive TSRMLS_DC);
 ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
+ZEND_API int string_case_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