From 935031e8f559f06d5d9880707dfa96168a145e7d Mon Sep 17 00:00:00 2001 From: kitsunyan Date: Sun, 3 Jun 2018 03:40:48 +0300 Subject: Recognize comments only at the beginning of line in config file --- src/config.nim | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/config.nim b/src/config.nim index be27291..f391884 100644 --- a/src/config.nim +++ b/src/config.nim @@ -61,14 +61,8 @@ proc readConfigFile*(configFile: string): var matches: array[2, string] while true: - let rawLine = readLine(file).strip(leading = false, trailing = true) - let commentIndex = rawLine.find('#') - let line = if commentIndex >= 0: - rawLine[0 .. commentIndex - 1].strip(leading = false, trailing = true) - else: - rawLine - - if line.len > 0: + let line = readLine(file).strip(leading = false, trailing = true) + if line.len > 0 and line[0] != '#': if line.match(re"\[(.*)\]", matches): currentCategory = matches[0] if table.hasKey(currentCategory): -- cgit v1.2.3-70-g09d2