|
|
@ -78,12 +78,10 @@ int lenient_strcmp(char *a, char *b) {
|
|
|
|
list_t *split_string(const char *str, const char *delims) {
|
|
|
|
list_t *split_string(const char *str, const char *delims) {
|
|
|
|
list_t *res = create_list();
|
|
|
|
list_t *res = create_list();
|
|
|
|
char *copy = strdup(str);
|
|
|
|
char *copy = strdup(str);
|
|
|
|
char *token;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
token = strtok(copy, delims);
|
|
|
|
char *token = strtok(copy, delims);
|
|
|
|
while (token) {
|
|
|
|
while (token) {
|
|
|
|
token = strdup(token);
|
|
|
|
list_add(res, strdup(token));
|
|
|
|
list_add(res, token);
|
|
|
|
|
|
|
|
token = strtok(NULL, delims);
|
|
|
|
token = strtok(NULL, delims);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(copy);
|
|
|
|
free(copy);
|
|
|
@ -268,13 +266,13 @@ char *argsep(char **stringp, const char *delim) {
|
|
|
|
escaped = !escaped;
|
|
|
|
escaped = !escaped;
|
|
|
|
} else if (*end == '\0') {
|
|
|
|
} else if (*end == '\0') {
|
|
|
|
*stringp = NULL;
|
|
|
|
*stringp = NULL;
|
|
|
|
goto found;
|
|
|
|
break;
|
|
|
|
} else if (!in_string && !in_char && !escaped && strchr(delim, *end)) {
|
|
|
|
} else if (!in_string && !in_char && !escaped && strchr(delim, *end)) {
|
|
|
|
if (end - start) {
|
|
|
|
if (end - start) {
|
|
|
|
*(end++) = 0;
|
|
|
|
*(end++) = 0;
|
|
|
|
*stringp = end + strspn(end, delim);;
|
|
|
|
*stringp = end + strspn(end, delim);;
|
|
|
|
if (!**stringp) *stringp = NULL;
|
|
|
|
if (!**stringp) *stringp = NULL;
|
|
|
|
goto found;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
++start;
|
|
|
|
++start;
|
|
|
|
end = start;
|
|
|
|
end = start;
|
|
|
@ -285,6 +283,5 @@ char *argsep(char **stringp, const char *delim) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++end;
|
|
|
|
++end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
found:
|
|
|
|
|
|
|
|
return start;
|
|
|
|
return start;
|
|
|
|
}
|
|
|
|
}
|
|
|
|