mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
* added zend_binary_strcasecmp()
This commit is contained in:
parent
8eec7a022f
commit
80f1ce5eed
2 changed files with 25 additions and 0 deletions
|
@ -1140,6 +1140,30 @@ ZEND_API int zend_binary_strcmp(zval *s1, zval *s2)
|
|||
}
|
||||
|
||||
|
||||
ZEND_API int zend_binary_strcasecmp(zval *s1, zval *s2)
|
||||
{
|
||||
const unsigned char *p1 = (const unsigned char *)s1->value.str.val;
|
||||
const unsigned char *p2 = (const unsigned char *)s2->value.str.val;
|
||||
unsigned char c1 = 0, c2 = 0;
|
||||
int len1, len2;
|
||||
|
||||
len1 = s1->value.str.len;
|
||||
len2 = s2->value.str.len;
|
||||
if (len1 != len2 || !len1) {
|
||||
return len1 - len2;
|
||||
}
|
||||
|
||||
while (len1--) {
|
||||
c1 = tolower(*p1++);
|
||||
c2 = tolower(*p2++);
|
||||
if (c1 != c2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return c1 - c2;
|
||||
}
|
||||
|
||||
ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2)
|
||||
{
|
||||
int ret1,ret2;
|
||||
|
|
|
@ -63,6 +63,7 @@ ZEND_API int compare_function(zval *result, zval *op1, zval *op2);
|
|||
|
||||
ZEND_API void zend_str_tolower(char *str, unsigned int length);
|
||||
ZEND_API int zend_binary_strcmp(zval *s1, zval *s2);
|
||||
ZEND_API int zend_binary_strcasecmp(zval *s1, zval *s2);
|
||||
ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue