X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=win32%2Fconfig_sh.PL;h=fc0daf05bc0f51184780b07c27f81cb0f0d11278;hb=9cc6feabb930fb7cac992ab0a2febf2fb1986667;hp=e62e47f4f75bca48ec94cd39fae898b020025e32;hpb=7bac28a0157dcaf170649e8928f053f76dda4253;p=p5sagit%2Fp5-mst-13.2.git diff --git a/win32/config_sh.PL b/win32/config_sh.PL index e62e47f..fc0daf0 100644 --- a/win32/config_sh.PL +++ b/win32/config_sh.PL @@ -1,3 +1,15 @@ +# take a semicolon separated path list and turn it into a quoted +# list of paths that Text::Parsewords will grok +sub mungepath { + my $p = shift; + # remove leading/trailing semis/spaces + $p =~ s/^[ ;]+//; + $p =~ s/[ ;]+$//; + $p =~ s/'/"/g; + my @p = map { $_ = "\"$_\"" if /\s/ and !/^".*"$/; $_ } split /;/, $p; + return join(' ', @p); +} + my %opt; while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/) { @@ -5,11 +17,33 @@ while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/) shift(@ARGV); } -@opt{'PATCHLEVEL','SUBVERSION'} = ($] =~ /\.0*([1-9]+)(\d\d)$/); +$opt{VERSION} = $]; +$opt{INST_VER} =~ s|~VERSION~|$]|g; +if ($] =~ /\.(\d\d\d)?(\d\d)?$/) { # should always be true + $opt{PERL_VERSION} = int($1 || 0); + $opt{PERL_SUBVERSION} = $2 || '00'; +} + +$opt{'cf_by'} = $ENV{USERNAME} unless $opt{'cf_by'}; +$opt{'cf_email'} = $opt{'cf_by'} . '@' . (gethostbyname('localhost'))[0] + unless $opt{'cf_email'}; +$opt{'usemymalloc'} = 'y' if $opt{'d_mymalloc'} eq 'define'; + +$opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth}; +$opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath}; + while (<>) { s/~([\w_]+)~/$opt{$1}/g; - $_ = "$1='$opt{$1}'\n" if (/^([\w_]+)=/ && exists($opt{$1})); + if (/^([\w_]+)=(.*)$/) { + # this depends on cf_time being empty in the template (or we'll get a loop) + if ($1 eq 'cf_time') { + $_ = "$1='" . localtime(time) . "'\n" if $2 =~ /^\s*'\s*'/; + } + elsif (exists $opt{$1}) { + $_ = "$1='$opt{$1}'\n"; + } + } print; }