string: fix strtok detecting NUL only after separators

This commit is contained in:
Lephenixnoir 2021-08-17 17:30:21 +02:00
parent ea35c18c41
commit a0ceeefaf4
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495

View file

@ -12,7 +12,7 @@ char *strtok(char * restrict new_s, char const * restrict separators)
/* Skip non-delimiters */
char *token = s;
s += strcspn(s, separators);
*s++ = 0;
if(*s) *s++ = 0;
return token;
}