fixup! stringop.c: rewrite strip_whitespace

This commit is contained in:
Ian Fan 2019-01-02 18:47:22 +00:00
parent bd35879e1c
commit 5bef06adfd

View File

@ -16,10 +16,10 @@ void strip_whitespace(char *str) {
size_t start = strspn(str, whitespace); size_t start = strspn(str, whitespace);
memmove(str, &str[start], len + 1 - start); memmove(str, &str[start], len + 1 - start);
if (!*str) return; if (*str) {
for (len -= start + 1; isspace(str[len]); --len) {}
for (len -= start + 1; isspace(str[len]); --len) {} str[len + 1] = '\0';
str[len + 1] = '\0'; }
} }
void strip_quotes(char *str) { void strip_quotes(char *str) {