diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-08-03 14:03:36 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-08-03 14:03:36 +0200 |
commit | d417ed4a1875321b28c47ea5f6324479d1592309 (patch) | |
tree | 4a2c09d1f9fb8b5de2409d9457cd229a99175ff6 /lib | |
parent | ef4bb8963e1a89da2b62274758361617f5384ce3 (diff) | |
download | config-parser-d417ed4a1875321b28c47ea5f6324479d1592309.tar.gz config-parser-d417ed4a1875321b28c47ea5f6324479d1592309.tar.bz2 |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Config/Parser.pm | 11 |
1 files 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 =~ /^:(?<kw>.+?)(?:\s*=\s*(?<val>.*))?$/) { $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}; |