You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by mm...@apache.org on 2007/08/22 02:04:54 UTC

svn commit: r568336 - in /spamassassin/trunk/lib/Mail: ./ SpamAssassin/ SpamAssassin/BayesStore/ SpamAssassin/Conf/ SpamAssassin/Locker/ SpamAssassin/Logger/ SpamAssassin/Plugin/ SpamAssassin/Util/

Author: mmartinec
Date: Tue Aug 21 17:04:52 2007
New Revision: 568336

URL: http://svn.apache.org/viewvc?rev=568336&view=rev
Log:
take two: converted almost all eval calls in lib to check for eval result instead of for $@, as per bug 5589; some futher dbg calls edits

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/AICache.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/AutoWhitelist.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Conf/LDAP.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Conf/SQL.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Locker/Flock.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Logger.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Logger/Syslog.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AWL.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyRuleBaseExtractor.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DKIM.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/MIMEHeader.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/SPF.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/PluginHandler.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Timeout.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Util/MemoryDump.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Util/Progress.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin.pm Tue Aug 21 17:04:52 2007
@@ -383,7 +383,11 @@
   eval '
     use Mail::SpamAssassin::Locker::'.$class.';
     $self->{locker} = new Mail::SpamAssassin::Locker::'.$class.' ($self);
-  '; ($@) and die $@;
+    1;
+  ' or do {
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    die "Mail::SpamAssassin::Locker::$class error: $eval_stat\n";
+  };
 
   if (!defined $self->{locker}) { die "locker: oops! no locker"; }
 }
@@ -1431,7 +1435,7 @@
             (($t->{end} - $t->{start}) * 1000) + ($t->{elapsed} || 0));
 
   if (would_log('dbg', 'timing') > 1) {
-    dbg("timing: '$name' ended after ".$t->{elapsed}." msecs");
+    dbg("timing: '%s' ended after %.0f msecs", $name, $t->{elapsed});
   }
 }
 
@@ -1672,7 +1676,12 @@
 
   if (!-d $fname) {
     # not being able to create the *dir* is not worth a warning at all times
-    eval { mkpath($fname, 0, 0700) } or dbg("config: mkdir $fname failed: $@ $!\n");
+    eval {
+      mkpath($fname, 0, 0700);  1;
+    } or do {
+      my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+      dbg("config: mkdir $fname failed: $eval_stat");
+    };
   }
 
   $fname;

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/AICache.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/AICache.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/AICache.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/AICache.pm Tue Aug 21 17:04:52 2007
@@ -144,10 +144,11 @@
   # create enclosing dir tree, if required
   eval {
     mkpath(dirname($self->{cache_file}));
+    1;
+  } or do {
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    warn "Can't mkpath for AI cache file ($self->{cache_file}): $eval_stat\n";
   };
-  if ($@) {
-    warn "Can't mkpath for AI cache file (".$self->{cache_file}."): $@ $!";
-  }
 
   my $towrite = '';
   while(my($k,$v) = each %{$self->{cache}}) {

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/AutoWhitelist.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/AutoWhitelist.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/AutoWhitelist.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/AutoWhitelist.pm Tue Aug 21 17:04:52 2007
@@ -78,11 +78,13 @@
       eval '
   	    require '.$type.';
             $factory = '.$type.'->new();
-           ';
-      if ($@) { 
-	warn "auto-whitelist: $@";
+            1;
+           '
+      or do {
+	my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+	warn "auto-whitelist: $eval_stat\n";
 	undef $factory;
-      }
+      };
       $main->set_persistent_address_list_factory($factory) if $factory;
     }
     else {

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Bayes.pm Tue Aug 21 17:04:52 2007
@@ -242,8 +242,11 @@
     eval '
       require '.$module.';
       $store = '.$module.'->new($self);
-    ';
-    if ($@) { die $@; }
+      1;
+    ' or do {
+      my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+      die "bayes: (in new) $eval_stat\n";
+    };
     $self->{store} = $store;
   }
   else {
@@ -714,13 +717,12 @@
         $self->{store}->untie_db();
       }
     }
-  };
-
-  if ($@) {		# if we died, untie the dbs.
-    my $failure = $@;
+    1;
+  } or do {		# if we died, untie the dbs.
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
     $self->{store}->untie_db();
-    die "bayes: $failure";
-  }
+    die "bayes: (in learn) $eval_stat\n";
+  };
 
   return $ret;
 }
@@ -848,13 +850,12 @@
         $self->{store}->untie_db();
       }
     }
-  };
-
-  if ($@) {		# if we died, untie the dbs.
-    my $failure = $@;
+    1;
+  } or do {		# if we died, untie the dbs.
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
     $self->{store}->untie_db();
-    die "bayes: $failure";
-  }
+    die "bayes: (in forget) $eval_stat\n";
+  };
 
   return $ret;
 }

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore.pm Tue Aug 21 17:04:52 2007
@@ -209,20 +209,23 @@
   my ($self, $opts) = @_;
   my $ret;
 
+  my $eval_stat;
   eval {
     local $SIG{'__DIE__'};	# do not run user die() traps in here
     if ($self->tie_db_writable()) {
       $ret = $self->expire_old_tokens_trapped ($opts);
     }
+    1;
+  } or do {
+    $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
   };
-  my $err = $@;
 
   if (!$self->{bayes}->{main}->{learn_caller_will_untie}) {
     $self->untie_db();
   }
 
-  if ($err) {		# if we died, untie the dbs.
-    warn "bayes: expire_old_tokens: $err\n";
+  if (defined $eval_stat) {	# if we died, untie the dbs.
+    warn "bayes: expire_old_tokens: $eval_stat\n";
     return 0;
   }
   $ret;

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/BayesStore/DBM.pm Tue Aug 21 17:04:52 2007
@@ -1195,13 +1195,16 @@
     return 0;
   }
 
