From b96d8d305508bdf84c764fc53c332452b3707bab Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Thu, 28 Jul 2016 23:27:44 +0200 Subject: [PATCH] Handle tabs in finit.conf better Should probably be extended to handle any non-space blank character. Signed-off-by: Joachim Nilsson --- conf.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/conf.c b/conf.c index 54ac50fb..aa9e9ecf 100644 --- a/conf.c +++ b/conf.c @@ -377,6 +377,17 @@ static void parse_dynamic(char *line, time_t mtime) } } +static void tabstospaces(char *line) +{ + if (!line) + return; + + for (int i = 0; line[i]; i++) { + if (line[i] == '\t') + line[i] = ' '; + } +} + static int parse_conf_dynamic(char *file, time_t mtime) { FILE *fp = fopen(file, "r"); @@ -393,6 +404,7 @@ static int parse_conf_dynamic(char *file, time_t mtime) continue; chomp(line); + tabstospaces(line); _d("dyn conf: %s", line); parse_dynamic(line, mtime); @@ -438,9 +450,11 @@ static int parse_conf(char *file) while (!feof(fp)) { if (!fgets(line, sizeof(line), fp)) continue; - chomp(line); + chomp(line); + tabstospaces(line); _d("conf: %s", line); + parse_static(line); parse_dynamic(line, 0); }