Skip Menu |

This queue is for tickets about the PathTools CPAN distribution.

Report information
The Basics
Id: 32968
Status: resolved
Priority: 0/
Queue: PathTools

People
Owner: Nobody in particular
Requestors: cpan [...] pjedwards.co.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 3.27
Fixed in: (no value)



Subject: File::Spec::VMS->splitpath and $no_file
I'm not sure this is a bug but I thought I'd mention that I've posted the following to the moderated group perl.vmsperl Trying to get Path::Class to pass it's tests on VMS Perl 5.8.7 on ODS-2 disk. One of the test cases is calling: File::Spec->splitpath('t',1); So on Unix: perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',0))" ||t perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',1))" |t| On VMS: perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',0))" ||t perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',1))" ||t It's this last command that is the problem, the expected behaviour in Path::Class is |t|. The doc for File::Spec->splitpath states: splitpath Splits a path in to volume, directory, and filename portions. On systems with no concept of volume, returns '' for volume. ($volume,$directories,$file) = File::Spec->splitpath( $path ); ($volume,$directories,$file) = File::Spec->splitpath( $path, $no_file ); For systems with no syntax differentiating filenames from directories, assumes that the last file is a path unless $no_file is true or a trailing separator or /. or /.. is present. On Unix, this means that $no_file true makes this return ( '', $path, '' ). The directory portion may or may not be returned with a trailing '/'. The results can be passed to "catpath()" to get back a path equivalent to (usually identical to) the original path. So I'm wondering if File::Spec::VMS->splitpath should support $no_file or not? It looks like the majority of File::Spec::* modules do, I don't know if they all have syntax that does not differentiate filenames from directories. Current File::Spec::VMS splitpath is: sub splitpath { my($self,$path) = @_; my($dev,$dir,$file) = ('','',''); vmsify($path) =~ /(.+:)?([\[<].*[\]>])?(.*)/s; return ($1 || '',$2 || '',$3); } This hack changes the behaviour so that File::Spec::VMS->splitpath('t',1) returns t as the dir and not the file. All PathTools 3.27 tests still pass. sub splitpath { my($self,$path, $nofile) = @_; my($dev,$dir,$file) = ('','',''); if ( $nofile ){ vmsify($path) =~ /(.+:)?(.*)/s; return ($1 || '',$2 || '',$file); } else { vmsify($path) =~ /(.+:)?([\[<].*[\]>])?(.*)/s; return ($1 || '',$2 || '',$3); } } Just wondering if anyone has any thoughts on this? Thanks, Peter (Stig) Edwards
RT-Send-CC: craigberry [...] mac.com
On Wed Feb 06 12:14:06 2008, cpan@pjedwards.co.uk wrote: Show quoted text
> I'm not sure this is a bug but I thought I'd mention that I've posted > the following to the moderated group perl.vmsperl > > Trying to get Path::Class to pass it's tests on VMS Perl 5.8.7 on ODS-
2 Show quoted text
> disk. > > One of the test cases is calling: > > File::Spec->splitpath('t',1); > > So on Unix: > > perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',0))" > ||t > > perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',1))" > |t| > > On VMS: > > perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',0))" > ||t > > perl -e "use File::Spec;print join('|',File::Spec->splitpath('t',1))" > ||t > > It's this last command that is the problem, the expected behaviour in > Path::Class is |t|. > > The doc for File::Spec->splitpath states: > > splitpath > > Splits a path in to volume, directory, and filename portions. On > systems with no concept of volume, returns '' for volume. > > ($volume,$directories,$file) = File::Spec->splitpath( $path ); > ($volume,$directories,$file) = File::Spec->splitpath( $path, > $no_file ); > > For systems with no syntax differentiating filenames from > directories, assumes that the last file is a path unless $no_file is > true or a trailing separator or /. or /.. is present. On Unix, this > means that $no_file true makes this return ( '', $path, '' ). > > The directory portion may or may not be returned with a
trailing '/'. Show quoted text
> > The results can be passed to "catpath()" to get back a path > equivalent to (usually identical to) the original path. > > > So I'm wondering if File::Spec::VMS->splitpath should support $no_file > or not? It looks like the majority of File::Spec::* modules do, I
don't Show quoted text
> know if they all have syntax that does not differentiate filenames
from Show quoted text
> directories. > > Current File::Spec::VMS splitpath is: > > sub splitpath { > my($self,$path) = @_; > my($dev,$dir,$file) = ('','',''); > > vmsify($path) =~ /(.+:)?([\[<].*[\]>])?(.*)/s; > return ($1 || '',$2 || '',$3); > } > > This hack changes the behaviour so that > File::Spec::VMS->splitpath('t',1) returns t as the dir and not the
file. Show quoted text
> All PathTools 3.27 tests still pass. > > sub splitpath { > my($self,$path, $nofile) = @_; > my($dev,$dir,$file) = ('','',''); > if ( $nofile ){ > vmsify($path) =~ /(.+:)?(.*)/s; > return ($1 || '',$2 || '',$file); > } > else { > vmsify($path) =~ /(.+:)?([\[<].*[\]>])?(.*)/s; > return ($1 || '',$2 || '',$3); > } > } > > Just wondering if anyone has any thoughts on this? > > Thanks, > > Peter (Stig) Edwards
Craig A. Berry (cc'ed) did post a follow up: http://www.nntp.perl.org/group/perl.vmsperl/2008/02/msg14704.html I followed up with a patch against 3.27. Here is a patch against 3.2701: lib/File/Spec/VMS.pm 245c245,250 < Splits using VMS syntax. --- Show quoted text
> ($volume,$directories,$file) = File::Spec->splitpath( $path ); > ($volume,$directories,$file) = File::Spec->splitpath( $path,
$no_file ); Show quoted text
> > $no_file means the path being split only contains directory
components Show quoted text
> even on systems where you can usually (when not supporting a
foreign Show quoted text
> syntax) tell the difference between directories and files at a
glance. 250,254c255,271 < my($self,$path) = @_; < my($dev,$dir,$file) = ('','',''); < < vmsify($path) =~ /(.+:)?([\[<].*[\]>])?(.*)/s; < return ($1 || '',$2 || '',$3); --- Show quoted text
> my($self,$path, $nofile) = @_; > my($dev,$dir,$file) = ('','',''); > my $vmsify_path = vmsify($path); > if ( $nofile ){ > #vmsify('d1/d2/d3') returns '[.d1.d2]d3' > #vmsify('/d1/d2/d3') returns 'd1:[d2]d3' > if( $vmsify_path =~ /(.*)\](.+)/ ){ > $vmsify_path = $1.'.'.$2.']'; > } > $vmsify_path =~ /(.+:)?(.*)/s; > $dir = defined $2 ? $2 : ''; # dir can be '0' > return ($1 || '',$dir,$file); > } > else { > $vmsify_path =~ /(.+:)?([\[<].*[\]>])?(.*)/s; > return ($1 || '',$2 || '',$3); > }
t/spec.t 314a315,352 Show quoted text
> [ "VMS->splitpath('[]')", ',
[],' ], Show quoted text
> [ "VMS->splitpath('[-]')", ',[-
],' ], Show quoted text
> [ "VMS->splitpath('[]file')", ',
[],file' ], Show quoted text
> [ "VMS->splitpath('[-]file')", ',[-
],file' ], Show quoted text
> [ "VMS->splitpath
('')", ',,' ], Show quoted text
> [ "VMS->splitpath
('0')", ',,0' ], Show quoted text
> [ "VMS->splitpath('[0]')", ',
[0],' ], Show quoted text
> [ "VMS->splitpath('[.0]')", ',
[.0],' ], Show quoted text
> [ "VMS->splitpath('[0.0.0]')", ',
[0.0.0],' ], Show quoted text
> [ "VMS->splitpath('[.0.0.0]')", ',
[.0.0.0],' ], Show quoted text
> [ "VMS->splitpath('[0]0')", ',
[0],0' ], Show quoted text
> [ "VMS->splitpath('[0.0.0]0')", ',
[0.0.0],0' ], Show quoted text
> [ "VMS->splitpath('[.0.0.0]0')", ',
[.0.0.0],0' ], Show quoted text
> [ "VMS->splitpath('0/0')", ',
[.0],0' ], Show quoted text
> [ "VMS->splitpath('0/0/0')", ',
[.0.0],0' ], Show quoted text
> [ "VMS->splitpath('/0/0')", '0:,
[000000],0' ], Show quoted text
> [ "VMS->splitpath('/0/0/0')", '0:,
[0],0' ], Show quoted text
> [ "VMS->splitpath
('d1',1)", ',d1,' ], Show quoted text
> # $no_file tests > [ "VMS->splitpath('[d1.d2.d3]',1)", ',
[d1.d2.d3],' ], Show quoted text
> [ "VMS->splitpath('[.d1.d2.d3]',1)", ',
[.d1.d2.d3],' ], Show quoted text
> [ "VMS->splitpath('d1/d2/d3',1)", ',
[.d1.d2.d3],' ], Show quoted text
> [ "VMS->splitpath
('/d1/d2/d3',1)", 'd1:, [d2.d3],' ], Show quoted text
> [ "VMS->splitpath('node::volume:
[d1.d2.d3]',1)", 'node::volume:, [d1.d2.d3],' ], Show quoted text
> [ "VMS->splitpath('node\"access_spec\"::volume:
[d1.d2.d3]',1)", 'node"access_spec"::volume:,[d1.d2.d3],' ], Show quoted text
> [ "VMS->splitpath('[]',1)", ',
[],' ], Show quoted text
> [ "VMS->splitpath('[-]',1)", ',[-
],' ], Show quoted text
> [ "VMS->splitpath
('',1)", ',,' ], Show quoted text
> [ "VMS->splitpath
('0',1)", ',0,' ], Show quoted text
> [ "VMS->splitpath('[0]',1)", ',
[0],' ], Show quoted text
> [ "VMS->splitpath('[.0]',1)", ',
[.0],' ], Show quoted text
> [ "VMS->splitpath('[0.0.0]',1)", ',
[0.0.0],' ], Show quoted text
> [ "VMS->splitpath('[.0.0.0]',1)", ',
[.0.0.0],' ], Show quoted text
> [ "VMS->splitpath('0/0',1)", ',
[.0.0],' ], Show quoted text
> [ "VMS->splitpath('0/0/0',1)", ',
[.0.0.0],' ], Show quoted text
> [ "VMS->splitpath('/0/0',1)", '0:,
[000000.0],' ], Show quoted text
> [ "VMS->splitpath('/0/0/0',1)", '0:,
[0.0],' ], Show quoted text
>
Cheers, Peter (Stig) Edwards
lib/File/Spec/VMS.pm 245c245,250 < Splits using VMS syntax. --- > ($volume,$directories,$file) = File::Spec->splitpath( $path ); > ($volume,$directories,$file) = File::Spec->splitpath( $path, $no_file ); > > $no_file means the path being split only contains directory components > even on systems where you can usually (when not supporting a foreign > syntax) tell the difference between directories and files at a glance. 250,254c255,271 < my($self,$path) = @_; < my($dev,$dir,$file) = ('','',''); < < vmsify($path) =~ /(.+:)?([\[<].*[\]>])?(.*)/s; < return ($1 || '',$2 || '',$3); --- > my($self,$path, $nofile) = @_; > my($dev,$dir,$file) = ('','',''); > my $vmsify_path = vmsify($path); > if ( $nofile ){ > #vmsify('d1/d2/d3') returns '[.d1.d2]d3' > #vmsify('/d1/d2/d3') returns 'd1:[d2]d3' > if( $vmsify_path =~ /(.*)\](.+)/ ){ > $vmsify_path = $1.'.'.$2.']'; > } > $vmsify_path =~ /(.+:)?(.*)/s; > $dir = defined $2 ? $2 : ''; # dir can be '0' > return ($1 || '',$dir,$file); > } > else { > $vmsify_path =~ /(.+:)?([\[<].*[\]>])?(.*)/s; > return ($1 || '',$2 || '',$3); > } t/spec.t 314a315,352 > [ "VMS->splitpath('[]')", ',[],' ], > [ "VMS->splitpath('[-]')", ',[-],' ], > [ "VMS->splitpath('[]file')", ',[],file' ], > [ "VMS->splitpath('[-]file')", ',[-],file' ], > [ "VMS->splitpath('')", ',,' ], > [ "VMS->splitpath('0')", ',,0' ], > [ "VMS->splitpath('[0]')", ',[0],' ], > [ "VMS->splitpath('[.0]')", ',[.0],' ], > [ "VMS->splitpath('[0.0.0]')", ',[0.0.0],' ], > [ "VMS->splitpath('[.0.0.0]')", ',[.0.0.0],' ], > [ "VMS->splitpath('[0]0')", ',[0],0' ], > [ "VMS->splitpath('[0.0.0]0')", ',[0.0.0],0' ], > [ "VMS->splitpath('[.0.0.0]0')", ',[.0.0.0],0' ], > [ "VMS->splitpath('0/0')", ',[.0],0' ], > [ "VMS->splitpath('0/0/0')", ',[.0.0],0' ], > [ "VMS->splitpath('/0/0')", '0:,[000000],0' ], > [ "VMS->splitpath('/0/0/0')", '0:,[0],0' ], > [ "VMS->splitpath('d1',1)", ',d1,' ], > # $no_file tests > [ "VMS->splitpath('[d1.d2.d3]',1)", ',[d1.d2.d3],' ], > [ "VMS->splitpath('[.d1.d2.d3]',1)", ',[.d1.d2.d3],' ], > [ "VMS->splitpath('d1/d2/d3',1)", ',[.d1.d2.d3],' ], > [ "VMS->splitpath('/d1/d2/d3',1)", 'd1:,[d2.d3],' ], > [ "VMS->splitpath('node::volume:[d1.d2.d3]',1)", 'node::volume:,[d1.d2.d3],' ], > [ "VMS->splitpath('node\"access_spec\"::volume:[d1.d2.d3]',1)", 'node"access_spec"::volume:,[d1.d2.d3],' ], > [ "VMS->splitpath('[]',1)", ',[],' ], > [ "VMS->splitpath('[-]',1)", ',[-],' ], > [ "VMS->splitpath('',1)", ',,' ], > [ "VMS->splitpath('0',1)", ',0,' ], > [ "VMS->splitpath('[0]',1)", ',[0],' ], > [ "VMS->splitpath('[.0]',1)", ',[.0],' ], > [ "VMS->splitpath('[0.0.0]',1)", ',[0.0.0],' ], > [ "VMS->splitpath('[.0.0.0]',1)", ',[.0.0.0],' ], > [ "VMS->splitpath('0/0',1)", ',[.0.0],' ], > [ "VMS->splitpath('0/0/0',1)", ',[.0.0.0],' ], > [ "VMS->splitpath('/0/0',1)", '0:,[000000.0],' ], > [ "VMS->splitpath('/0/0/0',1)", '0:,[0.0],' ], >
Thanks, I've applied this patch. I'll release a beta to CPAN shortly and if there's no breakage I can make an official release. -Ken
Thanks, I tested 3.28_01 on 5.8.7 on VMS, it tested ok. I did notice a Win32 CPAN Testers failure.