]> diplodocus.org Git - minc/commitdiff
(mark): Since new.c only uses the lists from .mh_sequences, it doesn't
authorepg <>
Thu, 19 Jan 2006 19:48:46 +0000 (19:48 +0000)
committerepg <>
Thu, 19 Jan 2006 19:48:46 +0000 (19:48 +0000)
parse them, simply appending here really hurts.  Bite the bullet and
properly merge new messages into the existing .mh_sequences message
lists (i.e. 1-39 becomes 1-40).

minc

diff --git a/minc b/minc
index 8ac7af2..a48e412 100755 (executable)
--- a/minc
+++ b/minc
@@ -361,8 +361,42 @@ sub mark {
     my $marked = 0;
     open($fh, '>', $fn) or die("open(>$fn): $!");
     for $_ (@sequences) {
-        if (/^$seq: /) {
-            print($fh "$_ $msgnum\n");
+        if (/^$seq: (.*)/) {
+            my @parts;
+            my @result;
+            my $done = 0;
+            for my $part (split(' ', $1)) {
+                if (not $done) {
+                    my ($st, $en) = split('-', $part);
+                    if ((defined($en) and ($msgnum >= $st and $msgnum <= $en))
+                        or $msgnum == $st) {
+                        # It's already there.
+                        $done = 1;
+                    }
+                    if (defined($en)) {
+                        if ($st - 1 == $msgnum) {
+                            $part = "$msgnum-$en";
+                            $done = 1;
+                        } elsif ($en + 1 == $msgnum) {
+                            $part = "$st-$msgnum";
+                            $done = 1;
+                        }
+                    } else {
+                        if ($part - 1 == $msgnum) {
+                            $part = "$msgnum-$part";
+                            $done = 1;
+                        } elsif ($part + 1 == $msgnum) {
+                            $part = "$part-$msgnum";
+                            $done = 1;
+                        }
+                    }
+                }
+                push(@result, $part);
+            }
+            if (not $done) {
+                push(@result, $msgnum);
+            }
+            print($fh "$seq: ", join(' ', @result), "\n");
             $marked = 1;
         } else {
             print($fh "$_\n");