summaryrefslogtreecommitdiff
path: root/util/perl
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2019-12-12 19:49:49 +0100
committerRichard Levitte <levitte@openssl.org>2019-12-21 22:53:54 +0100
commit5423cabb50edf1ad4c5bba1cbaab8d5fd0826fb7 (patch)
tree44c6cd27412748dacaf8d6367fe4d0e6d1b1a8e0 /util/perl
parentb0d3442efc10b635863b915c2d014345f6e5a219 (diff)
downloadopenssl-new-5423cabb50edf1ad4c5bba1cbaab8d5fd0826fb7.tar.gz
perl: OpenSSL::Util::Pod::extract_pod_info() now saves the file contents
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10621)
Diffstat (limited to 'util/perl')
-rw-r--r--util/perl/OpenSSL/Util/Pod.pm24
1 files changed, 20 insertions, 4 deletions
diff --git a/util/perl/OpenSSL/Util/Pod.pm b/util/perl/OpenSSL/Util/Pod.pm
index 16622c933c..b34161a04b 100644
--- a/util/perl/OpenSSL/Util/Pod.pm
+++ b/util/perl/OpenSSL/Util/Pod.pm
@@ -82,6 +82,10 @@ was given as input.
All the names extracted from the NAME section.
+=item B<contents =E<gt> "...">
+
+The whole contents of the .pod file.
+
=back
=back
@@ -94,17 +98,24 @@ sub extract_pod_info {
my %defaults = ( debug => 0, section => 0, %$defaults_ref );
my $fh = undef;
my $filename = undef;
+ my $contents;
# If not a file handle, then it's assume to be a file path (a string)
- unless (ref $input eq "GLOB") {
+ if (ref $input eq "") {
$filename = $input;
open $fh, $input or die "Trying to read $filename: $!\n";
print STDERR "DEBUG: Reading $input\n" if $defaults{debug};
$input = $fh;
}
+ if (ref $input eq "GLOB") {
+ local $/ = undef;
+ $contents = <$input>;
+ } else {
+ die "Unknown input type";
+ }
my %podinfo = ( section => $defaults{section});
- while(<$input>) {
+ foreach (split /^/, $contents) {
s|\R$||;
# Stop reading when we have reached past the NAME section.
last if (m|^=head1|
@@ -140,10 +151,15 @@ sub extract_pod_info {
$podinfo{lastsecttext} =~ s| - .*$||;
my @names =
- map { s|\s+||g; s|/|-|g; $_ }
+ map { s/^\s+//g; # Trim prefix blanks
+ s/\s+$//g; # Trim suffix blanks
+ s|/|-|g; # Treat slash as dash
+ $_ }
split(m|,|, $podinfo{lastsecttext});
- return ( section => $podinfo{section}, names => [ @names ] );
+ return ( section => $podinfo{section},
+ names => [ @names ],
+ contents => $contents );
}
1;