From cf2f24a416dd5be7d3f4153bf173ec2a57eaed43 Mon Sep 17 00:00:00 2001 From: Jan Dubois Date: Fri, 8 Dec 2006 11:07:06 -0800 Subject: [PATCH] First patch from: Subject: [PATCH] Move Win32::* functions from win32/win32.c to ext/Win32/Win32.xs Message-ID: p4raw-id: //depot/perl@29509 --- ext/SDBM_File/Makefile.PL | 2 +- lib/Cwd.pm | 7 ++++++- lib/ExtUtils/MM.pm | 8 +++++++- lib/File/CheckTree.t | 5 +++++ lib/File/Copy.pm | 3 ++- t/op/fork.t | 1 + win32/FindExt.pm | 7 ++++--- win32/config_sh.PL | 5 +++-- win32/ext/Win32API/File/t/file.t | 6 ++++++ 9 files changed, 35 insertions(+), 9 deletions(-) diff --git a/ext/SDBM_File/Makefile.PL b/ext/SDBM_File/Makefile.PL index ba4214c..1267efc 100644 --- a/ext/SDBM_File/Makefile.PL +++ b/ext/SDBM_File/Makefile.PL @@ -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'; diff --git a/lib/Cwd.pm b/lib/Cwd.pm index 70aa811..cfc0294 100644 --- a/lib/Cwd.pm +++ b/lib/Cwd.pm @@ -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'}; } diff --git a/lib/ExtUtils/MM.pm b/lib/ExtUtils/MM.pm index e592bb8..6fa2354 100644 --- a/lib/ExtUtils/MM.pm +++ b/lib/ExtUtils/MM.pm @@ -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'; diff --git a/lib/File/CheckTree.t b/lib/File/CheckTree.t index 0257f4e..60f1a42 100755 --- a/lib/File/CheckTree.t +++ b/lib/File/CheckTree.t @@ -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 diff --git a/lib/File/Copy.pm b/lib/File/Copy.pm index ea56dc6..d87c191 100644 --- a/lib/File/Copy.pm +++ b/lib/File/Copy.pm @@ -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); diff --git a/t/op/fork.t b/t/op/fork.t index 2d6232e..7318449 100755 --- a/t/op/fork.t +++ b/t/op/fork.t @@ -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) { diff --git a/win32/FindExt.pm b/win32/FindExt.pm index b73d777..690be6d 100644 --- a/win32/FindExt.pm +++ b/win32/FindExt.pm @@ -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 diff --git a/win32/config_sh.PL b/win32/config_sh.PL index 6aa2a32..b4af906 100644 --- a/win32/config_sh.PL +++ b/win32/config_sh.PL @@ -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'; } diff --git a/win32/ext/Win32API/File/t/file.t b/win32/ext/Win32API/File/t/file.t index 739b773..f7f16c5 100644 --- a/win32/ext/Win32API/File/t/file.t +++ b/win32/ext/Win32API/File/t/file.t @@ -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"; -- 2.7.4