From cf7f7e9dfdb0241d091655bca63edcdae5b81c03 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 25 Dec 2019 17:08:19 +0000 Subject: [PATCH] Syntax: only some directives' RHS should be &-expanded In principle this is an incompatible change but only for strange input files and only if they use &:changequote. We need an ad-hoc test for this. Signed-off-by: Ian Jackson --- README | 3 ++- generate | 13 ++++++++----- tests/filter/sub/dir/Subdir.mk.expected | 3 +++ tests/filter/sub/dir/Subdir.sd.mk | 4 ++++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/README b/README index 6bc8e82..63e4188 100644 --- a/README +++ b/README @@ -268,9 +268,10 @@ So pathname syntax is a subset of: recognised at start of line only (possibly after lwsp) args are processed for & -&:include filename filename should usually be foo.sd.mk +&:include filename filename should usually be [&]foo.sd.mk &:-include filename tolerate nonexistent file filenames are relative to $(top_srcdir) + RHS is &-expanded &! disables & until EOL (and then disappears) diff --git a/generate b/generate index e7da435..e1efc06 100755 --- a/generate +++ b/generate @@ -147,8 +147,14 @@ sub process_input_mk ($$$$$$$$$) { $pfxmap{$_} = $srcdirmap{$_}.'/' foreach keys %srcdirmap; while (<$input>) { - if (s#^\s*$esc\:##) { + if (s#^\s*$esc\:changequote\s+(\S+)\s+$##) { + $$esclitr = $1; + $set_esc->(); + next; + } elsif (s#^\s*$esc\:(?=(-?)include)##) { $buffering_output=''; + } elsif (m#^\s*$esc\:([a-z][-0-9a-z_]*)#) { + die "unknown directive $1"; } for (;;) { unless (s{^(.*?)$esc}{}) { o $_; last; } @@ -194,11 +200,8 @@ sub process_input_mk ($$$$$$$$$) { $var_prefix, $var_prefix_name, $targets, $subf, $esclitr, $1); o "\n"; - } elsif (m#^changequote\s+(\S+)\s+$#) { - $$esclitr = $1; - $set_esc->(); } else { - die "unknown directive $_ "; + die "internal error buffering directive $_ "; } } } diff --git a/tests/filter/sub/dir/Subdir.mk.expected b/tests/filter/sub/dir/Subdir.mk.expected index 9f7cb70..8a3e94f 100644 --- a/tests/filter/sub/dir/Subdir.mk.expected +++ b/tests/filter/sub/dir/Subdir.mk.expected @@ -1,5 +1,8 @@ # autogenerated - do not edit # subdirectory test cases + +sub/dir/ + # doctests: sub/dir/all:: $(sub_dir_TARGETS) diff --git a/tests/filter/sub/dir/Subdir.sd.mk b/tests/filter/sub/dir/Subdir.sd.mk index f06ea99..99f6f4e 100644 --- a/tests/filter/sub/dir/Subdir.sd.mk +++ b/tests/filter/sub/dir/Subdir.sd.mk @@ -1,3 +1,7 @@ # subdirectory test cases + +&:changequote & +&/ + # doctests: &:include &doctest.sd.mk -- 2.30.2