Replace unnecessary merge
function with hash initializers
This commit is contained in:
parent
52864f2bb1
commit
5e3e10d32e
1 changed files with 12 additions and 22 deletions
34
ddclient.in
34
ddclient.in
|
@ -1050,10 +1050,10 @@ my %services = (
|
||||||
'updateable' => undef,
|
'updateable' => undef,
|
||||||
'update' => \&nic_keysystems_update,
|
'update' => \&nic_keysystems_update,
|
||||||
'examples' => \&nic_keysystems_examples,
|
'examples' => \&nic_keysystems_examples,
|
||||||
'variables' => merge(
|
'variables' => {
|
||||||
$variables{'keysystems-common-defaults'},
|
%{$variables{'service-common-defaults'}},
|
||||||
$variables{'service-common-defaults'},
|
%{$variables{'keysystems-common-defaults'}},
|
||||||
),
|
},
|
||||||
},
|
},
|
||||||
'dnsexit2' => {
|
'dnsexit2' => {
|
||||||
'updateable' => undef,
|
'updateable' => undef,
|
||||||
|
@ -1072,10 +1072,10 @@ my %services = (
|
||||||
'updateable' => undef,
|
'updateable' => undef,
|
||||||
'update' => \&nic_regfishde_update,
|
'update' => \&nic_regfishde_update,
|
||||||
'examples' => \&nic_regfishde_examples,
|
'examples' => \&nic_regfishde_examples,
|
||||||
'variables' => merge(
|
'variables' => {
|
||||||
$variables{'regfishde-common-defaults'},
|
%{$variables{'service-common-defaults'}},
|
||||||
$variables{'service-common-defaults'},
|
%{$variables{'regfishde-common-defaults'}},
|
||||||
),
|
},
|
||||||
},
|
},
|
||||||
'enom' => {
|
'enom' => {
|
||||||
'updateable' => undef,
|
'updateable' => undef,
|
||||||
|
@ -1816,7 +1816,7 @@ sub _read_config {
|
||||||
my ($host, $login, $password) = @args;
|
my ($host, $login, $password) = @args;
|
||||||
|
|
||||||
## add in any globals..
|
## add in any globals..
|
||||||
%locals = %{merge(\%locals, \%globals)};
|
%locals = (%globals, %locals);
|
||||||
|
|
||||||
## override login and password if specified the old way.
|
## override login and password if specified the old way.
|
||||||
$locals{'login'} = $login if defined $login;
|
$locals{'login'} = $login if defined $login;
|
||||||
|
@ -1826,7 +1826,7 @@ sub _read_config {
|
||||||
foreach my $h (split_by_comma($host)) {
|
foreach my $h (split_by_comma($host)) {
|
||||||
if ($config{$h}) {
|
if ($config{$h}) {
|
||||||
## host already defined, merging configs
|
## host already defined, merging configs
|
||||||
$config{$h} = { %{merge($config{$h}, \%locals)} };
|
$config{$h} = {%locals, %{$config{$h}}};
|
||||||
} else {
|
} else {
|
||||||
## save a copy of the current globals
|
## save a copy of the current globals
|
||||||
$config{$h} = { %locals };
|
$config{$h} = { %locals };
|
||||||
|
@ -1916,11 +1916,11 @@ sub init_config {
|
||||||
## merge options into host definitions or globals
|
## merge options into host definitions or globals
|
||||||
if (@hosts) {
|
if (@hosts) {
|
||||||
foreach my $h (@hosts) {
|
foreach my $h (@hosts) {
|
||||||
$config{$h} = merge(\%options, $config{$h});
|
$config{$h} = {%{$config{$h}}, %options};
|
||||||
}
|
}
|
||||||
$opt{'host'} = join(',', @hosts);
|
$opt{'host'} = join(',', @hosts);
|
||||||
} else {
|
} else {
|
||||||
%globals = %{merge(\%options, \%globals)};
|
%globals = (%globals, %options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2353,7 +2353,6 @@ sub sendmail {
|
||||||
}
|
}
|
||||||
######################################################################
|
######################################################################
|
||||||
## split_by_comma
|
## split_by_comma
|
||||||
## merge
|
|
||||||
## default
|
## default
|
||||||
## minimum
|
## minimum
|
||||||
## opt
|
## opt
|
||||||
|
@ -2364,15 +2363,6 @@ sub split_by_comma {
|
||||||
return split /\s*[, ]\s*/, $string if defined $string;
|
return split /\s*[, ]\s*/, $string if defined $string;
|
||||||
return ();
|
return ();
|
||||||
}
|
}
|
||||||
sub merge {
|
|
||||||
my %merged = ();
|
|
||||||
foreach my $h (@_) {
|
|
||||||
foreach my $k (keys %$h) {
|
|
||||||
$merged{$k} = $h->{$k} unless exists $merged{$k};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return \%merged;
|
|
||||||
}
|
|
||||||
sub default {
|
sub default {
|
||||||
my $v = shift;
|
my $v = shift;
|
||||||
return $variables{'merged'}{$v}{'default'};
|
return $variables{'merged'}{$v}{'default'};
|
||||||
|
|
Loading…
Reference in a new issue