diff options
author | Nicholas Clark <nick@ccl4.org> | 2013-07-03 15:51:16 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2013-07-07 12:42:02 +0200 |
commit | 779d6b4a99e81aab11db9c66ab07286850b2d575 (patch) | |
tree | 5f9be79ae5d0c853402bfa3add9878883c5b2a57 /regen | |
parent | f4e064af84aaaa725dac7cde712c82576f87c83f (diff) | |
download | perl-779d6b4a99e81aab11db9c66ab07286850b2d575.tar.gz |
Refactor the Text::Wrap::wrap() logic in regen/regen_lib.pl
Provide a local subroutine wrap(). Pass columns as its first parameter and
set $Text::Wrap::columns, as all uses of Text::Wrap::wrap() were setting
this variable.
Diffstat (limited to 'regen')
-rw-r--r-- | regen/regen_lib.pl | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/regen/regen_lib.pl b/regen/regen_lib.pl index 4753fad2bf..f0bbe936d0 100644 --- a/regen/regen_lib.pl +++ b/regen/regen_lib.pl @@ -3,7 +3,7 @@ use strict; use vars qw($Needs_Write $Verbose @Changed $TAP); use File::Compare; use Symbol; -use Text::Wrap; +use Text::Wrap(); # Common functions needed by the regen scripts @@ -98,8 +98,7 @@ sub read_only_top { } if ($args{copyright}) { local $" = ', '; - local $Text::Wrap::columns = 75; - $raw .= wrap(' ', ' ', <<"EOM") . "\n"; + $raw .= wrap(75, ' ', ' ', <<"EOM") . "\n"; Copyright (C) @{$args{copyright}} by\0Larry\0Wall\0and\0others @@ -126,10 +125,9 @@ EOM $raw .= "Any changes made here will be lost!\n"; $raw .= $args{final} if $args{final}; - local $Text::Wrap::columns = 78; my $cooked = $lang eq 'C' - ? wrap('/* ', $style, $raw) . " */\n\n" - : wrap($lang_opener{$lang}, $lang_opener{$lang}, $raw) . "\n"; + ? wrap(78, '/* ', $style, $raw) . " */\n\n" + : wrap(78, $lang_opener{$lang}, $lang_opener{$lang}, $raw) . "\n"; $cooked =~ tr/\0/ /; # Don't break Larry's name etc $cooked =~ s/ +$//mg; # Remove all trailing spaces $cooked =~ s! \*/\n!$args{quote}!s if $args{quote}; @@ -183,4 +181,9 @@ sub digest { return Digest::SHA::sha256_hex($raw); }; +sub wrap { + local $Text::Wrap::columns = shift; + Text::Wrap::wrap(@_); +} + 1; |