From: Richard Levitte Date: Fri, 13 Dec 2019 10:53:31 +0000 (+0100) Subject: OpenSSL::Util::extract_pod_info(): Read the POD one paragraph at a time X-Git-Tag: openssl-3.0.0-alpha1~781 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=dfb45dc82479929621c43db921ecfcecc08d3b94;p=oweals%2Fopenssl.git OpenSSL::Util::extract_pod_info(): Read the POD one paragraph at a time POD files should always be treated this way Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/10621) --- diff --git a/util/perl/OpenSSL/Util/Pod.pm b/util/perl/OpenSSL/Util/Pod.pm index b34161a04b..9f63bf3f96 100644 --- a/util/perl/OpenSSL/Util/Pod.pm +++ b/util/perl/OpenSSL/Util/Pod.pm @@ -115,8 +115,18 @@ sub extract_pod_info { } my %podinfo = ( section => $defaults{section}); - foreach (split /^/, $contents) { - s|\R$||; + + # Regexp to split a text into paragraphs found at + # https://www.perlmonks.org/?node_id=584367 + # Most of all, \G (continue at last match end) and /g (anchor + # this match for \G) are significant + foreach (map { /\G((?:(?!\n\n).)*\n+|.+\z)/sg } $contents) { + # Remove as many line endings as possible from the end of the paragraph + while (s|\R$||) {} + + print STDERR "DEBUG: Paragraph:\n$_\n" + if $defaults{debug}; + # Stop reading when we have reached past the NAME section. last if (m|^=head1| && defined $podinfo{lastsect} @@ -148,7 +158,7 @@ sub extract_pod_info { print STDERR "DEBUG: Done reading $filename\n" if $defaults{debug}; } - $podinfo{lastsecttext} =~ s| - .*$||; + $podinfo{lastsecttext} =~ s|\s+-\s+.*$||s; my @names = map { s/^\s+//g; # Trim prefix blanks @@ -157,6 +167,10 @@ sub extract_pod_info { $_ } split(m|,|, $podinfo{lastsecttext}); + print STDERR + "DEBUG: Collected names are: ", join(', ', @names), "\n" + if $defaults{debug}; + return ( section => $podinfo{section}, names => [ @names ], contents => $contents );