+  my $eval_stat;
   eval {
     local $SIG{'__DIE__'};	# do not run user die() traps in here
     if ($self->tie_db_writable()) {
       $ret = $self->_sync_journal_trapped($opts, $path);
     }
+    1;
+  } or do {
+    $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
   };
-  my $err = $@;
 
   # ok, untie from write-mode if we can
   if (!$self->{bayes}->{main}->{learn_caller_will_untie}) {
@@ -1209,8 +1212,8 @@
   }
 
   # handle any errors that may have occurred
-  if ($err) {
-    warn "bayes: $err\n";
+  if (defined $eval_stat) {
+    warn "bayes: $eval_stat\n";
     return 0;
   }
 
@@ -1413,6 +1416,7 @@
   my ($self, $opts) = @_;
   my $ret = 0;
 
+  my $eval_stat;
   eval {
     local $SIG{'__DIE__'};	# do not run user die() traps in here
 
@@ -1458,14 +1462,16 @@
     else {
       print "import failed, original files saved with \"old\" prefix\n";
     }
+    1;
+  } or do {
+    $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
   };
-  my $err = $@;
 
   $self->untie_db();
 
   # if we died, untie the dbm files
-  if ($err) {
-    warn "bayes: perform_upgrade: $err\n";
+  if (defined $eval_stat) {
+    warn "bayes: perform_upgrade: $eval_stat\n";
     return 0;
   }
   $ret;
@@ -1486,15 +1492,19 @@
     # modules directly.
     # Note: (bug 2390), the 'use' needs to be on the same line as the eval
     # for RPM dependency checks to work properly.  It's lame, but...
+    my $eval_stat;
     eval 'use ' . $dbm . ';
       tie %in, "' . $dbm . '", $filename, O_RDONLY, 0600;
       %{ $output } = %in;
       $count = scalar keys %{ $output };
       untie %in;
-    ';
-    if ($@) {
-      print "$dbm: $dbm module not installed, nothing copied\n";
-      dbg("bayes: error was: $@");
+      1;
+    ' or do {
+      $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    };
+    if (defined $eval_stat) {
+      print "$dbm: $dbm module not installed(?), nothing copied: $eval_stat\n";
+      dbg("bayes: error was: $eval_stat");
     }
     elsif ($count == 0) {
       print "$dbm: no database of that kind found, nothing copied\n";

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf/LDAP.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf/LDAP.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf/LDAP.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf/LDAP.pm Tue Aug 21 17:04:52 2007
@@ -104,11 +104,11 @@
      require Net::LDAP;
      require URI;
      load_with_ldap($self, $username, $url);
+     1;
+   } or do {
+     my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+     warn "ldap: failed to load user ($username) scores from LDAP server, ignored: $eval_stat\n";
    };
-
-   if ($@) {
-     warn "ldap: failed to load user scores from LDAP server, ignored ($@)\n";
-   }
 }
 
 sub load_with_ldap {

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf/Parser.pm Tue Aug 21 17:04:52 2007
@@ -1114,13 +1114,11 @@
   if (eval $evalstr) {
     return 1;
   }
-  if ($@) {
-    my $err = $@;
-    $err =~ s/\s+(?:at|near)\b.*//s;
-    $err =~ s/Illegal division by zero/division by zero possible/i;
-    $self->lint_warn("config: invalid expression for rule $name: \"$rule\": $err\n", $name);
-    return 0;
-  }
+  my $err = $@ ne '' ? $@ : "errno=$!";  chomp $err;
+  $err =~ s/\s+(?:at|near)\b.*//s;
+  $err =~ s/Illegal division by zero/division by zero possible/i;
+  $self->lint_warn("config: invalid expression for rule $name: \"$rule\": $err\n", $name);
+  return 0;
 }
 
 sub is_delimited_regexp_valid {
@@ -1174,8 +1172,7 @@
   if (eval { ("" =~ m#${re}#); 1; }) {
     return 1;
   }
-
-  my $err = $@;
+  my $err = $@ ne '' ? $@ : "errno=$!";  chomp $err;
   $err =~ s/ at .*? line \d.*$//;
   $self->lint_warn("config: invalid regexp for rule $name: $origre: $err\n", $name);
   return 0;

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf/SQL.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf/SQL.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf/SQL.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf/SQL.pm Tue Aug 21 17:04:52 2007
@@ -100,12 +100,12 @@
      local $SIG{'__DIE__'} = sub { die "$_[0]"; };
      require DBI;
      load_with_dbi($self, $username, $dsn);
-   };
-
-   if ($@) {
-     warn "config: failed to load user ($username) scores from SQL database: $@\n";
+     1;
+   } or do {
+     my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+     warn "config: failed to load user ($username) scores from SQL database: $eval_stat\n";
      return 0;
-   }
+   };
    return 1;
 }
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/DnsResolver.pm Tue Aug 21 17:04:52 2007
@@ -133,7 +133,10 @@
       $self->{res}->persistent_udp(0);  # bug 3997
     }
     1;
-  };   #  or warn "dns: eval failed: $@ $!\n";
+  } or do {
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    dbg("dns: eval failed: $eval_stat");
+  };
 
   dbg("dns: no ipv6") if $force_ipv4;
   dbg("dns: is Net::DNS::Resolver available? %s",

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Locker/Flock.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Locker/Flock.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Locker/Flock.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Locker/Flock.pm Tue Aug 21 17:04:52 2007
@@ -72,6 +72,7 @@
 
   # use a SIGALRM-based timer -- more efficient than second-by-second
   # sleeps
+  my $eval_stat;
   eval {
     local $SIG{ALRM} = sub { die "alarm\n" };
     dbg("locker: safe_lock: trying to get lock on $path with $max_retries timeout");
@@ -96,16 +97,18 @@
       $self->{lock_fhs} ||= { };
       $self->{lock_fhs}->{$path} = $fh;
     }
+    1;
+  } or do {
+    $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
   };
 
