X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=configpm;h=4f301c38fa5464bb4d4501fa1a405faea7ca7e4b;hb=91451e42347a75e822ac69341556a66aff081878;hp=7816c8d66959609315079ab119cd94ec633f16e1;hpb=a48f8c779b973cde21f91eb6230f57994f5c9ad9;p=p5sagit%2Fp5-mst-13.2.git diff --git a/configpm b/configpm index 7816c8d..4f301c3 100755 --- a/configpm +++ b/configpm @@ -118,7 +118,7 @@ sub fetch_string { my $quote_type = "'"; my $marker = "$key="; - # Check for the common case, ' delimeted + # Check for the common case, ' delimited my $start = index($Config_SH, "\n$marker$quote_type"); # If that failed, check for " delimited if ($start == -1) { @@ -213,21 +213,24 @@ close CONFIG_SH; print CONFIG @non_v, "\n"; # copy config summary format from the myconfig.SH script -print CONFIG "my \$summary = <<'!END!';\n"; +print CONFIG "our \$summary : unique = <<'!END!';\n"; open(MYCONFIG,") && !/^Summary of/; do { print CONFIG $_ } until !defined($_ = ) || /^\s*$/; close(MYCONFIG); +# NB. as $summary is unique, we need to copy it in a lexical variable +# before expanding it, because may have been made readonly if a perl +# interpreter has been cloned. + print CONFIG "\n!END!\n", <<'EOT'; -my $summary_expanded = 0; +my $summary_expanded; sub myconfig { - return $summary if $summary_expanded; - $summary =~ s{\$(\w+)} + return $summary_expanded if $summary_expanded; + ($summary_expanded = $summary) =~ s{\$(\w+)} { my $c = $Config{$1}; defined($c) ? $c : 'undef' }ge; - $summary_expanded = 1; - $summary; + $summary_expanded; } our $Config_SH : unique = <<'!END!'; @@ -326,18 +329,23 @@ sub config_sh { sub config_re { my $re = shift; - return map { chomp; $_ } grep /^$re=/, split /^/, $config_sh; + return map { chomp; $_ } grep /^$re=/, split /^/, $Config_SH; } sub config_vars { foreach (@_) { - if (/\W/) { - my @matches = config_re($_); - print map "$_\n", @matches ? @matches : "$_: not found"; + my ($notag,$qry,$lncont) = m/^(:)?(.*?)(:)?$/; # flags fore and aft, + my $prfx = $notag ? '': "$qry="; # prefix for print + my $lnend = $lncont ? ' ' : ";\n"; # ending for print + + if ($qry =~ /\W/) { + my @matches = config_re($qry); + print map "$_$lnend", @matches ? @matches : "$qry: not found" if !$notag; + print map { s/\w+=//; "$_$lnend" } @matches ? @matches : "$qry: not found" if $notag; } else { - my $v = (exists $Config{$_}) ? $Config{$_} : 'UNKNOWN'; + my $v = (exists $Config{$qry}) ? $Config{$qry} : 'UNKNOWN'; $v = 'undef' unless defined $v; - print "$_='$v';\n"; + print "${prfx}'${v}'$lnend"; } } } @@ -406,7 +414,7 @@ EOT } my $fast_config = join '', map { " $_,\n" } - values (%v_fast), 'byteorder => $value' ; + sort values (%v_fast), 'byteorder => $value' ; print CONFIG sprintf <<'ENDOFTIE', $byteorder_code, $fast_config; @@ -432,8 +440,8 @@ Config - access Perl configuration information =head1 SYNOPSIS use Config; - if ($Config{'cc'} =~ /gcc/) { - print "built by gcc\n"; + if ($Config{usethreads}) { + print "has thread support\n" } use Config qw(myconfig config_sh config_vars config_re);