pkgsrc-Changes archive

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

CVS commit: pkgsrc



Module Name:    pkgsrc
Committed By:   rillig
Date:           Sat Apr 18 15:04:34 UTC 2020

Modified Files:
        pkgsrc/mk: subst.mk
        pkgsrc/regress/infra-unittests: subst.sh

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


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 pkgsrc/mk/subst.mk
cvs rdiff -u -r1.18 -r1.19 pkgsrc/regress/infra-unittests/subst.sh

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

Modified files:

Index: pkgsrc/mk/subst.mk
diff -u pkgsrc/mk/subst.mk:1.78 pkgsrc/mk/subst.mk:1.79
--- pkgsrc/mk/subst.mk:1.78     Sat Apr 18 12:59:43 2020
+++ pkgsrc/mk/subst.mk  Sat Apr 18 15:04:34 2020
@@ -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_FILTER_CMD.${class}?= LC_ALL=C ${S
 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

Index: pkgsrc/regress/infra-unittests/subst.sh
diff -u pkgsrc/regress/infra-unittests/subst.sh:1.18 pkgsrc/regress/infra-unittests/subst.sh:1.19
--- pkgsrc/regress/infra-unittests/subst.sh:1.18        Sat Apr 18 14:06:06 2020
+++ pkgsrc/regress/infra-unittests/subst.sh     Sat Apr 18 15:04:34 2020
@@ -797,17 +797,30 @@ if test_case_begin "SUBST_VARS for varia
        # 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 @@ if test_case_begin "SUBST_VARS for varia
                "@VAR.abcde@" \
                "@VAR.()@" \
                "@VAR.<>@" \
-               "@VAR.[]@"
+               "@VAR.[]@" \
+               '@VAR.$x@' \
+               '@VAR.^@' \
+               '@VAR.\x@'
 
        run_bmake "testcase.mk" "pre-configure" \
                1> "$tmpdir/stdout" \
@@ -828,7 +844,10 @@ if test_case_begin "SUBST_VARS for varia
                "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