From: Charles Bailey Date: Mon, 23 Aug 1999 03:17:33 +0000 (+0000) Subject: update MM_VMS to use new File::Spec routines X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=377875b926c86a98f77adb365611978943fd9ece;p=p5sagit%2Fp5-mst-13.2.git update MM_VMS to use new File::Spec routines p4raw-id: //depot/vmsperl@4022 --- diff --git a/lib/ExtUtils/MM_VMS.pm b/lib/ExtUtils/MM_VMS.pm index ba4c2cc..4c64910 100644 --- a/lib/ExtUtils/MM_VMS.pm +++ b/lib/ExtUtils/MM_VMS.pm @@ -12,10 +12,11 @@ use Config; require Exporter; use VMS::Filespec; use File::Basename; - -use vars qw($Revision); +use File::Spec; +use vars qw($Revision @ISA); $Revision = '5.56 (27-Apr-1999)'; +@ISA = qw( File::Spec ); unshift @MM::ISA, 'ExtUtils::MM_VMS'; Exporter::import('ExtUtils::MakeMaker', '$Verbose', '&neatvalue'); @@ -38,156 +39,6 @@ the semantics. =over -=item eliminate_macros - -Expands MM[KS]/Make macros in a text string, using the contents of -identically named elements of C<%$self>, and returns the result -as a file specification in Unix syntax. - -=cut - -sub eliminate_macros { - my($self,$path) = @_; - unless ($path) { - print "eliminate_macros('') = ||\n" if $Verbose >= 3; - return ''; - } - my($npath) = unixify($path); - my($complex) = 0; - my($head,$macro,$tail); - - # perform m##g in scalar context so it acts as an iterator - while ($npath =~ m#(.*?)\$\((\S+?)\)(.*)#g) { - if ($self->{$2}) { - ($head,$macro,$tail) = ($1,$2,$3); - if (ref $self->{$macro}) { - if (ref $self->{$macro} eq 'ARRAY') { - print "Note: expanded array macro \$($macro) in $path\n" if $Verbose; - $macro = join ' ', @{$self->{$macro}}; - } - else { - print "Note: can't expand macro \$($macro) containing ",ref($self->{$macro}), - "\n\t(using MMK-specific deferred substitutuon; MMS will break)\n"; - $macro = "\cB$macro\cB"; - $complex = 1; - } - } - else { ($macro = unixify($self->{$macro})) =~ s#/$##; } - $npath = "$head$macro$tail"; - } - } - if ($complex) { $npath =~ s#\cB(.*?)\cB#\${$1}#g; } - print "eliminate_macros($path) = |$npath|\n" if $Verbose >= 3; - $npath; -} - -=item fixpath - -Catchall routine to clean up problem MM[SK]/Make macros. Expands macros -in any directory specification, in order to avoid juxtaposing two -VMS-syntax directories when MM[SK] is run. Also expands expressions which -are all macro, so that we can tell how long the expansion is, and avoid -overrunning DCL's command buffer when MM[KS] is running. - -If optional second argument has a TRUE value, then the return string is -a VMS-syntax directory specification, if it is FALSE, the return string -is a VMS-syntax file specification, and if it is not specified, fixpath() -checks to see whether it matches the name of a directory in the current -default directory, and returns a directory or file specification accordingly. - -=cut - -sub fixpath { - my($self,$path,$force_path) = @_; - unless ($path) { - print "eliminate_macros('') = ||\n" if $Verbose >= 3; - return ''; - } - my($fixedpath,$prefix,$name); - - if ($path =~ m#^\$\([^\)]+\)$# || $path =~ m#[/:>\]]#) { - if ($force_path or $path =~ /(?:DIR\)|\])$/) { - $fixedpath = vmspath($self->eliminate_macros($path)); - } - else { - $fixedpath = vmsify($self->eliminate_macros($path)); - } - } - elsif ((($prefix,$name) = ($path =~ m#^\$\(([^\)]+)\)(.+)#)) && $self->{$prefix}) { - my($vmspre) = $self->eliminate_macros("\$($prefix)"); - # is it a dir or just a name? - $vmspre = ($vmspre =~ m|/| or $prefix =~ /DIR$/) ? vmspath($vmspre) : ''; - $fixedpath = ($vmspre ? $vmspre : $self->{$prefix}) . $name; - $fixedpath = vmspath($fixedpath) if $force_path; - } - else { - $fixedpath = $path; - $fixedpath = vmspath($fixedpath) if $force_path; - } - # No hints, so we try to guess - if (!defined($force_path) and $fixedpath !~ /[:>(.\]]/) { - $fixedpath = vmspath($fixedpath) if -d $fixedpath; - } - # Trim off root dirname if it's had other dirs inserted in front of it. - $fixedpath =~ s/\.000000([\]>])/$1/; - print "fixpath($path) = |$fixedpath|\n" if $Verbose >= 3; - $fixedpath; -} - -=item catdir - -Concatenates a list of file specifications, and returns the result as a -VMS-syntax directory specification. - -=cut - -sub catdir { - my($self,@dirs) = @_; - my($dir) = pop @dirs; - @dirs = grep($_,@dirs); - my($rslt); - if (@dirs) { - my($path) = (@dirs == 1 ? $dirs[0] : $self->catdir(@dirs)); - my($spath,$sdir) = ($path,$dir); - $spath =~ s/.dir$//; $sdir =~ s/.dir$//; - $sdir = $self->eliminate_macros($sdir) unless $sdir =~ /^[\w\-]+$/; - $rslt = $self->fixpath($self->eliminate_macros($spath)."/$sdir",1); - } - else { - if ($dir =~ /^\$\([^\)]+\)$/) { $rslt = $dir; } - else { $rslt = vmspath($dir); } - } - print "catdir(",join(',',@_[1..$#_]),") = |$rslt|\n" if $Verbose >= 3; - $rslt; -} - -=item catfile - -Concatenates a list of file specifications, and returns the result as a -VMS-syntax directory specification. - -=cut - -sub catfile { - my($self,@files) = @_; - my($file) = pop @files; - @files = grep($_,@files); - my($rslt); - if (@files) { - my($path) = (@files == 1 ? $files[0] : $self->catdir(@files)); - my($spath) = $path; - $spath =~ s/.dir$//; - if ( $spath =~ /^[^\)\]\/:>]+\)$/ && basename($file) eq $file) { $rslt = "$spath$file"; } - else { - $rslt = $self->eliminate_macros($spath); - $rslt = vmsify($rslt.($rslt ? '/' : '').unixify($file)); - } - } - else { $rslt = vmsify($file); } - print "catfile(",join(',',@_[1..$#_]),") = |$rslt|\n" if $Verbose >= 3; - $rslt; -} - =item wraplist Converts a list into a string wrapped at approximately 80 columns. @@ -212,16 +63,6 @@ sub wraplist { $line; } -=item curdir (override) - -Returns a string representing of the current directory. - -=cut - -sub curdir { - return '[]'; -} - =item rootdir (override) Returns a string representing of the root directory. @@ -232,16 +73,6 @@ sub rootdir { return ''; } -=item updir (override) - -Returns a string representing of the parent directory. - -=cut - -sub updir { - return '[-]'; -} - package ExtUtils::MM_VMS; sub ExtUtils::MM_VMS::ext; diff --git a/lib/File/Spec/VMS.pm b/lib/File/Spec/VMS.pm index d13f5e6..00c068a 100644 --- a/lib/File/Spec/VMS.pm +++ b/lib/File/Spec/VMS.pm @@ -22,6 +22,12 @@ See File::Spec::Unix for a documentation of the methods provided there. This package overrides the implementation of these methods, not the semantics. +=item eliminate_macros + +Expands MM[KS]/Make macros in a text string, using the contents of +identically named elements of C<%$self>, and returns the result +as a file specification in Unix syntax. + =cut sub eliminate_macros { @@ -55,6 +61,22 @@ sub eliminate_macros { $npath; } +=item fixpath + +Catchall routine to clean up problem MM[SK]/Make macros. Expands macros +in any directory specification, in order to avoid juxtaposing two +VMS-syntax directories when MM[SK] is run. Also expands expressions which +are all macro, so that we can tell how long the expansion is, and avoid +overrunning DCL's command buffer when MM[KS] is running. + +If optional second argument has a TRUE value, then the return string is +a VMS-syntax directory specification, if it is FALSE, the return string +is a VMS-syntax file specification, and if it is not specified, fixpath() +checks to see whether it matches the name of a directory in the current +default directory, and returns a directory or file specification accordingly. + +=cut + sub fixpath { my($self,$path,$force_path) = @_; return '' unless $path;