#!/usr/bin/perl # # Special wrapper script to generate the actual pod2man script. This is # required for proper start-up code on non-UNIX platforms, and is used inside # Perl core. use 5.008; use strict; use warnings; use Config qw(%Config); use Cwd qw(cwd); use File::Basename qw(basename dirname); # List explicitly here the variables you want Configure to generate. # Metaconfig only looks for shell variables, so you have to mention them as if # they were shell variables, not %Config entries. Thus you write # $startperl # to ensure Configure will look for $Config{startperl}. # This forces PL files to create target in same directory as PL file. # This is so that make depend always knows where to find PL derivatives. chdir(dirname($0)) or die "Cannot change directories: $!\n"; my $file = basename($0, '.PL'); if ($^O eq 'VMS') { $file .= '.com'; } # Create the generated script. ## no critic (InputOutput::RequireBriefOpen) ## no critic (InputOutput::RequireCheckedSyscalls) open(my $out, '>', $file) or die "Cannot create $file: $!\n"; print "Extracting $file (with variable substitutions)\n"; ## use critic # In this section, Perl variables will be expanded during extraction. You can # use $Config{...} to use Configure variables. print {$out} <<"PREAMBLE" or die "Cannot write to $file: $!\n"; $Config{startperl} eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' if \$running_under_some_shell; PREAMBLE # In the following, Perl variables are not expanded during extraction. print {$out} <<'SCRIPT_BODY' or die "Cannot write to $file: $!\n"; # Convert POD data to formatted *roff input. # # The driver script for Pod::Man. # # SPDX-License-Identifier: GPL-1.0-or-later OR Artistic-1.0-Perl use 5.006; use strict; use warnings; use Getopt::Long qw(GetOptions); use Pod::Man (); use Pod::Usage qw(pod2usage); use strict; # Clean up $0 for error reporting. $0 =~ s%.*/%%; # Insert -- into @ARGV before any single dash argument to hide it from # Getopt::Long; we want to interpret it as meaning stdin. my $stdin; @ARGV = map { $_ eq '-' && !$stdin++ ? ('--', $_) : $_ } @ARGV; # Parse our options, trying to retain backward compatibility with pod2man but # allowing short forms as well. --lax is currently ignored. my %options; Getopt::Long::config ('bundling_override'); GetOptions (\%options, 'center|c=s', 'date|d=s', 'errors=s', 'fixed=s', 'fixedbold=s', 'fixeditalic=s', 'fixedbolditalic=s', 'help|h', 'lax|l', 'lquote=s', 'name|n=s', 'nourls', 'official|o', 'quotes|q=s', 'release|r=s', 'rquote=s', 'section|s=s', 'stderr', 'verbose|v', 'utf8|u') or exit 1; pod2usage (0) if $options{help}; # Official sets --center, but don't override things explicitly set. if ($options{official} && !defined $options{center}) { $options{center} = 'Perl Programmers Reference Guide'; } # Verbose is only our flag, not a Pod::Man flag. my $verbose = $options{verbose}; delete $options{verbose}; # This isn't a valid Pod::Man option and is only accepted for backward # compatibility. delete $options{lax}; # If neither stderr nor errors is set, default to errors = die. if (!defined $options{stderr} && !defined $options{errors}) { $options{errors} = 'die'; } # Initialize and run the formatter, pulling a pair of input and output off at # a time. For each file, we check whether the document was completely empty # and, if so, will remove the created file and exit with a non-zero exit # status. my $parser = Pod::Man->new (%options); my $status = 0; my @files; do { @files = splice (@ARGV, 0, 2); print " $files[1]\n" if $verbose; $parser->parse_from_file (@files); if ($parser->{CONTENTLESS}) { $status = 1; if (defined $files[0]) { warn "$0: unable to format $files[0]\n"; } else { warn "$0: unable to format standard input\n"; } if (defined ($files[1]) and $files[1] ne '-') { unlink $files[1] unless (-s $files[1]); } } } while (@ARGV); exit $status; __END__ =for stopwords en em --stderr stderr --utf8 UTF-8 overdo markup MT-LEVEL Allbery Solaris URL troff troff-specific formatters uppercased Christiansen --nourls UTC prepend lquote rquote =head1 NAME pod2man - Convert POD data to formatted *roff input =head1 SYNOPSIS pod2man [B<--center>=I] [B<--date>=I] [B<--errors>=I