chiark / gitweb /
Deal more sensibly with various combinations of input format
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 4 Mar 2010 17:23:17 +0000 (17:23 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 4 Mar 2010 17:23:17 +0000 (17:23 +0000)
xlog/bin/record

index 11c7e60..1ba50b7 100755 (executable)
@@ -39,16 +39,28 @@ sub parse_posted () {
 }
 sub parse_submission () {
     my $hadng=0;
+    my %oldf;
+    my $had2=0;
     while (<STDIN>) {
        chomp;
+print STDERR "$hadng $had2|$_|\n";
        $hadng++ if m/^Newsgroups:/i;
        if (m/^$/) {
            last if $hadng;
+           last if $had2++;
+           %oldf= %f;
            undef %f;
        }
+       last unless m/^\S+\:|^\s|^$|^From /;
        parse__headerline();
     }
-    $f{Event}= 'receive';
+    if ($hadng) {
+       $f{Event}= $had2 ? 'receive newstyle' : 'receive';
+    } else {
+       %f= %oldf if $had2;
+       $f{Subject}= '[suppressed]';
+       $f{Event}= 'receive junk';
+    }
 }
 
 sub parse_stump2webstump () {