From 6aeafc6651766ef8918c47bf6e478a467d27229d Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 12 Jan 2020 22:44:41 +1100 Subject: [PATCH] [common] add comment support to the ini parser --- VERSION | 2 +- common/src/option.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 1cefca16..c9eb49ab 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-84-g7de030bb69+1 \ No newline at end of file +B1-85-g1aadf91901+1 \ No newline at end of file diff --git a/common/src/option.c b/common/src/option.c index 0121198d..39314a28 100644 --- a/common/src/option.c +++ b/common/src/option.c @@ -367,6 +367,7 @@ bool option_load(const char * filename) int lineno = 1; char * module = NULL; bool line = true; + bool comment = false; bool expectLine = false; bool expectValue = false; char * name = NULL; @@ -379,6 +380,9 @@ bool option_load(const char * filename) for(int c = fgetc(fp); !feof(fp); c = fgetc(fp)) { + if (comment && c != '\n') + continue; + switch(c) { case '[': @@ -477,6 +481,14 @@ bool option_load(const char * filename) (*p)[(*len)++] = c; break; + case ';': + if (line) + { + comment = true; + break; + } + // fallthrough + default: if (expectLine) {