From d417ed4a1875321b28c47ea5f6324479d1592309 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sat, 3 Aug 2019 14:03:36 +0200 Subject: Fix default values handling * lib/Config/Parser.pm (loadsynt): If the setting is of array type, use the words remaining after attribute processing as its default value. Otherwise, concatenate the words using single whitespace character as a delimiter and use that value as the default. --- lib/Config/Parser.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Config/Parser.pm b/lib/Config/Parser.pm index ee5055b..843b70c 100644 --- a/lib/Config/Parser.pm +++ b/lib/Config/Parser.pm @@ -100,11 +100,18 @@ sub loadsynt { unshift @words, $val; } - while (($val = shift @words) + while (($val = $words[0]) && $val =~ /^:(?.+?)(?:\s*=\s*(?.*))?$/) { $ret->{$+{kw}} = $+{val} // 1; + shift @words; + } + if (@words) { + if ($ret->{array}) { + $ret->{default} = [@words]; + } else { + $ret->{default} = join(' ', @words); + } } - $ret->{default} = $val if defined($val); ($name, $ret); } })->{section}; -- cgit v1.2.1