mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
28 lines
330 B
C
28 lines
330 B
C
|
|
#include <ctype.h>
|
||
|
|
#include <stdio.h>
|
||
|
|
#include <string.h>
|
||
|
|
|
||
|
|
static void
|
||
|
|
rtrim(char **s)
|
||
|
|
{
|
||
|
|
size_t len = strlen(*s);
|
||
|
|
if (!len) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
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++;
|
||
|
|
}
|
||
|
|
return s;
|
||
|
|
}
|