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:
parent
446d6afc58
commit
b83363e351
@ -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 ';':
|
||||
|
Loading…
x
Reference in New Issue
Block a user