diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-05-14 17:08:56 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-05-19 10:18:14 +0100 |
commit | 29c22b52682692a630218342d1997c803a3b487b (patch) | |
tree | 292f5591f4269ba0567791e22c5a87e2f93ba358 /regen/regen_lib.pl | |
parent | fb8ff1db5449e3c679d9193f00ffaa0a15f88fd7 (diff) | |
download | perl-29c22b52682692a630218342d1997c803a3b487b.tar.gz |
Rename safer_open() to open_new(), and eliminate the first parameter.
Update the SHA256s where necessary in the generated files.
Diffstat (limited to 'regen/regen_lib.pl')
-rw-r--r-- | regen/regen_lib.pl | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/regen/regen_lib.pl b/regen/regen_lib.pl index a243ee671d..951c23b431 100644 --- a/regen/regen_lib.pl +++ b/regen/regen_lib.pl @@ -60,19 +60,18 @@ sub rename_if_different { safer_rename_silent($from, $to) or die "renaming $from to $to: $!"; } -# Saf*er*, but not totally safe. And assumes always open for output. -sub safer_open { - my ($name, $final_name) = @_; +# Open a new file. +sub open_new { + my ($final_name) = @_; + my $name = $final_name . '-new'; 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; - if (defined $final_name) { - *{$fh}->{final_name} = $final_name; - *{$fh}->{lang} = ($final_name =~ /\.(?:c|h|tab|act)$/ ? 'C' : 'Perl'); - } + *{$fh}->{final_name} = $final_name; + *{$fh}->{lang} = ($final_name =~ /\.(?:c|h|tab|act)$/ ? 'C' : 'Perl'); binmode $fh; $fh; } |