This is the mail archive of the newlib@sourceware.cygnus.com mailing list for the newlib project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Hi Guys, This is just a quick note to say that I have applied the enclosed patch to memchr(). It fixes a bug reported by a customer where they were passing a large integer value as the character to be sought, assuming that memchr would only look at the bottom byte of that value. (This is the documented behaviour). Cheers Nick 1998-12-15 Nick Clifton <nickc@cygnus.com> * libc/string/memchr.c: Treat 'c' argument as an unsigned byte not a signed int. Index: memchr.c =================================================================== RCS file: /cvs/cvsfiles/devo/newlib/libc/string/memchr.c,v retrieving revision 1.10.42.1 diff -p -r1.10.42.1 memchr.c *** memchr.c 1998/06/03 22:05:05 1.10.42.1 --- memchr.c 1998/12/16 01:14:20 *************** _DEFUN (memchr, (src_void, c, length), *** 74,79 **** --- 74,81 ---- #if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) _CONST unsigned char *src = (_CONST unsigned char *) src_void; + c &= 0xff; + while (length--) { if (*src == c) *************** _DEFUN (memchr, (src_void, c, length), *** 88,93 **** --- 90,97 ---- unsigned long mask; int i, j; + c &= 0xff; + /* If the size is small, or src is unaligned, then use the bytewise loop. We can hope this is rare. */ if (TOO_SMALL (length) || UNALIGNED (src))