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

interchange-core@interchange.redhat.com interchange-core@interchange.redhat.com
Wed Oct 31 17:23:01 2001


User:      heins
Date:      2001-10-31 22:22:35 GMT
Modified:  lib/Vend Util.pm
Log:
	* Fix variable suicide problem found by Javier Martin <martin@trymedia.com>.
	  Thanks for the good eye.

Revision  Changes    Path
2.7       +9 -9      interchange/lib/Vend/Util.pm


rev 2.7, prev_rev 2.6
Index: Util.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Util.pm,v
retrieving revision 2.6
retrieving revision 2.7
diff -u -r2.6 -r2.7
--- Util.pm	2001/10/09 22:32:52	2.6
+++ Util.pm	2001/10/31 22:22:35	2.7
@@ -1,6 +1,6 @@
 # Vend::Util - Interchange utility functions
 #
-# $Id: Util.pm,v 2.6 2001/10/09 22:32:52 mheins Exp $
+# $Id: Util.pm,v 2.7 2001/10/31 22:22:35 mheins Exp $
 # 
 # Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -79,7 +79,7 @@
 use Safe;
 use subs qw(logError logGlobal);
 use vars qw($VERSION @EXPORT @EXPORT_OK);
-$VERSION = substr(q$Revision: 2.6 $, 10);
+$VERSION = substr(q$Revision: 2.7 $, 10);
 
 BEGIN {
 	eval {
@@ -815,17 +815,17 @@
 }
 
 sub get_option_hash {
-	if (ref $_[0]) {
-		return $_[0] unless ref $_[1];
-		for(keys %{$_[1]}) {
-			$_[0]->{$_} = $_[1]->{$_}
-				unless defined $_[0]->{$_};
-		}
-		return $_[0];
-	}
-	return {} unless $_[0] =~ /\S/;
 	my $string = shift;
 	my $merge = shift;
+	if (ref $string) {
+		return $string unless ref $merge;
+		for(keys %{$merge}) {
+			$string->{$_} = $merge->{$_}
+				unless defined $string->{$_};
+		}
+		return $string;
+	}
+	return {} unless $string =~ /\S/;
 	$string =~ s/^\s+//;
 	$string =~ s/\s+$//;
 	if($string =~ /^{/ and $string =~ /}/) {