| Andrei Zmievski 2005-08-22, 6:57 pm |
| andrei Mon Aug 22 18:17:20 2005 EDT
Modified files:
/ZendEngine2 zend_builtin_functions.c zend_operators.c
zend_operators.h
Log:
Unicode support for strcasecmp().
http://cvs.php.net/diff.php/ZendEng...6&r2=1.287&ty=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.286 ZendEngine2/zend_builtin_functions.c:1.287
--- ZendEngine2/zend_builtin_functions.c:1.286 Mon Aug 22 08:22:07 2005
+++ ZendEngine2/zend_builtin_functions.c Mon Aug 22 18:17:19 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_builtin_functions.c,v 1.286 2005/08/22 12:22:07 dmitry Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.287 2005/08/22 22:17:19 andrei Exp $ */
#include "zend.h"
#include "zend_API.h"
@@ -347,14 +347,19 @@
Binary safe case-insensitive string comparison */
ZEND_FUNCTION(strcasecmp)
{
- zval **s1, **s2;
-
- if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &s1, &s2) == FAILURE) {
- ZEND_WRONG_PARAM_COUNT();
+ void *s1, *s2;
+ int32_t s1_len, s2_len;
+ zend_uchar s1_type, s2_type;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "TT", &s1, &s1_len,
+ &s1_type, &s2, &s2_len, &s2_type) == FAILURE) {
+ return;
+ }
+ if (s1_type == IS_UNICODE) {
+ RETURN_LONG(zend_u_binary_strcasecmp(
s1, s1_len, s2, s2_len));
+ } else {
+ RETURN_LONG(zend_binary_strcasecmp(s1
, s1_len, s2, s2_len));
}
- convert_to_string_ex(s1);
- convert_to_string_ex(s2);
- RETURN_LONG(zend_binary_zval_strcasecmp
(*s1, *s2));
}
/* }}} */
http://cvs.php.net/diff.php/ZendEng...4&r2=1.215&ty=u
Index: ZendEngine2/zend_operators.c
diff -u ZendEngine2/zend_operators.c:1.214 ZendEngine2/zend_operators.c:1.215
--- ZendEngine2/zend_operators.c:1.214 Fri Aug 19 19:15:36 2005
+++ ZendEngine2/zend_operators.c Mon Aug 22 18:17:19 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.c,v 1.214 2005/08/19 23:15:36 andrei Exp $ */
+/* $Id: zend_operators.c,v 1.215 2005/08/22 22:17:19 andrei Exp $ */
#include <ctype.h>
@@ -2254,6 +2254,18 @@
return len1 - len2;
}
+ZEND_API int zend_u_binary_strcasecmp(UChar *s1, int32_t len1, UChar *s2, int32_t len2)
+{
+ int retval;
+ UErrorCode status = U_ZERO_ERROR;
+
+ retval = ZEND_NORMALIZE_BOOL(u_strCaseCompare(s1,
len1, s2, len2, U_COMPARE_CODE_POINT_ORDER, &status));
+ if (!retval) {
+ return (len1 - len2);
+ } else {
+ return retval;
+ }
+}
ZEND_API int zend_binary_strncasecmp(char *s1, uint len1, char *s2, uint len2, uint length)
{
http://cvs.php.net/diff.php/ZendEng...98&r2=1.99&ty=u
Index: ZendEngine2/zend_operators.h
diff -u ZendEngine2/zend_operators.h:1.98 ZendEngine2/zend_operators.h:1.99
--- ZendEngine2/zend_operators.h:1.98 Fri Aug 19 19:15:36 2005
+++ ZendEngine2/zend_operators.h Mon Aug 22 18:17:19 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.h,v 1.98 2005/08/19 23:15:36 andrei Exp $ */
+/* $Id: zend_operators.h,v 1.99 2005/08/22 22:17:19 andrei Exp $ */
#ifndef ZEND_OPERATORS_H
#define ZEND_OPERATORS_H
@@ -289,6 +289,7 @@
ZEND_API int zend_u_binary_zval_strcmp(zval *s1, zval *s2);
ZEND_API int zend_u_binary_strcmp(UChar *s1, int32_t len1, UChar *s2, int32_t len2);
ZEND_API int zend_u_binary_strncmp(UChar *s1, int32_t len1, UChar *s2, int32_t len2, uint length);
+ZEND_API int zend_u_binary_strcasecmp(UChar *s1, int32_t len1, UChar *s2, int32_t len2);
ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2);
ZEND_API void zendi_u_smart_strcmp(zval *result, zval *s1, zval *s2);
|