From: Andrei Zmievski Date: Tue, 8 Apr 2003 15:04:26 +0000 (+0000) Subject: Move memnstr into Zend and make an alias for BC in PHP. X-Git-Tag: RELEASE_0_5~93 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2154cddd0ec3d68274dac88c420f52c3c000698b;p=php Move memnstr into Zend and make an alias for BC in PHP. --- diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 5aa17bcd03..8d724480cf 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -143,6 +143,31 @@ static inline zend_bool is_numeric_string(char *str, int length, long *lval, dou return 0; } +static inline char * +zend_memnstr(char *haystack, char *needle, int needle_len, char *end) +{ + char *p = haystack; + char ne = needle[needle_len-1]; + + end -= needle_len; + + while (p <= end) { + if ((p = memchr(p, *needle, (end-p+1))) && ne == p[needle_len-1]) { + if (!memcmp(needle, p, needle_len-1)) { + return p; + } + } + + if (p == NULL) { + return NULL; + } + + p++; + } + + return NULL; +} + ZEND_API int increment_function(zval *op1); ZEND_API int decrement_function(zval *op2); diff --git a/main/php.h b/main/php.h index afe7628b8c..55970a5d80 100644 --- a/main/php.h +++ b/main/php.h @@ -289,6 +289,8 @@ PHPAPI void php_error_docref2(const char *docref TSRMLS_DC, const char *param1, #define phprestart zendrestart #define phpin zendin +#define php_memnstr zend_memnstr + /* functions */ int php_startup_internal_extensions(void);