diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/stringop.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/common/stringop.c b/common/stringop.c index b42604c1..dea152cc 100644 --- a/common/stringop.c +++ b/common/stringop.c | |||
@@ -78,12 +78,10 @@ int lenient_strcmp(char *a, char *b) { | |||
78 | list_t *split_string(const char *str, const char *delims) { | 78 | list_t *split_string(const char *str, const char *delims) { |
79 | list_t *res = create_list(); | 79 | list_t *res = create_list(); |
80 | char *copy = strdup(str); | 80 | char *copy = strdup(str); |
81 | char *token; | ||
82 | 81 | ||
83 | token = strtok(copy, delims); | 82 | char *token = strtok(copy, delims); |
84 | while(token) { | 83 | while (token) { |
85 | token = strdup(token); | 84 | list_add(res, strdup(token)); |
86 | list_add(res, token); | ||
87 | token = strtok(NULL, delims); | 85 | token = strtok(NULL, delims); |
88 | } | 86 | } |
89 | free(copy); | 87 | free(copy); |
@@ -268,13 +266,13 @@ char *argsep(char **stringp, const char *delim) { | |||
268 | escaped = !escaped; | 266 | escaped = !escaped; |
269 | } else if (*end == '\0') { | 267 | } else if (*end == '\0') { |
270 | *stringp = NULL; | 268 | *stringp = NULL; |
271 | goto found; | 269 | break; |
272 | } else if (!in_string && !in_char && !escaped && strchr(delim, *end)) { | 270 | } else if (!in_string && !in_char && !escaped && strchr(delim, *end)) { |
273 | if (end - start) { | 271 | if (end - start) { |
274 | *(end++) = 0; | 272 | *(end++) = 0; |
275 | *stringp = end + strspn(end, delim);; | 273 | *stringp = end + strspn(end, delim);; |
276 | if (!**stringp) *stringp = NULL; | 274 | if (!**stringp) *stringp = NULL; |
277 | goto found; | 275 | break; |
278 | } else { | 276 | } else { |
279 | ++start; | 277 | ++start; |
280 | end = start; | 278 | end = start; |
@@ -285,6 +283,5 @@ char *argsep(char **stringp, const char *delim) { | |||
285 | } | 283 | } |
286 | ++end; | 284 | ++end; |
287 | } | 285 | } |
288 | found: | ||
289 | return start; | 286 | return start; |
290 | } | 287 | } |