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 Jun 6 13:17:34 UTC 2020
Modified Files:
pkgsrc/mk/scripts: subst-identity.awk
pkgsrc/regress/infra-unittests: subst.sh
Log Message:
mk/subst.mk: fix wrong SUBST failure in mail/policyd-weight
The general rule is that a SUBST_SED that contains _any_ identity
substitution may leave files unmodified, no matter if there are other
substitutions as well.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 pkgsrc/mk/scripts/subst-identity.awk
cvs rdiff -u -r1.44 -r1.45 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/scripts/subst-identity.awk
diff -u pkgsrc/mk/scripts/subst-identity.awk:1.4 pkgsrc/mk/scripts/subst-identity.awk:1.5
--- pkgsrc/mk/scripts/subst-identity.awk:1.4 Sat May 16 12:43:10 2020
+++ pkgsrc/mk/scripts/subst-identity.awk Sat Jun 6 13:17:34 2020
@@ -1,12 +1,19 @@
#! /usr/bin/awk -f
-# $NetBSD: subst-identity.awk,v 1.4 2020/05/16 12:43:10 rillig Exp $
+# $NetBSD: subst-identity.awk,v 1.5 2020/06/06 13:17:34 rillig Exp $
#
-# Tests whether a sed(1) command line consists of only identity substitutions
-# like s,id,id,.
+# Tests whether a sed(1) command line contains an identity substitution
+# like s,id,id,. When used in a SUBST block, these commands may leave a
+# file unmodified, which is ok since such an identity substitution
+# typically looks like s,/var,${VARBASE},.
#
# See SUBST_NOOP_OK and regress/infra-unittests/subst.sh.
#
+BEGIN {
+ false = 0;
+ true = 1;
+}
+
# Returns the first character of the given regular expression,
# if it is a single-character regular expression.
function identity_char(s, sep, i) {
@@ -48,13 +55,13 @@ function is_identity_subst(s, len, i,
return s == subst || s == subst "g" || s == subst "1";
}
-function main( i) {
+function contains_identity_subst( i) {
for (i = 1; i + 1 < ARGC; i += 2)
- if (ARGV[i] != "-e" || !is_identity_subst(ARGV[i + 1]))
- return 0;
- return i == ARGC && ARGC > 1;
+ if (ARGV[i] == "-e" && is_identity_subst(ARGV[i + 1]))
+ return true;
+ return false;
}
BEGIN {
- exit(main() ? 0 : 1);
+ exit(contains_identity_subst() ? 0 : 1);
}
Index: pkgsrc/regress/infra-unittests/subst.sh
diff -u pkgsrc/regress/infra-unittests/subst.sh:1.44 pkgsrc/regress/infra-unittests/subst.sh:1.45
--- pkgsrc/regress/infra-unittests/subst.sh:1.44 Sat Jun 6 13:00:52 2020
+++ pkgsrc/regress/infra-unittests/subst.sh Sat Jun 6 13:17:34 2020
@@ -1,5 +1,5 @@
#! /bin/sh
-# $NetBSD: subst.sh,v 1.44 2020/06/06 13:00:52 rillig Exp $
+# $NetBSD: subst.sh,v 1.45 2020/06/06 13:17:34 rillig Exp $
#
# Tests for mk/subst.mk.
#
@@ -1265,12 +1265,14 @@ if test_case_begin 'identity substitutio
assert_identity 'yes' -e 's!/dev/audio!/dev/audio!'
# There may be several identity substitutions in the same
- # SUBST_SED. As long as all these substitutions are identity
- # substitutions, they may be skipped. As soon as there is one
- # other substitution, the whole SUBST_SED is treated as usual.
+ # SUBST_SED. As long as any of these substitutions is an
+ # identity substitution, it can happen that a file stays the
+ # same. It still might be modified in a different pkgsrc
+ # configuration.
assert_identity 'yes' -e 's;from;from;' -e 's!second!second!'
- assert_identity 'no' -e 's,changing,x,' -e 's,id,id,'
- assert_identity 'no' -e 's,id,id,' -e 's,changing,x,'
+ assert_identity 'yes' -e 's,changing,x,' -e 's,id,id,'
+ assert_identity 'yes' -e 's,id,id,' -e 's,changing,x,'
+ assert_identity 'no' -e 's,changing,x,' -e 's,changing,x,'
# A demonstration of all ASCII characters that may appear in an
# identity substitution.
@@ -1656,26 +1658,13 @@ if test_case_begin 'several substitution
run_bmake 'testcase.mk' 'subst-id' 1> "$tmpdir/output" 2>&1 \
&& exitcode=0 || exitcode=$?
- # FIXME: This is not the intended behavior.
# Each of the files contains at least one of the sed patterns,
# therefore the substitutions _could_ have an effect, depending
# on the pkgsrc configuration.
- #
- # Instead of testing whether the sed command is an identity
- # substitution, the original idea was to find files that contain
- # _none_ of the patterns.
- #
- # The proper fix might be as simple as replacing the "all" with an
- # "any" in mk/scripts/subst-identity.awk. This would also nicely
- # remove the special handling of an empty command line.
- assert_that "$tmpdir/output" --file-is-lines \
- '=> Substituting "id" in first second' \
- 'warning: [subst.mk:id] Nothing changed in "second".' \
- 'fail: [subst.mk:id] The filename pattern "second" has no effect.' \
- '*** Error code 1' \
- '' \
- 'Stop.' \
- "$make: stopped in $PWD"
+ assert_that "$tmpdir/output" --file-is-lines \
+ '=> Substituting "id" in first second'
+ assert_that 'first' --file-contains-exactly 'first-modified'
+ assert_that 'second' --file-contains-exactly 'second'
test_case_end
fi
Home |
Main Index |
Thread Index |
Old Index