From 684a5adf95a56105469092b1612d8497e5ada040 Mon Sep 17 00:00:00 2001 From: Scoopta Date: Sun, 26 Jan 2020 00:44:24 -0800 Subject: [PATCH] Fixed up config parsing --- src/config.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/config.c b/src/config.c index 5d025dd..7c90862 100644 --- a/src/config.c +++ b/src/config.c @@ -18,24 +18,18 @@ #include void config_put(struct map* map, char* line) { - line = strdup(line); - char* hash = strchr(line, '#'); - if(hash != NULL) { - if(hash == line || *(hash - 1) != '\\') { - *hash = 0; - } - } - size_t line_size = strlen(line); char* new_line = calloc(1, line_size + 1); size_t new_line_count = 0; for(size_t count = 0; count < line_size; ++count) { - if(line[count] == '\\' && line[count + 1] != '\\') { - continue; + if(line[count] == '\\') { + new_line[new_line_count++] = line[++count]; + } else if(line[count] == '#') { + break; + } else { + new_line[new_line_count++] = line[count]; } - new_line[new_line_count++] = line[count]; } - free(line); line = new_line; char* equals = strchr(line, '='); if(equals == NULL) {