1/*
2   SYNOPSIS
3       #include <string.h>
4
5       char *strchr(char const *s, int c);
6
7       char *strrchr(char const *s, int c);
8
9   DESCRIPTION
10       The  strchr() function returns a pointer to the first occurrence of the
11       character c in the string s.
12
13       The strrchr() function returns a pointer to the last occurrence of  the
14       character c in the string s.
15
16       Here  "character"  means "byte" - these functions do not work with wide
17       or multi-byte characters.
18
19   RETURN VALUE
20       The strchr() and strrchr() functions return a pointer  to  the  matched
21       character or NULL if the character is not found.
22
23   CONFORMING TO
24       SVID 3, POSIX, BSD 4.3, ISO 9899
25*/
26
27char*
28strchr( char const *s, int c)
29{
30    do {
31        if ((unsigned)*s == (unsigned)c)
32            return s;
33
34    } while (*(++s) != NUL);
35
36    return NULL;
37}
38
39char*
40strrchr( char const *s, int c)
41{
42    char const *e = s + strlen(s);
43
44    for (;;) {
45        if (--e < s)
46            break;
47
48        if ((unsigned)*e == (unsigned)c)
49            return e;
50    }
51    return NULL;
52}
53
54/*
55 * Local Variables:
56 * mode: C
57 * c-file-style: "stroustrup"
58 * indent-tabs-mode: nil
59 * End:
60 * end of compat/strsignal.c */
61