summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Maischein <corion@corion.net>2012-02-21 18:59:26 +0100
committerMax Maischein <corion@corion.net>2012-02-21 18:59:26 +0100
commit8d132c8e8666728992a21bfb759cc0613408a653 (patch)
treeae6709c598f235ae75ee86bacadb2db0f37d3234
parent48100be180e1ed747313758d3ed70dd9c8879f3e (diff)
downloadperl-8d132c8e8666728992a21bfb759cc0613408a653.tar.gz
Make corelist-perldelta.pl keep the existing heading
86c08a2ca2546ef08513c65dabf686423cade2f3 changed Porting/corelist-perldelta.pl to be more accepting in section headings when reading in an existing perldelta. caaa1415975f6b8763b186234d77803148a4fd37 changed it to output the correctly pluralized form of "Pragmata". corelist-perldelta.pl used the same data structure for both, input and output. This patch divides up the logic between input and output in two data structures, and keeps the heading of the input file when generating a fresh pod section.
-rwxr-xr-xPorting/corelist-perldelta.pl24
1 files changed, 19 insertions, 5 deletions
diff --git a/Porting/corelist-perldelta.pl b/Porting/corelist-perldelta.pl
index d596d7641b..15b63f1175 100755
--- a/Porting/corelist-perldelta.pl
+++ b/Porting/corelist-perldelta.pl
@@ -9,6 +9,12 @@ use Getopt::Long;
require Algorithm::Diff;
my %sections = (
+ new => qr/New Modules and Pragma(ta)?/,
+ updated => qr/Updated Modules and Pragma(ta)?/,
+ removed => qr/Removed Modules and Pragma(ta)?/,
+);
+
+my %titles = (
new => 'New Modules and Pragmata',
updated => 'Updated Modules and Pragmata',
removed => 'Removed Modules and Pragmata',
@@ -133,9 +139,9 @@ sub do_generate {
my ($old, $new) = @_;
my ($added, $removed, $pragmas, $modules) = corelist_delta($old => $new);
- generate_section($sections{new}, \&added, @{ $added });
- generate_section($sections{updated}, \&updated, @{ $pragmas }, @{ $modules });
- generate_section($sections{removed}, \&removed, @{ $removed });
+ generate_section($titles{new}, \&added, @{ $added });
+ generate_section($titles{updated}, \&updated, @{ $pragmas }, @{ $modules });
+ generate_section($titles{removed}, \&removed, @{ $removed });
}
sub do_check {
@@ -187,7 +193,7 @@ sub do_check {
my $parsed_pod = Pod::Simple::SimpleTree->new->parse_file($input)->root;
splice @{ $parsed_pod }, 0, 2; # we don't care about the document structure,
- # just the nods within it
+ # just the nodes within it
$self->_parse_delta($parsed_pod);
@@ -205,6 +211,14 @@ sub do_check {
map {
my ($t, $s) = @{ $_ };
+
+ # Keep the section title if it has one:
+ if( $s->[0]->[0] eq 'head2' ) {
+ #warn "Keeping section title '$s->[0]->[2]'";
+ $titles{ $t } = $s->[0]->[2]
+ if $s->[0]->[2];
+ };
+
$self->${\"_parse_${t}_section"}($s)
} map {
my $s = $self->_look_for_section($pod => $sections{$_})
@@ -312,7 +326,7 @@ sub do_check {
sub {
my ($el) = @_;
my ($heading) = $el->[0] =~ /^head(\d)$/;
- my $f = $heading && $el->[2] =~ /^\Q$section\E/;
+ my $f = $heading && $el->[2] =~ /^$section/;
$level = $heading if $f && !$level;
return $f;
},