1#!/usr/local/bin/ruby
2
3# scan history
4
5def usage
6  STDERR.print "usage: scanhist -h HISTORY ML-archive1 ML-archive2 ...\n"
7  exit 1
8end
9
10def html_quote(s)
11  s.gsub!(/&/,"&")
12  s.gsub!(/</,"&lt;")
13  s.gsub!(/>/,"&gt;")
14  s
15end
16
17if ARGV.size == 0 then
18  usage
19end
20
21histfile = nil
22
23while ARGV[0] =~ /^-/
24  case ARGV.shift
25  when "-h"
26    histfile = ARGV.shift
27  else
28    usage
29  end
30end
31
32if histfile.nil? then
33  usage
34end
35
36patched = {}
37histline = {}
38f = open(histfile)
39while f.gets
40  if /Subject: (\[w3m-dev.*\])/ then
41    patched[$1] = true
42    histline[$1] = $.
43  end
44end
45f.close
46
47archive = {}
48subject = nil
49for fn in ARGV
50  f = open(fn)
51  while f.gets
52    if /^From / then
53       # beginning of a mail
54       subject = nil
55    elsif subject.nil? and /^Subject: / then
56       $_ =~ /Subject: (\[w3m-dev.*\])/
57       subject = $1
58       archive[subject] = [$_.chop.sub(/^Subject:\s*/,""),false,fn+"#"+($.).to_s]
59    elsif /^\+\+\+/ or /\*\*\*/ or  /filename=.*(patch|diff).*/ or /^begin \d\d\d/
60       archive[subject][1] = true
61    end
62  end
63  f.close
64end
65
66print "<html><head><title>w3m patch configuration\n</title></head><body>\n"
67print "<pre>\n"
68for sub in archive.keys.sort
69  a = archive[sub]
70  if a[1] then
71    if patched[sub] then
72      print "[<a href=\"#{histfile}\##{histline[sub]}\">+</a>]"
73    else
74      print "[-]"
75    end
76    print "<a href=\"#{a[2]}\">"
77    print "<b>",html_quote(a[0]),"</b></a>\n"
78  else
79    if patched[sub] then
80      print "[<a href=\"#{histfile}\##{histline[sub]}\">o</a>]"
81    else
82      print "   "
83    end
84    print "<a href=\"#{a[2]}\">"
85    print "<b>",html_quote(a[0]),"</b></a>\n"
86  end
87end
88print "</pre></body></html>\n"
89