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.
# 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',
# 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',
# Get function prototypes
require 'regen/regen_lib.pl';
}
-#use Fatal qw(open close rename chmod unlink);
use strict;
open DESC, 'regcomp.sym';
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',
# 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;