From ae7403c7e4ed65a3e22188f9a8cdb87d6381284f Mon Sep 17 00:00:00 2001 From: Jeffy Chen Date: Wed, 15 Jun 2022 12:08:39 +0800 Subject: [PATCH 72/72] config-parser: Strip leading spaces Tested with: [core] gbm-format=argb8888 Signed-off-by: Jeffy Chen --- shared/config-parser.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/shared/config-parser.c b/shared/config-parser.c index ef72fe908..8415d8582 100644 --- a/shared/config-parser.c +++ b/shared/config-parser.c @@ -421,7 +421,7 @@ static bool weston_config_parse_fd(struct weston_config *config, int fd) { FILE *fp; - char line[512], *p; + char buf[512], *line, *p; struct stat filestat; struct weston_config_section *section = NULL; int i; @@ -439,10 +439,15 @@ weston_config_parse_fd(struct weston_config *config, int fd) if (fp == NULL) return false; - while (fgets(line, sizeof line, fp)) { + while (fgets(buf, sizeof buf, fp)) { + line = buf; + while (isspace(*line)) + line++; + switch (line[0]) { case '#': case '\n': + case '\0': continue; case '[': p = strchr(&line[1], ']'); -- 2.20.1