|
@ -40,11 +40,10 @@ strtok(char *s, const char *delim) |
|
|
char * |
|
|
char * |
|
|
strtok_r(char *s, const char *delim, char **last) |
|
|
strtok_r(char *s, const char *delim, char **last) |
|
|
{ |
|
|
{ |
|
|
char *spanp; |
|
|
|
|
|
|
|
|
const char *spanp; |
|
|
int c, sc; |
|
|
int c, sc; |
|
|
char *tok; |
|
|
char *tok; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (s == NULL && (s = *last) == NULL) |
|
|
if (s == NULL && (s = *last) == NULL) |
|
|
return (NULL); |
|
|
return (NULL); |
|
|
|
|
|
|
|
@ -53,7 +52,7 @@ strtok_r(char *s, const char *delim, char **last) |
|
|
*/ |
|
|
*/ |
|
|
cont: |
|
|
cont: |
|
|
c = *s++; |
|
|
c = *s++; |
|
|
for (spanp = (char *)delim; (sc = *spanp++) != 0;) { |
|
|
|
|
|
|
|
|
for (spanp = delim; (sc = *spanp++) != 0;) { |
|
|
if (c == sc) |
|
|
if (c == sc) |
|
|
goto cont; |
|
|
goto cont; |
|
|
} |
|
|
} |
|
@ -70,13 +69,13 @@ cont: |
|
|
*/ |
|
|
*/ |
|
|
for (;;) { |
|
|
for (;;) { |
|
|
c = *s++; |
|
|
c = *s++; |
|
|
spanp = (char *)delim; |
|
|
|
|
|
|
|
|
spanp = delim; |
|
|
do { |
|
|
do { |
|
|
if ((sc = *spanp++) == c) { |
|
|
if ((sc = *spanp++) == c) { |
|
|
if (c == 0) |
|
|
if (c == 0) |
|
|
s = NULL; |
|
|
s = NULL; |
|
|
else |
|
|
else |
|
|
s[-1] = 0; |
|
|
|
|
|
|
|
|
s[-1] = '\0'; |
|
|
*last = s; |
|
|
*last = s; |
|
|
return (tok); |
|
|
return (tok); |
|
|
} |
|
|
} |
|
|