Received: by mail.netbsd.org (Postfix, from userid 605) id 44B4884DCD; Sat, 18 Apr 2020 12:21:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id BFFC684DB7 for ; Sat, 18 Apr 2020 12:21:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([IPv6:::1]) by localhost (mail.netbsd.org [IPv6:::1]) (amavisd-new, port 10025) with ESMTP id GWS_vEuaempw for ; Sat, 18 Apr 2020 12:21:11 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.netbsd.org [199.233.217.197]) by mail.netbsd.org (Postfix) with ESMTP id 2F24884D2C for ; Sat, 18 Apr 2020 12:21:11 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 22944FB27; Sat, 18 Apr 2020 12:21:11 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_1587212471197570" MIME-Version: 1.0 Date: Sat, 18 Apr 2020 12:21:11 +0000 From: "Roland Illig" Subject: CVS commit: pkgsrc To: pkgsrc-changes@NetBSD.org Reply-To: rillig@netbsd.org X-Mailer: log_accum Message-Id: <20200418122111.22944FB27@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: pkgsrc-changes.NetBSD.org Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_1587212471197570 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Module Name: pkgsrc Committed By: rillig Date: Sat Apr 18 12:21:11 UTC 2020 Modified Files: pkgsrc/mk: subst.mk pkgsrc/regress/infra-unittests: subst.sh Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 pkgsrc/mk/subst.mk cvs rdiff -u -r1.15 -r1.16 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. --_----------=_1587212471197570 Content-Disposition: inline Content-Length: 2413 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii Modified files: Index: pkgsrc/mk/subst.mk diff -u pkgsrc/mk/subst.mk:1.76 pkgsrc/mk/subst.mk:1.77 --- pkgsrc/mk/subst.mk:1.76 Sat Apr 18 11:42:34 2020 +++ pkgsrc/mk/subst.mk Sat Apr 18 12:21:10 2020 @@ -1,4 +1,4 @@ -# $NetBSD: subst.mk,v 1.76 2020/04/18 11:42:34 rillig Exp $ +# $NetBSD: subst.mk,v 1.77 2020/04/18 12:21:10 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|[^A-Za-z0-9_]|\\\\&|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.15 pkgsrc/regress/infra-unittests/subst.sh:1.16 --- pkgsrc/regress/infra-unittests/subst.sh:1.15 Sat Mar 28 12:08:28 2020 +++ pkgsrc/regress/infra-unittests/subst.sh Sat Apr 18 12:21:10 2020 @@ -801,7 +801,7 @@ if test_case_begin "SUBST_VARS for varia '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 varia "@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 --_----------=_1587212471197570--