summaryrefslogtreecommitdiff
path: root/fml
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-01-21 07:07:05 +0000
committerfukachan <fukachan>2001-01-21 07:07:05 +0000
commit30d69b41db411b1d573ce74c35fd7ab797b8d2a8 (patch)
tree3402195bde8086c4479edb0a4fdaa8032f96e230 /fml
parentd358d8770ce57d1abbe10ecc55b8b54fefa4653e (diff)
downloadfml8-30d69b41db411b1d573ce74c35fd7ab797b8d2a8.tar.gz
fml8-30d69b41db411b1d573ce74c35fd7ab797b8d2a8.tar.bz2
fml8-30d69b41db411b1d573ce74c35fd7ab797b8d2a8.zip
expand variables after we load all *cf files
Diffstat (limited to 'fml')
-rw-r--r--fml/lib/FML/Config.pm24
-rw-r--r--fml/lib/FML/Process/Kernel.pm3
2 files changed, 14 insertions, 13 deletions
diff --git a/fml/lib/FML/Config.pm b/fml/lib/FML/Config.pm
index f149cadb..b76262ca 100644
--- a/fml/lib/FML/Config.pm
+++ b/fml/lib/FML/Config.pm
@@ -69,7 +69,6 @@ sub overload
sub load_file
{
my ($self, $file) = @_;
- my (@key_order) = ();
my $config = \%_fml_config;
# open the $file by using FileHandle.pm
@@ -92,7 +91,6 @@ sub load_file
$value =~ s/\s*$//o;
$curkey = $key;
$config->{$key} = $value;
- push(@key_order, $key);
}
if (/^\s+(.*)/) {
my $value = $1;
@@ -105,29 +103,29 @@ sub load_file
else {
$self->_log("Error: cannot open $file");
}
-
- # expand variable name e.g. $dir/xxx -> /var/spool/ml/elena/xxx
- _expand_variables( $config, \@key_order );
}
-sub _expand_variables
+# expand variable name e.g. $dir/xxx -> /var/spool/ml/elena/xxx
+sub expand_variables
{
- my ($config, $order) = @_;
- my $max = 0;
- my $org = '';
+ my ($self) = @_;
+ my $config = \%_fml_config;
+ my @order = keys %_fml_config;
# check whether the variable definition is recursive.
- # For example, definition "var_a = $var_a/b/c" causes loop.
- for my $x ( @$order ) {
+ # For example, definition "var_a = $var_a/b/c" causes a loop.
+ for my $x ( @order ) {
if ($config->{ $x } =~ /\$$x/) {
croak("loop1: definition of $x is recursive\n");
}
}
-
+ # main expansion loop
+ my $org = '';
+ my $max = 0;
KEY:
- for my $x ( @$order ) {
+ for my $x ( @order ) {
next KEY if $config->{ $x } !~ /\$/o;
# we need a loop to expand nested variables, for example,
diff --git a/fml/lib/FML/Process/Kernel.pm b/fml/lib/FML/Process/Kernel.pm
index 4e514c69..e7a4bfc9 100644
--- a/fml/lib/FML/Process/Kernel.pm
+++ b/fml/lib/FML/Process/Kernel.pm
@@ -162,6 +162,9 @@ sub load_config_files
for my $cf (@$files) {
$curproc->{ config }->overload( $cf );
}
+
+ # XXX We need to expand variables after we load all *cf files.
+ $curproc->{ config }->expand_variables();
}