Skip to content

Commit b9af980

Browse files
authored
Add case insensitive versions of the zend_string_starts_with_* APIs (#11032)
1 parent 6c532df commit b9af980

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Zend/zend_string.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,19 @@ static zend_always_inline bool zend_string_starts_with(const zend_string *str, c
411411
#define zend_string_starts_with_literal(str, prefix) \
412412
zend_string_starts_with_cstr(str, prefix, strlen(prefix))
413413

414+
static zend_always_inline bool zend_string_starts_with_cstr_ci(const zend_string *str, const char *prefix, size_t prefix_length)
415+
{
416+
return ZSTR_LEN(str) >= prefix_length && !strncasecmp(ZSTR_VAL(str), prefix, prefix_length);
417+
}
418+
419+
static zend_always_inline bool zend_string_starts_with_ci(const zend_string *str, const zend_string *prefix)
420+
{
421+
return zend_string_starts_with_cstr_ci(str, ZSTR_VAL(prefix), ZSTR_LEN(prefix));
422+
}
423+
424+
#define zend_string_starts_with_literal_ci(str, prefix) \
425+
zend_string_starts_with_cstr(str, prefix, strlen(prefix))
426+
414427
/*
415428
* DJBX33A (Daniel J. Bernstein, Times 33 with Addition)
416429
*

0 commit comments

Comments
 (0)