mhonarc-commits
[Top] [All Lists]

CVS: mhonarc/MHonArc/lib mhamain.pl,2.93,2.94 mhdb.pl,2.40,2.41 mhdysub.pl,...

2009-05-03 16:11:37
Update of mhonarc/MHonArc/lib
Modified Files:
	mhamain.pl mhdb.pl mhdysub.pl mhindex.pl mhinit.pl mhopt.pl 
	mhrcvars.pl mhutil.pl 
Log Message:
* Added pre-extraction of From name and From address.  This
  provides a performance improvement for archives that make use
  of the $FROMADDR$ and $FROMADDRNAME$ resource variables along
  with author sorting.

* Added mapping of message index keys to time stamp.  This should
  provide some performance gain since parsing out of time stamp from
  index is no longer required.

* Cache last message number in db to avoid directory scan of archive
  each time an add operation is performed.  This provides a performance
  improvement for large archives and on file systems where directory
  reading with many files may not be optimal.  Thanks go to Christopher
  Lindsey for patch.

* Added References and In-Reply-To to as-is fields list to avoid
  automatic modification of message IDs if address-rewriting is
  in effect.


======================================================================
FILE: mhonarc/MHonArc/lib/mhamain.pl
<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/*checkout*/mhonarc/MHonArc/lib/mhamain.pl?rev=2.94>

<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/mhonarc/MHonArc/lib/mhamain.pl.diff?r1=2.93&r2=2.94&diff_format=h>
--- mhamain.pl	10 Jun 2006 02:42:58 -0000	2.93
+++ mhamain.pl	3 May 2009 20:11:27 -0000	2.94
@@ -8,5 +8,5 @@
 ##---------------------------------------------------------------------------##
 ##    MHonArc -- Internet mail-to-HTML converter
-##    Copyright (C) 1995-2005   Earl Hood, mhonarc(_at_)mhonarc(_dot_)org
+##    Copyright (C) 1995-2009   Earl Hood, mhonarc(_at_)mhonarc(_dot_)org
 ##
 ##    This program is free software; you can redistribute it and/or modify
@@ -30,8 +30,8 @@
 require 5;
 
-$VERSION = '2.6.16';
+$VERSION = '2.6.16+';
 $VINFO =<<EndOfInfo;
   MHonArc v$VERSION (Perl $] $^O)
-  Copyright (C) 1995-2005  Earl Hood, mhonarc\(_at_)mhonarc(_dot_)org
+  Copyright (C) 1995-2009  Earl Hood, mhonarc\(_at_)mhonarc(_dot_)org
   MHonArc comes with ABSOLUTELY NO WARRANTY and MHonArc may be copied only
   under the terms of the GNU General Public License, which may be found in
@@ -487,10 +487,10 @@
             last  unless
                     ($MAXSIZE && ($NumOfMsgs > $MAXSIZE)) ||
-                    (&expired_time(&get_time_from_index($index)));
+                    (&expired_time($Time{$index}));
 
             &delmsg($index);
 
             # Mark messages that need to be updated
