From b83363e351d2ced3728e51f622eac5bf6c895902 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 23 Feb 2017 23:05:46 -0500 Subject: [PATCH] option_parser: Simplify backslash code. Treating unrecognized sequences as invalid means that the backslash itself is never propagated; so we can hoist the handling of it outside of the switch; simplifying the code a bit. --- src/option_parser.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/option_parser.c b/src/option_parser.c index 33b9a06..91de826 100644 --- a/src/option_parser.c +++ b/src/option_parser.c @@ -198,14 +198,12 @@ char *clean_value(char *value, int line_num) in_quote = !in_quote; break; case '\\': - switch (unparsed[1]) { + memmove(unparsed, unparsed + 1, strlen(unparsed)); + switch (*unparsed) { case '\\': case '"': - memmove(unparsed, unparsed + 1, strlen(unparsed)); - unparsed++; break; default: - unparsed++; fprintf(stderr, "Warning: invalid config file at line %d\n", line_num); @@ -214,6 +212,7 @@ char *clean_value(char *value, int line_num) *unparsed); return NULL; } + unparsed++; break; case '#': case ';':