]> granicus.if.org Git - php/commitdiff
add zend_memrchr()
authorAntony Dovgal <tony2001@php.net>
Tue, 8 Aug 2006 09:41:09 +0000 (09:41 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 8 Aug 2006 09:41:09 +0000 (09:41 +0000)
Zend/zend_operators.h
configure.in

index cf21c87c71835677e92075223b773c9980ebc1d3..ba86413044525b1ad7efd31327f41ed075127524 100644 (file)
@@ -160,6 +160,29 @@ zend_memnstr(char *haystack, char *needle, int needle_len, char *end)
        return NULL;
 }
 
+#ifdef HAVE_MEMRCHR
+# ifndef __USE_GNU
+#  define __USE_GNU
+# endif
+
+#include <string.h>
+#define zend_memrchr memrchr
+
+#else
+
+static inline void *zend_memrchr(const void *s, int c, size_t n)
+{
+       register unsigned char *e = (unsigned char *)s + n;
+
+       for (e--; e >= (unsigned char *)s; e--) {
+               if (*e == (unsigned char)c) {
+                       return (void *)e;
+               }
+       }
+
+       return NULL;
+}
+#endif
 
 BEGIN_EXTERN_C()
 ZEND_API int increment_function(zval *op1);
index f9df4138650e26c83f73a903a8525d3e7d755b15..242b25ab2eeff7b98e273cf7f5564a9737e28626 100644 (file)
@@ -491,6 +491,7 @@ lchown \
 lrand48 \
 memcpy \
 memmove \
+memrchr \
 mkstemp \
 mmap \
 nl_langinfo \