Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File::Spec Cygwin/Win32 case_tolerant improvement #9359

Closed
p5pRT opened this issue Jun 1, 2008 · 7 comments
Closed

File::Spec Cygwin/Win32 case_tolerant improvement #9359

p5pRT opened this issue Jun 1, 2008 · 7 comments
Labels
dist-PathTools issues in the dual-life blead-first PathTools distribution

Comments

@p5pRT
Copy link

p5pRT commented Jun 1, 2008

Migrated from rt.perl.org#55156 (status was 'open')

Searchable as RT55156$

@p5pRT
Copy link
Author

p5pRT commented Jun 1, 2008

From @rurban

This patch is a significant performance improvement of my initial
case_tolerant patch,
which is esp. noticable on Module​::Build

--
Reini Urban
http​://phpwiki.org/ http​://murbreak.at/

@p5pRT
Copy link
Author

p5pRT commented Jun 1, 2008

From @rurban

pl-CYG18-case_tol-511.patch
difforig perl-current/lib/File

2008-06-01 rurban@cpan.org
	* File::Spec->case_tolerant performance improvement on cygwin and Win32.
	Esp. noticable in Module::Build. 

diff -u  perl-current/lib/File/Spec.pm.orig
--- perl-current/lib/File/Spec.pm.orig	2008-02-12 16:12:46.000000000 +0100
+++ perl-current/lib/File/Spec.pm	2008-06-01 14:10:03.703125000 +0200
@@ -3,7 +3,7 @@
 use strict;
 use vars qw(@ISA $VERSION);
 
