head	1.7;
access;
symbols
	netbsd-11-0-RC4:1.7
	netbsd-11-0-RC3:1.7
	netbsd-11-0-RC2:1.7
	netbsd-11-0-RC1:1.7
	perseant-exfatfs-base-20250801:1.7
	netbsd-11:1.7.0.4
	netbsd-11-base:1.7
	netbsd-10-1-RELEASE:1.5
	perseant-exfatfs-base-20240630:1.7
	perseant-exfatfs:1.7.0.2
	perseant-exfatfs-base:1.7
	netbsd-10-0-RELEASE:1.5
	netbsd-10-0-RC6:1.5
	netbsd-10-0-RC5:1.5
	netbsd-10-0-RC4:1.5
	netbsd-10-0-RC3:1.5
	netbsd-10-0-RC2:1.5
	netbsd-10-0-RC1:1.5
	netbsd-10:1.5.0.2
	netbsd-10-base:1.5
	cjep_sun2x-base1:1.1
	cjep_sun2x:1.1.0.4
	cjep_sun2x-base:1.1
	cjep_staticlib_x-base1:1.1
	cjep_staticlib_x:1.1.0.2
	cjep_staticlib_x-base:1.1;
locks; strict;
comment	@# @;


1.7
date	2023.02.18.11.16.09;	author rillig;	state Exp;
branches;
next	1.6;
commitid	wIqh35TVpkNKOZdE;

1.6
date	2023.02.14.21.56.48;	author rillig;	state Exp;
branches;
next	1.5;
commitid	NFr45lm31yW8DxdE;

1.5
date	2022.09.25.21.26.23;	author rillig;	state Exp;
branches;
next	1.4;
commitid	d01HKd9dfXWB1iVD;

1.4
date	2022.08.23.19.22.01;	author rillig;	state Exp;
branches;
next	1.3;
commitid	c1yzpPE9oG6En2RD;

1.3
date	2022.08.08.18.23.30;	author rillig;	state Exp;
branches;
next	1.2;
commitid	6J4i0OadfoN0x6PD;

1.2
date	2022.08.06.21.26.05;	author rillig;	state Exp;
branches;
next	1.1;
commitid	gzuvfhDqRg3kBROD;

1.1
date	2020.10.04.06.53.15;	author rillig;	state Exp;
branches;
next	;
commitid	ZZbVxlZJpDcImyqC;


desc
@@


1.7
log
@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.
@
text
@exit status 0
@


1.6
log
@make: remove redundant type VarParseResult

No functional change.
@
text
@d1 1
a1 5
make: Unfinished modifier for "BRACE_GROUP" (',' missing)
make: "parse-var.mk" line 129: Malformed conditional (0 && ${BRACE_GROUP:S,${BRACE_PAIR:S,{,{{,},<lbraces>,})
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
@


1.5
log
@tests/make: document how variable evaluation needs to be tested

It's about 100_000 combinations to cover the basic edge cases.
@
text
@d2 1
a2 1
make: "parse-var.mk" line 130: Malformed conditional (0 && ${BRACE_GROUP:S,${BRACE_PAIR:S,{,{{,},<lbraces>,})
@


1.4
log
@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.
@
text
@d2 1
a2 1
make: "parse-var.mk" line 57: Malformed conditional (0 && ${BRACE_GROUP:S,${BRACE_PAIR:S,{,{{,},<lbraces>,})
@


1.3
log
@make: fix parsing of modifiers containing unbalanced subexpressions
@
text
@d1 5
a5 1
exit status 0
@


1.2
log
@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'.
@
text
@d1 1
a1 5
make: Unfinished modifier for "BRACE_GROUP" (',' missing)
make: "parse-var.mk" line 47: Malformed conditional (0 && ${BRACE_GROUP:S,${BRACE_PAIR:S,{,{{,},<lbraces>,})
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
@


1.1
log
@make(1): add tests for parsing assignments, especially :sh

Luckily nobody uses the :sh variable assignment modifier since its
syntactical variant != is simpler.
@
text
@d1 5
a5 1
exit status 0
@

