diff options
author | Stig S. Bakken <stig@php.net> | 1999-06-15 22:32:51 +0000 |
---|---|---|
committer | Stig S. Bakken <stig@php.net> | 1999-06-15 22:32:51 +0000 |
commit | 80f1ce5eeded90225949130c5356eee2d6d96b6c (patch) | |
tree | 82da9d48514f9ab5bd14a694def1e34cb0ba4e90 | |
parent | 8eec7a022f371952a212e250e12903396671d3fa (diff) | |
download | php-git-80f1ce5eeded90225949130c5356eee2d6d96b6c.tar.gz |
* added zend_binary_strcasecmp()
-rw-r--r-- | Zend/zend_operators.c | 24 | ||||
-rw-r--r-- | Zend/zend_operators.h | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index a5848d6dd7..9496edd5d2 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -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; diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index ee0eb96b3d..5eff1b10dc 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -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 |