pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc mk/subst.mk: substitute embedded newlines, escape dots...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/dd123ccf2ad2
branches:  trunk
changeset: 393376:dd123ccf2ad2
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Mar 17 12:01:14 2019 +0000

description:
mk/subst.mk: substitute embedded newlines, escape dots in variable names

diffstat:

 mk/subst.mk                  |   4 ++--
 regress/subst/Makefile       |   9 +++++----
 regress/subst/files/expected |  10 ++++++----
 3 files changed, 13 insertions(+), 10 deletions(-)

diffs (79 lines):

diff -r d4edf974985e -r dd123ccf2ad2 mk/subst.mk
--- a/mk/subst.mk       Sun Mar 17 11:28:13 2019 +0000
+++ b/mk/subst.mk       Sun Mar 17 12:01:14 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: subst.mk,v 1.58 2018/11/30 18:38:19 rillig Exp $
+# $NetBSD: subst.mk,v 1.59 2019/03/17 12:01:14 rillig Exp $
 #
 # This Makefile fragment implements a general text replacement facility.
 # Package makefiles define a ``class'', for each of which a particular
@@ -84,7 +84,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}@,${${v}:S|\\|\\\\|gW:S|,|\\,|gW:S|&|\\\&|gW:Q},g
+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
 .  endfor
 .  if !empty(SUBST_SHOW_DIFF.${_class_}:Uno:M[Yy][Ee][Ss])
 _SUBST_KEEP.${_class_}?=       ${DIFF} -u "$$file" "$$tmpfile" || true
diff -r d4edf974985e -r dd123ccf2ad2 regress/subst/Makefile
--- a/regress/subst/Makefile    Sun Mar 17 11:28:13 2019 +0000
+++ b/regress/subst/Makefile    Sun Mar 17 12:01:14 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.5 2019/03/17 11:28:13 rillig Exp $
+# $NetBSD: Makefile,v 1.6 2019/03/17 12:01:14 rillig Exp $
 #
 
 DISTNAME=      subst-19.03
@@ -18,7 +18,8 @@
 SUBST_VARS.vars=       PLAIN DQUOT SQUOT DELIM PRINTABLE
 SUBST_VARS.vars+=      UNDEFINED
 SUBST_VARS.vars+=      BETWEEN_SPACE BETWEEN_TAB BETWEEN_NL
-SUBST_VARS.vars+=      BACKSLASHES VAR...... VAR.abcde
+SUBST_VARS.vars+=      BACKSLASHES
+SUBST_VARS.vars+=      VAR...... VAR.abcde VAR.<>
 
 PLAIN=         hello_world
 DQUOT=         "hello   world"
@@ -31,14 +32,14 @@
 # Ensure that leading and trailing whitespace is preserved.
 BETWEEN_SPACE= ${:U }between spaces${:U }
 BETWEEN_TAB=   ${:U    }between tabs${:U       }
-# TODO: currently fails; needs to be fixed in subst.mk
-#BETWEEN_NL=   ${.newline}between newlines${.newline}
+BETWEEN_NL=    ${.newline}between newlines${.newline}
 
 BACKSLASHES=   \" \, \\, \" \' \0\000 \x40 \089 \a \$$
 
 # Ensure that special regex characters may appear in variable names.
 VAR......=     dots
 VAR.abcde=     letters
+VAR.<>=                angle brackets
 
 do-extract:
        ${RUN} ${SED} -e /^\#/d -e /^$$/d ${FILESDIR}/expected \
diff -r d4edf974985e -r dd123ccf2ad2 regress/subst/files/expected
--- a/regress/subst/files/expected      Sun Mar 17 11:28:13 2019 +0000
+++ b/regress/subst/files/expected      Sun Mar 17 12:01:14 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: expected,v 1.1 2019/03/17 11:28:13 rillig Exp $
+# $NetBSD: expected,v 1.2 2019/03/17 12:01:14 rillig Exp $
 #
 # The expected output from the SUBST_VARS test.
 # Each substituted value is enclosed in <angle brackets> to clearly
@@ -14,10 +14,12 @@
 
 BETWEEN_SPACE: < between spaces >
 BETWEEN_TAB: < between tabs    >
-BETWEEN_NL: <>
+BETWEEN_NL: <
+between newlines
+>
 
 BACKSLASHES: <\" \, \\, \" \' \0\000 \x40 \089 \a \$>
 
 VAR......: <dots>
-# FIXME: must be <letters> instead of <dots>
-VAR.abcde: <dots>
+VAR.abcde: <letters>
+VAR.<>: <angle brackets>



Home | Main Index | Thread Index | Old Index