1181834Sroberto/*
2181834Sroberto   SYNOPSIS
3181834Sroberto       #include <string.h>
4181834Sroberto
5181834Sroberto       char *strchr(char const *s, int c);
6181834Sroberto
7181834Sroberto       char *strrchr(char const *s, int c);
8181834Sroberto
9181834Sroberto   DESCRIPTION
10181834Sroberto       The  strchr() function returns a pointer to the first occurrence of the
11181834Sroberto       character c in the string s.
12181834Sroberto
13181834Sroberto       The strrchr() function returns a pointer to the last occurrence of  the
14181834Sroberto       character c in the string s.
15181834Sroberto
16181834Sroberto       Here  "character"  means "byte" - these functions do not work with wide
17181834Sroberto       or multi-byte characters.
18181834Sroberto
19181834Sroberto   RETURN VALUE
20181834Sroberto       The strchr() and strrchr() functions return a pointer  to  the  matched
21181834Sroberto       character or NULL if the character is not found.
22181834Sroberto
23181834Sroberto   CONFORMING TO
24181834Sroberto       SVID 3, POSIX, BSD 4.3, ISO 9899
25181834Sroberto*/
26181834Sroberto
27280849Scystatic char *
28280849Scystrchr(char const *s, int c);
29280849Scy
30280849Scystatic char *
31280849Scystrrchr(char const *s, int c);
32280849Scy
33280849Scystatic char *
34280849Scystrchr(char const *s, int c)
35181834Sroberto{
36181834Sroberto    do {
37280849Scy        if ((unsigned char)*s == (unsigned char)c)
38181834Sroberto            return s;
39181834Sroberto
40181834Sroberto    } while (*(++s) != NUL);
41181834Sroberto
42181834Sroberto    return NULL;
43181834Sroberto}
44181834Sroberto
45280849Scystatic char *
46280849Scystrrchr(char const *s, int c)
47181834Sroberto{
48181834Sroberto    char const *e = s + strlen(s);
49181834Sroberto
50181834Sroberto    for (;;) {
51181834Sroberto        if (--e < s)
52181834Sroberto            break;
53181834Sroberto
54280849Scy        if ((unsigned char)*e == (unsigned char)c)
55181834Sroberto            return e;
56181834Sroberto    }
57181834Sroberto    return NULL;
58181834Sroberto}
59181834Sroberto
60181834Sroberto/*
61181834Sroberto * Local Variables:
62181834Sroberto * mode: C
63181834Sroberto * c-file-style: "stroustrup"
64181834Sroberto * indent-tabs-mode: nil
65181834Sroberto * End:
66181834Sroberto * end of compat/strsignal.c */
67