mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Slightly improved version of mystrtok_r
This commit is contained in:
parent
69ba485415
commit
9d69b38583
@ -50,7 +50,6 @@ size_t curl_write_data(char *ptr, size_t size, size_t nmemb, void *userdata) {
|
|||||||
|
|
||||||
char *mystrtok_r(char *s, const char *sep, char **lasts) {
|
char *mystrtok_r(char *s, const char *sep, char **lasts) {
|
||||||
char *t;
|
char *t;
|
||||||
int delim_reached;
|
|
||||||
|
|
||||||
if (!s)
|
if (!s)
|
||||||
s = *lasts;
|
s = *lasts;
|
||||||
@ -61,15 +60,11 @@ char *mystrtok_r(char *s, const char *sep, char **lasts) {
|
|||||||
if (!*s)
|
if (!*s)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
delim_reached = 0;
|
|
||||||
t = s;
|
t = s;
|
||||||
while (*t) {
|
while (*t) {
|
||||||
if (strchr(sep, *t)) {
|
if (strchr(sep, *t)) {
|
||||||
*t = '\0';
|
*t++ = '\0';
|
||||||
delim_reached = 1;
|
break;
|
||||||
} else if (delim_reached) {
|
|
||||||
*lasts = t;
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
t++;
|
t++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user