-  my $err = $@;
-
   $unalarmed or alarm $oldalarm; # if we die'd above, need to reset here
-  if ($err) {
-    if ($err =~ /alarm/) {
+
+  if (defined $eval_stat) {
+    if ($eval_stat =~ /alarm/) {
       dbg("locker: safe_lock: timed out after $max_retries seconds");
     } else {
-      die "locker: safe_lock: $err";
+      die "locker: safe_lock: $eval_stat\n";
     }
   }
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Logger.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Logger.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Logger.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Logger.pm Tue Aug 21 17:04:52 2007
@@ -238,21 +238,36 @@
   my $name = lc($params{method});
   my $class = ucfirst($name);
 
-  eval 'use Mail::SpamAssassin::Logger::'.$class.';';
-  ($@) and die "logger: add $class failed: $@";
+  eval 'use Mail::SpamAssassin::Logger::'.$class.'; 1'
+  or do {
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    die "logger: add $class failed: $eval_stat\n";
+  };
 
   if (!exists $LOG_SA{method}->{$name}) {
-    my $object = eval 'Mail::SpamAssassin::Logger::'.$class.'->new(%params);';
-    if (!$@ && $object) {
+    my $object;
+    my $eval_stat;
+    eval '$object = Mail::SpamAssassin::Logger::'.$class.'->new(%params); 1'
+    or do {
+      $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+      undef $object;  # just in case
+    };
+    if (!$object) {
+      if (!defined $eval_stat) {
+        $eval_stat = "Mail::SpamAssassin::Logger::$class->new ".
+                     "failed to return an object";
+      }
+      warn "logger: failed to add $name method: $eval_stat\n";
+    }
+    else {
       $LOG_SA{method}->{$name} = $object;
       dbg("logger: successfully added $name method\n");
       return 1;
     }
-    warn("logger: failed to add $name method ($@)\n");
     return 0;
   }
 
-  warn("logger: $name method already added\n");
+  warn "logger: $name method already added\n";
   return 1;
 }
 
@@ -272,7 +287,7 @@
     info("logger: removing $name method");
     return 1;
   }
-  warn("logger: unable to remove $name method, not present to be removed");
+  warn "logger: unable to remove $name method, not present to be removed\n";
   return 1;
 }
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Logger/Syslog.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Logger/Syslog.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Logger/Syslog.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Logger/Syslog.pm Tue Aug 21 17:04:52 2007
@@ -72,36 +72,43 @@
 
   my $log_socket = $self->{log_socket};
 
-  dbg("logger: trying to connect to syslog/${log_socket}...\n");
+  dbg("logger: trying to connect to syslog/$log_socket ...\n");
+  my $eval_stat;
   eval {
-    defined(setlogsock($log_socket)) || die "logger: $!";
+    defined(setlogsock($log_socket))
+      or die "setlogsock($log_socket) failed: $!";
     dbg("logger: opening syslog with $log_socket socket");
     # the next call is required to actually open the socket
     openlog($self->{ident}, 'cons,pid,ndelay', $self->{log_facility});
+    1;
+  } or do {
+    $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    dbg("logger: connection to syslog/$log_socket failed: $eval_stat");
   };
-  my $err = $@;
-  chomp($err);
 
   # Solaris sometimes doesn't support UNIX-domain syslog sockets apparently;
   # the same is true for perl 5.6.0 build on an early version of Red Hat 7!
   # In these cases we try it with INET instead.
