diff options
author | Nicholas Clark <nick@ccl4.org> | 2004-11-26 12:33:34 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2004-11-26 12:33:34 +0000 |
commit | 2ddb7828e223e2d2bbe82a4f9efaac6997a16d6c (patch) | |
tree | 0b5ea3109cc8f150ea90c0831ab9ca6d40ff690e | |
parent | 2f4f46aded53c2e2c32bd47e9a9d227762d35452 (diff) | |
download | perl-2ddb7828e223e2d2bbe82a4f9efaac6997a16d6c.tar.gz |
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
-rwxr-xr-x | configpm | 9 | ||||
-rw-r--r-- | lib/Config.t | 19 |
2 files changed, 16 insertions, 12 deletions
@@ -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 76c249dae4..63e0f20c1a 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 |