summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2019-12-13 11:53:31 +0100
committerRichard Levitte <levitte@openssl.org>2019-12-21 22:53:54 +0100
commitdfb45dc82479929621c43db921ecfcecc08d3b94 (patch)
tree0fd607884ed74b566717744b5a9d715e7f066940 /util
parentccfce835e07210064450a58ce189d0e622a1fccf (diff)
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 <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10621)
Diffstat (limited to 'util')
-rw-r--r--util/perl/OpenSSL/Util/Pod.pm20
1 files changed, 17 insertions, 3 deletions
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 );