From 3a365ff8b88a29a5774f19a50e0aa8a9d713517f Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 31 Oct 2023 21:30:16 +0100 Subject: [PATCH] Fix flag option parsing bug in config file parser. The old code misparses the config file if it contains a flag option which is followed by a newline which starts with whitespace. In this case, since newlines belong to the [[:space:]] class, the option is regarded as an option with argumment. Fix this by s/:space:/:blank:/. The [[:blank:]] class only contains space and tab. which is what the code expects. --- config_file.l | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config_file.l b/config_file.l index 37cb0ac..66c1b76 100644 --- a/config_file.l +++ b/config_file.l @@ -21,7 +21,7 @@ %s SC_SCANNING IDENTIFIER [a-zA-Z]+[a-zA-Z0-9_-]* -EQUALS [[:space:]]*=[[:space:]]* +EQUALS [[:blank:]]*=[[:blank:]]* OPTION [a-zA-Z]+[a-zA-Z0-9_-]* %{ @@ -47,10 +47,10 @@ OPTION [a-zA-Z]+[a-zA-Z0-9_-]* %% /* skip comments and whitespace */ -^[[:space:]]*#.*\n ; -[[:space:]]|\n+ ; +^[[:blank:]]*#.*\n ; +[[:blank:]]|\n+ ; -\[[[:space:]]*{IDENTIFIER}[[:space:]]*\][[:space:]]*\n { +\[[[:blank:]]*{IDENTIFIER}[[:blank:]]*\][[:blank:]]*\n { int i, j; const char *subcmd = yyget_extra(yyscanner)->subcmd; @@ -71,9 +71,9 @@ OPTION [a-zA-Z]+[a-zA-Z0-9_-]* BEGIN(SC_SCANNING); } -{OPTION}[[:space:]]*\n add_option(yyscanner); +{OPTION}[[:blank:]]*\n add_option(yyscanner); -{OPTION}({EQUALS}|[[:space:]]+) { +{OPTION}({EQUALS}|[[:blank:]]+) { int ret = add_option(yyscanner); if (ret < 0) -- 2.39.2