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

interchange-core@icdevgroup.org interchange-core@icdevgroup.org
Mon Dec 2 17:13:01 2002


User:      heins
Date:      2002-12-02 22:12:57 GMT
Modified:  lib/Vend Util.pm
Log:
 * Allow delete of empty hash items in serial field setting.

Revision  Changes    Path
2.43      +10 -4     interchange/lib/Vend/Util.pm


rev 2.43, prev_rev 2.42
Index: Util.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Util.pm,v
retrieving revision 2.42
retrieving revision 2.43
diff -u -r2.42 -r2.43
--- Util.pm	28 Nov 2002 17:12:22 -0000	2.42
+++ Util.pm	2 Dec 2002 22:12:57 -0000	2.43
@@ -1,6 +1,6 @@
 # Vend::Util - Interchange utility functions
 #
-# $Id: Util.pm,v 2.42 2002/11/28 17:12:22 kwalsh Exp $
+# $Id: Util.pm,v 2.43 2002/12/02 22:12:57 mheins Exp $
 # 
 # Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -83,7 +83,7 @@
 use Safe;
 use subs qw(logError logGlobal);
 use vars qw($VERSION @EXPORT @EXPORT_OK);
-$VERSION = substr(q$Revision: 2.42 $, 10);
+$VERSION = substr(q$Revision: 2.43 $, 10);
 
 BEGIN {
 	eval {
@@ -841,7 +841,7 @@
 }
 
 sub dotted_hash {
-	my($hash, $key, $value) = @_;
+	my($hash, $key, $value, $delete_empty) = @_;
 	$hash = get_option_hash($hash) unless is_hash($hash);
 	unless (is_hash($hash)) {
 		return undef unless defined $value;
@@ -870,7 +870,13 @@
 		$ref = $ref->{$_};
 	}
 
-	$ref->{$final} = $value;
+	if($delete_empty and ! length($value)) {
+		delete $ref->{$final};
+	}
+	else {
+		$ref->{$final} = $value;
+	}
+
 	$hash = uneval_it($hash);
 	return $hash;
 }