[interchange-cvs] interchange - heins modified lib/Vend/Config.pm

interchange-core@interchange.redhat.com interchange-core@interchange.redhat.com
Tue Feb 5 21:39:01 2002


User:      heins
Date:      2002-02-06 02:38:58 GMT
Modified:  lib/Vend Config.pm
Log:
	* Warnings and errors in compiling system code were coming out with
	  the name of the file above (or that happened to be above when
	  this was triggered). Fixed this -- if the tag/routine fails the
	  error will now be specified as coming from the right line and file.

	* Improved setup of warning messages by turning off warnings
	  locally during logging.

Revision  Changes    Path
2.36      +16 -11    interchange/lib/Vend/Config.pm


rev 2.36, prev_rev 2.35
Index: Config.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Config.pm,v
retrieving revision 2.35
retrieving revision 2.36
diff -u -r2.35 -r2.36
--- Config.pm	4 Feb 2002 04:36:45 -0000	2.35
+++ Config.pm	6 Feb 2002 02:38:58 -0000	2.36
@@ -1,6 +1,6 @@
 # Vend::Config - Configure Interchange
 #
-# $Id: Config.pm,v 2.35 2002/02/04 04:36:45 mheins Exp $
+# $Id: Config.pm,v 2.36 2002/02/06 02:38:58 mheins Exp $
 #
 # Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -44,7 +44,7 @@
 use Vend::Parse;
 use Vend::Util;
 
-$VERSION = substr(q$Revision: 2.35 $, 10);
+$VERSION = substr(q$Revision: 2.36 $, 10);
 
 my %CDname;
 
@@ -148,7 +148,7 @@
 
 my $StdTags;
 
-my $configfile;
+use vars qw/ $configfile /;
 
 ### This is unset when interchange script is run, so that the default
 ### when used by an external program is not to compile subroutines
@@ -161,6 +161,7 @@
 		$msg = errmsg($msg, @_);
 	}
 
+	local($^W);
 	$msg = errmsg("%s\nIn line %s of the configuration file '%s':\n%s\n",
 			$msg,
 			$.,
@@ -181,13 +182,15 @@
 	if(@_) {
 		$msg = errmsg($msg, @_);
 	}
+
+	local($^W);
+
 	::logGlobal({level => 'notice'},
-				errmsg("%s\nIn line %s of the configuration file '%s':\n%s\n",
+				"%s\nIn line %s of the configuration file '%s':\n%s\n",
 						$msg,
 						$.,
 						$configfile,
 						$Vend::config_line,
-				)
 	);
 }
 
@@ -989,16 +992,19 @@
 	};
 	File::Find::find($wanted, @$Global::TagDir);
 
+	local($configfile);
 	for(@files) {
 		$CodeDest = $_->[1];
 
-		open SYSTAG, "< $_->[0]"
-			or config_error("read system tag file %s: %s", $_->[0], $!);
+		$configfile = $_->[0];
+		open SYSTAG, "< $configfile"
+			or config_error("read system tag file %s: %s", $configfile, $!);
 		while(<SYSTAG>) {
 			my($lvar, $value) = read_config_value($_, \*SYSTAG);
 			next unless $lvar;
 			$GlobalRead->($lvar, $value);
 		}
+		close SYSTAG;
 	}
 
 	undef $CodeDest;
@@ -3283,20 +3289,19 @@
 			}
 		}
 		local($^W) = 1;
-		my $fail;
+		my $fail = '';
 		{
-			local $SIG{'__WARN__'} = sub {$fail .= "@_";};
+			local $SIG{'__WARN__'} = sub {$fail .= "$_[0]\n";};
 			eval {
 				package Vend::Interpolate;
 				$sub = eval $val;
-				die $@ if $@;
 			};
 		}
 		if($@) {
 			config_warn(
 						"UserTag '%s' subroutine failed compilation:\n\n\t%s",
 						$tag,
-						"$fail $@",
+					"$@ (warnings=$fail)",
 			);
 			return $c;
 		}