This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Windows compatibility fixes for running expand-macro.pl:
authorMax Maischein <corion@corion.net>
Sat, 11 Dec 2010 14:21:11 +0000 (15:21 +0100)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 11 Dec 2010 22:09:44 +0000 (14:09 -0800)
a) Close filehandle to try.i so we can erase it
b) The build process wants to be run from bleadperl/Win32

Porting/expand-macro.pl

index 772bff6..6b33f74 100755 (executable)
@@ -51,6 +51,13 @@ while (<>) {
 }
 die "$macro not found\n" unless defined $header;
 
+if ($^O =~ /MSWin(32|64)/) {
+    # The Win32 (and Win64) build process expects to be run from
+    # bleadperl/Win32
+    chdir "Win32"
+       or die "Couldn't chdir to win32: $!";
+};
+
 open my $out, '>', $trysource or die "Can't open $trysource: $!";
 
 my $sentinel = "$macro expands to";
@@ -107,15 +114,17 @@ if ($opt{f} || $opt{F}) {
     $out_fh = \*STDOUT;
 }
 
-open my $fh, '<', $tryout or die "Can't open $tryout: $!";
+{
+    open my $fh, '<', $tryout or die "Can't open $tryout: $!";
 
-while (<$fh>) {
-    print $out_fh $_ if /$sentinel/o .. 1;
-}
+    while (<$fh>) {
+       print $out_fh $_ if /$sentinel/o .. 1;
+    }
+};
 
 unless ($opt{k}) {
     foreach($trysource, $tryout) {
-       die "Can't unlink $_" unless unlink $_;
+       die "Can't unlink $_: $!" unless unlink $_;
     }
 }