5
0
mirror of git://git.proxmox.com/git/pve-ha-manager.git synced 2025-01-26 14:03:52 +03:00

FenceConfig: move line parsing out to closure

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2019-01-13 12:30:36 +01:00
parent 92cfcee1ab
commit 98dca1a462

View File

@ -15,12 +15,8 @@ sub parse_config {
my $lineno = 0;
my $priority = 0;
eval {
while ($raw =~ /^\h*(.*?)\h*$/gm) {
my $line = $1;
$lineno++;
next if !$line || $line =~ /^#/;
my $parse_line = sub {
my ($line) = @_;
if ($line =~ m/^(device|connect)\s+(\S+)\s+(\S+)\s+(.+)$/) {
my ($command, $dev_name, $target) = ($1, $2, $3);
@ -75,6 +71,16 @@ sub parse_config {
} else {
warn "$fn ignore line $lineno: $line\n"
}
};
eval {
while ($raw =~ /^\h*(.*?)\h*$/gm) {
my $line = $1;
$lineno++;
next if !$line || $line =~ /^#/;
$parse_line->($line);
}
};
if (my $err = $@) {