mirror of
https://github.com/troglobit/finit.git
synced 2026-11-28 20:58:24 +00:00
Handle tabs in finit.conf better
Should probably be extended to handle any non-space blank character. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
4ede2a93b2
commit
b96d8d3055
1 file changed
+15
-1
@@ -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)
|
static int parse_conf_dynamic(char *file, time_t mtime)
|
||||||
{
|
{
|
||||||
FILE *fp = fopen(file, "r");
|
FILE *fp = fopen(file, "r");
|
||||||
@@ -393,6 +404,7 @@ static int parse_conf_dynamic(char *file, time_t mtime)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
chomp(line);
|
chomp(line);
|
||||||
|
tabstospaces(line);
|
||||||
_d("dyn conf: %s", line);
|
_d("dyn conf: %s", line);
|
||||||
|
|
||||||
parse_dynamic(line, mtime);
|
parse_dynamic(line, mtime);
|
||||||
@@ -438,9 +450,11 @@ static int parse_conf(char *file)
|
|||||||
while (!feof(fp)) {
|
while (!feof(fp)) {
|
||||||
if (!fgets(line, sizeof(line), fp))
|
if (!fgets(line, sizeof(line), fp))
|
||||||
continue;
|
continue;
|
||||||
chomp(line);
|
|
||||||
|
|
||||||
|
chomp(line);
|
||||||
|
tabstospaces(line);
|
||||||
_d("conf: %s", line);
|
_d("conf: %s", line);
|
||||||
|
|
||||||
parse_static(line);
|
parse_static(line);
|
||||||
parse_dynamic(line, 0);
|
parse_dynamic(line, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user