memchr is required by ansi to treat the argument character and the data as unsigned chars, and the extension memccpy might as well too. normal libc already does that. Reference: /n/sources/patch/applied/ape-memchr Date: Fri Sep 7 11:36:19 CES 2007 Signed-off-by: forsyth@terzarima.net --- /sys/src/ape/lib/ap/gen/memchr.c Fri Sep 7 11:31:36 2007 +++ /sys/src/ape/lib/ap/gen/memchr.c Fri Sep 7 11:31:34 2007 @@ -3,9 +3,10 @@ void* memchr(const void *ap, int c, size_t n) { - char *sp; + unsigned char *sp; sp = ap; + c &= 0xFF; while(n > 0) { if(*sp++ == c) return sp-1; --- /sys/src/ape/lib/ap/gen/memccpy.c Fri Sep 7 11:31:53 2007 +++ /sys/src/ape/lib/ap/gen/memccpy.c Fri Sep 7 11:31:50 2007 @@ -3,10 +3,11 @@ void* memccpy(void *a1, void *a2, int c, size_t n) { - char *s1, *s2; + unsigned char *s1, *s2; s1 = a1; s2 = a2; + c &= 0xFF; while(n > 0) { if((*s1++ = *s2++) == c) return s1;