From: | roam [...] ringlet.net |
Subject: | [PATCH] Reuse section hashes in Config::IniFiles::FETCH |
Hi,
First of all, thanks a lot for taking care of Config::IniFiles!
It's an extremely useful module for adding very simple support for
configuration files to simple tools.
What do you think about the attached patch that we just added to
the Debian package? It fixes a problem reported on the Debian
bug tracker: https://bugs.debian.org/849298
Now, I am aware that just this patch does not go all the way in
making a tied Config::IniFiles hash emulate the each() behavior
of untied hashes (e.g. the session is not reset after a keys() or
values() call), but according to the documenation of each(),
this is not necessary. Even like this, the change makes each()
actually useful on these hashes.
Description: Reuse section hashes in Config::IniFiles::FETCH
As reported by Johannes Schauer, code like
foreach my $s (keys %ini) {
while (my ($k,$v) = each %{$ini{$s}}) {
print("$s $k $v\n");
}
}
goes to an infinite loop. This is because every time $ini{$s}
is evaluated, Config::IniFiles::FETCH() creates a new
Config::IniFiles::_section tied hash that has its own each() iterator.
Store and reuse the section hashes instead.
Bug-Debian: https://bugs.debian.org/849298
Author: Niko Tyni <ntyni@debian.org>
Last-Update: 2018-04-05
The patch is tracked in our Git repository at
https://salsa.debian.org/perl-team/modules/packages/libconfig-inifiles-perl/raw/master/debian/patches/fetch.patch
Thanks for considering, and keep up the great work!
Peter Pentchev,
Debian Perl Group