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+ 0x90 ,0x91 ,0x92 ,0x93 ,0x94 ,0x95 ,0x96 ,0x97 ,0x98 ,0x99 ,0x9a ,0x9b ,0x9c ,0x9d ,0x9e ,0x9f ,
56
+ 0xa0 ,0xa1 ,0xa2 ,0xa3 ,0xa4 ,0xa5 ,0xa6 ,0xa7 ,0xa8 ,0xa9 ,0xaa ,0xab ,0xac ,0xad ,0xae ,0xaf ,
57
+ 0xb0 ,0xb1 ,0xb2 ,0xb3 ,0xb4 ,0xb5 ,0xb6 ,0xb7 ,0xb8 ,0xb9 ,0xba ,0xbb ,0xbc ,0xbd ,0xbe ,0xbf ,
58
+ 0xc0 ,0xc1 ,0xc2 ,0xc3 ,0xc4 ,0xc5 ,0xc6 ,0xc7 ,0xc8 ,0xc9 ,0xca ,0xcb ,0xcc ,0xcd ,0xce ,0xcf ,
59
+ 0xd0 ,0xd1 ,0xd2 ,0xd3 ,0xd4 ,0xd5 ,0xd6 ,0xd7 ,0xd8 ,0xd9 ,0xda ,0xdb ,0xdc ,0xdd ,0xde ,0xdf ,
60
+ 0xe0 ,0xe1 ,0xe2 ,0xe3 ,0xe4 ,0xe5 ,0xe6 ,0xe7 ,0xe8 ,0xe9 ,0xea ,0xeb ,0xec ,0xed ,0xee ,0xef ,
61
+ 0xf0 ,0xf1 ,0xf2 ,0xf3 ,0xf4 ,0xf5 ,0xf6 ,0xf7 ,0xf8 ,0xf9 ,0xfa ,0xfb ,0xfc ,0xfd ,0xfe ,0xff
62
+ };
63
+
64
+ #define zend_tolower_ascii (c ) (tolower_map[(c)])
65
+
66
+ /**
67
+ * Functions using locale lowercase:
68
+ zend_binary_strncasecmp_l
69
+ zend_binary_strcasecmp_l
70
+ zend_binary_zval_strcasecmp
71
+ zend_binary_zval_strncasecmp
72
+ string_compare_function_ex
73
+ string_case_compare_function
74
+ * Functions using ascii lowercase:
75
+ zend_str_tolower_copy
76
+ zend_str_tolower_dup
77
+ zend_str_tolower
78
+ zend_binary_strcasecmp
79
+ zend_binary_strncasecmp
80
+ */
81
+
45
82
ZEND_API int zend_atoi (const char * str , int str_len ) /* {{{ */
46
83
{
47
84
int retval ;
@@ -1908,7 +1945,7 @@ ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, unsigned in
1908
1945
register unsigned char * end = str + length ;
1909
1946
1910
1947
while (str < end ) {
1911
- * result ++ = zend_tolower ((int )* str ++ );
1948
+ * result ++ = zend_tolower_ascii ((int )* str ++ );
1912
1949
}
1913
1950
* result = '\0' ;
1914
1951
@@ -1928,7 +1965,7 @@ ZEND_API void zend_str_tolower(char *str, unsigned int length) /* {{{ */
1928
1965
register unsigned char * end = p + length ;
1929
1966
1930
1967
while (p < end ) {
1931
- * p = zend_tolower ((int )* p );
1968
+ * p = zend_tolower_ascii ((int )* p );
1932
1969
p ++ ;
1933
1970
}
1934
1971
}
@@ -1975,6 +2012,49 @@ ZEND_API int zend_binary_strcasecmp(const char *s1, uint len1, const char *s2, u
1975
2012
return 0 ;
1976
2013
}
1977
2014
2015
+ len = MIN (len1 , len2 );
2016
+ while (len -- ) {
2017
+ c1 = zend_tolower_ascii ((int )* (unsigned char * )s1 ++ );
2018
+ c2 = zend_tolower_ascii ((int )* (unsigned char * )s2 ++ );
2019
+ if (c1 != c2 ) {
2020
+ return c1 - c2 ;
2021
+ }
2022
+ }
2023
+
2024
+ return len1 - len2 ;
2025
+ }
2026
+ /* }}} */
2027
+
2028
+ ZEND_API int zend_binary_strncasecmp (const char * s1 , uint len1 , const char * s2 , uint len2 , uint length ) /* {{{ */
2029
+ {
2030
+ int len ;
2031
+ int c1 , c2 ;
2032
+
2033
+ if (s1 == s2 ) {
2034
+ return 0 ;
2035
+ }
2036
+ len = MIN (length , MIN (len1 , len2 ));
2037
+ while (len -- ) {
2038
+ c1 = zend_tolower_ascii ((int )* (unsigned char * )s1 ++ );
2039
+ c2 = zend_tolower_ascii ((int )* (unsigned char * )s2 ++ );
2040
+ if (c1 != c2 ) {
2041
+ return c1 - c2 ;
2042
+ }
2043
+ }
2044
+
2045
+ return MIN (length , len1 ) - MIN (length , len2 );
2046
+ }
2047
+ /* }}} */
2048
+
2049
+ ZEND_API int zend_binary_strcasecmp_l (const char * s1 , uint len1 , const char * s2 , uint len2 ) /* {{{ */
2050
+ {
2051
+ int len ;
2052
+ int c1 , c2 ;
2053
+
2054
+ if (s1 == s2 ) {
2055
+ return 0 ;
2056
+ }
2057
+
1978
2058
len = MIN (len1 , len2 );
1979
2059
while (len -- ) {
1980
2060
c1 = zend_tolower ((int )* (unsigned char * )s1 ++ );
@@ -1988,7 +2068,7 @@ ZEND_API int zend_binary_strcasecmp(const char *s1, uint len1, const char *s2, u
1988
2068
}
1989
2069
/* }}} */
1990
2070
1991
- ZEND_API int zend_binary_strncasecmp (const char * s1 , uint len1 , const char * s2 , uint len2 , uint length ) /* {{{ */
2071
+ ZEND_API int zend_binary_strncasecmp_l (const char * s1 , uint len1 , const char * s2 , uint len2 , uint length ) /* {{{ */
1992
2072
{
1993
2073
int len ;
1994
2074
int c1 , c2 ;
@@ -2023,13 +2103,13 @@ ZEND_API int zend_binary_zval_strncmp(zval *s1, zval *s2, zval *s3) /* {{{ */
2023
2103
2024
2104
ZEND_API int zend_binary_zval_strcasecmp (zval * s1 , zval * s2 ) /* {{{ */
2025
2105
{
2026
- return zend_binary_strcasecmp (Z_STRVAL_P (s1 ), Z_STRLEN_P (s1 ), Z_STRVAL_P (s2 ), Z_STRLEN_P (s2 ));
2106
+ return zend_binary_strcasecmp_l (Z_STRVAL_P (s1 ), Z_STRLEN_P (s1 ), Z_STRVAL_P (s2 ), Z_STRLEN_P (s2 ));
2027
2107
}
2028
2108
/* }}} */
2029
2109
2030
2110
ZEND_API int zend_binary_zval_strncasecmp (zval * s1 , zval * s2 , zval * s3 ) /* {{{ */
2031
2111
{
2032
- return zend_binary_strncasecmp (Z_STRVAL_P (s1 ), Z_STRLEN_P (s1 ), Z_STRVAL_P (s2 ), Z_STRLEN_P (s2 ), Z_LVAL_P (s3 ));
2112
+ return zend_binary_strncasecmp_l (Z_STRVAL_P (s1 ), Z_STRLEN_P (s1 ), Z_STRVAL_P (s2 ), Z_STRLEN_P (s2 ), Z_LVAL_P (s3 ));
2033
2113
}
2034
2114
/* }}} */
2035
2115
@@ -2064,7 +2144,7 @@ ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2) /* {{{ */
2064
2144
} else if (ret2 != IS_DOUBLE ) {
2065
2145
if (oflow1 ) {
2066
2146
ZVAL_LONG (result , oflow1 );
2067
- return ;
2147
+ return ;
2068
2148
}
2069
2149
dval2 = (double ) lval2 ;
2070
2150
} else if (dval1 == dval2 && !zend_finite (dval1 )) {
0 commit comments