fixed str_split

This commit is contained in:
fall-leaf 2023-08-04 14:50:29 +03:00
parent 5f77a905fa
commit 618d178724

View File

@ -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);