Configure,test/recipes: "pin" glob to File::Glob::glob.
[openssl.git] / util / process_docs.pl
index eaa4964869bc8cf549ba7234c23e6d4108db21ad..cf1d3260655e06d14cdd82046028884188e00a7f 100644 (file)
@@ -13,6 +13,9 @@ use File::Spec::Functions;
 use File::Basename;
 use File::Copy;
 use File::Path;
+if ($^O ne "VMS") {
+    use File::Glob qw/glob/;
+}
 use Getopt::Long;
 use Pod::Usage;
 
@@ -74,7 +77,7 @@ foreach my $subdir (keys %{$options{subdir}}) {
     my $podsourcedir = catfile($options{sourcedir}, $subdir);
     my $podglob = catfile($podsourcedir, "*.pod");
 
-    foreach my $podfile (glob "$podglob") {
+    foreach my $podfile (glob $podglob) {
         my $podname = basename($podfile, ".pod");
         my $podpath = catfile($podfile);
         my %podinfo = ( section => $section );
@@ -84,19 +87,30 @@ foreach my $subdir (keys %{$options{subdir}}) {
         while (<$pod_fh>) {
             s|\R$||;
             if (m|^=for\s+comment\s+openssl_manual_section:\s*([0-9])\s*$|) {
-                print STDERR "Found section number $1\n" if $options{debug};
+                print STDERR "DEBUG: Found man section number $1\n"
+                    if $options{debug};
                 $podinfo{section} = $1;
             }
-            last if m|^=head1| && defined $podinfo{lastsect} eq "NAME";
-            if (m|^head1=\s*(.*)|) {
+            last if (m|^=head1|
+                     && defined $podinfo{lastsect}
+                     && $podinfo{lastsect} eq "NAME");
+            if (m|^=head1\s*(.*)|) {
                 $podinfo{lastsect} = $1;
                 $podinfo{lastsect} =~ s/\s+$//;
+                print STDERR "DEBUG: Found new pod section $1\n"
+                    if $options{debug};
+                print STDERR "DEBUG: Clearing pod section text\n"
+                    if $options{debug};
+                $podinfo{lastsecttext} = "";
             }
             next if (m|^=| || m|^\s*$|);
-            $podinfo{lastsecttext} .= " ";
+            print STDERR "DEBUG: accumulating pod section text \"$_\"\n"
+                if $options{debug};
+            $podinfo{lastsecttext} .= " " if $podinfo{lastsecttext};
             $podinfo{lastsecttext} .= $_;
         }
         close $pod_fh;
+        print STDERR "DEBUG: Done reading $podpath\n" if $options{debug};
         $podinfo{lastsecttext} =~ s| - .*$||;
         print STDERR "DEBUG: Done reading $podpath\n" if $options{debug};