diff --git a/ChangeLog b/ChangeLog index 4bbc94c956..109f93a9f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Oct 27 11:53:17 2005 Hirokazu Yamamoto + + * missing.h, missing/memcmp.c, missing/memmove.c: + ANSI compatible interface. + Wed Oct 26 09:15:48 2005 Hirokazu Yamamoto * ext/syck/implicit.c (syck_type_id_to_uri): should return diff --git a/missing.h b/missing.h index 675d0d5e17..5b4dcc2747 100644 --- a/missing.h +++ b/missing.h @@ -76,12 +76,12 @@ extern int isnan(double); /* #ifndef HAVE_MEMCMP -extern int memcmp(char *, char *, int); +extern int memcmp(const void *, const void *, size_t); #endif */ #ifndef HAVE_MEMMOVE -extern void *memmove(void *, void *, int); +extern void *memmove(void *, const void *, size_t); #endif /* diff --git a/missing/memcmp.c b/missing/memcmp.c index 9edc9c13b9..5b3ad3817a 100644 --- a/missing/memcmp.c +++ b/missing/memcmp.c @@ -1,16 +1,15 @@ /* public domain rewrite of memcmp(3) */ +#include + int -memcmp(s1,s2,len) - char *s1; - char *s2; - register int len; +memcmp(const void *s1, const void *s2, size_t len) { register unsigned char *a = (unsigned char*)s1; register unsigned char *b = (unsigned char*)s2; register int tmp; - while (len--) { + for (; len; --len) { if (tmp = *a++ - *b++) return tmp; } diff --git a/missing/memmove.c b/missing/memmove.c index c9d67d8b45..19c5f18847 100644 --- a/missing/memmove.c +++ b/missing/memmove.c @@ -1,22 +1,21 @@ /* public domain rewrite of memcmp(3) */ +#include + void * -memmove (d, s, n) - void *d, *s; - int n; +memmove(void *d, const void *s, size_t n) { - char *dst = d; - char *src = s; - void *ret = dst; + char *dst = (char *)d; + const char *src = (const char *)s; if (src < dst) { src += n; dst += n; - while (n--) + for (; n; --n) *--dst = *--src; } else if (dst < src) - while (n--) + for (; n; --n) *dst++ = *src++; - return ret; + return d; }