summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2019-08-03 12:03:36 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2019-08-03 12:03:36 (GMT)
commitd417ed4a1875321b28c47ea5f6324479d1592309 (patch) (side-by-side diff)
tree4a2c09d1f9fb8b5de2409d9457cd229a99175ff6
parentef4bb8963e1a89da2b62274758361617f5384ce3 (diff)
downloadconfig-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 (more/less context) (ignore whitespace changes)
-rw-r--r--lib/Config/Parser.pm11
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};

Return to:

Send suggestions and report system problems to the System administrator.