update: Allow `;' comments.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 13 May 2024 22:51:57 +0000 (23:51 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 13 May 2024 22:55:48 +0000 (23:55 +0100)
Also, fix detection of erroneous input lines.

update

diff --git a/update b/update
index b2b60d8..79c6a35 100755 (executable)
--- 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 `$_'";
   }
 }