mirror of
https://github.com/labwc/labwc.git
synced 2026-03-08 05:33:52 -04:00
string-helpers: rtrim() with just char *s, call it later in string_strip
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().
This commit is contained in:
parent
75eb370d31
commit
84ba60f453
1 changed files with 5 additions and 5 deletions
|
|
@ -30,14 +30,14 @@ trim_last_field(char *buf, char delim)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rtrim(char **s)
|
rtrim(char *s)
|
||||||
{
|
{
|
||||||
size_t len = strlen(*s);
|
size_t len = strlen(s);
|
||||||
if (!len) {
|
if (!len) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char *end = *s + len - 1;
|
char *end = s + len - 1;
|
||||||
while (end >= *s && isspace(*end)) {
|
while (end >= s && isspace(*end)) {
|
||||||
end--;
|
end--;
|
||||||
}
|
}
|
||||||
*(end + 1) = '\0';
|
*(end + 1) = '\0';
|
||||||
|
|
@ -46,10 +46,10 @@ rtrim(char **s)
|
||||||
char *
|
char *
|
||||||
string_strip(char *s)
|
string_strip(char *s)
|
||||||
{
|
{
|
||||||
rtrim(&s);
|
|
||||||
while (isspace(*s)) {
|
while (isspace(*s)) {
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
rtrim(s);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue