chiark / gitweb /
Syntax: only some directives' RHS should be &-expanded
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 25 Dec 2019 17:08:19 +0000 (17:08 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 28 Dec 2019 22:19:08 +0000 (22:19 +0000)
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 <ijackson@chiark.greenend.org.uk>
README
generate
tests/filter/sub/dir/Subdir.mk.expected
tests/filter/sub/dir/Subdir.sd.mk

diff --git a/README b/README
index 6bc8e82d8611f4a31525e9c0f22590446d170a1a..63e41881b9674d440978d4f1076190f2df7fef3d 100644 (file)
--- 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
 
 &!<lwsp>       disables & until EOL (and then disappears)
 
index e7da43542b3b45f309313dca470122d0a2d26b6c..e1efc06a95bf11186df3f92c2d10cabf5d5552d4 100755 (executable)
--- 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 $_ ";
            }
        }
     }
index 9f7cb70f8223ddfd7a2866bea11b82f98a440396..8a3e94f33bc82643ff9671f005c7a297d6a5ecc5 100644 (file)
@@ -1,5 +1,8 @@
 # autogenerated - do not edit
 # subdirectory test cases
+
+sub/dir/
+
 # doctests:
 
 sub/dir/all:: $(sub_dir_TARGETS)
index f06ea993f340b3595e38eded839e63f87ceeb972..99f6f4e319efe37dc911757fdbb07b6803297216 100644 (file)
@@ -1,3 +1,7 @@
 # subdirectory test cases
+
+&:changequote &
+&/
+
 # doctests:
 &:include &doctest.sd.mk