lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2002 Manuel Novoa III |
| 3 | * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> |
| 4 | * |
| 5 | * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. |
| 6 | */ |
| 7 | |
| 8 | #include "_string.h" |
| 9 | |
| 10 | #ifdef __USE_BSD |
| 11 | |
| 12 | |
| 13 | char *strsep(char ** __restrict s1, const char * __restrict s2) |
| 14 | { |
| 15 | register char *s = *s1; |
| 16 | register char *p; |
| 17 | |
| 18 | #if 1 |
| 19 | p = NULL; |
| 20 | if (s && *s && (p = strpbrk(s, s2))) { |
| 21 | *p++ = 0; |
| 22 | } |
| 23 | #else |
| 24 | if (s && *s && *(p = s + strcspn(s, s2))) { |
| 25 | *p++ = 0; |
| 26 | } else { |
| 27 | p = NULL; |
| 28 | } |
| 29 | #endif |
| 30 | *s1 = p; |
| 31 | return s; |
| 32 | } |
| 33 | libc_hidden_def(strsep) |
| 34 | #endif |