mirror of
https://github.com/php/php-src.git
synced 2024-09-24 03:17:26 +00:00
Make string comparison functions conver to unicode or printable strings
depending on unicode.semantics and do the right thing.
This commit is contained in:
parent
622344c676
commit
f34e1baa9f
@ -1648,8 +1648,13 @@ ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_D
|
||||
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 (UG(unicode)) {
|
||||
zend_make_unicode_zval(op1, &op1_copy, &use_copy1);
|
||||
zend_make_unicode_zval(op2, &op2_copy, &use_copy2);
|
||||
} else {
|
||||
zend_make_printable_zval(op1, &op1_copy, &use_copy1);
|
||||
zend_make_printable_zval(op2, &op2_copy, &use_copy2);
|
||||
}
|
||||
|
||||
if (use_copy1) {
|
||||
op1 = &op1_copy;
|
||||
@ -1658,7 +1663,11 @@ ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_D
|
||||
op2 = &op2_copy;
|
||||
}
|
||||
|
||||
Z_LVAL_P(result) = zend_binary_zval_strcmp(op1, op2);
|
||||
if (UG(unicode)) {
|
||||
Z_LVAL_P(result) = zend_u_binary_zval_strcmp(op1, op2);
|
||||
} else {
|
||||
Z_LVAL_P(result) = zend_binary_zval_strcmp(op1, op2);
|
||||
}
|
||||
Z_TYPE_P(result) = IS_LONG;
|
||||
|
||||
if (use_copy1) {
|
||||
@ -1675,8 +1684,13 @@ ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 T
|
||||
zval op1_copy, op2_copy;
|
||||
int use_copy1, use_copy2;
|
||||
|
||||
zend_make_unicode_zval(op1, &op1_copy, &use_copy1);
|
||||
zend_make_unicode_zval(op2, &op2_copy, &use_copy2);
|
||||
if (UG(unicode)) {
|
||||
zend_make_unicode_zval(op1, &op1_copy, &use_copy1);
|
||||
zend_make_unicode_zval(op2, &op2_copy, &use_copy2);
|
||||
} else {
|
||||
zend_make_printable_zval(op1, &op1_copy, &use_copy1);
|
||||
zend_make_printable_zval(op2, &op2_copy, &use_copy2);
|
||||
}
|
||||
|
||||
if (use_copy1) {
|
||||
op1 = &op1_copy;
|
||||
@ -1685,7 +1699,11 @@ ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 T
|
||||
op2 = &op2_copy;
|
||||
}
|
||||
|
||||
Z_LVAL_P(result) = ucol_strcoll(UG(default_collator)->coll, Z_USTRVAL_P(op1), Z_USTRLEN_P(op1), Z_USTRVAL_P(op2), Z_USTRLEN_P(op2));
|
||||
if (UG(unicode)) {
|
||||
Z_LVAL_P(result) = ucol_strcoll(UG(default_collator)->coll, Z_USTRVAL_P(op1), Z_USTRLEN_P(op1), Z_USTRVAL_P(op2), Z_USTRLEN_P(op2));
|
||||
} else {
|
||||
Z_LVAL_P(result) = strcoll(Z_STRVAL_P(op1), Z_STRVAL_P(op2));
|
||||
}
|
||||
Z_TYPE_P(result) = IS_LONG;
|
||||
|
||||
if (use_copy1) {
|
||||
|
Loading…
Reference in New Issue
Block a user