Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src/usr.bin/make



Module Name:    src
Committed By:   rillig
Date:           Sat Feb 18 11:16:09 UTC 2023

Modified Files:
        src/usr.bin/make: make.h var.c
        src/usr.bin/make/unit-tests: parse-var.exp parse-var.mk
            var-eval-short.exp varmod-loop.mk

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.316 -r1.317 src/usr.bin/make/make.h
cvs rdiff -u -r1.1046 -r1.1047 src/usr.bin/make/var.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/parse-var.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/parse-var.mk
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmod-loop.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index