From: Nicholas Clark Date: Fri, 26 Nov 2004 11:29:21 +0000 (+0000) Subject: Make configpm and the generated Config.pm strict and warnings X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2f4f46aded53c2e2c32bd47e9a9d227762d35452;p=p5sagit%2Fp5-mst-13.2.git Make configpm and the generated Config.pm strict and warnings clean. p4raw-id: //depot/perl@23544 --- diff --git a/configpm b/configpm index 061528c..87dba35 100755 --- a/configpm +++ b/configpm @@ -1,4 +1,6 @@ #!./miniperl -w +use strict; +use vars qw(%Config $Config_SH_expanded); # commonly used names to put first (and hence lookup fastest) my %Common = map {($_,$_)} @@ -65,19 +67,25 @@ printf CONFIG <<'ENDOFBEG', ($myver) x 3; # made to this file will be lost the next time perl is built. package Config; -@EXPORT = qw(%%Config); -@EXPORT_OK = qw(myconfig config_sh config_vars config_re); +use strict; +# use warnings; Pulls in Carp +# use vars pulls in Carp +@Config::EXPORT = qw(%%Config); +@Config::EXPORT_OK = qw(myconfig config_sh config_vars config_re); -my %%Export_Cache = map {($_ => 1)} (@EXPORT, @EXPORT_OK); +my %%Export_Cache = map {($_ => 1)} (@Config::EXPORT, @Config::EXPORT_OK); + +our %%Config; # Define our own import method to avoid pulling in the full Exporter: sub import { my $pkg = shift; - @_ = @EXPORT unless @_; + @_ = @Config::EXPORT unless @_; my @funcs = grep $_ ne '%%Config', @_; my $export_Config = @funcs < @_ ? 1 : 0; + no strict 'refs'; my $callpkg = caller(0); foreach my $func (@funcs) { die sprintf qq{"%%s" is not exported by the %%s module\n}, @@ -154,8 +162,10 @@ EOT eval $fetch_string; die if $@; -open(CONFIG_SH, 'config.sh') || die "Can't open config.sh: $!"; -while () { +{ + my ($name, $val); + open(CONFIG_SH, 'config.sh') || die "Can't open config.sh: $!"; + while () { next if m:^#!/bin/sh:; # Catch PERL_CONFIG_SH=true and PERL_VERSION=n line from Configure. @@ -180,7 +190,7 @@ while () { push(@non_v, "#$_"); # not a name='value' line next; } - $quote = $2; + my $quote = $2; if ($in_v) { $val .= $_; } @@ -202,8 +212,10 @@ while () { push(@v_fast, $line); $v_fast{$name} = "'$name' => $quote$val$quote"; } + } + close CONFIG_SH; } -close CONFIG_SH; + # Calculation for the keys for byteorder # This is somewhat grim, but I need to run fetch_string here. @@ -550,8 +562,8 @@ ENDOFTAIL if ($Opts{glossary}) { open(GLOS, "<$Glossary") or die "Can't open $Glossary: $!"; } -%seen = (); -$text = 0; +my %seen = (); +my $text = 0; $/ = ''; sub process {