summaryrefslogtreecommitdiff
path: root/reentr.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 /reentr.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 'reentr.pl')
-rw-r--r--reentr.pl20
1 files changed, 9 insertions, 11 deletions
diff --git a/reentr.pl b/reentr.pl
index aea679df44..be15c40609 100644
--- a/reentr.pl
+++ b/reentr.pl
@@ -41,9 +41,8 @@ my %map = (
# safer_unlink 'reentr.h';
-die "reentr.pl: $!" unless open(H, ">reentr.h-new");
-binmode H;
-select H;
+my $h = safer_open("reentr.h-new");
+select $h;
print <<EOF;
/* -*- buffer-read-only: t -*-
*
@@ -332,7 +331,7 @@ close DATA;
# Prepare to continue writing the reentr.h.
-select H;
+select $h;
{
# Write out all the known prototype signatures.
@@ -788,15 +787,14 @@ typedef struct {
/* ex: set ro: */
EOF
-close(H);
-safer_rename('reentr.h-new', 'reentr.h');
+close($h);
+rename_if_different('reentr.h-new', 'reentr.h');
# Prepare to write the reentr.c.
# safer_unlink 'reentr.c';
-die "reentr.c: $!" unless open(C, ">reentr.c-new");
-binmode C;
-select C;
+my $c = safer_open("reentr.c-new");
+select $c;
print <<EOF;
/* -*- buffer-read-only: t -*-
*
@@ -1091,8 +1089,8 @@ Perl_reentrant_retry(const char *f, ...)
/* ex: set ro: */
EOF
-close(C);
-safer_rename('reentr.c-new', 'reentr.c');
+close($c);
+rename_if_different('reentr.c-new', 'reentr.c');
__DATA__
asctime S |time |const struct tm|B_SB|B_SBI|I_SB|I_SBI