[interchange-cvs] interchange - heins modified 2 files
interchange-core@interchange.redhat.com
interchange-core@interchange.redhat.com
Sun Nov 18 06:05:01 2001
User: heins
Date: 2001-11-18 11:04:13 GMT
Modified: lib/Vend Util.pm Config.pm
Log:
* Move part of a routine to Util.pm for reuse.
* Remove debug lines from some well-tested routines.
Revision Changes Path
2.9 +23 -2 interchange/lib/Vend/Util.pm
rev 2.9, prev_rev 2.8
Index: Util.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Util.pm,v
retrieving revision 2.8
retrieving revision 2.9
diff -u -r2.8 -r2.9
--- Util.pm 2001/11/15 11:15:22 2.8
+++ Util.pm 2001/11/18 11:04:13 2.9
@@ -1,6 +1,6 @@
# Vend::Util - Interchange utility functions
#
-# $Id: Util.pm,v 2.8 2001/11/15 11:15:22 mheins Exp $
+# $Id: Util.pm,v 2.9 2001/11/18 11:04:13 mheins Exp $
#
# Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
#
@@ -43,6 +43,7 @@
format_log_msg
generate_key
get_option_hash
+ hash_string
is_hash
is_no
is_yes
@@ -79,7 +80,7 @@
use Safe;
use subs qw(logError logGlobal);
use vars qw($VERSION @EXPORT @EXPORT_OK);
-$VERSION = substr(q$Revision: 2.8 $, 10);
+$VERSION = substr(q$Revision: 2.9 $, 10);
BEGIN {
eval {
@@ -857,6 +858,26 @@
}
}
return \%hash;
+}
+
+## This simply returns a hash of words, which may be quoted shellwords
+## Replaces most of parse_hash in Vend::Config
+sub hash_string {
+ my($settings, $ref) = @_;
+
+ return $ref if ! $settings or $settings !~ /\S/;
+
+ $ref ||= {};
+
+ $settings =~ s/^\s+//;
+ $settings =~ s/\s+$//;
+ my(@setting) = Text::ParseWords::shellwords($settings);
+
+ my $i;
+ for ($i = 0; $i < @setting; $i += 2) {
+ $ref->{$setting[$i]} = $setting[$i + 1];
+ }
+ return $ref;
}
## READIN
2.15 +3 -12 interchange/lib/Vend/Config.pm
rev 2.15, prev_rev 2.14
Index: Config.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Config.pm,v
retrieving revision 2.14
retrieving revision 2.15
diff -u -r2.14 -r2.15
--- Config.pm 2001/11/09 22:08:02 2.14
+++ Config.pm 2001/11/18 11:04:13 2.15
@@ -1,6 +1,6 @@
# Vend::Config - Configure Interchange
#
-# $Id: Config.pm,v 2.14 2001/11/09 22:08:02 mheins Exp $
+# $Id: Config.pm,v 2.15 2001/11/18 11:04:13 mheins Exp $
#
# Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
#
@@ -95,7 +95,7 @@
use Vend::Parse;
use Vend::Util;
-$VERSION = substr(q$Revision: 2.14 $, 10);
+$VERSION = substr(q$Revision: 2.15 $, 10);
my %CDname;
@@ -1813,10 +1813,6 @@
return $HashDefaultBlank{$item} ? '' : {} if ! $settings;
}
- $settings =~ s/^\s+//;
- $settings =~ s/\s+$//;
- my(@setting) = Text::ParseWords::shellwords($settings);
-
my $c;
if(defined $C) {
@@ -1827,12 +1823,7 @@
$c = ${"Global::$item"} || {};
}
- my $i;
- for ($i = 0; $i < @setting; $i += 2) {
- $c->{$setting[$i]} = $setting[$i + 1];
-#::logDebug("$item hash $setting[$i]=$setting[$i+1]");
- }
- $c;
+ return Vend::Util::hash_string($settings,$c);
}
# Set up illegal values for certain directives