about summary refs log tree commit homepage
path: root/lib/PublicInbox/Config.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-09-24 05:42:11 +0000
committerEric Wong <e@80x24.org>2023-09-24 18:56:06 +0000
commite11420993bf3b9e630f2797e07d8f6abd8d74e28 (patch)
treee3a6cc4895973d791473d31cfed8cd212ba61544 /lib/PublicInbox/Config.pm
parentb93890e268e375a980a0b4b3cfc30cf6192747c1 (diff)
downloadpublic-inbox-e11420993bf3b9e630f2797e07d8f6abd8d74e28.tar.gz
It's how git-config works, so our `git config --list' parser
must be able to handle it.  Fortunately this doesn't seem to
incur a measurable overhead when parsing a config with 50k
inboxes.
Diffstat (limited to 'lib/PublicInbox/Config.pm')
-rw-r--r--lib/PublicInbox/Config.pm5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 0a6b210f..f6236d84 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -151,8 +151,11 @@ sub config_fh_parse ($$$) {
         local $/ = $rs;
         while (defined($line = <$fh>)) { # perf critical with giant configs
                 $i = index($line, $fs);
+                # $i may be -1 if $fs not found and it's a key-only entry
+                # (meaning boolean true).  Either way the -1 will drop the
+                # $rs either from $k or $v.
                 $k = substr($line, 0, $i);
-                $v = substr($line, $i + 1, -1); # chop off $fs
+                $v = $i >= 0 ? substr($line, $i + 1, -1) : 1;
                 $section = substr($k, 0, rindex($k, '.'));
                 $seen{$section} //= push(@section_order, $section);