From 0b8495aec177de33bb6ff4c19b63450b6a6bff44 Mon Sep 17 00:00:00 2001 From: epg <> Date: Mon, 26 Apr 2004 16:19:58 +0000 Subject: [PATCH] (getfiles): Just return readdir results, don't strip . and .. and 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 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/minc b/minc index 137f436..09ae2bb 100755 --- 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); } -- 2.56.0