From: Andre Noll <maan@tuebingen.mpg.de>
Date: Tue, 31 Oct 2023 20:30:16 +0000 (+0100)
Subject: Fix flag option parsing bug in config file parser.
X-Git-Tag: v1.0.5~20
X-Git-Url: https://git.tuebingen.mpg.de/?a=commitdiff_plain;h=3a365ff8b88a29a5774f19a50e0aa8a9d713517f;p=lopsub.git

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.
---

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+ ;
 
-<INITIAL,SC_SCANNING>\[[[:space:]]*{IDENTIFIER}[[:space:]]*\][[:space:]]*\n {
+<INITIAL,SC_SCANNING>\[[[: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);
 }
 
-<SC_SCANNING>{OPTION}[[:space:]]*\n add_option(yyscanner);
+<SC_SCANNING>{OPTION}[[:blank:]]*\n add_option(yyscanner);
 
-<SC_SCANNING>{OPTION}({EQUALS}|[[:space:]]+) {
+<SC_SCANNING>{OPTION}({EQUALS}|[[:blank:]]+) {
 	int ret = add_option(yyscanner);
 
 	if (ret < 0)