-$VERSION = '3.2701';
+$VERSION = '3.2702';
 $VERSION = eval $VERSION;
 
 my %module = (MacOS   => 'Mac',
@@ -166,6 +166,7 @@
 
 Returns a true or false value indicating, respectively, that alphabetic
 case is not or is significant when comparing file specifications.
+Cygwin and Win32 accept an optional drive argument.
 
     $is_case_tolerant = File::Spec->case_tolerant();
 
diff -u  perl-current/lib/File/Spec/Cygwin.pm.orig
--- perl-current/lib/File/Spec/Cygwin.pm.orig	2008-02-12 16:12:46.000000000 +0100
+++ perl-current/lib/File/Spec/Cygwin.pm	2008-06-01 14:08:20.781250000 +0200
@@ -4,7 +4,7 @@
 use vars qw(@ISA $VERSION);
 require File::Spec::Unix;
 
-$VERSION = '3.2701';
+$VERSION = '3.2702';
 
 @ISA = qw(File::Spec::Unix);
 
@@ -107,16 +107,23 @@
 Override Unix. Cygwin case-tolerance depends on managed mount settings and
 as with MsWin32 on GetVolumeInformation() $ouFsFlags == FS_CASE_SENSITIVE,
 indicating the case significance when comparing file specifications.
+Since XP FS_CASE_SENSITIVE is effectively disabled for the NT subsubsystem. (TODO)
+See http://cygwin.com/ml/cygwin/2007-07/msg00891.html
+Accepts on optional drive-mount argument.
 Default: 1
 
 =cut
 
+my %tmp_case_tolerant;
 sub case_tolerant () {
   return 1 unless $^O eq 'cygwin'
     and defined &Cygwin::mount_flags;
 
   my $drive = shift;
+  $drive = shift if $drive =~ /^File::Spec/;
+  my $windrive;
   if (! $drive) {
+      $windrive = 'C:';
       my @flags = split(/,/, Cygwin::mount_flags('/cygwin'));
       my $prefix = pop(@flags);
       if (! $prefix || $prefix eq 'cygdrive') {
@@ -126,18 +133,19 @@
       } else {
           $drive = "$prefix/c";
       }
+  } else {
+      $windrive = Cygwin::posix_to_win_path($drive);
   }
+  return $tmp_case_tolerant{$drive} if exists $tmp_case_tolerant{$drive};
   my $mntopts = Cygwin::mount_flags($drive);
   if ($mntopts and ($mntopts =~ /,managed/)) {
+    $tmp_case_tolerant{$drive} = 0;
     return 0;
   }
-  eval { require Win32API::File; } or return 1;
-  my $osFsType = "\0"x256;
-  my $osVolName = "\0"x256;
-  my $ouFsFlags = 0;
-  Win32API::File::GetVolumeInformation($drive, $osVolName, 256, [], [], $ouFsFlags, $osFsType, 256 );
-  if ($ouFsFlags & Win32API::File::FS_CASE_SENSITIVE()) { return 0; }
-  else { return 1; }
+  require File::Spec::Win32;
+  $windrive =~ s/\\$//;
+  $tmp_case_tolerant{$drive} = File::Spec::Win32::case_tolerant($windrive);
+  return $tmp_case_tolerant{$drive};
 }
 
 =back
diff -u  perl-current/lib/File/Spec/Win32.pm.orig
--- perl-current/lib/File/Spec/Win32.pm.orig	2008-02-12 16:12:47.000000000 +0100
+++ perl-current/lib/File/Spec/Win32.pm	2008-06-01 14:08:57.250000000 +0200
@@ -5,7 +5,7 @@
 use vars qw(@ISA $VERSION);
 require File::Spec::Unix;
 
-$VERSION = '3.2701';
+$VERSION = '3.2702';
 
 @ISA = qw(File::Spec::Unix);
 
@@ -83,13 +83,20 @@
 indicating the case significance when comparing file specifications.
 Since XP FS_CASE_SENSITIVE is effectively disabled for the NT subsubsystem.
 See http://cygwin.com/ml/cygwin/2007-07/msg00891.html
+Accepts on optional drive-letter argument.
 Default: 1
 
 =cut
 
 sub case_tolerant () {
+  my @ver = Win32::GetOSVersion();
+  # From XP on this is disabled.
+  if ($ver[4] >= 2 and $ver[1] >= 5 and $ver[2] >= 1) { return 1; }
+  if ($ver[4] < 2) { return 1; } # Win32s,95,ME are always case_tolerant.
   eval { require Win32API::File; } or return 1;
-  my $drive = shift || "C:";
+  my $drive = shift || "C:";Accepts on optional drive-letter argument.
+
+  $drive = shift if $drive =~ /^File::Spec/;
   my $osFsType = "\0"x256;
   my $osVolName = "\0"x256;
   my $ouFsFlags = 0;

@p5pRT
Copy link
Author

p5pRT commented Jun 1, 2008

From @rurban

pl-CYG18-case_tol-510.patch
difforig perl-5.10.0/lib/File

2008-06-01 rurban@cpan.org
	* File::Spec->case_tolerant performance improvement on cygwin and Win32.
	Esp. noticable in Module::Build. 

diff -u  perl-5.10.0/lib/File/Spec.pm.orig
--- perl-5.10.0/lib/File/Spec.pm.orig	2007-12-18 11:47:07.000000000 +0100
+++ perl-5.10.0/lib/File/Spec.pm	2008-06-01 14:02:07.687500000 +0200
@@ -3,7 +3,7 @@
 use strict;
 use vars qw(@ISA $VERSION);
 
-$VERSION = '3.2501';
+$VERSION = '3.2502';
 $VERSION = eval $VERSION;
 
 my %module = (MacOS   => 'Mac',
diff -u  perl-5.10.0/lib/File/Spec/Cygwin.pm.orig
--- perl-5.10.0/lib/File/Spec/Cygwin.pm.orig	2007-12-18 11:47:07.000000000 +0100
+++ perl-5.10.0/lib/File/Spec/Cygwin.pm	2008-06-01 14:02:16.671875000 +0200
@@ -4,7 +4,7 @@
 use vars qw(@ISA $VERSION);
 require File::Spec::Unix;
 
-$VERSION = '3.2501';
+$VERSION = '3.2502';
 
 @ISA = qw(File::Spec::Unix);
 
@@ -104,16 +104,23 @@
 Override Unix. Cygwin case-tolerance depends on managed mount settings and
 as with MsWin32 on GetVolumeInformation() $ouFsFlags == FS_CASE_SENSITIVE,
 indicating the case significance when comparing file specifications.
+Since XP FS_CASE_SENSITIVE is effectively disabled for the NT subsubsystem. (TODO)
+See http://cygwin.com/ml/cygwin/2007-07/msg00891.html
+Accepts on optional drive-mount argument.
 Default: 1
 
 =cut
 
+my %tmp_case_tolerant;
 sub case_tolerant () {
   if ($^O ne 'cygwin') {
     return 1;
   }
   my $drive = shift;
+  $drive = shift if $drive =~ /^File::Spec/;
+  my $windrive;
   if (! $drive) {
+      $windrive = 'C:';
       my @flags = split(/,/, Cygwin::mount_flags('/cygwin'));
       my $prefix = pop(@flags);
       if (! $prefix || $prefix eq 'cygdrive') {
@@ -123,18 +130,19 @@
       } else {
           $drive = "$prefix/c";
       }
+  } else {
+      $windrive = Cygwin::posix_to_win_path($drive);
   }
+  return $tmp_case_tolerant{$drive} if exists $tmp_case_tolerant{$drive};
   my $mntopts = Cygwin::mount_flags($drive);
   if ($mntopts and ($mntopts =~ /,managed/)) {
+    $tmp_case_tolerant{$drive} = 0;
     return 0;
   }
-  eval { require Win32API::File; } or return 1;
-  my $osFsType = "\0"x256;
-  my $osVolName = "\0"x256;
-  my $ouFsFlags = 0;
-  Win32API::File::GetVolumeInformation($drive, $osVolName, 256, [], [], $ouFsFlags, $osFsType, 256 );
-  if ($ouFsFlags & Win32API::File::FS_CASE_SENSITIVE()) { return 0; }
-  else { return 1; }
+  require File::Spec::Win32;
+  $windrive =~ s/\\$//;
+  $tmp_case_tolerant{$drive} = File::Spec::Win32::case_tolerant($windrive);
+  return $tmp_case_tolerant{$drive};
 }
 
 =back
diff -u  perl-5.10.0/lib/File/Spec/Win32.pm.orig
--- perl-5.10.0/lib/File/Spec/Win32.pm.orig	2007-12-18 11:47:07.000000000 +0100
+++ perl-5.10.0/lib/File/Spec/Win32.pm	2008-06-01 14:02:25.312500000 +0200
@@ -5,7 +5,7 @@
 use vars qw(@ISA $VERSION);
 require File::Spec::Unix;
 
-$VERSION = '3.2501';
+$VERSION = '3.2502';
 
 @ISA = qw(File::Spec::Unix);
 
@@ -83,13 +83,20 @@
 indicating the case significance when comparing file specifications.
 Since XP FS_CASE_SENSITIVE is effectively disabled for the NT subsubsystem.
 See http://cygwin.com/ml/cygwin/2007-07/msg00891.html
+Accepts on optional drive-letter argument.
 Default: 1
 
 =cut
 
 sub case_tolerant () {
+  my @ver = Win32::GetOSVersion();
+  # From XP on this is disabled.
+  if ($ver[4] >= 2 and $ver[1] >= 5 and $ver[2] >= 1) { return 1; }
+  if ($ver[4] < 2) { return 1; } # Win32s,95,ME are always case_tolerant.
   eval { require Win32API::File; } or return 1;
-  my $drive = shift || "C:";
+  my $drive = shift || "C:";Accepts on optional drive-letter argument.
+
+  $drive = shift if $drive =~ /^File::Spec/;
   my $osFsType = "\0"x256;
   my $osVolName = "\0"x256;
   my $ouFsFlags = 0;

@p5pRT
Copy link
Author

p5pRT commented Jul 10, 2010

From @tsee

I tried to apply the newer patch to PathTools, but the changes don't
even compile. Even after fixing the trivial mistake, I see test failures
(on linux)​:

t/Spec.t ................ 1/598 # Test 68 got​: "Undefined subroutine
&Win32​::GetOSVersion called at
/home/tsee/perl/PathTools/trunk/blib/lib/File/Spec/Win32.pm line 93.\n"
(t/Spec.t at line 825)
# Expected​: "" (File​::Spec​::Win32->case_tolerant())
# t/Spec.t line 825 is​: ok $@​, '', $function;
t/Spec.t ................ Failed 1/598 subtests
  (less 126 skipped subtests​: 471 okay)
t/abs_path.t ............ 1/16 stat(dne)​: No such file or directory at
t/abs_path.t line 65
stat(dne/sub_dne)​: No such file or directory at t/abs_path.t line 70
stat(dne)​: No such file or directory at t/abs_path.t line 65
stat(dne/sub_dne)​: No such file or directory at t/abs_path.t line 70

@p5pRT
Copy link
Author

p5pRT commented Jul 10, 2010

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jul 23, 2010

From @tsee

Cf. https://rt.cpan.org/Ticket/Display.html?id=48182

When resolving this, please also note that in the CPAN RT instance.

@toddr toddr added the dist-PathTools issues in the dual-life blead-first PathTools distribution label Jan 31, 2020
@toddr
Copy link
Member

toddr commented Jan 31, 2020

I'm 99% certain this was fixed in efa159b There are bits of this in that so there's no way these patches will ever apply.

@toddr toddr closed this as completed Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dist-PathTools issues in the dual-life blead-first PathTools distribution
Projects
None yet
Development

No branches or pull requests

2 participants