From: Nicholas Clark Date: Fri, 26 Nov 2004 12:33:34 +0000 (+0000) Subject: The change to the internal representation introduced a bug whereby X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2ddb7828e223e2d2bbe82a4f9efaac6997a16d6c;p=p5sagit%2Fp5-mst-13.2.git The change to the internal representation introduced a bug whereby the key returned by FIRSTKEY had an erroneous leading newline. EXISTS was also buggy. p4raw-id: //depot/perl@23545 --- diff --git a/configpm b/configpm index 87dba35..9b83df0 100755 --- a/configpm +++ b/configpm @@ -329,7 +329,7 @@ my $prevpos = 0; sub FIRSTKEY { $prevpos = 0; - substr($Config_SH_expanded, 0, index($Config_SH_expanded, '=') ); + substr($Config_SH_expanded, 1, index($Config_SH_expanded, '=') - 1 ); } sub NEXTKEY { @@ -342,14 +342,11 @@ sub NEXTKEY { $len > 0 ? substr($Config_SH_expanded, $pos, $len) : undef; } -sub EXISTS { +sub EXISTS { return 1 if exists($_[0]->{$_[1]}); return(index($Config_SH_expanded, "\n$_[1]='") != -1 or - substr($Config_SH_expanded, 0, length($_[1])+2) eq "$_[1]='" or - index($Config_SH_expanded, "\n$_[1]=\"") != -1 or - substr($Config_SH_expanded, 0, length($_[1])+2) eq "$_[1]=\"" or - $_[1] =~ /^(?:(?:cc|ld)flags|libs(?:wanted)?)_nolargefiles$/ + index($Config_SH_expanded, "\n$_[1]=\"") != -1 ); } diff --git a/lib/Config.t b/lib/Config.t index 76c249d..63e0f20 100644 --- a/lib/Config.t +++ b/lib/Config.t @@ -14,7 +14,17 @@ use_ok('Config'); ok(keys %Config > 500, "Config has more than 500 entries"); -ok(each %Config); +my ($first) = Config::config_sh() =~ /^(\S+)=/m; +die "Can't find first entry in Config::config_sh()" unless defined $first; +print "# First entry is '$first'\n"; + +# It happens that the we know what the first key should be. This is somewhat +# cheating, but there was briefly a bug where the key got a bonus newline. +my ($first_each) = each %Config; +is($first_each, $first, "First key from each is correct"); +ok(exists($Config{$first_each}), "First key exists"); +ok(!exists($Config{"\n$first"}), + "Check that first key with prepended newline isn't falsely existing"); is($Config{PERL_REVISION}, 5, "PERL_REVISION is 5"); @@ -208,11 +218,8 @@ is($Config{sig_name_init} =~ tr/,/,/, $Config{sig_size}, "sig_name_init size"); my @virtual = qw(byteorder ccflags_nolargefiles ldflags_nolargefiles libs_nolargefiles libswanted_nolargefiles); -# Also test that the first entry in config.sh is found correctly. Currently -# there is special casing code for this -my ($first) = Config::config_sh() =~ /^(\S+)=/m; -die "Can't find first entry in Config::config_sh()" unless defined $first; -print "# First entry is '$first'\n"; +# Also test that the first entry in config.sh is found correctly. There was +# special casing code for this foreach my $pain ($first, @virtual) { # No config var is named with anything that is a regexp metachar