summaryrefslogtreecommitdiff
path: root/regen/regen_lib.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-05-14 17:08:56 +0100
committerNicholas Clark <nick@ccl4.org>2011-05-19 10:18:14 +0100
commit29c22b52682692a630218342d1997c803a3b487b (patch)
tree292f5591f4269ba0567791e22c5a87e2f93ba358 /regen/regen_lib.pl
parentfb8ff1db5449e3c679d9193f00ffaa0a15f88fd7 (diff)
downloadperl-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.pl13
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;
}