diff options
author | Nicholas Clark <nick@ccl4.org> | 2012-04-08 19:36:49 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2013-05-23 14:32:40 +0200 |
commit | 0caa72038c587cd4257f9deda63f99fc6cd42d7e (patch) | |
tree | 372bd08a770892d7935c5399649f8d72b78e9492 /regen | |
parent | 9c9407cf9dec1e81011bf9d3e4ac40f724af88ef (diff) | |
download | perl-0caa72038c587cd4257f9deda63f99fc6cd42d7e.tar.gz |
In regen/regen_lib.pl, add 'Pod' as a third supported 'language'.
Pod needs a commenting style distinct from C and Perl. (ie the empty string)
Diffstat (limited to 'regen')
-rw-r--r-- | regen/regen_lib.pl | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/regen/regen_lib.pl b/regen/regen_lib.pl index 3abec2ffd7..053f01bf81 100644 --- a/regen/regen_lib.pl +++ b/regen/regen_lib.pl @@ -36,7 +36,8 @@ sub safer_unlink { sub open_new { my ($final_name, $mode, $header) = @_; my $name = $final_name . '-new'; - my $lang = $final_name =~ /\.(?:c|h|tab|act)$/ ? 'C' : 'Perl'; + my $lang = $final_name =~ /\.pod$/ ? 'Pod' : + $final_name =~ /\.(?:c|h|tab|act)$/ ? 'C' : 'Perl'; my $fh = gensym; if (!defined $mode or $mode eq '>') { if (-f $name) { @@ -82,11 +83,13 @@ sub close_and_rename { rename $name, $final_name or die "renaming $name to $final_name: $!"; } +my %lang_opener = (Perl => '# ', Pod => '', C => '/* '); + sub read_only_top { my %args = @_; die "Missing language argument" unless defined $args{lang}; die "Unknown language argument '$args{lang}'" - unless $args{lang} eq 'Perl' or $args{lang} eq 'C'; + unless exists $lang_opener{$args{lang}}; my $style = $args{style} ? " $args{style} " : ' '; my $raw = "-*- buffer-read-only: t -*-\n"; @@ -125,8 +128,9 @@ EOM $raw .= $args{final} if $args{final}; local $Text::Wrap::columns = 78; - my $cooked = $args{lang} eq 'Perl' - ? wrap('# ', '# ', $raw) . "\n" : wrap('/* ', $style, $raw) . " */\n\n"; + my $cooked = $args{lang} eq 'C' + ? wrap('/* ', $style, $raw) . " */\n\n" + : wrap($lang_opener{$args{lang}}, $lang_opener{$args{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}; @@ -152,7 +156,7 @@ sub read_only_bottom_close_and_rename { if (defined $lang && $lang eq 'Perl') { $comment =~ s/^/# /mg; - } else { + } elsif (!defined $lang or $lang ne 'Pod') { $comment =~ s/^/ * /mg; $comment =~ s! \* !/* !; $comment .= " */"; |