1From 26b2f84053bb90aa3b502802dc89ee0e3f4e9532 Mon Sep 17 00:00:00 2001
2From: Jeffy Chen <jeffy.chen@rock-chips.com>
3Date: Wed, 15 Jun 2022 12:08:39 +0800
4Subject: [PATCH 71/79] config-parser: Strip leading spaces
5
6Tested with:
7[core]
8    gbm-format=argb8888
9
10Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
11---
12 shared/config-parser.c | 9 +++++++--
13 1 file changed, 7 insertions(+), 2 deletions(-)
14
15diff --git a/shared/config-parser.c b/shared/config-parser.c
16index 7df5a3b..fd347ee 100644
17--- a/shared/config-parser.c
18+++ b/shared/config-parser.c
19@@ -423,7 +423,7 @@ static bool
20 weston_config_parse_fd(struct weston_config *config, int fd)
21 {
22 	FILE *fp;
23-	char line[512], *p;
24+	char buf[512], *line, *p;
25 	struct stat filestat;
26 	struct weston_config_section *section = NULL;
27 	int i;
28@@ -441,10 +441,15 @@ weston_config_parse_fd(struct weston_config *config, int fd)
29 	if (fp == NULL)
30 		return false;
31
32-	while (fgets(line, sizeof line, fp)) {
33+	while (fgets(buf, sizeof buf, fp)) {
34+		line = buf;
35+		while (isspace(*line))
36+			line++;
37+
38 		switch (line[0]) {
39 		case '#':
40 		case '\n':
41+		case '\0':
42 			continue;
43 		case '[':
44 			p = strchr(&line[1], ']');
45--
462.20.1
47
48