Protect the fchdir() and lstat() with ifdefs.
[p5sagit/p5-mst-13.2.git] / opcode.pl
index f897bb9..2f4a7fd 100755 (executable)
--- a/opcode.pl
+++ b/opcode.pl
@@ -1,9 +1,7 @@
 #!/usr/bin/perl
 
-chmod 0666, "opcode.h", "opnames.h";
-unlink "opcode.h", "opnames.h";
-open(OC, ">opcode.h") || die "Can't create opcode.h: $!\n";
-open(ON, ">opnames.h") || die "Can't create opnames.h: $!\n";
+open(OC, ">opcode.h.new") || die "Can't create opcode.h.new: $!\n";
+open(ON, ">opnames.h.new") || die "Can't create opnames.h.new: $!\n";
 select OC;
 
 # Read data.
@@ -256,10 +254,14 @@ if (keys %OP_IS_FILETEST) {
 close OC or die "Error closing opcode.h: $!";
 close ON or die "Error closing opnames.h: $!";
 
-unlink "pp_proto.h";
-unlink "pp.sym";
-open PP, '>pp_proto.h' or die "Error creating pp_proto.h: $!";
-open PPSYM, '>pp.sym' or die "Error creating pp.sym: $!";
+chmod 0600, 'opcode.h';  # required by dosish filesystems
+chmod 0600, 'opnames.h'; # required by dosish filesystems
+
+rename 'opcode.h.new', 'opcode.h' or die "renaming opcode.h: $!\n";
+rename 'opnames.h.new', 'opnames.h' or die "renaming opnames.h: $!\n";
+
+open PP, '>pp_proto.h.new' or die "Error creating pp_proto.h.new: $!";
+open PPSYM, '>pp.sym.new' or die "Error creating pp.sym.new: $!";
 
 print PP <<"END";
 /* !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
@@ -296,6 +298,12 @@ for (@ops) {
 close PP or die "Error closing pp_proto.h: $!";
 close PPSYM or die "Error closing pp.sym: $!";
 
+chmod 0600, 'pp_proto.h'; # required by dosish filesystems
+chmod 0600, 'pp.sym';     # required by dosish filesystems
+
+rename 'pp_proto.h.new', 'pp_proto.h' or die "rename pp_proto.h: $!\n";
+rename 'pp.sym.new', 'pp.sym' or die "rename pp.sym: $!\n";
+
 ###########################################################################
 sub tab {
     local($l, $t) = @_;