From fadbfd4c136a2bae29922e3a3669a8db85b1baac Mon Sep 17 00:00:00 2001 From: Scoopta Date: Sun, 26 Jan 2020 00:21:29 -0800 Subject: [PATCH] Backslashes are no longer removed from the config completely but can now be escaped with \\ --- src/config.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/config.c b/src/config.c index 197114a..5d025dd 100644 --- a/src/config.c +++ b/src/config.c @@ -25,17 +25,12 @@ void config_put(struct map* map, char* line) { *hash = 0; } } - char* backslash = strchr(line, '\\'); - size_t backslash_count = 0; - while(backslash != NULL) { - ++backslash_count; - backslash = strchr(backslash + 1, '\\'); - } + size_t line_size = strlen(line); - char* new_line = calloc(1, line_size + 1 - backslash_count); + 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] == '\\') { + if(line[count] == '\\' && line[count + 1] != '\\') { continue; } new_line[new_line_count++] = line[count];