From f4c3d1318dd3c62a5af4099ef7624f49b5b2a4b4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Tue, 21 Nov 2023 10:57:01 -0500 Subject: Bugfix: Test for a comment first, then act accordingly, instead of testing only when a variable is being read --- src/ini.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ini.c b/src/ini.c index 0b61b1b..e34088e 100644 --- a/src/ini.c +++ b/src/ini.c @@ -273,9 +273,9 @@ struct INIFILE *ini_open(const char *filename) { } } // Find pointer to first comment character - if (!reading_value) { - char *comment = strpbrk(line, ";#"); - if (comment) { + char *comment = strpbrk(line, ";#"); + if (comment) { + if (!reading_value || line - comment == 0) { // Remove comment from line (standalone and inline comments) if (!((comment - line > 0 && (*(comment - 1) == '\\')) || (*comment - 1) == '#')) { *comment = '\0'; -- cgit