From f3f01fd97cb4a423d2e15bb6d2d80f6b58ae1b7f Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Mon, 13 May 2024 23:51:57 +0100 Subject: [PATCH] update: Allow `;' comments. Also, fix detection of erroneous input lines. --- update | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/update b/update index b2b60d8..79c6a35 100755 --- a/update +++ b/update @@ -83,17 +83,22 @@ sub flush_set () { $st_delete_disc_range->execute($id, $min_ndisc, $old_ndisc); } - for (my $i = $min_ndisc; $i < $ndisc; $i++) - { $st_add_disc->execute($id, $i, $path[$i]); } + for (my $i = $min_ndisc; $i < $ndisc; $i++) { + my $box = $box{$path[$i]}; + $st_add_disc->execute($id, $i, $path[$i], + $box eq "#nil" ? undef : $box); + } - $id = undef; @path = (); + $id = undef; @path = (); %box = (); } LINE: while (<>) { chomp; - if (/^ \[ \# (\d+ | NEW | UNK) \s* : \s* (\d+ | \* | DEL) ] - \s* (\S .*)? $/x) { + if (/^ \s* (\; .*)? $/x) { + next LINE; + } elsif (/^ \[ \# (\d+ | NEW | UNK) \s* : \s* (\d+ | \* | DEL) ] + \s* (\S .*)? $/x) { flush_set; ($id, $ndisc, $name) = ($1, $2, $3); @@ -111,8 +116,8 @@ LINE: while (<>) { } elsif (/^ \s+ (?: !! \s*)? (\S .*) $/x) { my $path = $1; defined $id or die "no active set"; - push @path, $path; - } elsif (/^ .* \S .* $/) { + push @path, $path; $box{$path} = $curbox; + } else { die "unrecognized line `$_'"; } } -- 2.11.0