xref: /OK3568_Linux_fs/buildroot/package/weston/0048-config-parser-Strip-leading-spaces.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From 166f76a549f570e70f0fbfaf143487ca7d649b2e 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 48/93] 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 e474963..e5195bd 100644
17--- a/shared/config-parser.c
18+++ b/shared/config-parser.c
19@@ -426,13 +426,18 @@ weston_config_parse_internal(struct weston_config *config, FILE *fp,
20 			     const char *file_name)
21 {
22 	struct weston_config_section *section = NULL;
23-	char line[512], *p;
24+	char buf[512], *line, *p;
25 	int i;
26
27-	while (fgets(line, sizeof line, fp)) {
28+	while (fgets(buf, sizeof buf, fp)) {
29+		line = buf;
30+		while (isspace(*line))
31+			line++;
32+
33 		switch (line[0]) {
34 		case '#':
35 		case '\n':
36+		case '\0':
37 			continue;
38 		case '[':
39 			p = strchr(&line[1], ']');
40--
412.20.1
42
43