memchr.c 562 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (C) 2002 Manuel Novoa III
  3. * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
  4. *
  5. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  6. */
  7. #include "_string.h"
  8. #ifdef WANT_WIDE
  9. # define Wmemchr wmemchr
  10. #else
  11. # undef memchr
  12. # define Wmemchr memchr
  13. #endif
  14. Wvoid *Wmemchr(const Wvoid *s, Wint c, size_t n)
  15. {
  16. register const Wuchar *r = (const Wuchar *) s;
  17. while (n) {
  18. if (*r == ((Wuchar)c)) {
  19. return (Wvoid *) r; /* silence the warning */
  20. }
  21. ++r;
  22. --n;
  23. }
  24. return NULL;
  25. }
  26. libc_hidden_def(Wmemchr)