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

index 24feea02d09e8fa87d32639d7af4b3fd65b3a21c..090a8057edd13b7bc973c73256dda82567c4c258 100644 (file)
@@ -233,6 +233,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 c5270bbedbc75dfdbfb0926146344892f0c45025..6444ba6e41e0f2f40d57e55e3639fefa623c33da 100644 (file)
@@ -489,6 +489,7 @@ lchown \
 lrand48 \
 memcpy \
 memmove \
+memrchr \
 mkstemp \
 mmap \
 nl_langinfo \