Add 'line' as a configuration parsing primitive

…and use it for ignoring comment lines, so that quotes in them
doesn't cause problems anymore.
This commit is contained in:
Eelis van der Weegen 2013-04-01 14:42:41 +02:00 committed by Michael Stapelberg
parent 82b59788ac
commit 7f5a18e093
2 changed files with 14 additions and 4 deletions

View File

@ -49,7 +49,7 @@ state INITIAL:
# We ignore comments and 'set' lines (variables). # We ignore comments and 'set' lines (variables).
state IGNORE_LINE: state IGNORE_LINE:
end, string line
-> INITIAL -> INITIAL
# floating_minimum_size <width> x <height> # floating_minimum_size <width> x <height>
@ -311,7 +311,7 @@ state MODE:
# We ignore comments and 'set' lines (variables). # We ignore comments and 'set' lines (variables).
state MODE_IGNORE_LINE: state MODE_IGNORE_LINE:
end, string line
-> MODE -> MODE
state MODE_BINDING: state MODE_BINDING:
@ -362,7 +362,7 @@ state BAR:
# We ignore comments and 'set' lines (variables). # We ignore comments and 'set' lines (variables).
state BAR_IGNORE_LINE: state BAR_IGNORE_LINE:
end, string line
-> BAR -> BAR
state BAR_BAR_COMMAND: state BAR_BAR_COMMAND:
@ -428,7 +428,7 @@ state BAR_COLORS:
# We ignore comments and 'set' lines (variables). # We ignore comments and 'set' lines (variables).
state BAR_COLORS_IGNORE_LINE: state BAR_COLORS_IGNORE_LINE:
end, string line
-> BAR_COLORS -> BAR_COLORS
state BAR_COLORS_SINGLE: state BAR_COLORS_SINGLE:

View File

@ -446,6 +446,16 @@ struct ConfigResult *parse_config(const char *input, struct context *context) {
} }
} }
if (strcmp(token->name, "line") == 0) {
while (*walk != '\0' && *walk != '\n' && *walk != '\r')
walk++;
next_state(token);
token_handled = true;
linecnt++;
walk++;
break;
}
if (strcmp(token->name, "end") == 0) { if (strcmp(token->name, "end") == 0) {
//printf("checking for end: *%s*\n", walk); //printf("checking for end: *%s*\n", walk);
if (*walk == '\0' || *walk == '\n' || *walk == '\r') { if (*walk == '\0' || *walk == '\n' || *walk == '\r') {