[Mimedefang] mimedefang.pl spilling "Use of inherited AUTOLOAD for non-method" errors

David F. Skoll dfs at roaringpenguin.com
Thu Feb 17 10:16:52 EST 2011


Hi,

Here's a patch against my git version of mimedefang.pl.in.  Not sure
how cleanly it will apply to the released or beta version, but if people
could try it out, I'd appreciate it.

Regards,

David.

commit 798005eb52c8ce9d5770be06a816dde21a0356f8
Author: David F. Skoll <dfs at roaringpenguin.com>
Date:   Thu Feb 17 10:14:05 2011 -0500

    Convert Unix::Syslog facilities lazily (see MD list.)

diff --git a/mimedefang.pl.in b/mimedefang.pl.in
index 4489c0c..5dc546f 100755
--- a/mimedefang.pl.in
+++ b/mimedefang.pl.in
@@ -669,17 +669,16 @@ sub time_str () {
 	{
 		my($facility) = @_;
 
-		if( ! defined $_fac_map ) {
-			$_fac_map = _make_fac_map();
-		}
-
 		my $num = 0;
 		foreach my $thing (split(/\|/, $facility)) {
-			next unless exists $_fac_map->{$thing};
+			if (!defined($_fac_map) ||
+			    !exists($_fac_map->{$thing})) {
+				$_fac_map->{$thing} = _fac_to_num($thing);
+			}
+			next unless defined $_fac_map->{$thing};
 			$num |= $_fac_map->{$thing};
 		}
 		return $num;
-
 	}
 
 	my %special = (
@@ -689,37 +688,15 @@ sub time_str () {
 
 	# Some of the Unix::Syslog 'macros' tag exports aren't
 	# constants, so we need to ignore them if found.
-	my %blacklisted = map { $_ => 1 } qw(
-		LOG_MASK
-		LOG_UPTO
-		LOG_PRI
-		LOG_MAKEPRI
-		LOG_FAC
-	);
-	sub _make_fac_map
-	{
-		my %map;
-
-		# Ugh.  Make sure we map only the available constants
-		# on this platform.  Some are not defined properly on
-		# all platforms.
-		foreach my $constant ( grep { /^LOG_/ && !exists $blacklisted{$_} } @{ $Unix::Syslog::EXPORT_TAGS{macros}} ) {
-			my $name = lc $constant;
-			$name =~ s/^log_//;
-
-			my $value = eval "Unix::Syslog::$constant()";
-			if( defined $value ) {
-				$map{$name} = $value;
-			}
-		}
+	my %blacklisted = map { $_ => 1 } qw(mask upto pri makepri fac);
 
-		# Some strings supported by Sys::Syslog don't
-		# correspond to a Unix::Syslog LOG_XXXX constant.
-		while( my($new_key, $existing_key) = each %special ) {
-			$map{$new_key} = $map{$existing_key};
-		}
-
-		return \%map;
+        sub _fac_to_num
+	{
+		my ($thing) = @_;
+		return undef if exists $blacklisted{$thing};
+		$thing = $special{$thing} if exists $special{$thing};
+		$thing = 'LOG_' . uc($thing);
+		return eval "Unix::Syslog::$thing()";
 	}
 }
 
@@ -7450,6 +7427,6 @@ sub md_check_against_smtp_server ($$$$;$) {
     return ($retval, $text, $code, $dsn);
 }
 
-exit(&main);
+exit(&main) unless caller;
 #------------------------------------------------------------
 1;



More information about the MIMEDefang mailing list