Skip to content

Commit c79069a

Browse files
committed
handle the 'Deprecations' section
1 parent cf7e7a9 commit c79069a

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

Porting/merge-deltas.pl

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,45 @@ ( $tree, $directive, $pos = 0 )
9595
splice @$master, next_header_pos( $master, 1, $master_pos ),
9696
0, $delta->@[ $delta_pos + 1 .. $end_pos ];
9797
},
98+
99+
# this one is very specific: 'Module removals' is treated separately
100+
deprecations => sub ( $master, $title, $delta ) {
101+
102+
# find the section in the delta and master
103+
my ( $master_pos, $delta_pos ) =
104+
map header_pos( $_, 1, $title ),
105+
$master, $delta;
106+
107+
# loop over the =head2 in the section
108+
while ( $delta_pos = next_header_pos( $delta, 2, $delta_pos ) ) {
109+
my $section_title = $delta->[$delta_pos][2];
110+
if ( $section_title eq 'Module removals' ) {
111+
$master_pos = # find the same =head2 in the master
112+
header_pos( $master, 2, $section_title, $master_pos );
113+
114+
# find the =over in both
115+
my ( $master_list_pos, $delta_list_pos ) = (
116+
next_directive_pos( $master, 'over-text', $master_pos ),
117+
next_directive_pos( $delta, 'over-text', $delta_pos )
118+
);
119+
120+
# inject the list from delta into the master
121+
push $master->[$master_list_pos]->@*,
122+
splice $delta->[$delta_list_pos]->@*, 2;
123+
}
124+
else {
125+
# find where the =head2 ends
126+
my $end_pos = next_header_pos( $delta, 2, $delta_pos )
127+
// next_header_pos( $delta, 1, $delta_pos );
128+
129+
# inject it at the end of the section
130+
$master_pos = next_header_pos( $master, 1, $master_pos );
131+
splice @$master, $master_pos, 0,
132+
$delta->@[ $delta_pos .. $end_pos - 1 ];
133+
}
134+
}
135+
continue { ++$delta_pos } # avoid an infinite loop
136+
},
98137
);
99138

100139
my %ACTION_FOR = (
@@ -104,7 +143,7 @@ ( $tree, $directive, $pos = 0 )
104143
'Core Enhancements' => 'head2',
105144
'Security' => 'head2',
106145
'Incompatible Changes' => 'head2',
107-
'Deprecations' => '...',
146+
'Deprecations' => 'deprecations',
108147
'Performance Enhancements' => 'item',
109148
'Modules and Pragmata' => 'skip',
110149
'Documentation' => 'skip',
@@ -228,7 +267,6 @@ ($file)
228267
{
229268
die "Unexpected section '=head1 $title' in $template_file\n"
230269
unless exists $ACTION_FOR{$title};
231-
die "No handler for '$title'\n" if $ACTION_FOR{$title} eq '...';
232270
next if $ACTION_FOR{$title} eq 'skip';
233271
$handler{ $ACTION_FOR{$title} }->( $master, $title, $delta );
234272
}

0 commit comments

Comments
 (0)