summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-01-23 09:39:21 +0000
committerNicholas Clark <nick@ccl4.org>2011-01-23 09:39:21 +0000
commit396ce246b9969d83ec11500def9604b58fb4c726 (patch)
treef734958364f9fa7ee848980d1455b4b2269d8056
parentbb5cff7d658d1934f2c79f668c3b916bd9abbcbb (diff)
downloadperl-396ce246b9969d83ec11500def9604b58fb4c726.tar.gz
In regen_lib.pl, when opening, first unlink a previous file of that name.
Previously regcomp.pl had an explicit unlink for the file it creates, but none of the other regen/*.pl scripts did. Also, remove commented out code relating to unlink.
-rw-r--r--regen/reentr.pl2
-rw-r--r--regen/regcomp.pl3
-rw-r--r--regen/regen_lib.pl3
3 files changed, 3 insertions, 5 deletions
diff --git a/regen/reentr.pl b/regen/reentr.pl
index 3586bc1348..963dd96e00 100644
--- a/regen/reentr.pl
+++ b/regen/reentr.pl
@@ -51,7 +51,6 @@ my %map = (
# Example #3: S_CBI means type func_r(const char*, char*, int)
-# safer_unlink 'reentr.h';
my $h = safer_open("reentr.h-new");
select $h;
print read_only_top(lang => 'C', by => 'regen/reentr.pl',
@@ -792,7 +791,6 @@ rename_if_different('reentr.h-new', 'reentr.h');
# Prepare to write the reentr.c.
-# safer_unlink 'reentr.c';
my $c = safer_open("reentr.c-new");
select $c;
my $top = read_only_top(lang => 'C', by => 'regen/reentr.pl',
diff --git a/regen/regcomp.pl b/regen/regcomp.pl
index 913dda59f6..98a3889ede 100644
--- a/regen/regcomp.pl
+++ b/regen/regcomp.pl
@@ -17,7 +17,6 @@ BEGIN {
# Get function prototypes
require 'regen/regen_lib.pl';
}
-#use Fatal qw(open close rename chmod unlink);
use strict;
open DESC, 'regcomp.sym';
@@ -129,8 +128,6 @@ EOP
my $tmp_h = 'regnodes.h-new';
-unlink $tmp_h if -f $tmp_h;
-
my $out = safer_open($tmp_h);
print $out read_only_top(lang => 'C', by => 'regen/regcomp.pl',
diff --git a/regen/regen_lib.pl b/regen/regen_lib.pl
index b4d9f86c1e..880a9754d5 100644
--- a/regen/regen_lib.pl
+++ b/regen/regen_lib.pl
@@ -63,6 +63,9 @@ sub rename_if_different {
# Saf*er*, but not totally safe. And assumes always open for output.
sub safer_open {
my $name = shift;
+ if (-f $name) {
+ unlink $name or die "$name exists but can't unlink: $!";
+ }
my $fh = gensym;
open $fh, ">$name" or die "Can't create $name: $!";
*{$fh}->{name} = $name;