summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
a7ee99a)
Nested named subroutines don't capture their lexical environment
properly on subsequent calls to the enclosing subroutine. This is
obviously a bug.
my $ln = 0;
## Report a syntax error, citing the offending file and line.
my $ln = 0;
## Report a syntax error, citing the offending file and line.
- sub syntax { fail "$fn:$ln: $_[0]"; }
+ my $syntax = sub { fail "$fn:$ln: $_[0]" };
## Report an error about an indented line with no stanza header.
## Report an error about an indented line with no stanza header.
- sub nomode { syntax "missing stanza header" };
- my $mode = \&nomode;
+ my $nomode = sub { $syntax->("missing stanza header") };
+ my $mode = $nomode;
## Parse an assignment LINE and store it in CSET.
## Parse an assignment LINE and store it in CSET.
my ($cset, $line) = @_;
$line =~ m{
^ \s*
my ($cset, $line) = @_;
$line =~ m{
^ \s*
\s* = \s*
(?P<VALUE> | \S | \S.*\S)
\s* $
\s* = \s*
(?P<VALUE> | \S | \S.*\S)
\s* $
- }x or syntax "invalid assignment";
+ }x or $syntax->("invalid assignment");
cset_store $cset, $+{TAG}, $+{IX} // "*", $+{VALUE};
cset_store $cset, $+{TAG}, $+{IX} // "*", $+{VALUE};
## Parse a subscription LINE and store it in @SUB.
## Parse a subscription LINE and store it in @SUB.
my ($line) = @_;
my @w = shellwords $line;
my @dist = ();
while (my $w = shift @w) { last if $w eq ":"; push @dist, $w; }
my ($line) = @_;
my @w = shellwords $line;
my @dist = ();
while (my $w = shift @w) { last if $w eq ":"; push @dist, $w; }
- @w and @dist or syntax "empty distribution or release list";
+ @w and @dist or $syntax->("empty distribution or release list");
push @SUB, [\@dist, \@w];
push @SUB, [\@dist, \@w];
## Split the header line into tokens and determine an action.
my @w = shellwords $line;
## Split the header line into tokens and determine an action.
my @w = shellwords $line;
if ($w[0] eq "distribution") {
if ($w[0] eq "distribution") {
- @w == 2 or syntax "usage: distribution NAME";
+ @w == 2 or $syntax->("usage: distribution NAME");
my $cset = $CSET{$w[1]} //= cset_new;
my $cset = $CSET{$w[1]} //= cset_new;
- $mode = sub { assign $cset, @_ };
+ $mode = sub { $assign->($cset, @_) };
} elsif ($w[0] eq "default") {
} elsif ($w[0] eq "default") {
- @w == 1 or syntax "usage: default";
- $mode = sub { assign \%DEFAULT, @_ };
+ @w == 1 or $syntax->("usage: default");
+ $mode = sub { $assign->(\%DEFAULT, @_) };
} elsif ($w[0] eq "subscribe") {
} elsif ($w[0] eq "subscribe") {
- @w == 1 or syntax "usage: subscribe";
- $mode = \&subscribe;
+ @w == 1 or $syntax->("usage: subscribe");
+ $mode = $subscribe;
- syntax "unknown toplevel directive `$w[0]'";
+ $syntax->("unknown toplevel directive `$w[0]'");