summaryrefslogtreecommitdiff
path: root/regen/regen_lib.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-03-22 15:27:56 +0000
committerNicholas Clark <nick@ccl4.org>2011-03-28 10:21:46 +0100
commit88f1af6092edef582e05fbebaf7780bd7cde0504 (patch)
tree7616727789b7c74cf80fa10aa36aef1bb4180f1c /regen/regen_lib.pl
parent12cf8ac4a401c27a3cb03ab674e3d31bbd913884 (diff)
downloadperl-88f1af6092edef582e05fbebaf7780bd7cde0504.tar.gz
Extract read_only_bottom() from read_only_bottom_close_and_rename()'s code.
Diffstat (limited to 'regen/regen_lib.pl')
-rw-r--r--regen/regen_lib.pl24
1 files changed, 16 insertions, 8 deletions
diff --git a/regen/regen_lib.pl b/regen/regen_lib.pl
index 85defb9ab6..a243ee671d 100644
--- a/regen/regen_lib.pl
+++ b/regen/regen_lib.pl
@@ -132,12 +132,9 @@ EOM
return $cooked;
}
-sub read_only_bottom_close_and_rename {
- my ($fh, $sources) = @_;
- my $name = *{$fh}->{name};
- my $lang = *{$fh}->{lang};
- die "No final name specified at open time for $name"
- unless *{$fh}->{final_name};
+sub read_only_bottom {
+ my ($sources, $lang) = @_;
+
my $comment;
if ($sources) {
$comment = "Generated from:\n";
@@ -148,14 +145,25 @@ sub read_only_bottom_close_and_rename {
}
$comment .= "ex: set ro:";
- if ($lang eq 'Perl') {
+ if (defined $lang && $lang eq 'Perl') {
$comment =~ s/^/# /mg;
} else {
$comment =~ s/^/ * /mg;
$comment =~ s! \* !/* !;
$comment .= " */";
}
- print $fh "\n$comment\n";
+ return "$comment\n";
+}
+
+sub read_only_bottom_close_and_rename {
+ my ($fh, $sources) = @_;
+ my $name = *{$fh}->{name};
+ my $lang = *{$fh}->{lang};
+ die "No final name specified at open time for $name"
+ unless *{$fh}->{final_name};
+
+ print $fh "\n", read_only_bottom($sources, $lang);
+
safer_close($fh);
rename_if_different($name, *{$fh}->{final_name});
}