From d95c04945fc85bcc584026f7fded57dc8724ba6a Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Thu, 22 Dec 2011 17:46:47 +1000 Subject: Allow comments after repo section header in pacman.conf Pacman assumes that the final character of a line specifing a repo in pacman.conf is a "]". But it did not clean whitespace from the line after removing any comments. So lines like: [allanbrokeit] # could break system caused pacman not to recognize the repo. Adjust config parsing to strip comments before trimming whitespace from the end of the string. Signed-off-by: Allan McRae Signed-off-by: Dan McGee --- src/pacman/conf.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/pacman/conf.c') diff --git a/src/pacman/conf.c b/src/pacman/conf.c index a4d115dd..a9f0de91 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -719,17 +719,19 @@ static int _parseconfig(const char *file, struct section_t *section, size_t line_len; linenum++; - strtrim(line); - line_len = strlen(line); /* ignore whole line and end of line comments */ - if(line_len == 0 || line[0] == '#') { - continue; - } if((ptr = strchr(line, '#'))) { *ptr = '\0'; } + strtrim(line); + line_len = strlen(line); + + if(line_len == 0) { + continue; + } + if(line[0] == '[' && line[line_len - 1] == ']') { char *name; /* only possibility here is a line == '[]' */ -- cgit v1.2.3-70-g09d2