summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2020-04-18 12:21:10 +0000
committerrillig <rillig@pkgsrc.org>2020-04-18 12:21:10 +0000
commit6d6b143d8f4e92c39f6534f7f0362ab471ac2fe0 (patch)
tree0f04e06261a76dc9d8502a583e380f0564b28493 /regress
parent5883c328090c4b268fee26c1f364d556141f0c85 (diff)
downloadpkgsrc-6d6b143d8f4e92c39f6534f7f0362ab471ac2fe0.tar.gz
mk/subst.mk: avoid undefined behavior in regular expressions
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html says in section 9.3.2 BRE Ordinary Characters that only very few characters may be preceded with a backslash. As a side effect, this change allows parentheses in the variable names listed in SUBST_VARS (even if that will never happen in practice). The reason that the regression test had not replaced VAR.[] before was simply that this variable had not been listed in SUBST_VARS.
Diffstat (limited to 'regress')
-rw-r--r--regress/infra-unittests/subst.sh9
1 files changed, 4 insertions, 5 deletions
diff --git a/regress/infra-unittests/subst.sh b/regress/infra-unittests/subst.sh
index aae897ded88..1c8395fac20 100644
--- a/regress/infra-unittests/subst.sh
+++ b/regress/infra-unittests/subst.sh
@@ -801,7 +801,7 @@ if test_case_begin "SUBST_VARS for variables with regex characters"; then
'SUBST_CLASSES+= vars' \
'SUBST_STAGE.vars= pre-configure' \
'SUBST_FILES.vars= vars.txt' \
- 'SUBST_VARS.vars= VAR...... VAR.abcde VAR.() VAR.<>' \
+ 'SUBST_VARS.vars= VAR...... VAR.abcde VAR.() VAR.<> VAR.[]' \
'' \
'VAR......= dots' \
'VAR.abcde= letters' \
@@ -817,20 +817,19 @@ if test_case_begin "SUBST_VARS for variables with regex characters"; then
"@VAR.()@" \
"@VAR.<>@" \
"@VAR.[]@"
+cp "$tmpdir/testcase.mk" /tmp
run_bmake "testcase.mk" "pre-configure" \
1> "$tmpdir/stdout" \
2> "$tmpdir/stderr" \
&& exitcode=0 || exitcode=$?
- # TODO: Why are the angle brackets replaced, but not the parentheses
- # and square brackets?
assert_that "vars.txt" --file-is-lines \
"dots" \
"letters" \
- "@VAR.()@" \
+ "parentheses" \
"angle brackets" \
- "@VAR.[]@"
+ "square brackets"
assert_that "stdout" --file-is-lines \
"=> Substituting \"vars\" in vars.txt"
assert_that "stderr" --file-is-empty