Home | History | Annotate | Download | only in unit-tests
History log of /src/usr.bin/make/unit-tests/parse-var.mk
RevisionDateAuthorComments
 1.10  02-Jun-2024  rillig make: sync VarEvalMode constant names with their debug log names
 1.9  19-Nov-2023  rillig tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity. The wording in make's diagnostics will be changed in a
follow-up commit.
 1.8  18-Feb-2023  rillig make: fix parsing of unevaluated subexpressions with unbalanced '{}'

Since var.c 1.323 from 2020-07-26, modifiers containing unbalanced
braces or parentheses were parsed differently, depending on whether they
were relevant or not.

For example, the expression '${VAR:...}' is enclosed with braces. When
this expression has a modifier ':S,},}},g' that would double each '}' in
that expression, the parser got confused:

If the expression was relevant, the modifier was parsed as usual, taking
into account that the 3 '}' in the modifier are ordinary characters.

If the expression was irrelevant, the parser only counted the '{' and
the '}', without taking into account that a '}' might be escaped by a
'\' or be an ordinary character. Parsing therefore stopped at the first
'}', assuming it would finish the expression '${VAR:S,}'.

This parsing mode of only counting balanced '{' and '}' makes sense for
the modifier ':@var@...@', which expands each word of the expression
using the template from the '...'. These templates tend to be simple
enough that counting the '{' and '}' suffices.
 1.7  14-Feb-2023  rillig make: remove redundant type VarParseResult

No functional change.
 1.6  25-Sep-2022  rillig tests/make: document how variable evaluation needs to be tested

It's about 100_000 combinations to cover the basic edge cases.
 1.5  23-Aug-2022  rillig make: revert parsing of modifier parts (since 2022-08-08)

The modifier ':@var@body@' parses the body in parse-only mode and later
uses Var_Subst on it, in which each literal '$' must be written as '$$'.

Trying to parse the loop body using Var_Parse treated the text
'$${var:-0}' as a single '$' followed by the expression '${var:-0}',
wrongly complaining about the 'Unknown modifier "-0"'.

Found by sjg.
 1.4  08-Aug-2022  rillig tests/make: document history of bug in parsing unbalanced expressions

The bug was introduced in var.c 1.323, which merged two flags that
sounded as if they had been exact opposites: VAR_NOSUBST (later named
VARE_NOSUBST) and VARE_WANTRES.

Before that commit, the branch where make only counted braces instead of
properly parsing the nested expression was only taken in the modifiers
':@var@body@' and '::=', but not in ':S' and ':C'.

After merging the two flags, the modifier parts of ':S' and ':C' had to
be balanced as well, otherwise parsing would fail in cases where the
expression was only parsed, not evaluated.
 1.3  08-Aug-2022  rillig make: fix parsing of modifiers containing unbalanced subexpressions
 1.2  06-Aug-2022  rillig tests/make: demonstrate bug in parsing of modifier parts

In the modifier ':S,from,to,', parsing the two parts 'from' and 'to' of
the modifier differs depending on whether the expression is actually
evaluated or merely parsed. This not only applies to the ':S' modifier,
but also to ':C', ':@var@body@', ':!cmd!', ':[...]', ':?:', '::=' and
':from=to'.
 1.1  04-Oct-2020  rillig make(1): add tests for parsing assignments, especially :sh

Luckily nobody uses the :sh variable assignment modifier since its
syntactical variant != is simpler.

RSS XML Feed