diff options
author | Sascha Schumann <sas@php.net> | 2000-09-27 15:18:00 +0000 |
---|---|---|
committer | Sascha Schumann <sas@php.net> | 2000-09-27 15:18:00 +0000 |
commit | 1cc3e6b5e664c25836bc770322d8a44e3b90f48a (patch) | |
tree | b4329706004e52b33702907eee0c27bbf2a9ddf7 /ext/standard/php_string.h | |
parent | d4cd24c22d33627277ec7da411fe2043b88cf31e (diff) | |
download | php-git-1cc3e6b5e664c25836bc770322d8a44e3b90f48a.tar.gz |
Move php_memnstr to the header file, so that the function body is available
in all compilation units (note the static linkage).
Diffstat (limited to 'ext/standard/php_string.h')
-rw-r--r-- | ext/standard/php_string.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/ext/standard/php_string.h b/ext/standard/php_string.h index 6f247e0df2..d4d89c8778 100644 --- a/ext/standard/php_string.h +++ b/ext/standard/php_string.h @@ -104,7 +104,21 @@ PHPAPI void php_char_to_str(char *str, uint len, char from, char *to, int to_len PHPAPI void php_implode(pval *delim, pval *arr, pval *return_value); PHPAPI void php_explode(pval *delim, pval *str, pval *return_value, int limit); -PHPAPI inline char *php_memnstr(char *haystack, char *needle, int needle_len, char *end); + +static inline char * +php_memnstr(char *haystack, char *needle, int needle_len, char *end) +{ + char *p = haystack; + char *s = NULL; + + for(; p <= end - needle_len && + (s = memchr(p, *needle, end - p - needle_len + 1)); p = s + 1) { + if(memcmp(s, needle, needle_len) == 0) + return s; + } + return NULL; +} + PHPAPI size_t php_strspn(char *s1, char *s2, char *s1_end, char *s2_end); PHPAPI size_t php_strcspn(char *s1, char *s2, char *s1_end, char *s2_end); |