From 1cc3e6b5e664c25836bc770322d8a44e3b90f48a Mon Sep 17 00:00:00 2001 From: Sascha Schumann Date: Wed, 27 Sep 2000 15:18:00 +0000 Subject: [PATCH] Move php_memnstr to the header file, so that the function body is available in all compilation units (note the static linkage). --- ext/standard/php_string.h | 16 +++++++++++++++- ext/standard/string.c | 14 -------------- 2 files changed, 15 insertions(+), 15 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); diff --git a/ext/standard/string.c b/ext/standard/string.c index 3baa4e2cb7..1f69c7feea 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2030,20 +2030,6 @@ PHPAPI void php_char_to_str(char *str,uint len,char from,char *to,int to_len,zva } -PHPAPI 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 char *php_str_to_str(char *haystack, int length, char *needle, int needle_len, char *str, int str_len, int *_new_length) { -- 2.50.1