From 8d57ce619aa49862caeee30181fbbd9c76846554 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 22 Aug 2014 09:26:28 +0200 Subject: Fix some minor estream things. * m4/estream.m4: Check for memrchr. * src/estream.c (memrchr) [!HAVE_MEMRCHR]: New. * src/init.c: Include estream.h (real_init): Init estream. --- src/estream.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/estream.c') diff --git a/src/estream.c b/src/estream.c index 8476f8b..e7a81e8 100644 --- a/src/estream.c +++ b/src/estream.c @@ -103,16 +103,8 @@ # include "../common/util.h" #endif -#ifndef HAVE_MKSTEMP -int mkstemp (char *template); -#endif - -#ifndef HAVE_MEMRCHR -void *memrchr (const void *block, int c, size_t size); -#endif - -#include -#include +#include "estream.h" +#include "estream-printf.h" @@ -340,6 +332,20 @@ map_w32_to_errno (DWORD w32_err) } #endif /*HAVE_W32_SYSTEM*/ +/* Replacement fucntions. */ + +#ifndef HAVE_MEMRCHR +static void * +memrchr (const void *buffer, int c, size_t n) +{ + const unsigned char *p = buffer; + + for (p += n; n ; n--) + if (*--p == c) + return (void *)p; + return NULL; +} +#endif /*HAVE_MEMRCHR*/ /* -- cgit v1.2.3