Mail Archives: djgpp-workers/1996/11/28/14:12:46
===============================================================================
Markus F.X.J. Oberhumer <markus DOT oberhumer AT jk DOT uni-linz DOT ac DOT at>
Subject: Bug: memchr() is not 8-bit clean
To: DJ, djgpp-workers AT delorie DOT com
===============================================================================
This is the correct version of src/libc/ansi/string/memchr.c:
/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <string.h>
#include <libc/unconst.h>
void *
memchr(const void *s, int c, size_t n)
{
if (n)
{
const char *p = s;
char cc = c;
do {
if (*p == cc)
return unconst(p, void *);
p++;
} while (--n != 0);
}
return 0;
}
- Raw text -