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)));
}
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;
return ZEND_NORMALIZE_BOOL(result);
}
+
ZEND_API int zend_binary_strncasecmp(char *s1, uint len1, char *s2, uint len2, uint length)
{
int len;
}
+/*
+ * 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);
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);