chiark / gitweb /
Macro assistance part 2 - syntax for $(eval $(call...))
[secnet.git] / tests / filter / extract-doctest
index b63f309e87f5875465399c15d2fd560298299a69..d779e00a5da4c152f9e55146a7c16b05f483c87c 100755 (executable)
@@ -56,6 +56,9 @@ while (<>) {
            $e->{OutTop} = $1 eq 'nothing' ? '' : $1;
        } elsif (# parse: expect other wordish things to be comments
                 m{^(?!or\b)\w{2,} }) {
+       } elsif (# adhoc: slightly special case for $(eval $(call
+                m{^\$\{.*}) {
+           $e->{Out} .= ' '.$&;
        } elsif (m/^$/) {
        } else {
            confess "unk rhs $_ ?";
@@ -106,20 +109,20 @@ sub write_permode ($$$$$;$$) {
     oh "${senl}# ----- $what starts -----\n";
     foreach my $e (@exp) {
        next unless $filter->($e);
-       my $rubric = $e->{In};
-       $rubric =~ s/\&/AMP /g;
-       $rubric =~ s/\$/DOLLAR /g;
-       $rubric =~ s/NEWQUOTE/NEW_QUOTE /g;
-       my $f = $e->{In} =~ m/\n/
-               ? "\n# %s:\n%s\n\n"
-               : "%-30s: %s.\n";
+       my $desc = $e->{In};
+       $desc =~ s/\&/AMP /g;
+       $desc =~ s/\$/DOLLAR /g;
+       $desc =~ s/NEWQUOTE/NEW_QUOTE /g;
+       my ($f,$pdesc) = $desc =~ m/^(.*)\n/
+               ? ("\n# %s:\n%s\n\n", $1)
+               : ("%-30s: %s .\n", $desc);
        my $o;
        $o = $e->{OutTop} if $dir_prefix eq '';
        $o //= $e->{Out};
        $o =~ s{/sub/dir}{} if $dir_prefix eq '' && !defined $e->{OutTop};
        $o = $omap->($o, $e);
-       oi sprintf $f, $rubric, $e->{In};
-       oo sprintf $f, $rubric, $o;
+       oi sprintf $f, $pdesc, $e->{In};
+       oo sprintf $f, $pdesc, $o;
     }
     oi $end;
     oh "${senl}# ----- $what ends -----\n";
@@ -138,6 +141,10 @@ sub writeout ($) {
                  'dollar doubling',
                  sub {
                      my ($e) = @_;
+                     # adhoc: skip &:macro in already-doubling part
+                     return 0 if $e->{In} =~ m{^\&\:macro};
+                     # adhoc: skip &${ ie eval in already-doubling part
+                     return 0 if $e->{In} =~ m{^\&\$\{};
                      return 0 if $e->{CQ};
                      return $e->{DD} || !grep {
                          # If there are two entries with the same In,