From 7f5a18e093e8734e182bdb60f178324795e950f6 Mon Sep 17 00:00:00 2001 From: Eelis van der Weegen Date: Mon, 1 Apr 2013 14:42:41 +0200 Subject: [PATCH] Add 'line' as a configuration parsing primitive MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit …and use it for ignoring comment lines, so that quotes in them doesn't cause problems anymore. --- parser-specs/config.spec | 8 ++++---- src/config_parser.c | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/parser-specs/config.spec b/parser-specs/config.spec index 6960510d..c6328a0e 100644 --- a/parser-specs/config.spec +++ b/parser-specs/config.spec @@ -49,7 +49,7 @@ state INITIAL: # We ignore comments and 'set' lines (variables). state IGNORE_LINE: - end, string + line -> INITIAL # floating_minimum_size x @@ -311,7 +311,7 @@ state MODE: # We ignore comments and 'set' lines (variables). state MODE_IGNORE_LINE: - end, string + line -> MODE state MODE_BINDING: @@ -362,7 +362,7 @@ state BAR: # We ignore comments and 'set' lines (variables). state BAR_IGNORE_LINE: - end, string + line -> BAR state BAR_BAR_COMMAND: @@ -428,7 +428,7 @@ state BAR_COLORS: # We ignore comments and 'set' lines (variables). state BAR_COLORS_IGNORE_LINE: - end, string + line -> BAR_COLORS state BAR_COLORS_SINGLE: diff --git a/src/config_parser.c b/src/config_parser.c index 1cdc7acb..f197c39d 100644 --- a/src/config_parser.c +++ b/src/config_parser.c @@ -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) { //printf("checking for end: *%s*\n", walk); if (*walk == '\0' || *walk == '\n' || *walk == '\r') { -- 2.39.2