diff --git a/src/parse.c b/src/parse.c index 7ee7e07..e371f75 100644 --- a/src/parse.c +++ b/src/parse.c @@ -79,10 +79,10 @@ str_split(char const * s, char c) for (i = 1; s[i]; ++i) { - if (s[i] == c && s[i - 1] != c) + if ((s[i + 1] == c || !s[i + 1]) && s[i] != c) { /* end of a token*/ - ret[current_token_i] = strndup(s + token_start_i, i - token_start_i); + ret[current_token_i] = strndup(s + token_start_i, i - token_start_i + 1); if (!ret[current_token_i]) { split_clean(ret);