diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-01-23 10:07:52 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-01-23 10:07:52 +0000 |
commit | f038801aea0ff24cf86511fa6679d7dcb859cd8d (patch) | |
tree | 8f46ea92b16a9121bab4ee0da59cdf219e43a254 /regen/reentr.pl | |
parent | 396ce246b9969d83ec11500def9604b58fb4c726 (diff) | |
download | perl-f038801aea0ff24cf86511fa6679d7dcb859cd8d.tar.gz |
In regen/*.pl, refactor the repeated code for close and rename if different.
Pass the final file name as an optional second argument of safer_open() and
store it with the file handle. Add a function close_and_rename() which closes
the file handle, then retrieves the final name, and renames the temporary file
if the two differ.
Diffstat (limited to 'regen/reentr.pl')
-rw-r--r-- | regen/reentr.pl | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/regen/reentr.pl b/regen/reentr.pl index 963dd96e00..0045b1896d 100644 --- a/regen/reentr.pl +++ b/regen/reentr.pl @@ -51,7 +51,7 @@ my %map = ( # Example #3: S_CBI means type func_r(const char*, char*, int) -my $h = safer_open("reentr.h-new"); +my $h = safer_open('reentr.h-new', 'reentr.h'); select $h; print read_only_top(lang => 'C', by => 'regen/reentr.pl', from => 'data in regen/reentr.pl', @@ -786,12 +786,11 @@ typedef struct { /* ex: set ro: */ EOF -safer_close($h); -rename_if_different('reentr.h-new', 'reentr.h'); +close_and_rename($h); # Prepare to write the reentr.c. -my $c = safer_open("reentr.c-new"); +my $c = safer_open('reentr.c-new', 'reentr.c'); select $c; my $top = read_only_top(lang => 'C', by => 'regen/reentr.pl', from => 'data in regen/reentr.pl', @@ -1082,8 +1081,7 @@ Perl_reentrant_retry(const char *f, ...) /* ex: set ro: */ EOF -safer_close($c); -rename_if_different('reentr.c-new', 'reentr.c'); +close_and_rename($c); __DATA__ asctime S |time |const struct tm|B_SB|B_SBI|I_SB|I_SBI |