From: Craig A. Berry Date: Mon, 8 Oct 2001 15:40:43 +0000 (-0500) Subject: Autosplit patch for VMS X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=64a3d80f001e333a9280dbb6ecc790d2991874df;p=p5sagit%2Fp5-mst-13.2.git Autosplit patch for VMS Message-Id: <5.1.0.14.0.20011008150808.02302618@exchi01> p4raw-id: //depot/perl@12365 --- diff --git a/lib/AutoSplit.pm b/lib/AutoSplit.pm index ae119d3..bf4d811 100644 --- a/lib/AutoSplit.pm +++ b/lib/AutoSplit.pm @@ -6,7 +6,7 @@ use Config qw(%Config); use Carp qw(carp); use File::Basename (); use File::Path qw(mkpath); -use File::Spec::Functions qw(curdir catfile); +use File::Spec::Functions qw(curdir catfile catdir); use strict; our($VERSION, @ISA, @EXPORT, @EXPORT_OK, $Verbose, $Keep, $Maxlen, $CheckForAutoloader, $CheckModTime); @@ -255,9 +255,6 @@ sub autosplit_file { $def_package or die "Can't find 'package Name;' in $filename\n"; my($modpname) = _modpname($def_package); - if ($Is_VMS) { - $modpname = VMS::Filespec::unixify($modpname); # may have dirs - } # this _has_ to match so we have a reasonable timestamp file die "Package $def_package ($modpname.pm) does not ". @@ -278,7 +275,7 @@ sub autosplit_file { } } - my($modnamedir) = catfile($autodir, $modpname); + my($modnamedir) = catdir($autodir, $modpname); print "AutoSplitting $filename ($modnamedir)\n" if $Verbose; @@ -326,7 +323,7 @@ sub autosplit_file { push(@subnames, $fq_subname); my($lname, $sname) = ($subname, substr($subname,0,$maxflen-3)); $modpname = _modpname($this_package); - my($modnamedir) = catfile($autodir, $modpname); + my($modnamedir) = catdir($autodir, $modpname); mkpath($modnamedir,0,0777); my($lpath) = catfile($modnamedir, "$lname.al"); my($spath) = catfile($modnamedir, "$sname.al"); @@ -435,9 +432,15 @@ sub _modpname ($) { if ($^O eq 'MSWin32') { $modpname =~ s#::#\\#g; } else { - while ($modpname =~ m#(.*?[^:])::([^:].*)#) { - $modpname = catfile($1, $2); - } + my @modpnames = (); + while ($modpname =~ m#(.*?[^:])::([^:].*)#) { + push @modpnames, $1; + $modpname = $2; + } + $modpname = catfile(@modpnames, $modpname); + } + if ($Is_VMS) { + $modpname = VMS::Filespec::unixify($modpname); # may have dirs } $modpname; } diff --git a/lib/AutoSplit.t b/lib/AutoSplit.t index 296e359..7723a53 100644 --- a/lib/AutoSplit.t +++ b/lib/AutoSplit.t @@ -65,14 +65,29 @@ sub split_a_file { return $output; } +# Brackets are valid in VMS filespecs and this test puts filespecs +# into regexes a lot. + +sub _escape_brackets { + my $str = shift; + $str =~ s/\[/\\\[/g; + $str =~ s/\]/\\\]/g; + return $str; +} + my $i = 0; -my $dir = File::Spec->catfile($incdir, 'auto'); +my $dir = File::Spec->catdir($incdir, 'auto'); +if ($^O eq 'VMS') { + $dir = VMS::Filespec::unixify($dir); + $dir =~ s/\/$//; +} foreach (@tests) { my $module = 'A' . $i . '_' . $$ . 'splittest'; my $file = File::Spec->catfile($incdir,"$module.pm"); s/\*INC\*/$incdir/gm; s/\*DIR\*/$dir/gm; s/\*MOD\*/$module/gm; + s#//#/#gm; # Build a hash for this test. my %args = /^\#\#\ ([^\n]*)\n # Key is on a line starting ## ((?:[^\#]+ # Any number of characters not # @@ -92,6 +107,17 @@ foreach (@tests) { $output = split_a_file (undef, $file, $dir, @extra_args); } + if ($^O eq 'VMS') { + my ($filespec, $replacement); + while ($output =~ m/(\[.+\])/) { + $filespec = $1; + $replacement = VMS::Filespec::unixify($filespec); + $filespec = _escape_brackets($filespec); + $replacement =~ s/\/$//; + $output =~ s/$filespec/$replacement/; + } + } + # test n+1 is ($output, $args{Get}, "Output from autosplit()ing $args{Name}"); @@ -101,6 +127,7 @@ foreach (@tests) { find (sub {$got{$File::Find::name}++ unless -d $_}, $dir); foreach (split /\n/, $args{Files}) { next if /^#/; + $_ = lc($_) if $^O eq 'VMS'; unless (delete $got{$_}) { $missing{$_}++; } @@ -143,6 +170,7 @@ foreach (@tests) { if ($args{Tests}) { foreach my $code (split /\n/, $args{Tests}) { next if $code =~ /^\#/; + $code =~ s/\[(File::Spec->catfile\(.*\))\]/[_escape_brackets($1)]/ if $^O eq 'VMS'; defined eval $code or fail(), print "# Code: $code\n# Error: $@"; } }