summaryrefslogtreecommitdiff
path: root/string/strsep.c
diff options
context:
space:
mode:
Diffstat (limited to 'string/strsep.c')
-rw-r--r--string/strsep.c29
1 files changed, 5 insertions, 24 deletions
diff --git a/string/strsep.c b/string/strsep.c
index 1054774048..cbd670bee3 100644
--- a/string/strsep.c
+++ b/string/strsep.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -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';
@@ -66,4 +46,5 @@ __strsep (char **stringp, const char *delim)
}
weak_alias (__strsep, strsep)
strong_alias (__strsep, __strsep_g)
+libc_hidden_def (__strsep)
libc_hidden_def (__strsep_g)