summaryrefslogtreecommitdiff
path: root/keywords.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-03-15 18:37:34 +0000
committerNicholas Clark <nick@ccl4.org>2008-03-15 18:37:34 +0000
commit424a4936e3f61f4e8db394f496a116e698cede85 (patch)
treee19475f64cd932d850b6975251ee284844aaf0d8 /keywords.pl
parentb6b9a09997c80269af874aff41936e014ed728f7 (diff)
downloadperl-424a4936e3f61f4e8db394f496a116e698cede85.tar.gz
Rename safer_rename() to rename_if_different(), to accurately describe
what it does. Use File::Compare rather than Digest::MD5, as the files are small enough to simply read in. (File::Compare dates from 5.004) Remove safer_rename_always(), which isn't used. DRY by replacing the cargo-culted "open or die" with a new function safer_open(), which uses Gensym (5.002) to create an anonymous file handle, and opens and binmodes the file, or dies. This necessitates replacing bareword file handles with lexicals in all the callers. Correct the names of files in close or die constructions. p4raw-id: //depot/perl@33538
Diffstat (limited to 'keywords.pl')
-rwxr-xr-xkeywords.pl11
1 files changed, 5 insertions, 6 deletions
diff --git a/keywords.pl b/keywords.pl
index 8e7a67804b..36035705c4 100755
--- a/keywords.pl
+++ b/keywords.pl
@@ -3,9 +3,8 @@ use strict;
require 'regen_lib.pl';
-open(KW, ">keywords.h-new") || die "Can't create keywords.h: $!\n";
-binmode KW;
-select KW;
+my $kw = safer_open("keywords.h-new");
+select $kw;
print <<EOM;
/* -*- buffer-read-only: t -*-
@@ -35,11 +34,11 @@ while (<DATA>) {
print &tab(5, "#define KEY_$keyword"), $keynum++, "\n";
}
-print KW "\n/* ex: set ro: */\n";
+print $kw "\n/* ex: set ro: */\n";
-close KW or die "Error closing keywords.h: $!";
+close $kw or die "Error closing keywords.h-new: $!";
-safer_rename("keywords.h-new", "keywords.h");
+rename_if_different("keywords.h-new", "keywords.h");
###########################################################################
sub tab {