-  if ($err and $log_socket ne 'inet') {
-    dbg("logger: connection to syslog/${log_socket} failed: $err\n"
-	. "trying to connect to syslog/inet...");
+  if (defined($eval_stat) && $log_socket ne 'inet') {
+    dbg("logger: trying to connect to syslog/inet...");
+    undef $eval_stat;
     eval {
-      defined(setlogsock('inet')) || die "logger: $!";
-      dbg("logger: failed to setlogsock(${log_socket}): $err");
+      defined(setlogsock('inet')) or die "setlogsock('inet') failed: $!";
       dbg("logger: opening syslog using inet socket");
       openlog($self->{ident}, 'cons,pid,ndelay', $self->{log_facility});
+      1;
+    } or do {
+      $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+      dbg("logger: connection to syslog/inet failed: $eval_stat");
     };
   }
 
   # we failed!
-  if ($@) {
+  if (defined $eval_stat) {
     return 0;
   }
   else {
-    dbg("logger: successfully connected to syslog/${log_socket}");
+    dbg("logger: successfully connected to syslog/$log_socket");
     return 1;
   }
 }
@@ -129,15 +136,20 @@
   # child_handler().   otherwise we can get into a loop if syslog()
   # forks a process -- as it does in syslog-ng apparently! (bug 3625)
   $Mail::SpamAssassin::Logger::LOG_SA{INHIBIT_LOGGING_IN_SIGCHLD_HANDLER} = 1;
-  eval { syslog($level, "%s", $msg); };
+  my $eval_stat;
+  eval {
+    syslog($level, "%s", $msg); 1;
+  } or do {
+    $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+  };
   $Mail::SpamAssassin::Logger::LOG_SA{INHIBIT_LOGGING_IN_SIGCHLD_HANDLER} = 0;
 
-  if ($@) {
+  if (defined $eval_stat) {
     if ($self->check_syslog_sigpipe($msg)) {
       # dealt with
     }
     else {
-      warn "logger: syslog failed: $@"; # includes a \n
+      warn "logger: syslog failed: $eval_stat\n";
 
       # only write this warning once, it gets annoying fast
       if (!$self->{already_done_failure_warning}) {
@@ -183,9 +195,10 @@
 
     $self->{SIGPIPE_RECEIVED} = 0;
     return 1;
-  };
-
-  if ($@) {     # something died?  that's not good.
+    1;  # just to not forget a good habit
+  } or do {  # something died?  that's not good.
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    dbg("log: failure in check_syslog_sigpipe: $eval_stat");
     $self->syslog_incr_failure_counter();
   }
 }

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Tue Aug 21 17:04:52 2007
@@ -232,6 +232,7 @@
   # bug 3704: temporarily override learn's ability to re-learn a message
   my $orig_learner = $self->{main}->init_learner({ "no_relearn" => 1 });
 
+  my $eval_stat;
   eval {
     my $learnstatus = $self->{main}->learn ($self->{msg}, undef, $isspam, 0);
     if ($learnstatus->did_learn()) {
@@ -244,13 +245,15 @@
     if (exists $self->{main}->{bayes_scanner}) {
       $self->{main}->{bayes_scanner}->sanity_check_is_untied();
     }
+  } or do {
+    $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
   };
 
   # reset learner options to their original values
   $self->{main}->init_learner($orig_learner);
 
-  if ($@) {
-    dbg("learn: auto-learning failed: $@");
+  if (defined $eval_stat) {
+    dbg("learn: auto-learning failed: $eval_stat");
     $self->{auto_learn_status} = "failed";
   }
 }
@@ -2048,7 +2051,7 @@
     my $elapsed = time - $start;
 
     if (!$self->is_rule_complete($r)) {
-      dbg ("rules: rule $r is still not complete; exited early?");
+      dbg("rules: rule $r is still not complete; exited early?");
     }
     elsif ($elapsed > 0) {
       info("rules: $r took $elapsed seconds to complete, for $metarule");
@@ -2098,12 +2101,12 @@
 	1;
 }
 ENDOFEVAL
-  eval $evalstr;    ## no critic
-
-  if ($@) {
-    warn "rules: failed to run header tests, skipping some: $@\n";
+  eval $evalstr . '; 1'   ## no critic
+  or do {
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    warn "rules: failed to run header tests, skipping some: $eval_stat\n";
     $self->{rule_errors}++;
-  }
+  };
 
   # ensure this method is deleted if finish_tests() is called
   push (@TEMPORARY_METHODS, $function);
@@ -2317,9 +2320,11 @@
     # Warn them if it's configured, but not there or not usable.
     if (defined $envf) {
       chomp $envf;
-      dbg("message: envelope_sender_header '$self->{conf}->{envelope_sender_header}: $envf' is not an FQDN, ignoring");
+      dbg("message: envelope_sender_header '%s: %s' is not an FQDN, ignoring",
+          $self->{conf}->{envelope_sender_header}, $envf);
     } else {
-      dbg("message: envelope_sender_header '".$self->{conf}->{envelope_sender_header}."' not found in message");
+      dbg("message: envelope_sender_header '%s' not found in message",
+          $self->{conf}->{envelope_sender_header});
     }
     # Couldn't get envelope-sender using the configured header.
     return;

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AWL.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AWL.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AWL.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AWL.pm Tue Aug 21 17:04:52 2007
@@ -351,7 +351,7 @@
 
    # Create the AWL object
     my $whitelist;
-    my $evalok = eval {
+    eval {
       $whitelist = Mail::SpamAssassin::AutoWhitelist->new($pms->{main});
 
       # check
@@ -388,14 +388,13 @@
 
       $whitelist->finish();
       1;
-    };
-
-    if (!$evalok) {
-      warn("auto-whitelist: open of auto-whitelist file failed: $@");
+    } or do {
+      my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+      warn("auto-whitelist: open of auto-whitelist file failed: $eval_stat\n");
       # try an unlock, in case we got that far
       eval { $whitelist->finish(); } if $whitelist;
       return 0;
-    }
+    };
 
     dbg("auto-whitelist: post auto-whitelist score: ".$pms->{score});
 
@@ -428,13 +427,13 @@
       $status = 1;
     }
     $whitelist->finish();
-  };
-
-  if ($@) {
-    warn("auto-whitelist: open of auto-whitelist file failed: $@");
+    1;
+  } or do {
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    warn("auto-whitelist: open of auto-whitelist file failed: $eval_stat\n");
     eval { $whitelist->finish(); };
     return 0;
-  }
+  };
 
   return $status;
 }
@@ -465,13 +464,13 @@
     }
 
     $whitelist->finish();
-  };
-
-  if ($@) {
-    warn("auto-whitelist: open of auto-whitelist file failed: $@");
+    1;
+  } or do {
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    warn("auto-whitelist: open of auto-whitelist file failed: $eval_stat\n");
     eval { $whitelist->finish(); };
     return 0;
-  }
+  };
 
   return $status;
 }
@@ -502,13 +501,13 @@
     }
   
     $whitelist->finish();
-  };
-
-  if ($@) {
-    warn("auto-whitelist: open of auto-whitelist file failed: $@");
+    1;
+  } or do {
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    warn("auto-whitelist: open of auto-whitelist file failed: $eval_stat\n");
     eval { $whitelist->finish(); };
     return 0;
-  }
+  };
 
   return $status;
 }

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyRuleBaseExtractor.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyRuleBaseExtractor.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyRuleBaseExtractor.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/BodyRuleBaseExtractor.pm Tue Aug 21 17:04:52 2007
@@ -168,8 +168,11 @@
     eval {  # catch die()s
       my ($qr, $mods) = $self->simplify_and_qr_regexp($rule);
       ($lossy, @bases) = $self->extract_hints($rule, $qr, $mods);
+      1;
+    } or do {
+      my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+      dbg("zoom: giving up on regexp: $eval_stat");
     };
