From: Antony Dovgal Date: Tue, 8 Aug 2006 09:40:50 +0000 (+0000) Subject: add zend_memrchr() X-Git-Tag: RELEASE_1_0_0RC1~2044 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a3c3b91b33f427b42efaf6ffb7c769c01446b390;p=php add zend_memrchr() --- diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 24feea02d0..090a8057ed 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -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 +#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); diff --git a/configure.in b/configure.in index c5270bbedb..6444ba6e41 100644 --- a/configure.in +++ b/configure.in @@ -489,6 +489,7 @@ lchown \ lrand48 \ memcpy \ memmove \ +memrchr \ mkstemp \ mmap \ nl_langinfo \