andrei Tue Aug 23 18:05:22 2005 EDT
Modified files:
/ZendEngine2 zend_builtin_functions.c zend_operators.c
zend_operators.h
Log:
Implement Unicode support for strncasecmp().
http://cvs.php.net/diff.php/ZendEngine2/zend_builtin_functions.c?r1=1.290&r2=1.291&ty=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.290
ZendEngine2/zend_builtin_functions.c:1.291
--- ZendEngine2/zend_builtin_functions.c:1.290 Tue Aug 23 08:53:20 2005
+++ ZendEngine2/zend_builtin_functions.c Tue Aug 23 18:05:22 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_builtin_functions.c,v 1.290 2005/08/23 12:53:20 dmitry Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.291 2005/08/23 22:05:22 andrei Exp $ */
#include "zend.h"
#include "zend_API.h"
@@ -378,7 +378,7 @@
return;
}
if (s1_type == IS_UNICODE) {
- RETURN_LONG(zend_u_binary_strcasecmp(s1, MIN(s1_len, len), s2,
MIN(s2_len, len)));
+ RETURN_LONG(zend_u_binary_strncasecmp(s1, s1_len, s2, s2_len,
len));
} else {
RETURN_LONG(zend_binary_strcasecmp(s1, MIN(s1_len, len), s2,
MIN(s2_len, len)));
}
http://cvs.php.net/diff.php/ZendEngine2/zend_operators.c?r1=1.218&r2=1.219&ty=u
Index: ZendEngine2/zend_operators.c
diff -u ZendEngine2/zend_operators.c:1.218 ZendEngine2/zend_operators.c:1.219
--- ZendEngine2/zend_operators.c:1.218 Tue Aug 23 17:08:35 2005
+++ ZendEngine2/zend_operators.c Tue Aug 23 18:05:22 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.c,v 1.218 2005/08/23 21:08:35 andrei Exp $ */
+/* $Id: zend_operators.c,v 1.219 2005/08/23 22:05:22 andrei Exp $ */
#include <ctype.h>
@@ -2258,6 +2258,7 @@
return len1 - len2;
}
+
ZEND_API int zend_u_binary_strcasecmp(UChar *s1, int32_t len1, UChar *s2,
int32_t len2)
{
UErrorCode status = U_ZERO_ERROR;
@@ -2265,6 +2266,7 @@
return ZEND_NORMALIZE_BOOL(result);
}
+
ZEND_API int zend_binary_strncasecmp(char *s1, uint len1, char *s2, uint len2,
uint length)
{
int len;
@@ -2284,6 +2286,24 @@
}
+/*
+ * Because we do not know UChar offsets for the passed-in limit of the number
of
+ * codepoints to compare, we take a hit upfront by iterating over both strings
+ * until we find them. Then we can simply use u_strCaseCompare().
+ */
+ZEND_API int zend_u_binary_strncasecmp(UChar *s1, int32_t len1, UChar *s2,
int32_t len2, uint length)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ int32_t off1 = 0, off2 = 0;
+ int32_t result;
+
+ U16_FWD_N(s1, off1, len1, length);
+ U16_FWD_N(s2, off2, len2, length);
+ result = u_strCaseCompare(s1, off1, s2, off2,
U_COMPARE_CODE_POINT_ORDER, &status);
+ return ZEND_NORMALIZE_BOOL(result);
+}
+
+
ZEND_API int zend_binary_zval_strcmp(zval *s1, zval *s2)
{
return zend_binary_strcmp(s1->value.str.val, s1->value.str.len,
s2->value.str.val, s2->value.str.len);
http://cvs.php.net/diff.php/ZendEngine2/zend_operators.h?r1=1.99&r2=1.100&ty=u
Index: ZendEngine2/zend_operators.h
diff -u ZendEngine2/zend_operators.h:1.99 ZendEngine2/zend_operators.h:1.100
--- ZendEngine2/zend_operators.h:1.99 Mon Aug 22 18:17:19 2005
+++ ZendEngine2/zend_operators.h Tue Aug 23 18:05:22 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_operators.h,v 1.99 2005/08/22 22:17:19 andrei Exp $ */
+/* $Id: zend_operators.h,v 1.100 2005/08/23 22:05:22 andrei Exp $ */
#ifndef ZEND_OPERATORS_H
#define ZEND_OPERATORS_H
@@ -290,6 +290,7 @@
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 int zend_u_binary_strncasecmp(UChar *s1, int32_t len1, UChar *s2,
int32_t len2, uint length);
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);
--
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|