Skip Menu |

This queue is for tickets about the AppConfig CPAN distribution.

Report information
The Basics
Id: 28766
Status: new
Priority: 0/
Queue: AppConfig

People
Owner: Nobody in particular
Requestors: bruno [...] victoria.frmug.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 1.63
  • 1.64
  • 1.65
  • 1.66
Fixed in: (no value)



Subject: [PATCH] With CREATE = 1, HASH are always having a 1 key
When trying to auto-create (CREATE = 1) a hash, the File module systematically adds a key '1', per the set launched to create the variable: # if the variable doesn't exist, we call set() to give # AppConfig::State a chance to auto-create it unless ($state->_exists($variable) || $state->set($variable, 1)) { Even if it works for variables, lists, this doesn't work for hashes, as it will systematically create the '1' key. Proposed patch solves the proble; for me and is attached (against 1.63)
Subject: AppConfig::File.patch
--- /usr/lib/perl5/vendor_perl/5.8.8/AppConfig/File.pm.orig 2007-08-09 17:44:26.000000000 +0200 +++ /usr/lib/perl5/vendor_perl/5.8.8/AppConfig/File.pm 2007-08-09 17:44:32.000000000 +0200 @@ -20,7 +20,7 @@ require 5.005; -use AppConfig; +use AppConfig qw(:argcount); use AppConfig::State; use File::HomeDir; @@ -227,6 +227,11 @@ my $nargs = $state->_argcount($variable); + # Fix a bug if the variable is a hash - 1 has been created as a key + if ($nargs eq AppConfig::ARGCOUNT_HASH) { + delete $state->{ VARIABLE }->{ $variable }}; + } + # variables prefixed '-' are reset to their default values if ($flag eq '-') { $state->_default($variable);
From: bruno [...] victoria.frmug.org
Le Jeu. Aoû. 09 12:03:24 2007, brunocornec a écrit : Show quoted text
> Proposed patch solves the proble; for me and is attached (against 1.63)
The patch was broken. Here is the right one. Sorry for the inconvenience.
--- /usr/lib/perl5/vendor_perl/5.8.8/AppConfig/File.pm.orig 2007-08-09 17:44:26.000000000 +0200 +++ /usr/lib/perl5/vendor_perl/5.8.8/AppConfig/File.pm 2007-08-09 18:04:46.000000000 +0200 @@ -20,7 +20,7 @@ require 5.005; -use AppConfig; +use AppConfig qw(:argcount); use AppConfig::State; use File::HomeDir; @@ -227,6 +227,11 @@ my $nargs = $state->_argcount($variable); + # Fix a bug if the variable is a hash - 1 has been created as a key + if ($nargs eq AppConfig::ARGCOUNT_HASH) { + delete $state->{ VARIABLE }->{ $variable }{1}; + } + # variables prefixed '-' are reset to their default values if ($flag eq '-') { $state->_default($variable);