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 6bc8e82..63e4188 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 e7da435..e1efc06 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 9f7cb70..8a3e94f 100644 (file)
@@ -1,5 +1,8 @@
 # autogenerated - do not edit
 # subdirectory test cases
+
+sub/dir/
+
 # doctests:
 
 sub/dir/all:: $(sub_dir_TARGETS)
index f06ea99..99f6f4e 100644 (file)
@@ -1,3 +1,7 @@
 # subdirectory test cases
+
+&:changequote &
+&/
+
 # doctests:
 &:include &doctest.sd.mk