1 /* Copyright (c) 2011 Corinna Vinschen <corinna@vinschen.de> */
2 /*
3 FUNCTION
4 <<strchrnul>>---search for character in string
5
6 INDEX
7 strchrnul
8
9 SYNOPSIS
10 #include <string.h>
11 char * strchrnul(const char *<[string]>, int <[c]>);
12
13 DESCRIPTION
14 This function finds the first occurence of <[c]> (converted to
15 a char) in the string pointed to by <[string]> (including the
16 terminating null character).
17
18 RETURNS
19 Returns a pointer to the located character, or a pointer
20 to the concluding null byte if <[c]> does not occur in <[string]>.
21
22 PORTABILITY
23 <<strchrnul>> is a GNU extension.
24
25 <<strchrnul>> requires no supporting OS subroutines. It uses
26 strchr() and strlen() from elsewhere in this library.
27
28 QUICKREF
29 strchrnul
30 */
31
32 #include <string.h>
33
34 char *
strchrnul(const char * s1,int i)35 strchrnul (const char *s1,
36 int i)
37 {
38 char *s = strchr(s1, i);
39
40 return s ? s : (char *)s1 + strlen(s1);
41 }
42