Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / mhnote.pl
CommitLineData
86530b38
AT
1##---------------------------------------------------------------------------##
2## File:
3## $Id: mhnote.pl,v 1.3 2001/09/17 16:10:26 ehood Exp $
4## Author:
5## Earl Hood mhonarc@mhonarc.org
6## Description:
7## Annotation routine for MHonArc.
8##---------------------------------------------------------------------------##
9## MHonArc -- Internet mail-to-HTML converter
10## Copyright (C) 1995-1999 Earl Hood, mhonarc@mhonarc.org
11##
12## This program is free software; you can redistribute it and/or modify
13## it under the terms of the GNU General Public License as published by
14## the Free Software Foundation; either version 2 of the License, or
15## (at your option) any later version.
16##
17## This program is distributed in the hope that it will be useful,
18## but WITHOUT ANY WARRANTY; without even the implied warranty of
19## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20## GNU General Public License for more details.
21##
22## You should have received a copy of the GNU General Public License
23## along with this program; if not, write to the Free Software
24## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25## 02111-1307, USA
26##---------------------------------------------------------------------------##
27
28package mhonarc;
29
30##---------------------------------------------------------------------------
31## Function for annotating messages.
32##
33sub annotate {
34 my $notetxt = pop(@_); # last arg is note data
35
36 my(@numbers) = ();
37 my($key, %Num2Index, $num, $i, $pg, $file);
38 local($_);
39
40 ## Create list of messages to annotate
41 foreach (@_) {
42 # range
43 if (/^(\d+)-(\d+)$/) {
44 push(@numbers, $1 .. $2); # range op removes leading zeros
45 next;
46 }
47 # single number
48 if (/^\d+$/) {
49 push(@numbers, int($_)); # int() removes leading zeros
50 next;
51 }
52 # probably message-id
53 push(@numbers, $_);
54 }
55
56 if ($#numbers < 0) {
57 warn("Warning: No messages specified\n");
58 return 0;
59 }
60
61 ## Make hash to perform deletions
62 foreach $key (keys %IndexNum) {
63 $Num2Index{$IndexNum{$key}} = $key;
64 }
65
66 ## Define %Index2MLoc for determining min main index page update
67 $i=0; foreach $key (sort_messages()) {
68 $Index2MLoc{$key} = $i++;
69 }
70
71 ## Make sure notes directory exists
72 my $notedir = get_note_dir();
73 if (! -d $notedir and !mkdir($notedir, 0777)) {
74 warn qq/Warning: Unable to create "$notedir": $!\n/;
75 return 0;
76 }
77
78 ## Annotate messages
79 foreach $num (@numbers) {
80 if ($key = $Num2Index{$num} || $MsgId{$num}) {
81
82 ## write note to file
83 $file = join($DIRSEP, $notedir,
84 msgid_to_filename($Index2MsgId{$key}));
85 if (!open(NOTEFILE, ">$file")) {
86 warn qq/Warning: Unable to create "$file": $!\n/;
87 next;
88 }
89 print NOTEFILE $notetxt;
90 close NOTEFILE;
91
92 ## flag message to be updated
93 $Update{$IndexNum{$key}} = 1;
94
95 ## mark where index page updates start
96 if ($MULTIIDX) {
97 $pg = int($Index2MLoc{$key}/$IDXSIZE)+1;
98 $IdxMinPg = $pg
99 if ($pg < $IdxMinPg || $IdxMinPg < 0);
100 $pg = int($Index2TLoc{$key}/$IDXSIZE)+1;
101 $TIdxMinPg = $pg
102 if ($pg < $TIdxMinPg || $TIdxMinPg < 0);
103 }
104
105 next;
106 }
107
108 # message not in archive
109 warn qq/Warning: Message "$num" not in archive\n/;
110 }
111
112 ## Clear data that will get recomputed
113 %Index2MLoc = ();
114
115 write_pages();
116 1;
117}
118
119##---------------------------------------------------------------------------##
1201;