]> diplodocus.org Git - minc/commitdiff
(getfiles): Just return readdir results, don't strip . and .. and
authorepg <>
Mon, 26 Apr 2004 16:19:58 +0000 (16:19 +0000)
committerepg <>
Mon, 26 Apr 2004 16:19:58 +0000 (16:19 +0000)
don't return absolute paths.  We walk the file list enough times
already, there's no need to walk it for this.

(filter_mail): Skip . and .. in the @msglist.

(MAIN): Instead of passing getfiles $MAILDIR/new, chdir there and pass '.'.

minc

diff --git a/minc b/minc
index 137f436..09ae2bb 100755 (executable)
--- a/minc
+++ b/minc
@@ -271,11 +271,7 @@ sub getfiles {
     # to detect an error.  Real Programmers don't handle errors,
     # right?  >sigh<
     $! = 0;
-    @result = grep {
-        ($_ ne '.' and $_ ne '..')
-          and $_ = "$MAILDIR/new/$_"
-      } readdir(DIR);
-
+    @result = readdir(DIR);
     if ($! != 0) {
         die("readdir($dir): $!");
     }
@@ -555,6 +551,8 @@ sub filter_mail {
     @baton = spam_start_hook();
 
     foreach $msg (@msglist) {
+        ($msg eq '.' or $msg eq '..') and next;
+
         if ($printfilenames) {
             print("$msg\n");
         }
@@ -596,6 +594,7 @@ MAIN: {
         exit;
     }
 
+    chdir("$MAILDIR/new") or die("chdir($MAILDIR/new): $!");
     filter_mail(map { $_->[1] }
                 sort { $a->[0] <=> $b->[0] }
                 map {
@@ -604,7 +603,7 @@ MAIN: {
                     }
                     [$st->mtime, $_]
                 }
-                getfiles("$MAILDIR/new"));
+                getfiles('.'));
 
     @SPAM and (exec('scan', '+SPAM', @SPAM) or die);
 }