From: Michael Tremer Date: Fri, 26 Feb 2021 10:36:50 +0000 (+0000) Subject: parser: Do not consider a READLINES block opening with fewer indents X-Git-Tag: 0.9.28~1285^2~687 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b8c6a8e98f269d41593b6a976ffc9f7bcf8c02a;p=pakfire.git parser: Do not consider a READLINES block opening with fewer indents Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/parser/scanner.l b/src/libpakfire/parser/scanner.l index 5b6ac0a7e..373be3b79 100644 --- a/src/libpakfire/parser/scanner.l +++ b/src/libpakfire/parser/scanner.l @@ -231,19 +231,31 @@ scriptlet script(let)? . { yyless(0); + // This is the first line if (!readline_indent) { - readline_indent = current_indent; - return T_INDENT; + // If indentation is above indent level, + // we are good to continue + if (current_indent > indent_level) { + readline_indent = current_indent; + return T_INDENT; + + // If we found the same or less indentation we go back + // to the previous state and continue parsing there + } else { + yy_pop_state(); + } } // <-- ? - if (current_indent < readline_indent) { + else if (current_indent < readline_indent) { readline_indent = 0; yy_pop_state(); return T_OUTDENT; - } - yy_push_state(READLINE); + // The indentation stayed the same, read the next line + } else { + yy_push_state(READLINE); + } } \t { current_indent++; }