]> granicus.if.org Git - php/commitdiff
Move memnstr into Zend and make an alias for BC in PHP.
authorAndrei Zmievski <andrei@php.net>
Tue, 8 Apr 2003 15:04:26 +0000 (15:04 +0000)
committerAndrei Zmievski <andrei@php.net>
Tue, 8 Apr 2003 15:04:26 +0000 (15:04 +0000)
Zend/zend_operators.h
main/php.h

index 5aa17bcd0300a211d718a607107cbc9674a10bf9..8d724480cf3ff116085fb7414423fa98501897e4 100644 (file)
@@ -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);
 
index afe7628b8c701b94fb6f8d985dad3f88562a1e4b..55970a5d806de856ad453595cb4a241886db70d2 100644 (file)
@@ -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);