hc
2023-05-26 a23f51ed7a39e452c1037343a84d7db1ca2c5bd7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From bae9932b21333438930bfc8c9eeede9eab0f8a8d Mon Sep 17 00:00:00 2001
From: Jeffy Chen <jeffy.chen@rock-chips.com>
Date: Wed, 15 Jun 2022 12:08:39 +0800
Subject: [PATCH 71/76] config-parser: Strip leading spaces
 
Tested with:
[core]
    gbm-format=argb8888
 
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
 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 7df5a3b..fd347ee 100644
--- a/shared/config-parser.c
+++ b/shared/config-parser.c
@@ -423,7 +423,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;
@@ -441,10 +441,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