-    $@ and dbg("giving up on regexp: $@");
 
     # if any of the extracted hints in a set are too short, the entire
     # set is invalid; this is because each set of N hints represents just
@@ -221,9 +224,8 @@
 
   $self->{show_progress} and $progress->final();
 
-  dbg ("$ruletype: found ".(scalar @good_bases).
-        " usable base strings in ".
-        "$yes rules, skipped $no rules");
+  dbg("zoom: $ruletype: found ".(scalar @good_bases).
+      " usable base strings in $yes rules, skipped $no rules");
 
   # NOTE: re2c will attempt to provide the longest pattern that matched; e.g.
   # ("food" =~ "foo" / "food") will return "food".  So therefore if a pattern

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm Tue Aug 21 17:04:52 2007
@@ -190,14 +190,14 @@
 
     my $result;
     eval {
-       $result = $pms->$function($rulename, @args);
-    };
-
-    if ($@) {
-      warn "rules: failed to run $rulename RBL test, skipping:\n" . "\t($@)\n";
+      $result = $pms->$function($rulename, @args);  1;
+    } or do {
+      my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+      warn "rules: failed to run $rulename RBL test, skipping:\n".
+           "\t($eval_stat)\n";
       $pms->{rule_errors}++;
       next;
-    }
+    };
   }
 }
 
@@ -210,7 +210,7 @@
                                         { permsgstatus => $pms });
 
   my $ruletype = $opts{type};
-  dbg("rules: running ".$ruletype." tests; score so far=".$pms->{score});
+  dbg("rules: running $ruletype tests; score so far=".$pms->{score});
   $pms->{test_log_msgs} = ();        # clear test state
 
   my $conf = $pms->{conf};
@@ -280,13 +280,14 @@
   delete $self->{evalstr2}; # free up some RAM before we eval()
 
   ## dbg ("rules: eval code to compile: $evalstr");
-  eval $evalstr;
-  if ($@) {
-    warn("rules: failed to compile $ruletype tests, skipping:\n\t($@)\n");
+  if (!eval($evalstr . '; 1')) {
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    warn "rules: failed to compile $ruletype tests, skipping:\n".
+         "\t($eval_stat)\n";
     $pms->{rule_errors}++;
   }
   else {
-    dbg("rules: compiled ".$ruletype." tests");
+    dbg("rules: compiled $ruletype tests");
     goto run_compiled_method;
   }
 }
@@ -937,9 +938,10 @@
     $evalstr .= '
 
       eval {
-        $result = $self->' . $function . ' (@extraevalargs '. $argstr .' );
+        $result = $self->' . $function . ' (@extraevalargs '. $argstr .' );  1;
+      } or do {
+        $self->handle_eval_rule_errors($rulename);
       };
-      if ($@) { $self->handle_eval_rule_errors($rulename); }
 
     ';
 
@@ -989,10 +991,9 @@
 EOT
 
   undef &{$methodname};
-  eval $evalstr;
-
-  if ($@) {
-    warn "rules: failed to compile eval tests, skipping some: $@\n";
+  if (!eval($evalstr . '; 1')) {
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    warn "rules: failed to compile eval tests, skipping some: $eval_stat\n";
     $self->{rule_errors}++;
   }
   else {

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DKIM.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DKIM.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DKIM.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/DKIM.pm Tue Aug 21 17:04:52 2007
@@ -274,12 +274,12 @@
       $line =~ s/\r?$/\015\012/s;       # ensure \015\012 ending
       $message->PRINT($line);
     }
-  };
-
-  if ($@) {             # intercept die() exceptions and render safe
-    dbg ("dkim: verification failed, intercepted error: $@");
+    1;
+  } or do {  # intercept die() exceptions and render safe
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    dbg("dkim: verification failed, intercepted error: $eval_stat");
     return 0;           # cannot verify message
-  }
+  };
 
   my $timeout = $scan->{conf}->{dkim_timeout};
 
@@ -290,7 +290,8 @@
     $message->CLOSE();      # the action happens here
 
     $scan->{dkim_address} = ($message->message_originator ? $message->message_originator->address() : '');
