com php-src: use zend_ascii_tolower/toupper instead of glibc funcs: Zend/zend_operators.c Zend/zend_o perators.h ext/standard/string.c
ext/standard/strnatcmp .c
| From: | Antony Dovgal | Date: | Thu, 12 Dec 2013 08:47:42 +0000 |
| Subject: | com php-src: use zend_ascii_tolower/toupper instead of glibc funcs: Zend/zend_operators.c Zend/zend_o perators.h ext/standard/string.c ext/standard/strnatcmp .c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76641@lists.php.net to get a copy of this message | ||
Commit: ecbf8fcb8466410e89aaf235135c4149aab59edb
Author: Antony Dovgal <tony2001@php.net> Fri, 26 Jul 2013 12:38:25 +0400
Parents: 505483796d1fabbc0285f580221c84fb57d91874
Branches: badoo-5.5_mysqlnd
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ecbf8fcb8466410e89aaf235135c4149aab59edb
Log:
use zend_ascii_tolower/toupper instead of glibc funcs
Conflicts:
ext/standard/string.c
Changed paths:
M Zend/zend_operators.c
M Zend/zend_operators.h
M ext/standard/string.c
M ext/standard/strnatcmp.c
Diff:
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 509cd3d...c886325 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -40,15 +40,6 @@ static _locale_t current_locale = NULL;
#define zend_tolower(c) zend_ascii_tolower(c)
#endif
-inline static int zend_ascii_tolower(int i)
-{
- if (64 < i && i < 91) {
- return (i + 32);
- } else {
- return i;
- }
-}
-
#define TYPE_PAIR(t1,t2) (((t1) << 4) | (t2))
static const unsigned char tolower_map[256] = {
diff --git a/Zend/zend_operators.h b/Zend/zend_operators..h
index 815cf58..bec60ee 100644
--- a/Zend/zend_operators.h
+++ b/Zend/zend_operators.h
@@ -319,6 +319,24 @@ static inline const void *zend_memrchr(const void *s, int c, size_t n)
return NULL;
}
+static inline int zend_ascii_tolower(int i)
+{
+ if (64 < i && i < 91) {
+ return (i + 32);
+ } else {
+ return i;
+ }
+}
+
+static inline int zend_ascii_toupper(int i)
+{
+ if (96 < i && i < 123) {
+ return (i - 32);
+ } else {
+ return i;
+ }
+}
+
BEGIN_EXTERN_C()
ZEND_API int increment_function(zval *op1);
ZEND_API int decrement_function(zval *op2);
diff --git a/ext/standard/string.c b/ext/standard/string.c
index b9d7427..35f8502 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -1352,7 +1352,7 @@ PHPAPI char *php_strtoupper(char *s, size_t len)
e = (unsigned char *)c+len;
while (c < e) {
- *c = toupper(*c);
+ *c = zend_ascii_toupper(*c);
c++;
}
return s;
@@ -1386,7 +1386,7 @@ PHPAPI char *php_strtolower(char *s, size_t len)
e = c+len;
while (c < e) {
- *c = tolower(*c);
+ *c = zend_ascii_tolower(*c);
c++;
}
return s;
@@ -1888,7 +1888,7 @@ PHP_FUNCTION(stripos)
efree(haystack_dup);
RETURN_FALSE;
}
- needle_char[0] = tolower(needle_char[0]);
+ needle_char[0] = zend_ascii_tolower(needle_char[0]);
needle_char[1] = '\0';
found = php_memnstr(haystack_dup + offset,
needle_char,
@@ -2031,10 +2031,10 @@ PHP_FUNCTION(strripos)
}
e = haystack + haystack_len + offset;
}
- /* Borrow that ord_needle buffer to avoid repeatedly tolower()ing needle */
- *ord_needle = tolower(*needle);
+ /* Borrow that ord_needle buffer to avoid repeatedly zend_ascii_tolower()ing needle */
+ *ord_needle = zend_ascii_tolower(*needle);
while (e >= p) {
- if (tolower(*e) == *ord_needle) {
+ if (zend_ascii_tolower(*e) == *ord_needle) {
RETURN_LONG(e - p + (offset > 0 ? offset : 0));
}
e--;
@@ -2672,7 +2672,7 @@ static void php_ucfirst(char *str)
{
register char *r;
r = str;
- *r = toupper((unsigned char) *r);
+ *r = zend_ascii_toupper((unsigned char) *r);
}
/* }}} */
@@ -2702,7 +2702,7 @@ static void php_lcfirst(char *str)
{
register char *r;
r = str;
- *r = tolower((unsigned char) *r);
+ *r = zend_ascii_tolower((unsigned char) *r);
}
/* }}} */
@@ -2745,10 +2745,10 @@ PHP_FUNCTION(ucwords)
ZVAL_STRINGL(return_value, str, str_len, 1);
r = Z_STRVAL_P(return_value);
- *r = toupper((unsigned char) *r);
+ *r = zend_ascii_toupper((unsigned char) *r);
for (r_end = r + Z_STRLEN_P(return_value) - 1; r < r_end; ) {
if (isspace((int) *(unsigned char *)r++)) {
- *r = toupper((unsigned char) *r);
+ *r = zend_ascii_toupper((unsigned char) *r);
}
}
}
@@ -3587,7 +3587,7 @@ PHPAPI int php_char_to_str_ex(char *str, uint len, char from, char *to, int
to_l
}
} else {
for (source = str; source < source_end; source++) {
- if (tolower(*source) == tolower(from)) {
+ if (zend_ascii_tolower(*source) == zend_ascii_tolower(from)) {
char_count++;
}
}
@@ -3621,7 +3621,7 @@ PHPAPI int php_char_to_str_ex(char *str, uint len, char from, char *to, int
to_l
}
} else {
for (source = str; source < source_end; source++) {
- if (tolower(*source) == tolower(from)) {
+ if (zend_ascii_tolower(*source) == zend_ascii_tolower(from)) {
replaced = 1;
if (replace_count) {
*replace_count += 1;
@@ -4491,8 +4491,8 @@ int php_tag_find(char *tag, int len, char *set) {
n = norm;
t = tag;
- c = tolower(*t);
- /*
+ c = zend_ascii_tolower(*t);
+ /*
normalize the tag removing leading and trailing whitespace
and turn any <a whatever...> into just <a> and any </tag>
into <tag>
@@ -4519,8 +4519,8 @@ int php_tag_find(char *tag, int len, char *set) {
}
break;
}
- c = tolower(*(++t));
- }
+ c = zend_ascii_tolower(*(++t));
+ }
*(n++) = '>';
*n = '\0';
if (strstr(set, norm)) {
@@ -4775,12 +4775,12 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char
*allow,
case 'e':
/* !DOCTYPE exception */
if (state==3 && p > buf+6
- && tolower(*(p-1)) == 'p'
- && tolower(*(p-2)) == 'y'
- && tolower(*(p-3)) == 't'
- && tolower(*(p-4)) == 'c'
- && tolower(*(p-5)) == 'o'
- && tolower(*(p-6)) == 'd') {
+ && zend_ascii_tolower(*(p-1)) == 'p'
+ && zend_ascii_tolower(*(p-2)) == 'y'
+ && zend_ascii_tolower(*(p-3)) == 't'
+ && zend_ascii_tolower(*(p-4)) == 'c'
+ && zend_ascii_tolower(*(p-5)) == 'o'
+ && zend_ascii_tolower(*(p-6)) == 'd') {
state = 1;
break;
}
diff --git a/ext/standard/strnatcmp.c b/ext/standard/strnatcmp..c
index face191..1fdaaed 100644
--- a/ext/standard/strnatcmp.c
+++ b/ext/standard/strnatcmp.c
@@ -157,8 +157,8 @@ PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t b_len
}
if (fold_case) {
- ca = toupper((int)(unsigned char)ca);
- cb = toupper((int)(unsigned char)cb);
+ ca = zend_ascii_toupper((int)(unsigned char)ca);
+ cb = zend_ascii_toupper((int)(unsigned char)cb);
}
if (ca < cb)