* modules/string (string.h): Also substitute GNULIB_MBSSEP.
* MODULES.html.sh (Internationalization functions): Add mbssep.
+2007-02-05 Bruno Haible <bruno@clisp.org>
+
+ * lib/strsep.c (strsep): Fix actions in case of no delimiters.
+ Optimize search in case of 1 delimiter.
+
2007-02-05 Paolo Bonzini <bonzini@gnu.org>
* lib/acl.h: Include sys/types.h before sys/acl.h.
char *start = *stringp;
char *ptr;
- if (!start)
+ if (start == NULL)
return NULL;
- if (!*delim)
- ptr = start + strlen (start);
+ /* Optimize the case of no delimiters. */
+ if (delim[0] == '\0')
+ {
+ *stringp = NULL;
+ return start;
+ }
+
+ /* Optimize the case of one delimiter. */
+ if (delim[1] == '\0')
+ ptr = strchr (start, delim[0]);
else
+ /* The general case. */
+ ptr = strpbrk (start, delim);
+ if (ptr == NULL)
{
- ptr = strpbrk (start, delim);
- if (!ptr)
- {
- *stringp = NULL;
- return start;
- }
+ *stringp = NULL;
+ return start;
}
*ptr = '\0';