-    dbg("dkim: originator address: ".($scan->{dkim_address} ? $scan->{dkim_address} : 'none'));
+    dbg("dkim: originator address: %s",
+        $scan->{dkim_address} ? $scan->{dkim_address} : 'none');
 
     $scan->{dkim_identity} = '';
     if ($message->signature) {
@@ -370,12 +371,14 @@
       dbg("dkim: policy: performing lookup");
 
       my $policy;
-      eval { $policy = $message->fetch_author_policy };
-      if ($@ ne '') {
+      eval {
+        $policy = $message->fetch_author_policy;  1;
+      } or do {
         # fetching or parsing a policy may throw an error, ignore such policy
-        chomp($@); dbg("dkim: policy: fetch or parse failed: $@");
+        my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+        dbg("dkim: policy: fetch or parse failed: $eval_stat");
         undef $policy;
-      }
+      };
       if (!$policy) {
         dbg("dkim: policy: none");
       } else {
@@ -419,11 +422,13 @@
   }
 
   unless ($scanner->{dkim_address}) {
-    dbg("dkim: ". ($default ? "def_" : "") ."whitelist_from_dkim: could not find originator address");
+    dbg("dkim: %swhitelist_from_dkim: could not find originator address",
+        $default ? "def_" : "");
     return;
   }
   unless ($scanner->{dkim_identity}) {
-    dbg("dkim: ". ($default ? "def_" : "") ."whitelist_from_dkim: could not find identity");
+    dbg("dkim: %swhitelist_from_dkim: could not find identity",
+        $default ? "def_" : "");
     return;
   }
 
@@ -451,34 +456,34 @@
   if ($default) {
     if ($scanner->{def_dkim_whitelist_from}) {
       if ($self->check_dkim_verified($scanner)) {
-        dbg("dkim: address: $scanner->{dkim_address} identity: ".
-          "$scanner->{dkim_identity} is in user's DEF_WHITELIST_FROM_DKIM and ".
-          "passed DKIM verification");
+        dbg("dkim: address: %s identity: %s is in user's ".
+            "DEF_WHITELIST_FROM_DKIM and passed DKIM verification",
+          $scanner->{dkim_address}, $scanner->{dkim_identity});
       } else {
-        dbg("dkim: address: $scanner->{dkim_address} identity: ".
-	  "$scanner->{dkim_identity} is in user's DEF_WHITELIST_FROM_DKIM but ".
-	  "failed DKIM verification");
+        dbg("dkim: address: %s identity: %s is in user's ".
+            "DEF_WHITELIST_FROM_DKIM but failed DKIM verification",
+          $scanner->{dkim_address}, $scanner->{dkim_identity});
 	$scanner->{def_dkim_whitelist_from} = 0;
       }
     } else {
-      dbg("dkim: address: $scanner->{dkim_address} identity: ".
-	  "$scanner->{dkim_identity} is not in user's DEF_WHITELIST_FROM_DKIM");
+      dbg("dkim: address: %s identity: %s is not in user's DEF_WHITELIST_FROM_DKIM",
+          $scanner->{dkim_address}, $scanner->{dkim_identity});
     }
   } else {
     if ($scanner->{dkim_whitelist_from}) {
       if ($self->check_dkim_verified($scanner)) {
-	dbg("dkim: address: $scanner->{dkim_address} identity: ".
-	  "$scanner->{dkim_identity} is in user's WHITELIST_FROM_DKIM and ".
-	  "passed DKIM verification");
+	dbg("dkim: address: %s identity: %s is in user's ".
+            "WHITELIST_FROM_DKIM and passed DKIM verification",
+            $scanner->{dkim_address}, $scanner->{dkim_identity});
       } else {
-	dbg("dkim: address: $scanner->{dkim_address} identity: ".
-	  "$scanner->{dkim_identity} is in user's WHITELIST_FROM_DKIM but ".
-	  "failed DKIM verification");
+	dbg("dkim: address: %s identity: %s is in user's ".
+            "WHITELIST_FROM_DKIM but failed DKIM verification",
+            $scanner->{dkim_address}, $scanner->{dkim_identity});
 	$scanner->{dkim_whitelist_from} = 0;
       }
     } else {
-      dbg("dkim: address: $scanner->{dkim_address} identity: ".
-	  "$scanner->{dkim_identity} is not in user's WHITELIST_FROM_DKIM");
+      dbg("dkim: address: %s identity: %s is not in user's WHITELIST_FROM_DKIM",
+          $scanner->{dkim_address}, $scanner->{dkim_identity});
     }
   }
 }

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/MIMEHeader.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/MIMEHeader.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/MIMEHeader.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/MIMEHeader.pm Tue Aug 21 17:04:52 2007
@@ -141,11 +141,13 @@
         }
       ';
 
-      eval $evalcode;
-      if ($@) {
-        warn "mimeheader: plugin error: $@";
+      eval
+        $evalcode . '; 1'
+      or do {
+        my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+        warn "mimeheader: plugin error: $eval_stat\n";
         return $Mail::SpamAssassin::Conf::INVALID_VALUE;
-      }
+      };
 
       $pluginobj->register_eval_rule($evalfn);
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/RelayCountry.pm Tue Aug 21 17:04:52 2007
@@ -67,11 +67,12 @@
   eval {
     require IP::Country::Fast;
     $reg = IP::Country::Fast->new();
-  };
-  if ($@) {
-    dbg("metadata: failed to load 'IP::Country::Fast', skipping ($@)");
+    1;
+  } or do {
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    dbg("metadata: failed to load 'IP::Country::Fast', skipping: $eval_stat");
     return 1;
-  }
+  };
 
   my $msg = $opts->{msg};
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/SPF.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/SPF.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/SPF.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/SPF.pm Tue Aug 21 17:04:52 2007
@@ -365,7 +365,8 @@
 
 	  # and the result
 	  $scanner->{"spf_${identity}${result}"} = 1;
-	  dbg("spf: re-using ".($identity ? 'helo' : 'mfrom')." result from Received-SPF header: $result");
+	  dbg("spf: re-using %s result from Received-SPF header: %s",
+              ($identity ? 'helo' : 'mfrom'), $result);
 
 	  # if we've got *both* the mfrom and helo results we're done
 	  return if ($scanner->{spf_checked} && $scanner->{spf_helo_checked});
