summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2020-06-06 13:17:34 +0000
committerrillig <rillig@pkgsrc.org>2020-06-06 13:17:34 +0000
commitede28e2ba83902057226a8b5c33b787907312112 (patch)
tree09f1dfebe2797b861cc86c80b119419f706348b8 /mk
parentc07204d7317884d0141c06b37dbce47ce090e2fd (diff)
downloadpkgsrc-ede28e2ba83902057226a8b5c33b787907312112.tar.gz
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.
Diffstat (limited to 'mk')
-rw-r--r--mk/scripts/subst-identity.awk23
1 files changed, 15 insertions, 8 deletions
diff --git a/mk/scripts/subst-identity.awk b/mk/scripts/subst-identity.awk
index 6a6757e2da4..b1ce9bfcfcf 100644
--- a/mk/scripts/subst-identity.awk
+++ b/mk/scripts/subst-identity.awk
@@ -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, sep, pat_from, pat_to, ch, subst) {
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);
}