Commit
This commit is contained in:
@ -17,20 +17,26 @@
|
||||
char *
|
||||
strsep_gnu (char **stringp, const char *delim)
|
||||
{
|
||||
char *begin, *end;
|
||||
begin = *stringp;
|
||||
if (begin == NULL)
|
||||
return NULL;
|
||||
/* Find the end of the token. */
|
||||
end = begin + strcspn (begin, delim);
|
||||
if (*end)
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
return strsep(stringp, delim);
|
||||
#endif /* __APPLE__ or __FreeBSD__ */
|
||||
|
||||
#if defined(__linux__)
|
||||
char *begin, *end;
|
||||
begin = *stringp;
|
||||
if (begin == NULL)
|
||||
return NULL;
|
||||
/* Find the end of the token. */
|
||||
end = begin + strcspn (begin, delim);
|
||||
if (*end)
|
||||
{
|
||||
/* Terminate the token and set *STRINGP past NUL character. */
|
||||
*end++ = '\0';
|
||||
*stringp = end;
|
||||
/* Terminate the token and set *STRINGP past NUL character. */
|
||||
*end++ = '\0';
|
||||
*stringp = end;
|
||||
}
|
||||
else
|
||||
/* No more delimiters; this is the last token. */
|
||||
*stringp = NULL;
|
||||
return begin;
|
||||
else
|
||||
/* No more delimiters; this is the last token. */
|
||||
*stringp = NULL;
|
||||
return begin;
|
||||
#endif /* __linux__ */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user