@@ -386,6 +387,7 @@
 
   # select the SPF module we're going to use
   unless (defined $self->{has_mail_spf}) {
+    my $eval_stat;
     eval {
       die("Mail::SPF disabled by admin setting\n") if $scanner->{conf}->{do_not_use_mail_spf};
 
@@ -398,18 +400,22 @@
       $self->{spf_server} = Mail::SPF::Server->new(
 				hostname     => $scanner->get_tag('HOSTNAME'),
 				dns_resolver => $self->{main}->{resolver} );
+      1;
+    } or do {
+      $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
     };
 
-    unless ($@) {
+    if (!defined($eval_stat)) {
       dbg("spf: using Mail::SPF for SPF checks");
       $self->{has_mail_spf} = 1;
     } else {
       # strip the @INC paths... users are going to see it and think there's a problem even though
       # we're going to fall back to Mail::SPF::Query (which will display the same paths if it fails)
-      $@ =~ s#^Can't locate Mail/SPFd.pm in \@INC .*#Can't locate Mail/SPFd.pm#;
-      dbg("spf: cannot load Mail::SPF module or create Mail::SPF::Server object: $@");
+      $eval_stat =~ s#^Can't locate Mail/SPFd.pm in \@INC .*#Can't locate Mail/SPFd.pm#;
+      dbg("spf: cannot load Mail::SPF module or create Mail::SPF::Server object: $eval_stat");
       dbg("spf: attempting to use legacy Mail::SPF::Query module instead");
 
+      undef $eval_stat;
       eval {
 	die("Mail::SPF::Query disabled by admin setting\n") if $scanner->{conf}->{do_not_use_mail_spf_query};
 
@@ -418,13 +424,16 @@
 	  die "Mail::SPF::Query 1.996 or later required, this is ".
 	    (defined $Mail::SPF::Query::VERSION ? $Mail::SPF::Query::VERSION : 'unknown')."\n";
 	}
+        1;
+      } or do {
+        $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
       };
 
-      unless ($@) {
+      if (!defined($eval_stat)) {
 	dbg("spf: using Mail::SPF::Query for SPF checks");
 	$self->{has_mail_spf} = 0;
       } else {
-	dbg("spf: cannot load Mail::SPF::Query module: $@");
+	dbg("spf: cannot load Mail::SPF::Query module: $eval_stat");
 	dbg("spf: one of Mail::SPF or Mail::SPF::Query is required for SPF checks, SPF checks disabled");
 	$self->{no_spf_module} = 1;
 	return;
@@ -458,7 +467,8 @@
 
   my $lasthop = $self->_get_relay($scanner);
   if (!defined $lasthop) {
-    dbg("spf: no suitable relay for spf use found, skipping SPF". ($ishelo ? '-helo' : '') ." check");
+    dbg("spf: no suitable relay for spf use found, skipping SPF%s check",
+        $ishelo ? '-helo' : '');
     return;
   }
 
@@ -484,7 +494,8 @@
       # we already dbg'd that we couldn't get an Envelope-From and can't do SPF
       return;
     }
-    dbg("spf: checking EnvelopeFrom (helo=".($helo ? $helo : '').", ip=$ip, envfrom=$scanner->{sender})");
+    dbg("spf: checking EnvelopeFrom (helo=%s, ip=%s, envfrom=%s)",
+        ($helo ? $helo : ''), $ip, $scanner->{sender});
   }
 
   # this test could probably stand to be more strict, but try to test
@@ -509,8 +520,8 @@
     my $identity = $ishelo ? $helo : ($scanner->{sender}); # || $helo);
 
     unless ($identity) {
-      dbg("spf: cannot determine ".($ishelo ? 'helo' : 'mfrom').
-	  " identity, skipping ".($ishelo ? 'helo' : 'mfrom')." SPF check");
+      dbg("spf: cannot determine %s identity, skipping %s SPF check",
+          ($ishelo ? 'helo' : 'mfrom'),  ($ishelo ? 'helo' : 'mfrom') );
       return;
     }
     $helo ||= 'unknown';  # only used for macro expansion in the mfrom explanation
@@ -521,12 +532,12 @@
 					  identity      => $identity,
 					  ip_address    => $ip,
 					  helo_identity => $helo );
-    };
-
-    if ($@) {
-      dbg("spf: cannot create Mail::SPF::Request object ($@)");
+      1;
+    } or do {
+      my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+      dbg("spf: cannot create Mail::SPF::Request object: $eval_stat");
       return;
-    }
+    };
 
     my $timeout = $scanner->{conf}->{spf_timeout};
 
@@ -558,12 +569,12 @@
 				    helo => $helo,
 				    debug => 0,
 				    trusted => 0);
-    };
-
-    if ($@) {
-      dbg("spf: cannot create Mail::SPF::Query object ($@)");
+      1;
+    } or do {
+      my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+      dbg("spf: cannot create Mail::SPF::Query object: $eval_stat");
       return;
-    }
+    };
 
     my $timeout = $scanner->{conf}->{spf_timeout};
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PluginHandler.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/PluginHandler.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PluginHandler.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PluginHandler.pm Tue Aug 21 17:04:52 2007
@@ -198,10 +198,11 @@
 
     eval {
       $ret = &$methodref ($plugin, @_);
+      1;
+    } or do {
+      my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+      warn "plugin: eval failed: $eval_stat\n";
     };
