From f038801aea0ff24cf86511fa6679d7dcb859cd8d Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Sun, 23 Jan 2011 10:07:52 +0000 Subject: 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. --- regen/keywords.pl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'regen/keywords.pl') diff --git a/regen/keywords.pl b/regen/keywords.pl index be87d9ef17..185d433f17 100755 --- a/regen/keywords.pl +++ b/regen/keywords.pl @@ -14,7 +14,7 @@ use strict; require 'regen/regen_lib.pl'; -my $kw = safer_open("keywords.h-new"); +my $kw = safer_open('keywords.h-new', 'keywords.h'); select $kw; print read_only_top(lang => 'C', by => 'regen/keywords.pl', from => 'its data', @@ -34,9 +34,7 @@ while () { print $kw "\n/* ex: set ro: */\n"; -safer_close($kw); - -rename_if_different("keywords.h-new", "keywords.h"); +close_and_rename($kw); ########################################################################### sub tab { -- cgit v1.2.1