From 4a87185f577d61f51c94e9b158d602460c795330 Mon Sep 17 00:00:00 2001 From: Fabiano Furtado <fabianofurtado <at> gmail <dot> com> Date: Sun, 24 Jul 2022 16:44:31 -0300 Subject: [PATCH] As described in https://archlinux.org/pacman/pacman.conf.5.html#_description, "Comments are only supported by beginning a line with the hash (#) symbol. Comments cannot begin in the middle of a line.". This patch allows comments in the middle of a line. Example: LogFile = /tmp/pacman.log#/var/log/pacman.log
Signed-off-by: Fabiano Furtado <fabianofurtado <at> gmail <dot> com> --- src/common/ini.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/common/ini.c b/src/common/ini.c index 410a2843..4d09d844 100644 --- a/src/common/ini.c +++ b/src/common/ini.c @@ -60,14 +60,22 @@ int parse_ini(const char *file, ini_parser_fn cb, void *data) } while(safe_fgets(line, PATH_MAX, fp)) { - char *key, *value; + char *key, *value, *comment; size_t line_len; linenum++; + if(line[0] == '#') { + continue; + } + + if((comment = strchr(line,'#')) != NULL) { + *comment = '\0'; + } + line_len = strtrim(line); - if(line_len == 0 || line[0] == '#') { + if(line_len == 0) { continue; } -- 2.37.1