When producing man-pages, ensure NAME section is one line only
authorRichard Levitte <levitte@openssl.org>
Wed, 16 May 2018 09:12:21 +0000 (11:12 +0200)
committerRichard Levitte <levitte@openssl.org>
Wed, 16 May 2018 18:49:33 +0000 (20:49 +0200)
There are *roff parsers that are strict about the NAME section being
one line only.  The man(7) on Debian GNU/Linux suggests that this is
appropriate, so we compensate our multi-line NAME sections by fixing
the *roff output.

Noted by Eric S. Raymond

Related to #6264

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6268)

util/process_docs.pl

index 2b7f3227d3c8a0510506209281eb1540f528f65b..ef79a1f5cd928b9f2e62ac8872d4e0e8d48573e7 100755 (executable)
@@ -112,6 +112,32 @@ foreach my $section (sort @{$options{section}}) {
                 @output = `$generate`;
                 map { s|href="http://man\.he\.net/(man\d/[^"]+)(?:\.html)?"|href="../$1.html"|g; } @output
                     if $options{type} eq "html";
+                if ($options{type} eq "man") {
+                    # Because some *roff parsers are more strict than others,
+                    # multiple lines in the NAME section must be merged into
+                    # one.
+                    my $in_name = 0;
+                    my $name_line = "";
+                    my @newoutput = ();
+                    foreach (@output) {
+                        if ($in_name) {
+                            if (/^\.SH "/) {
+                                $in_name = 0;
+                                push @newoutput, $name_line."\n";
+                            } else {
+                                chomp (my $x = $_);
+                                $name_line .= " " if $name_line;
+                                $name_line .= $x;
+                                next;
+                            }
+                        }
+                        if (/^\.SH +"NAME" *$/) {
+                            $in_name = 1;
+                        }
+                        push @newoutput, $_;
+                    }
+                    @output = @newoutput;
+                }
             }
             print STDERR "DEBUG: Done processing\n" if $options{debug};