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 #define _GNU_SOURCE
33 #include <string.h>
34
35 char *
strchrnul(const char * s1,int i)36 strchrnul (const char *s1,
37 int i)
38 {
39 char *s = strchr(s1, i);
40
41 return s ? s : (char *)s1 + strlen(s1);
42 }
43