-    if ($@) {
-      warn "plugin: eval failed: $@";
-    }
 
     if ($ret) {
       #dbg("plugin: ${plugin}->${methodref} => $ret");

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Timeout.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Timeout.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Timeout.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Timeout.pm Tue Aug 21 17:04:52 2007
@@ -139,6 +139,7 @@
   # it will not require malloc() be called if it fires
   my $timedout = 0;
 
+  my $eval_stat;
   eval {
     # note use of local to ensure closed scope here
     local $SIG{ALRM} = sub { $timedout++; die "__alarm__ignore__\n" };
@@ -158,10 +159,11 @@
     # still worth avoiding anyway.
 
     alarm 0;
+    1;
+  } or do {
+    $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
   };
 
-  my $err = $@;
-
   if (defined $oldalarm) {
     # now, we could have died from a SIGALRM == timed out.  if so,
     # restore the previously-active one, or zero all timeouts if none
@@ -169,20 +171,18 @@
     alarm $oldalarm;
   }
 
-  if ($err) {
-    if ($err =~ /__alarm__ignore__/) {
+  if (defined $eval_stat) {
+    if ($eval_stat =~ /__alarm__ignore__/) {
       $self->{timed_out} = 1;
+    } elsif ($and_catch) {
+      return $eval_stat;
     } else {
-      if ($and_catch) {
-        return $@;
-      } else {
-        die $@;             # propagate any "real" errors
-      }
+      die "Timeout::_run: $eval_stat\n";  # propagate any "real" errors
     }
   } elsif ($timedout) {
     # this happens occasionally; haven't figured out why.  seems
     # harmless in effect, though, so just issue a warning and carry on...
-    warn "timeout with empty \$@";  
+    warn "timeout with empty eval status\n";
     $self->{timed_out} = 1;
   }
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm Tue Aug 21 17:04:52 2007
@@ -186,7 +186,7 @@
     # seriously mind-bending perl
     $AM_TAINTED = not eval { eval "1 || $blank" || 1 };
   }
-  dbg("util: running in taint mode? ". ($AM_TAINTED ? "yes" : "no"));
+  dbg("util: running in taint mode? %s", $AM_TAINTED ? "yes" : "no");
   return $AM_TAINTED;
 }
 
@@ -484,12 +484,12 @@
   my $time;
   eval {		# could croak
     $time = timegm($ss, $mm, $hh, $dd, $mmm-1, $yyyy);
-  };
-
-  if ($@) {
-    dbg("util: time cannot be parsed: $date, $yyyy-$mmm-$dd $hh:$mm:$ss");
+    1;
+  } or do {
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    dbg("util: time cannot be parsed: $date, $yyyy-$mmm-$dd $hh:$mm:$ss, $eval_stat");
     return undef;
-  }
+  };
 
   if ($tzoff =~ /([-+])(\d\d)(\d\d)$/)	# convert to seconds difference
   {
@@ -673,15 +673,16 @@
     return Mail::SpamAssassin::Util::_getpwuid_wrapper(@_);
   }
 
+  my $sts;
   if (!RUNNING_ON_WINDOWS) {
-    eval ' sub _getpwuid_wrapper { getpwuid($_[0]); } ';
+    $sts = eval ' sub _getpwuid_wrapper { getpwuid($_[0]); }; 1 ';
   } else {
     dbg("util: defining getpwuid() wrapper using 'unknown' as username");
-    eval ' sub _getpwuid_wrapper { _fake_getpwuid($_[0]); } ';
+    $sts = eval ' sub _getpwuid_wrapper { _fake_getpwuid($_[0]); }; 1 ';
   }
-
-  if ($@) {
-    warn "util: failed to define getpwuid() wrapper: $@\n";
+  if (!$sts) {
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    warn "util: failed to define getpwuid() wrapper: $eval_stat\n";
   } else {
     return Mail::SpamAssassin::Util::_getpwuid_wrapper(@_);
   }

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util/DependencyInfo.pm Tue Aug 21 17:04:52 2007
@@ -265,16 +265,17 @@
 sub try_module {
   my ($required, $moddef, $summref) = @_;
 
-  eval "use $moddef->{module} $moddef->{version};";
-  if (!$@) {
+  if (eval "use $moddef->{module} $moddef->{version}; 1") {
     return;
-  }
+  };
 
   my $not_installed = 0;
-  eval "use $moddef->{module};";
-  if ($@) {
+  my $eval_stat;
+  eval "use $moddef->{module}; 1"
+  or do {
     $not_installed = 1;
-  }
+    $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+  };
 
   my $pretty_name = $moddef->{alt_name} || $moddef->{module};
   my $pretty_version = ($moddef->{version} > 0 ?
@@ -287,6 +288,7 @@
   } else {
     $errtype = "is installed,\nbut is not an up-to-date version.";
   }
+  dbg("dependency: $eval_stat");
 
   print "\n", ("*" x 75), "\n";
   if ($required) {

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util/MemoryDump.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Util/MemoryDump.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util/MemoryDump.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util/MemoryDump.pm Tue Aug 21 17:04:52 2007
@@ -125,9 +125,11 @@
 
       $objcount{ref $val}++;
     }
-
+    1;
+  } or do {
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    warn "census: $eval_stat\n";
   };
-  ($@) and warn "census: ".$@;
 
   foreach my $id (sort { $objcount{$b} <=> $objcount{$a} } keys %objcount) {
     my $c = $objcount{$id};
@@ -175,8 +177,11 @@
     my $dump = Dumper($obj);
     $dump =~ s/ {8}/  /gs;
     print DUMP $dump;
+    1;
+  } or do {
+    my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+    warn "dump: $eval_stat\n";
   };
-  ($@) and warn "dump: ".$@;
 
   close DUMP or warn "close failed";
   warn "MEMDEBUG_dump_obj end: wrote to $name\n";

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util/Progress.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Util/Progress.pm?rev=568336&r1=568335&r2=568336&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util/Progress.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util/Progress.pm Tue Aug 21 17:04:52 2007
@@ -142,8 +142,13 @@
   # The ideal case would be if they happen to have Term::ReadKey installed
   if (!defined($term_size) && HAS_TERM_READKEY) {
     my $term_readkey_term_size;
-    eval { $term_readkey_term_size = (Term::ReadKey::GetTerminalSize($self->{fh}))[0] };
-    unless ($@) { # an error will just keep the default
+    eval {
+      $term_readkey_term_size =
+        (Term::ReadKey::GetTerminalSize($self->{fh}))[0];
+      1;
+    } or do {  # an error will just keep the default
+      my $eval_stat = $@ ne '' ? $@ : "errno=$!";  chomp $eval_stat;
+      # dbg("progress: Term::ReadKey::GetTerminalSize failed: $eval_stat");
       # GetTerminalSize might have returned an empty array, so check the
       # value and set if it exists, if not we keep the default
       $term_size = $term_readkey_term_size if ($term_readkey_term_size);