]> git.tuebingen.mpg.de Git - lopsub.git/commitdiff
Fix flag option parsing bug in config file parser.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 31 Oct 2023 20:30:16 +0000 (21:30 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 7 Nov 2023 14:07:31 +0000 (15:07 +0100)
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

index 37cb0aca6deb7bcee9cd74768db22b165561db27..66c1b769192186ba77b474bc4bdf65190962768c 100644 (file)
@@ -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)