summaryrefslogtreecommitdiff
path: root/Zend/zend_operators.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-07-01 19:04:18 +0300
committerDmitry Stogov <dmitry@zend.com>2015-07-01 19:04:18 +0300
commitd2d326a381d99fdf148ea30e2d96a7b525e35d9f (patch)
tree8ef88e0bd9a2e918019664ce4eeaa257173335f0 /Zend/zend_operators.c
parent068f63ceb263a5595227b9f1de77a6be6d456c71 (diff)
downloadphp-git-d2d326a381d99fdf148ea30e2d96a7b525e35d9f.tar.gz
Cleanup (avoid reallocatios and side effects in php_strip_tags)
Diffstat (limited to 'Zend/zend_operators.c')
-rw-r--r--Zend/zend_operators.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 1abfcca7a5..2b90475ba0 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -2417,6 +2417,34 @@ ZEND_API void ZEND_FASTCALL zend_str_tolower(char *str, size_t length) /* {{{ */
}
/* }}} */
+ZEND_API char* ZEND_FASTCALL zend_str_tolower_dup_ex(const char *source, size_t length) /* {{{ */
+{
+ register const unsigned char *p = (const unsigned char*)source;
+ register const unsigned char *end = p + length;
+
+ while (p < end) {
+ if (*p != zend_tolower_ascii(*p)) {
+ char *res = (char*)emalloc(length + 1);
+ register unsigned char *r;
+
+ if (p != (const unsigned char*)source) {
+ memcpy(res, source, p - (const unsigned char*)source);
+ }
+ r = (unsigned char*)p + (res - source);
+ while (p < end) {
+ *r = zend_tolower_ascii(*p);
+ p++;
+ r++;
+ }
+ *r = '\0';
+ return res;
+ }
+ p++;
+ }
+ return NULL;
+}
+/* }}} */
+
ZEND_API zend_string* ZEND_FASTCALL zend_string_tolower(zend_string *str) /* {{{ */
{
register unsigned char *p = (unsigned char*)ZSTR_VAL(str);