This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Change 27330 failed to decontaminate SvCUR/GvFLAGS when upgrading an
[perl5.git] / pod / splitpod
index 889dfa2..d5963bf 100755 (executable)
@@ -5,30 +5,43 @@ use Pod::Functions;
 
 local $/ = '';
 
+$level = 0;
+
 $cur = '';
 while (<>) {
 
     next unless /^=(?!cut)/ .. /^=cut/;
 
-    if (s/=item (\S+)/$1/) {
-       #$cur = "POSIX::" . $1;
-       $cur = $1;
+    ++$level if /^=over/;
+    --$level if /^=back/;
+
+    # Ignore items that are nested within other items, e.g. don't split on the
+    # items nested within the pack() and sprintf() items in perlfunc.pod.
+    if (/=item (\S+)/ and $level == 1) {
+       my $item = $1;
+       s/=item //; 
+       $next{$cur} = $item;
+       $cur = $item;
        $syn{$cur} .= $_;
        next;
     } else { 
-       #s,L</,L<POSIX/,g;
        s,L</,L<perlfunc/,g;
-       push @{$pod{$cur} ||= []}, $_ if $cur;
+       push @{$pod{$cur}}, $_ if $cur;
     }
 } 
 
 for $f ( keys %syn ) {
-    $type = $Type{$f} || next;
+    next unless $Type{$f};
     $flavor = $Flavor{$f};
     $orig = $f;
     ($name = $f) =~ s/\W//g;
+
+    # deal with several functions sharing a description
+    $func = $orig;
+    $func = $next{$func} until $pod{$func};
+    my $body = join "", @{$pod{$func}};
+
     # deal with unbalanced =over and =back cause by the split
-    my $body = $pod{$orig};
     my $has_over = $body =~ /^=over/;
     my $has_back = $body =~ /^=back/;
     $body =~ s/^=over\s*//m if $has_over and !$has_back;