From: Mark Wooding Date: Mon, 13 May 2024 22:51:57 +0000 (+0100) Subject: update: Allow `;' comments. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/dvddb/commitdiff_plain/f3f01fd97cb4a423d2e15bb6d2d80f6b58ae1b7f?ds=sidebyside update: Allow `;' comments. Also, fix detection of erroneous input lines. --- 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 `$_'"; } }