First patch from:
authorJan Dubois <jand@activestate.com>
Fri, 8 Dec 2006 19:07:06 +0000 (11:07 -0800)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Mon, 11 Dec 2006 13:21:28 +0000 (13:21 +0000)
Subject: [PATCH] Move Win32::* functions from win32/win32.c to ext/Win32/Win32.xs
Message-ID: <lc9kn2tb0p5sdd4q69rbc7067r4imar59r@4ax.com>

p4raw-id: //depot/perl@29509

ext/SDBM_File/Makefile.PL
lib/Cwd.pm
lib/ExtUtils/MM.pm
lib/File/CheckTree.t
lib/File/Copy.pm
t/op/fork.t
win32/FindExt.pm
win32/config_sh.PL
win32/ext/Win32API/File/t/file.t

index ba4214c..1267efc 100644 (file)
@@ -25,7 +25,7 @@ WriteMakefile(
              );
 
 sub MY::postamble {
-  if ($^O =~ /MSWin32/ && Win32::IsWin95()) {
+  if ($^O =~ /MSWin32/ && !defined($ENV{SYSTEMROOT})) {
        if ($Config{'make'} =~ /dmake/i) {
            # dmake-specific
            return <<'EOT';
index 70aa811..cfc0294 100644 (file)
@@ -660,7 +660,12 @@ sub _os2_cwd {
 }
 
 sub _win32_cwd {
-    $ENV{'PWD'} = Win32::GetCwd();
+    if (defined &DynaLoader::boot_DynaLoader) {
+       $ENV{'PWD'} = Win32::GetCwd();
+    }
+    else { # miniperl
+       chomp($ENV{'PWD'} = `cd`);
+    }
     $ENV{'PWD'} =~ s:\\:/:g ;
     return $ENV{'PWD'};
 }
index e592bb8..6fa2354 100644 (file)
@@ -48,7 +48,13 @@ $Is{VMS}    = $^O eq 'VMS';
 $Is{OS2}    = $^O eq 'os2';
 $Is{MacOS}  = $^O eq 'MacOS';
 if( $^O eq 'MSWin32' ) {
-    Win32::IsWin95() ? $Is{Win95} = 1 : $Is{Win32} = 1;
+    if (defined &DynaLoader::boot_DynaLoader) {
+       Win32::IsWin95() ? $Is{Win95} = 1 : $Is{Win32} = 1;
+    }
+    else {
+       # Can't use Win32::* with miniperl
+       !(defined $ENV{SYSTEMROOT}) ? $Is{Win95} = 1 : $Is{Win32} = 1;
+    }
 }
 $Is{UWIN}   = $^O =~ /^uwin(-nt)?$/;
 $Is{Cygwin} = $^O eq 'cygwin';
index 0257f4e..60f1a42 100755 (executable)
@@ -11,6 +11,11 @@ BEGIN { plan tests => 6 }
 
 use strict;
 
+# Cwd::cwd does an implicit "require Win32", but
+# the ../lib directory in @INC will no longer work once
+# we chdir() out of the "t" directory.
+use Win32;
+
 use File::CheckTree;
 use File::Spec;          # used to get absolute paths
 
index ea56dc6..d87c191 100644 (file)
@@ -258,7 +258,8 @@ unless (defined &syscopy) {
            # preserve MPE file attributes.
            return system('/bin/cp', '-f', $_[0], $_[1]) == 0;
        };
-    } elsif ($^O eq 'MSWin32') {
+    } elsif ($^O eq 'MSWin32' && defined &DynaLoader::boot_DynaLoader) {
+       # Win32::CopyFile() fill only work if we can load Win32.xs
        *syscopy = sub {
            return 0 unless @_ == 2;
            return Win32::CopyFile(@_, 1);
index 2d6232e..7318449 100755 (executable)
@@ -245,6 +245,7 @@ EXPECT
 ########
 $| = 1;
 use Cwd;
+my $cwd = cwd(); # Make sure we load Win32.pm while "../lib" still works.
 $\ = "\n";
 my $dir;
 if (fork) {
index b73d777..690be6d 100644 (file)
@@ -14,9 +14,10 @@ my $ext;
 my %static;
 
 sub getcwd {
-    $ENV{'PWD'} = Win32::GetCwd();
-    $ENV{'PWD'} =~ s:\\:/:g ;
-    return $ENV{'PWD'};
+    $_ = `cd`;
+    chomp;
+    s:\\:/:g ;
+    return $ENV{'PWD'} = $_;
 }
 
 sub set_static_extensions
index 6aa2a32..b4af906 100644 (file)
@@ -73,7 +73,8 @@ $opt{INST_VER} =~ s|~VERSION~|$opt{VERSION}|g;
 $opt{'version_patchlevel_string'} = "version $opt{PERL_VERSION} subversion $opt{PERL_SUBVERSION}";
 $opt{'version_patchlevel_string'} .= " patchlevel $opt{PERL_PATCHLEVEL}" if exists $opt{PERL_PATCHLEVEL};
 
-$opt{'osvers'} = join '.', (Win32::GetOSVersion())[1,2];
+#$opt{'osvers'} = join '.', (Win32::GetOSVersion())[1,2];
+$opt{'osvers'} = "4.0";
 
 if (exists $opt{cc}) {
     # cl and bcc32 version detection borrowed from Test::Smoke's configsmoke.pl
@@ -99,7 +100,7 @@ $opt{libpth} = mungepath($opt{libpth}) if exists $opt{libpth};
 $opt{incpath} = mungepath($opt{incpath}) if exists $opt{incpath};
 
 # some functions are not available on Win9x
-if (defined(&Win32::IsWin95) && Win32::IsWin95()) {
+unless (defined $ENV{SYSTEMROOT}) { # SystemRoot has been introduced by WinNT
     $opt{d_flock} = 'undef';
     $opt{d_link} = 'undef';
 }
index 739b773..f7f16c5 100644 (file)
@@ -6,6 +6,12 @@
 
 BEGIN { $|= 1; print "1..267\n"; }
 END {print "not ok 1\n" unless $loaded;}
+
+# Win32API::File does an implicit "require Win32", but
+# the ../lib directory in @INC will no longer work once
+# we chdir() into the TEMP directory.
+use Win32;
+
 use Win32API::File qw(:ALL);
 $loaded = 1;
 print "ok 1\n";