chiark / gitweb /
Warnings: Track basic $-references
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 28 Dec 2019 12:31:49 +0000 (12:31 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 30 Dec 2019 11:35:16 +0000 (11:35 +0000)
We must always stop at $'s in the input now.

Having stopped at $, we normally just output it and carry on.  Ie, we
only stop so we can do some inspection: as before, we do this variable
tracking as inspection before processing, rather entangled with
processing.

We can deal reasonably properly with ${ } and $( ).

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
generate

index cbc91721473a7bc4de563ea0f6842d3e25aec0b5..d8183d07dd9356e005d90a8160038dae4b9f3047 100755 (executable)
--- a/generate
+++ b/generate
@@ -270,8 +270,8 @@ sub process_input_mk ($$$$) {
            err 'cannot $-double &-processed RHS of directive'
                if $ddbl && defined $buffering_output;
            unless ($nest[0][0] eq 'eval'
            err 'cannot $-double &-processed RHS of directive'
                if $ddbl && defined $buffering_output;
            unless ($nest[0][0] eq 'eval'
-                   ? s{^(.*?)($esc|[{}])}{}
-                   : s{^(.*?)($esc)}{}) { od $_; last; }
+                   ? s{^(.*?)($esc|\$|[{}])}{}
+                   : s{^(.*?)($esc|\$)}{}) { od $_; last; }
            od $1;
            if ($2 eq '{') {
                od $2;
            od $1;
            if ($2 eq '{') {
                od $2;
@@ -283,6 +283,14 @@ sub process_input_mk ($$$$) {
                $pop_nest->('eval');
                od '}';
                next;
                $pop_nest->('eval');
                od '}';
                next;
+           } elsif ($2 eq '$') {
+               od $2;
+               if (s{^\$}{}) { od $&; }
+               elsif (m{^\(($esc)?([^()\$]+)\)} ||
+                      m{^\{($esc)?([^{}\$]+)\}}) {
+                   $note_varref->($2,!!$1);
+               }
+               next;
            }
            if (s{^\\$esc}{}) { od "$$esclitr" }
            elsif (s{^\\\$}{}) { oud '$' }
            }
            if (s{^\\$esc}{}) { od "$$esclitr" }
            elsif (s{^\\\$}{}) { oud '$' }