Mercurial > hg > th-libs
comparison th_string.c @ 701:d687bbb54c1a
Add th_strpbrk().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 10 Mar 2020 21:06:09 +0200 |
parents | 9bbacd72df3d |
children | 5653e386730b |
comparison
equal
deleted
inserted
replaced
700:ec8fe89576ff | 701:d687bbb54c1a |
---|---|
21 { | 21 { |
22 for (th_char_t *p = (th_char_t *) str; *p; p++) | 22 for (th_char_t *p = (th_char_t *) str; *p; p++) |
23 { | 23 { |
24 if (*p == ch) | 24 if (*p == ch) |
25 return p; | 25 return p; |
26 } | |
27 return NULL; | |
28 } | |
29 | |
30 | |
31 /** | |
32 * Implementation of strpbrk() for th_char_t. | |
33 * @param[in] src string to find any th_char_t in @p valid from | |
34 * @returns pointer to the match position, NULL if no match found | |
35 */ | |
36 th_char_t *th_strpbrk(const th_char_t *str, const th_char_t *valid) | |
37 { | |
38 for (th_char_t *p = (th_char_t *) str; *p; p++) | |
39 { | |
40 for (const th_char_t *ch = valid; *valid; valid++) | |
41 { | |
42 if (*p == *ch) | |
43 return p; | |
44 } | |
26 } | 45 } |
27 return NULL; | 46 return NULL; |
28 } | 47 } |
29 | 48 |
30 | 49 |