-            if (!$NoMsgPgs) {
+            if (!$NoMsgPgs && !$KeepOnRmm) {
                 $mloc = $Index2MLoc{$index};  $tloc = $Index2TLoc{$index};
                 $Update{$IndexNum{$MListOrder[$mloc-1]}} = 1
@@ -869,5 +869,6 @@
     if (!$index) {
         warn qq/\nWarning: Could not parse date for message\n/,
-               qq/         Message-Id: <$msgid>\n/;
+               qq/         Message-Id: <$msgid>\n/,
+               qq/         Date: $date\n/;
         # Use current time
         $index = time;
@@ -937,4 +938,5 @@
 
     ## Insure uniqueness of index
+    my $t = $index;
     $index .= $X . sprintf('%d',(defined($msgnum)?$msgnum:($LastMsgNum+1)));
 
@@ -951,5 +953,8 @@
     }
 
+    $Time{$index} = $t;
     $From{$index} = $from;
+    $FromName{$index} = extract_email_name($from)  if $DoFromName;
+    $FromAddr{$index} = extract_email_address($from)  if $DoFromAddr;
     $Date{$index} = $date;
     $Subject{$index} = $sub;
@@ -1396,5 +1401,5 @@
     if ($MODTIME && !$SINGLE) {
         eval {
-            $tmp = get_time_from_index($index);
+            $tmp = $Time{$index};
             if (defined($Derived{$index})) {
               @array2 = @{$Derived{$index}};

======================================================================
FILE: mhonarc/MHonArc/lib/mhdb.pl
<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/*checkout*/mhonarc/MHonArc/lib/mhdb.pl?rev=2.41>

<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/mhonarc/MHonArc/lib/mhdb.pl.diff?r1=2.40&r2=2.41&diff_format=h>
--- mhdb.pl	20 Dec 2005 21:28:15 -0000	2.40
+++ mhdb.pl	3 May 2009 20:11:27 -0000	2.41
@@ -66,11 +66,17 @@
 print_var($db,'FollowOld',   \%Follow);
 print_var($db,'From',        \%From);
+print_var($db,'DoFromName',  \$DoFromName);
+print_var($db,'FromName',    \%FromName)  if $DoFromName;
+print_var($db,'DoFromAddr',  \$DoFromAddr);
+print_var($db,'FromAddr',    \%FromAddr)  if $DoFromAddr;
 print_var($db,'IndexNum',    \%IndexNum);
 print_var($db,'MsgId',       \%MsgId);
 print_var($db,'Refs',        \%Refs);
 print_var($db,'Subject',     \%Subject);
+print_var($db,'Time',        \%Time);
 print_var($db,'ExtraHFields',\(_at_)ExtraHFields);
 print_var($db,'ExtraHFields',\%ExtraHFields);
 print_var($db,'TListOrder',  \(_at_)TListOrder);
+print_var($db,'LastMsgNum',  \$LastMsgNum);
 print_var($db,'MAXPGS',      \$MAXPGS);
 print_var($db,'MULTIIDX',    \$MULTIIDX);

======================================================================
FILE: mhonarc/MHonArc/lib/mhdysub.pl
<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/*checkout*/mhonarc/MHonArc/lib/mhdysub.pl?rev=2.12>

<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/mhonarc/MHonArc/lib/mhdysub.pl.diff?r1=2.11&r2=2.12&diff_format=h>
--- mhdysub.pl	9 Mar 2004 07:14:01 -0000	2.11
+++ mhdysub.pl	3 May 2009 20:11:27 -0000	2.12
@@ -92,4 +92,6 @@
     ##-----------------------------------------------------------------------
     ##  Routine to determine last message number in use.
+    ##  If $LastMsgNum set, we return it after a sanity check
+    ##  is done.  If check fails, scan directory to determine last number.
     ##
     $sub =<<'EndOfRoutine';
@@ -97,4 +99,11 @@
         opendir(DIR, $OUTDIR) || die("ERROR: Unable to open $OUTDIR\n");
         my($max) = -1;
+        if ($LastMsgNum >= 0) {
+           return $LastMsgNum if (
+                 -s $OUTDIR . $DIRSEP . msgnum_filename($LastMsgNum)) &&
+                 ((! -f $OUTDIR . $DIRSEP . msgnum_filename($LastMsgNum + 1))
+           );
+        }
+
         my $msgrex = '^'.
                      "\Q$MsgPrefix".
@@ -108,4 +117,5 @@
         }
         closedir(DIR);
+        $LastMsgNum = $max;
         $max;
     }

======================================================================
FILE: mhonarc/MHonArc/lib/mhindex.pl
<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/*checkout*/mhonarc/MHonArc/lib/mhindex.pl?rev=1.14>

<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/mhonarc/MHonArc/lib/mhindex.pl.diff?r1=1.13&r2=1.14&diff_format=h>
--- mhindex.pl	8 Jul 2005 06:34:03 -0000	1.13
+++ mhindex.pl	3 May 2009 20:11:27 -0000	1.14
@@ -147,5 +147,5 @@
             my($time);
             foreach $index (@a) {
-                $time = &get_time_from_index($index);
+                $time = $Time{$index};
                 $tmp = join("", $UseLocalTime ? (localtime($time))[3,4,5] :
                                                 (gmtime($time))[3,4,5]);

======================================================================
FILE: mhonarc/MHonArc/lib/mhinit.pl
<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/*checkout*/mhonarc/MHonArc/lib/mhinit.pl?rev=2.55>

<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/mhonarc/MHonArc/lib/mhinit.pl.diff?r1=2.54&r2=2.55&diff_format=h>
--- mhinit.pl	8 Jul 2005 06:34:03 -0000	2.54
+++ mhinit.pl	3 May 2009 20:11:27 -0000	2.55
@@ -238,4 +238,5 @@
 %MsgHtml        = ();   # Flag if message is html
 %Subject        = ();   # Message indexes to subjects
+%Time           = ();   # Message indexes to message unix date/time
 %From           = ();   # Message indexes to froms
 %Date           = ();   # Message indexes to dates
@@ -251,4 +252,9 @@
 %AddIndex       = ();   # Flags for messages that must be written
 
+$DoFromName     = 1;
+$DoFromAddr     = 1;
+%FromName       = ();   # Message indexes to from human name
+%FromAddr       = ();   # Message indexes to from address
+
 @MListOrder     = ();   # List of indexes in order printed on main index
 %Index2Mloc     = ();   # Map index to position in main index

======================================================================
FILE: mhonarc/MHonArc/lib/mhopt.pl
<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/*checkout*/mhonarc/MHonArc/lib/mhopt.pl?rev=2.64>

<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/mhonarc/MHonArc/lib/mhopt.pl.diff?r1=2.63&r2=2.64&diff_format=h>
--- mhopt.pl	8 Jul 2005 06:34:03 -0000	2.63
+++ mhopt.pl	3 May 2009 20:11:27 -0000	2.64
@@ -419,4 +419,24 @@
             ## Set %Follow here just incase it does not get recomputed
             %Follow = %FollowOld;
+            
+            ## Check if %Time is defined
+            if (!%Time) {
+                my($k,$v);
+                while (($k,$v) = each %IndexNum) {
+                    $Time{$k} = (split(/$X/o, $k, 2))[0];
+                }
+            }
+            if ($DoFromAddr && !%FromAddr) {
+                my($k,$v);
+                while (($k,$v) = each %From) {
+                    $FromAddr{$k} = extract_email_address($v);
+                }
+            }
+            if ($DoFromName && !%FromName) {
+                my($k,$v);
+                while (($k,$v) = each %From) {
+                    $FromName{$k} = extract_email_name($v);
+                }
+            }
         }
         if (!$IDXONLY) {

======================================================================
FILE: mhonarc/MHonArc/lib/mhrcvars.pl
<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/*checkout*/mhonarc/MHonArc/lib/mhrcvars.pl?rev=2.29>

<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/mhonarc/MHonArc/lib/mhrcvars.pl.diff?r1=2.28&r2=2.29&diff_format=h>
--- mhrcvars.pl	8 Jul 2005 05:27:52 -0000	2.28
+++ mhrcvars.pl	3 May 2009 20:11:27 -0000	2.29
@@ -136,15 +136,37 @@
             last REPLACESW;
         }
-        my($cnd1, $cnd2, $cnd3) = (0,0,0);
-        if (($cnd1 = ($var eq 'FROM')) ||       ## Message "From:"
-            ($cnd2 = ($var eq 'FROMADDR')) ||   ## Message from mail address
-            ($cnd3 = ($var eq 'FROMNAME'))) {   ## Message from name
-            my $esub = $cnd1 ? sub { $_[0]; } :
-                       $cnd2 ? \&extract_email_address :
-                               \&extract_email_name;
+        if ($var eq 'FROM') {           ## Message "From:"
             $canclip = 1; $raw = 1;
             ($lref, $key, $pos) = compute_msg_pos($index, $var, $arg);
-            $tmp = defined($key) ? &$esub($From{$key}) : "(nil)";
-            if ($cnd3 && $SpamMode) {
+            $tmp = defined($key) ? $From{$key} : '(nil)';
+            $isaddr = 1;
+            last REPLACESW;
+        }
+        if ($var eq 'FROMADDR') {       ## Message from mail address
+            $canclip = 1; $raw = 1;
+            ($lref, $key, $pos) = compute_msg_pos($index, $var, $arg);
+            if (!defined($key)) {
+                $tmp = '(nil)';
+                last REPLACESW;
+            }
+            my $caddr = $FromAddr{$key};
+            $tmp = defined($caddr)
+                    ? $caddr
+                    : extract_email_address($From{$key});
+            $isaddr = 1;
+            last REPLACESW;
+        }
+        if ($var eq 'FROMNAME') {       ## Message from mail name
+            $canclip = 1; $raw = 1;
+            ($lref, $key, $pos) = compute_msg_pos($index, $var, $arg);
+            if (!defined($key)) {
+                $tmp = '(nil)';
+                last REPLACESW;
+            }
+            my $cname = $FromName{$key};
+            $tmp = defined($cname)
+                    ? $cname
+                    : extract_email_name($From{$key});
+            if ($SpamMode) {
                 $tmp =~ s/($AddrExp)/rewrite_raw_address($1)/geo;
             } else {
@@ -153,4 +175,6 @@
             last REPLACESW;
         }
+
+        my($cnd1, $cnd2) = (0,0);
         if ( ($cnd1 = ($var eq 'FROMADDRNAME')) ||
              ($cnd2 = ($var eq 'FROMADDRDOMAIN')) ) {
@@ -160,5 +184,11 @@
                 last REPLACESW;
             }
-            my @a = split(/@/, extract_email_address($From{$key}), 2);
+            my $caddr = $FromAddr{$key};
+            my @a;
+            if (defined($caddr)) {
+              @a = split(/@/, $caddr, 2);
+            } else {
+              @a = split(/@/, extract_email_address($From{$key}), 2);
+            }
             if ($cnd1) {
                 $tmp = $a[0];
@@ -227,5 +257,5 @@
             ($lref, $key, $pos, $opt) = compute_msg_pos($index, $var, $arg);
             $tmp = &time2str($opt || $MsgGMTDateFmt,
-                             &get_time_from_index($key), 0);
+                             $Time{$key}, 0);
             last REPLACESW;
         }
@@ -238,5 +268,5 @@
             ($lref, $key, $pos, $opt) = compute_msg_pos($index, $var, $arg);
             $tmp = &time2str($opt || $MsgLocalDateFmt,
-                             &get_time_from_index($key), 1);
+                             $Time{$key}, 1);
             last REPLACESW;
         }

======================================================================
FILE: mhonarc/MHonArc/lib/mhutil.pl
<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/*checkout*/mhonarc/MHonArc/lib/mhutil.pl?rev=2.33>

<http://www.mhonarc.org/cgi-bin/viewcvs.cgi/mhonarc/MHonArc/lib/mhutil.pl.diff?r1=2.32&r2=2.33&diff_format=h>
--- mhutil.pl	8 Jul 2005 05:27:53 -0000	2.32
+++ mhutil.pl	3 May 2009 20:11:27 -0000	2.33
@@ -40,5 +40,5 @@
 );
 
-## Do not apply ADDRESSMODIFYCODE headerfiels
+## Do not apply ADDRESSMODIFYCODE headerfields
 %HFieldsAsIsList = (
     %HFieldsList,
@@ -47,4 +47,6 @@
     'content-type'        => 1,
     'message-id'          => 1,
+    'references'          => 1,
+    'in-reply-to'         => 1,
 );
 
@@ -241,9 +243,9 @@
         if ($revsort) {
             return sort { ($sub{$a} cmp $sub{$b}) ||
-                          (get_time_from_index($b) <=> get_time_from_index($a))
+                          ($Time{$b} <=> $Time{$a})
                         } keys %Subject;
         } else {
             return sort { ($sub{$a} cmp $sub{$b}) ||
-                          (get_time_from_index($a) <=> get_time_from_index($b))
+                          ($Time{$a} <=> $Time{$b})
                         } keys %Subject;
         }
@@ -257,15 +259,20 @@
             keys(%from) = $hs;
         };
-        while (($idx, $from) = each(%From)) {
-            $from = lc extract_email_name($from);
-            $from{$idx} = $from;
+        if ($DoFromName && %FromName) {
+            while (($idx, $from) = each(%FromName)) {
+                $from{$idx} = lc $from;
+            }
+        } else {
+            while (($idx, $from) = each(%From)) {
+                $from{$idx} = lc extract_email_name($from);
+            }
         }
         if ($revsort) {
             return sort { ($from{$a} cmp $from{$b}) ||
-                          (get_time_from_index($b) <=> get_time_from_index($a))
+                          ($Time{$b} <=> $Time{$a})
                         } keys %Subject;
         } else {
             return sort { ($from{$a} cmp $from{$b}) ||
-                          (get_time_from_index($a) <=> get_time_from_index($b))
+                          ($Time{$a} <=> $Time{$a})
                         } keys %Subject;
         }
@@ -274,9 +281,9 @@
         ## Date order
         if ($revsort) {
-            return sort { (get_time_from_index($b) <=> get_time_from_index($a))
+            return sort { ($Time{$b} <=> $Time{$a})
                           || ($IndexNum{$b} <=> $IndexNum{$a})
                         } keys %Subject;
         } else {
-            return sort { (get_time_from_index($a) <=> get_time_from_index($b))
+            return sort { ($Time{$a} <=> $Time{$b})
                           || ($IndexNum{$a} <=> $IndexNum{$b})
                         } keys %Subject;
@@ -321,5 +328,5 @@
 ##
 sub get_time_from_index {
-    (split(/$X/o, $_[0], 2))[0];
+    $Time{$_[0]} || (split(/$X/o, $_[0], 2))[0];
 }
 
@@ -360,4 +367,7 @@
 ##
 sub get_base_author {
+    if ($DoFromName && %FromName) {
+      return lc $FromName{$_[0]};
+    }
     lc extract_email_name($From{$_[0]});
 }
@@ -486,5 +496,5 @@
                                                  &$MHeadCnvFunc($tmp);
                     $tmp = field_add_links($item, $tmp, $fields)
-                        unless $HFieldsAsIsList{$key};
+                        unless $HFieldsAsIsList{$item};
                     ($tago, $tagc, $ftago, $ftagc) = &get_header_tags($item);
                     $mesg .= join('', $LABELBEG,

---------------------------------------------------------------------
To sign-off this list, send email to majordomo(_at_)mhonarc(_dot_)org with the
message text UNSUBSCRIBE MHONARC-COMMITS