string.c: rework strtok again
This commit is contained in:
parent
08b54c22f5
commit
9476b3f810
2 changed files with 9 additions and 9 deletions
17
lib/string.c
17
lib/string.c
|
|
@ -122,21 +122,20 @@ char *strchr(const char *s, int c)
|
|||
|
||||
char *strtok(char *str, const char *delim, char **llast)
|
||||
{
|
||||
char *last = *llast;
|
||||
if (str)
|
||||
last = str;
|
||||
(*llast) = str;
|
||||
|
||||
if (!last)
|
||||
if (!(*llast))
|
||||
return NULL;
|
||||
|
||||
char *ret = last;
|
||||
while (*last) {
|
||||
if (strchr(delim, *last)) {
|
||||
*last = 0;
|
||||
last++;
|
||||
char *ret = (*llast);
|
||||
while (*(*llast)) {
|
||||
if (strchr(delim, *(*llast))) {
|
||||
*(*llast) = 0;
|
||||
(*llast)++;
|
||||
return ret;
|
||||
}
|
||||
last++;
|
||||
(*llast)++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Reference in a new issue