Source-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc mk/subst.mk: document that SUBST_VARS does not support...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/0d9a80fdaf01
branches:  trunk
changeset: 429332:0d9a80fdaf01
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Apr 18 15:04:34 2020 +0000

description:
mk/subst.mk: document that SUBST_VARS does not support dollar

diffstat:

 mk/subst.mk                      |   4 ++--
 regress/infra-unittests/subst.sh |  25 ++++++++++++++++++++++---
 2 files changed, 24 insertions(+), 5 deletions(-)

diffs (77 lines):

diff -r 5b42dba14099 -r 0d9a80fdaf01 mk/subst.mk
--- a/mk/subst.mk       Sat Apr 18 14:56:25 2020 +0000
+++ b/mk/subst.mk       Sat Apr 18 15:04:34 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: subst.mk,v 1.78 2020/04/18 12:59:43 rillig Exp $
+# $NetBSD: subst.mk,v 1.79 2020/04/18 15:04:34 rillig Exp $
 #
 # The subst framework replaces text in one or more files in the WRKSRC
 # directory. Packages can define several ``classes'' of replacements.
@@ -128,7 +128,7 @@
 SUBST_VARS.${class}?=          # none
 SUBST_MESSAGE.${class}?=       Substituting "${class}" in ${SUBST_FILES.${class}}
 .  for v in ${SUBST_VARS.${class}}
-SUBST_FILTER_CMD.${class}+=    -e s,@${v:C|[.[\\*^${$}]|\\\\&|gW:Q}@,${${v}:S|\\|\\\\|gW:S|,|\\,|gW:S|&|\\\&|gW:S|${.newline}|\\${.newline}|gW:Q},g
+SUBST_FILTER_CMD.${class}+=    -e s,@${v:C|[.[\\*^]|\\\\&|gW:Q}@,${${v}:S|\\|\\\\|gW:S|,|\\,|gW:S|&|\\\&|gW:S|${.newline}|\\${.newline}|gW:Q},g
 .  endfor
 .  if ${SUBST_SHOW_DIFF.${class}:U${SUBST_SHOW_DIFF}:tl} == yes
 _SUBST_KEEP.${class}?=         LC_ALL=C ${DIFF} -u "$$file" "$$tmpfile" || true
diff -r 5b42dba14099 -r 0d9a80fdaf01 regress/infra-unittests/subst.sh
--- a/regress/infra-unittests/subst.sh  Sat Apr 18 14:56:25 2020 +0000
+++ b/regress/infra-unittests/subst.sh  Sat Apr 18 15:04:34 2020 +0000
@@ -797,17 +797,30 @@
        # Ensure that special regex characters like dots and parentheses
        # may appear in variable names and are properly escaped.
 
+       # Variable names containing a dollar are not supported.
+       # Bmake behaves very surprisingly when a $ is expanded inside a :C
+       # modifier. Nobody needs this feature anyway, it was just an
+       # experiment to see whether this would be theoretically possible.
+
+       # Variable names ending with a backslash are not supported.
+       # The backslash may only occur in the middle of the variable name.
+
        create_file_lines "testcase.mk" \
                'SUBST_CLASSES+=        vars' \
                'SUBST_STAGE.vars=      pre-configure' \
                'SUBST_FILES.vars=      vars.txt' \
-               'SUBST_VARS.vars=       VAR...... VAR.abcde VAR.() VAR.<> VAR.[]' \
+               'SUBST_VARS.vars=       VAR...... VAR.abcde' \
+               'SUBST_VARS.vars+=      VAR.() VAR.<> VAR.[]' \
+               'SUBST_VARS.vars+=      VAR.$$x VAR.^ VAR.\x' \
                '' \
                'VAR......=     dots' \
                'VAR.abcde=     letters' \
                'VAR.()=        parentheses' \
                'VAR.<>=        angle brackets' \
                'VAR.[]=        square brackets' \
+               'VAR.$$x=       dollar' \
+               'VAR.^=         circumflex' \
+               'VAR.\x=        backslash' \
                '' \
                '.include "prepare-subst.mk"' \
                '.include "mk/subst.mk"'
@@ -816,7 +829,10 @@
                "@VAR.abcde@" \
                "@VAR.()@" \
                "@VAR.<>@" \
-               "@VAR.[]@"
+               "@VAR.[]@" \
+               '@VAR.$x@' \
+               '@VAR.^@' \
+               '@VAR.\x@'
 
        run_bmake "testcase.mk" "pre-configure" \
                1> "$tmpdir/stdout" \
@@ -828,7 +844,10 @@
                "letters" \
                "parentheses" \
                "angle brackets" \
-               "square brackets"
+               "square brackets" \
+               '@VAR.$x@' \
+               'circumflex' \
+               'backslash'
        assert_that "stdout" --file-is-lines \
                "=> Substituting \"vars\" in vars.txt"
        assert_that "stderr" --file-is-empty



Home | Main Index | Thread Index | Old Index