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.
This commit is contained in:
Luke Shumaker 2017-02-23 23:05:46 -05:00
parent 446d6afc58
commit b83363e351

View File

@ -198,14 +198,12 @@ char *clean_value(char *value, int line_num)
in_quote = !in_quote; in_quote = !in_quote;
break; break;
case '\\': case '\\':
switch (unparsed[1]) { memmove(unparsed, unparsed + 1, strlen(unparsed));
switch (*unparsed) {
case '\\': case '\\':
case '"': case '"':
memmove(unparsed, unparsed + 1, strlen(unparsed));
unparsed++;
break; break;
default: default:
unparsed++;
fprintf(stderr, fprintf(stderr,
"Warning: invalid config file at line %d\n", "Warning: invalid config file at line %d\n",
line_num); line_num);
@ -214,6 +212,7 @@ char *clean_value(char *value, int line_num)
*unparsed); *unparsed);
return NULL; return NULL;
} }
unparsed++;
break; break;
case '#': case '#':
case ';': case ';':