mhrmm.pl untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 1 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 72 CC 8 SCAR 42.8
CC
8
Cov
0%
rmm
72.0
CRAP 72.0
1 ##---------------------------------------------------------------------------##
2 ## File:
3 ## $Id: mhrmm.pl,v 1.6 2001/09/17 16:10:35 ehood Exp $
4 ## Author:
5 ## Earl Hood mhonarc@mhonarc.org
6 ## Description:
7 ## Rmm 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  
28 package mhonarc;
29  
30 ##---------------------------------------------------------------------------
31 ## Function for removing messages.
32 ##
33 sub rmm {
34 my (@numbers) = ();
35 my ($key, %Num2Index, $num, $i, $pg);
36 local ($_);
37  
38 ## Create list of messages to remove
39 foreach (@_) {
40 # range
41 if (/^(\d+)-(\d+)$/) {
42 push(@numbers, int($1) .. int($2));
43 next;
44 }
45 # single number
46 if (/^\d+$/) {
47 push(@numbers, int($_));
48 next;
49 }
50 # probably message-id
51 push(@numbers, $_);
52 }
53  
54 if ($#numbers < 0) {
55 warn("Warning: No messages specified\n");
56 return 0;
57 }
58  
59 ## Make hash to perform deletions
60 foreach $key (keys %IndexNum) {
61 $Num2Index{$IndexNum{$key}} = $key;
62 }
63  
64 ## Set @MListOrder to flag next/prev messages to be updated.
65 ## @TListOrder is already set since it is saved in db.
66 @MListOrder = &sort_messages();
67 $i = 0;
68 foreach $key (@MListOrder) {
69 $Index2MLoc{$key} = $i++;
70 }
71  
72 ## Remove messages
73 foreach $num (@numbers) {
74 if (($key = $Num2Index{$num}) || ($key = $MsgId{$num})) {
75 &delmsg($key);
76  
77 # Need to flag messages that link to deleted message so
78 # they will be updated.
79 foreach (@{$FollowOld{$index}}) {
80 $Update{$IndexNum{$_}} = 1;
81 }
82 $Update{$IndexNum{$TListOrder[$Index2TLoc{$key} - 1]}} = 1;
83 $Update{$IndexNum{$TListOrder[$Index2TLoc{$key} + 1]}} = 1;
84 $Update{$IndexNum{$MListOrder[$Index2MLoc{$key} - 1]}} = 1;
85 $Update{$IndexNum{$MListOrder[$Index2MLoc{$key} + 1]}} = 1;
86  
87 # Mark where index page updates start
88 if ($MULTIIDX) {
89 $pg = int($Index2MLoc{$key} / $IDXSIZE) + 1;
90 $IdxMinPg = $pg
91 if ($pg < $IdxMinPg || $IdxMinPg < 0);
92 $pg = int($Index2TLoc{$key} / $IDXSIZE) + 1;
93 $TIdxMinPg = $pg
94 if ($pg < $TIdxMinPg || $TIdxMinPg < 0);
95 }
96  
97 next;
98 }
99  
100 # message not in archive
101 warn qq/Warning: Message "$num" not in archive\n/;
102 }
103  
104 ## Clear loc data; it will get recomputed
105 @MListOrder = ();
106 %Index2MLoc = ();
107  
108 write_pages();
109 1;
110 }
111  
112 ##---------------------------------------------------------------------------##
113 1;