summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c4aca01)
raw | patch | inline | side by side (parent: c4aca01)
author | Max Kellermann <max.kellermann@gmail.com> | |
Tue, 28 Mar 2017 21:17:19 +0000 (23:17 +0200) | ||
committer | Max Kellermann <max.kellermann@gmail.com> | |
Tue, 28 Mar 2017 21:17:19 +0000 (23:17 +0200) |
src/conf.c | patch | blob | history |
diff --git a/src/conf.c b/src/conf.c
index 496dcab6dc974cc429247fd0ee9fb54a1e9a92a2..ae362f142d67f6363e3eceec352b6afde1f2e254 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
#define CONF_CHAT_PREFIX "chat-prefix"
#define CONF_SECOND_COLUMN "second-column"
+gcc_const
+static bool
+is_space_not_null(char ch)
+{
+ unsigned char uch = (unsigned char)ch;
+ return uch <= 0x20 && uch > 0;
+}
+
+/**
+ * Returns the first non-space character (or a pointer to the null
+ * terminator). Similar to g_strchug(), but just moves the pointer
+ * forward without modifying the string contents.
+ */
+gcc_pure
+static char *
+skip_spaces(char *p)
+{
+ while (is_space_not_null(*p))
+ ++p;
+ return p;
+}
+
static bool
str2bool(char *str)
{
*value++ = 0;
g_strchomp(p);
- return g_strchug(value);
+ return skip_spaces(value);
}
static bool
if (comma != NULL) {
*comma++ = 0;
- comma = g_strchug(comma);
+ comma = skip_spaces(comma);
} else
comma = p + strlen(p);
char line[MAX_LINE_LENGTH];
while (fgets(line, sizeof(line), file) != NULL) {
- char *p = g_strchug(line);
+ char *p = skip_spaces(line);
if (*p != 0 && *p != COMMENT_TOKEN)
parse_line(g_strchomp(p));