char **s not needed to get trailing whitespace trimmed,
and rtrim() does not return anything
if there is leading whitespace in *s in call to string_strip(),
there is less chars left to scan in rtrim().
}
static void
-rtrim(char **s)
+rtrim(char *s)
{
- size_t len = strlen(*s);
+ size_t len = strlen(s);
if (!len) {
return;
}
- char *end = *s + len - 1;
- while (end >= *s && isspace(*end)) {
+ char *end = s + len - 1;
+ while (end >= s && isspace(*end)) {
end--;
}
*(end + 1) = '\0';
char *
string_strip(char *s)
{
- rtrim(&s);
while (isspace(*s)) {
s++;
}
+ rtrim(s);
return s;
}