OSDN Git Service

hidden_def/hidden_proto: convert all users (I hope) termios split, add some missing...
[uclinux-h8/uClibc.git] / libc / string / memchr.c
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
8 #include "_string.h"
9
10 #ifdef WANT_WIDE
11 # define Wmemchr wmemchr
12 #else
13 # define Wmemchr memchr
14 #endif
15
16 libc_hidden_proto(Wmemchr)
17
18 Wvoid *Wmemchr(const Wvoid *s, Wint c, size_t n)
19 {
20         register const Wuchar *r = (const Wuchar *) s;
21 #ifdef __BCC__
22         /* bcc can optimize the counter if it thinks it is a pointer... */
23         register const char *np = (const char *) n;
24 #else
25 # define np n
26 #endif
27
28         while (np) {
29                 if (*r == ((Wuchar)c)) {
30                         return (Wvoid *) r;     /* silence the warning */
31                 }
32                 ++r;
33                 --np;
34         }
35
36         return NULL;
37 }
38 #undef np
39
40 libc_hidden_def(Wmemchr)