aboutsummaryrefslogtreecommitdiff
path: root/string/strsep.c
diff options
context:
space:
mode:
Diffstat (limited to 'string/strsep.c')
-rw-r--r--string/strsep.c26
1 files changed, 3 insertions, 23 deletions
diff --git a/string/strsep.c b/string/strsep.c
index 1054774..68581c8 100644
--- a/string/strsep.c
+++ b/string/strsep.c
@@ -29,30 +29,10 @@ __strsep (char **stringp, const char *delim)
if (begin == NULL)
return NULL;
- /* A frequent case is when the delimiter string contains only one
- character. Here we don't need to call the expensive `strpbrk'
- function and instead work using `strchr'. */
- if (delim[0] == '\0' || delim[1] == '\0')
- {
- char ch = delim[0];
-
- if (ch == '\0')
- end = NULL;
- else
- {
- if (*begin == ch)
- end = begin;
- else if (*begin == '\0')
- end = NULL;
- else
- end = strchr (begin + 1, ch);
- }
- }
- else
- /* Find the end of the token. */
- end = strpbrk (begin, delim);
+ /* Find the end of the token. */
+ end = begin + strcspn (begin, delim);
- if (end)
+ if (*end)
{
/* Terminate the token and set *STRINGP past NUL character. */
*end++ = '\0';