mirror of
https://github.com/labwc/labwc.git
synced 2026-02-15 22:05:25 -05:00
Add string-helpers.c
This commit is contained in:
parent
51507df2e7
commit
7e55e2cd09
6 changed files with 47 additions and 54 deletions
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "common/dir.h"
|
||||
#include "common/log.h"
|
||||
#include "common/string-helpers.h"
|
||||
#include "theme/theme.h"
|
||||
|
||||
static int
|
||||
|
|
@ -67,30 +68,6 @@ static void entry(const char *key, const char *value)
|
|||
}
|
||||
/* clang-format on */
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
static char *
|
||||
strstrip(char *s)
|
||||
{
|
||||
rtrim(&s);
|
||||
while (isspace(*s)) {
|
||||
s++;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
static void
|
||||
parse_config_line(char *line, char **key, char **value)
|
||||
{
|
||||
|
|
@ -99,8 +76,8 @@ parse_config_line(char *line, char **key, char **value)
|
|||
return;
|
||||
}
|
||||
*p = '\0';
|
||||
*key = strstrip(line);
|
||||
*value = strstrip(++p);
|
||||
*key = string_strip(line);
|
||||
*value = string_strip(++p);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue