4 use File::Basename qw(&basename &dirname);
6 # List explicitly here the variables you want Configure to
7 # generate. Metaconfig only looks for shell variables, so you
8 # have to mention them as if they were shell variables, not
9 # %Config entries. Thus you write
12 # to ensure Configure will look for $Config{startperl}.
16 $file .= '.com' if $^O eq 'VMS';
18 chdir("pod") or die "Can't chdir to pod: $!";
19 open OUT,">$file" or die "Can't create $file: $!";
21 print "Extracting $file (with variable substitutions)\n";
23 # In this section, perl variables will be expanded during extraction.
24 # You can use $Config{...} to use Configure variables.
26 print OUT <<"!GROK!THIS!";
28 eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
29 if \$running_under_some_shell;
31 \$DEF_PM_SECTION = '$Config{man3ext}' || '3';
34 # In the following, perl variables are not expanded during extraction.
36 print OUT <<'!NO!SUBS!';
40 pod2man - translate embedded Perl pod directives into man pages
45 [ B<--section=>I<manext> ]
46 [ B<--release=>I<relpatch> ]
47 [ B<--center=>I<string> ]
48 [ B<--date=>I<string> ]
49 [ B<--fixed=>I<font> ]
56 B<pod2man> converts its input file containing embedded pod directives (see
57 L<perlpod>) into nroff source suitable for viewing with nroff(1) or
58 troff(1) using the man(7) macro set.
60 Besides the obvious pod conversions, B<pod2man> also takes care of
61 func(), func(n), and simple variable references like $foo or @bar so
62 you don't have to use code escapes for them; complex expressions like
63 C<$fred{'stuff'}> will still need to be escaped, though. Other nagging
64 little roffish things that it catches include translating the minus in
65 something like foo-bar, making a long dash--like this--into a real em
66 dash, fixing up "paired quotes", putting a little space after the
67 parens in something like func(), making C++ and PI look right, making
68 double underbars have a little tiny space between them, making ALLCAPS
69 a teeny bit smaller in troff(1), and escaping backslashes so you don't
78 Set the centered header to a specific string. The default is
79 "User Contributed Perl Documentation", unless the C<--official> flag is
80 given, in which case the default is "Perl Programmers Reference Guide".
84 Set the left-hand footer string to this value. By default,
85 the modification date of the input file will be used.
89 The fixed font to use for code refs. Defaults to CW.
93 Set the default header to indicate that this page is of
94 the standard release in case C<--center> is not given.
98 Set the centered footer. By default, this is the current
103 Set the section for the C<.TH> macro. The standard conventions on
104 sections are to use 1 for user commands, 2 for system calls, 3 for
105 functions, 4 for devices, 5 for file formats, 6 for games, 7 for
106 miscellaneous information, and 8 for administrator commands. This works
107 best if you put your Perl man pages in a separate tree, like
108 F</usr/local/perl/man/>. By default, section 1 will be used
109 unless the file ends in F<.pm> in which case section 3 will be selected.
113 Don't complain when required sections aren't present.
117 =head1 Anatomy of a Proper Man Page
119 For those not sure of the proper layout of a man page, here's
120 an example of the skeleton of a proper man page. Head of the
121 major headers should be setout as a C<=head1> directive, and
122 are historically written in the rather startling ALL UPPER CASE
123 format, although this is not mandatory.
124 Minor headers may be included using C<=head2>, and are
125 typically in mixed case.
131 Mandatory section; should be a comma-separated list of programs or
132 functions documented by this podpage, such as:
134 foo, bar - programs to do something
138 A short usage summary for programs and functions, which
139 may someday be deemed mandatory.
143 Long drawn out discussion of the program. It's a good idea to break this
144 up into subsections using the C<=head2> directives, like
146 =head2 A Sample Subection
148 =head2 Yet Another Sample Subection
152 Some people make this separate from the description.
156 What the program or function returns if successful.
160 Exceptions, return codes, exit stati, and errno settings.
164 Give some example uses of the program.
168 Envariables this program might care about.
172 All files used by the program. You should probably use the FE<lt>E<gt>
177 Other man pages to check out, like man(1), man(7), makewhatis(8), or catman(8).
181 Miscellaneous commentary.
185 Things to take special care with; sometimes called WARNINGS.
189 All possible messages the program can print out--and
194 Things that are broken or just don't work quite right.
198 Bugs you don't plan to fix :-)
202 Who wrote it (or AUTHORS if multiple).
206 Programs derived from other sources sometimes have this, or
207 you might keep a modification log here.
213 pod2man program > program.1
214 pod2man some_module.pm > /usr/perl/man/man3/some_module.3
215 pod2man --section=7 note.pod > note.7
219 The following diagnostics are generated by B<pod2man>. Items
220 marked "(W)" are non-fatal, whereas the "(F)" errors will cause
221 B<pod2man> to immediately exit with a non-zero status.
225 =item bad option in paragraph %d of %s: ``%s'' should be [%s]<%s>
227 (W) If you start include an option, you should set it off
228 as bold, italic, or code.
230 =item can't open %s: %s
232 (F) The input file wasn't available for the given reason.
234 =item Improper man page - no dash in NAME header in paragraph %d of %s
236 (W) The NAME header did not have an isolated dash in it. This is
237 considered important.
239 =item Invalid man page - no NAME line in %s
241 (F) You did not include a NAME header, which is essential.
243 =item roff font should be 1 or 2 chars, not `%s' (F)
245 (F) The font specified with the C<--fixed> option was not
246 a one- or two-digit roff font.
248 =item %s is missing required section: %s
250 (W) Required sections include NAME, DESCRIPTION, and if you're
251 using a section starting with a 3, also a SYNOPSIS. Actually,
252 not having a NAME is a fatal.
254 =item Unknown escape: %s in %s
256 (W) An unknown HTML entity (probably for an 8-bit character) was given via
257 a C<EE<lt>E<gt>> directive. Besides amp, lt, gt, and quot, recognized
258 entities are Aacute, aacute, Acirc, acirc, AElig, aelig, Agrave, agrave,
259 Aring, aring, Atilde, atilde, Auml, auml, Ccedil, ccedil, Eacute, eacute,
260 Ecirc, ecirc, Egrave, egrave, ETH, eth, Euml, euml, Iacute, iacute, Icirc,
261 icirc, Igrave, igrave, Iuml, iuml, Ntilde, ntilde, Oacute, oacute, Ocirc,
262 ocirc, Ograve, ograve, Oslash, oslash, Otilde, otilde, Ouml, ouml, szlig,
263 THORN, thorn, Uacute, uacute, Ucirc, ucirc, Ugrave, ugrave, Uuml, uuml,
264 Yacute, yacute, and yuml.
266 =item Unmatched =back
268 (W) You have a C<=back> without a corresponding C<=over>.
270 =item Unrecognized pod directive: %s
272 (W) You specified a pod directive that isn't in the known list of
273 C<=head1>, C<=head2>, C<=item>, C<=over>, C<=back>, or C<=cut>.
280 If you would like to print out a lot of man page continuously, you
281 probably want to set the C and D registers to set contiguous page
282 numbering and even/odd paging, at least on some versions of man(7).
283 Settting the F register will get you some additional experimental
286 troff -man -rC1 -rD1 -rF1 perl.1 perldata.1 perlsyn.1 ...
288 The indexing merely outputs messages via C<.tm> for each
289 major page, section, subsection, item, and any C<XE<lt>E<gt>>
299 The =over and =back directives don't really work right. They
300 take absolute positions instead of offsets, don't nest well, and
301 making people count is suboptimal in any event.
305 Original prototype by Larry Wall, but so massively hacked over by
306 Tom Christiansen such that Larry probably doesn't recognize it anymore.
314 # We try first to get the version number from a local binary, in case we're
315 # running an installed version of Perl to produce documentation from an
316 # uninstalled newer version's pod files.
317 if ($^O ne 'plan9' and $^O ne 'dos' and $^O ne 'os2' and $^O ne 'MSWin32') {
318 my $perl = (-x './perl' && -f './perl' ) ?
320 ((-x '../perl' && -f '../perl') ?
323 ($version,$patch) = `$perl -e 'print $]'` =~ /^(\d\.\d{3})(\d{2})?/ if $perl;
325 # No luck; we'll just go with the running Perl's version
326 ($version,$patch) = $] =~ /^(.{5})(\d{2})?/ unless $version;
327 $DEF_RELEASE = "perl $version";
328 $DEF_RELEASE .= ", patch $patch" if $patch;
333 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secs);
334 my $mname = (qw{Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec})[$mon];
336 return "$mday/$mname/$year";
342 $DEF_CENTER = "User Contributed Perl Documentation";
343 $STD_CENTER = "Perl Programmers Reference Guide";
348 warn "$0: @_\n" if @_;
350 usage: $0 [options] podpage
352 --section=manext (default "$DEF_SECTION")
353 --release=relpatch (default "$DEF_RELEASE")
354 --center=string (default "$DEF_CENTER")
355 --date=string (default "$DEF_DATE")
356 --fixed=font (default "$DEF_FIXED")
357 --official (default NOT)
362 $uok = GetOptions( qw(
372 $DEF_DATE = makedate((stat($ARGV[0]))[9] || time());
374 usage("Usage error!") unless $uok;
375 usage() if $opt_help;
376 usage("Need one and only one podpage argument") unless @ARGV == 1;
378 $section = $opt_section || ($ARGV[0] =~ /\.pm$/
379 ? $DEF_PM_SECTION : $DEF_SECTION);
380 $RP = $opt_release || $DEF_RELEASE;
381 $center = $opt_center || ($opt_official ? $STD_CENTER : $DEF_CENTER);
382 $lax = $opt_lax || $DEF_LAX;
384 $CFont = $opt_fixed || $DEF_FIXED;
386 if (length($CFont) == 2) {
387 $CFont_embed = "\\f($CFont";
389 elsif (length($CFont) == 1) {
390 $CFont_embed = "\\f$CFont";
393 die "roff font should be 1 or 2 chars, not `$CFont_embed'";
396 $date = $opt_date || $DEF_DATE;
398 for (qw{NAME DESCRIPTION}) {
399 # for (qw{NAME DESCRIPTION AUTHOR}) {
402 $wanna_see{SYNOPSIS}++ if $section =~ /^3/;
405 $name = @ARGV ? $ARGV[0] : "<STDIN>";
407 if ($section =~ /^1/) {
408 require File::Basename;
409 $name = uc File::Basename::basename($name);
411 $name =~ s/\.(pod|p[lm])$//i;
413 # Lose everything up to the first of
414 # */lib/*perl* standard or site_perl module
415 # */*perl*/lib from -D prefix=/opt/perl
416 # */*perl*/ random module hierarchy
419 if ($name =~ s-^.*?/lib/[^/]*perl[^/]*/--i
420 or $name =~ s-^.*?/[^/]*perl[^/]*/lib/--i
421 or $name =~ s-^.*?/[^/]*perl[^/]*/--i) {
422 # Lose ^site(_perl)?/.
423 $name =~ s-^site(_perl)?/--;
424 # Lose ^arch/. (XXX should we use Config? Just for archname?)
425 $name =~ s~^(.*-$^O|$^O-.*)/~~o;
427 $name =~ s-^\d+\.\d+/--;
430 # Translate Getopt/Long to Getopt::Long, etc.
433 if ($name ne 'something') {
435 open(F, "< $ARGV[0]") || die "can't open $ARGV[0]: $!";
438 if (/^=head1\s+NAME\s*$/) { # an /m would forgive mistakes
440 unless (/\s*-+\s+/) {
442 warn "$0: Improper man page - no dash in NAME header in paragraph $. of $ARGV[0]\n"
444 my @n = split /\s+-+\s+/;
447 warn "$0: Improper man page - malformed NAME header in paragraph $. of $ARGV[0]\n"
455 next if /^=cut\b/; # DB_File and Net::Ping have =cut before NAME
456 next if /^=pod\b/; # It is OK to have =pod before NAME
457 die "$0: Invalid man page - 1st pod line is not NAME in $ARGV[0]\n" unless $lax;
459 die "$0: Invalid man page - no documentation in $ARGV[0]\n" unless $lax;
466 ''' \$RCSfile\$\$Revision\$\$Date\$
484 .ie \\\\n(.\$>=3 .ne \\\\\$3
486 .IP "\\\\\$1" \\\\\$2
500 ''' Set up \\*(-- to give an unbreakable dash;
501 ''' string Tr holds user defined translation string.
502 ''' Bell System Logo is used as a dummy character.
504 .tr \\(*W-|\\(bv\\*(Tr
508 .if (\\n(.H=4u)&(1m=24u) .ds -- \\(*W\\h'-12u'\\(*W\\h'-12u'-\\" diablo 10 pitch
509 .if (\\n(.H=4u)&(1m=20u) .ds -- \\(*W\\h'-12u'\\(*W\\h'-8u'-\\" diablo 12 pitch
512 ''' \\*(M", \\*(S", \\*(N" and \\*(T" are the equivalent of
513 ''' \\*(L" and \\*(R", except that they are used on ".xx" lines,
514 ''' such as .IP and .SH, which do another additional levels of
515 ''' double-quote interpretation
547 .\" If the F register is turned on, we'll generate
548 .\" index entries out stderr for the following things:
553 .\" X<> Xref (embedded
554 .\" Of course, you have to process the output yourself
555 .\" in some meaninful fashion.
558 .tm Index:\\$1\t\\n%\t"\\$2"
566 .TH $name $section "$date" "$RP" "$center"
570 push(@Indices, qq{.IX Title "$name $section"});
572 while (($name, $desc) = each %namedesc) {
573 for ($name, $desc) { s/^\s+//; s/\s+$//; }
574 push(@Indices, qq(.IX Name "$name - $desc"\n));
580 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
581 .de CQ \" put $1 in typewriter font
583 print ".ft $CFont\n";
589 \\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7
592 .\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2
593 . \" AM - accent mark definitions
595 . \" fudge factors for nroff and troff
604 . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
610 . \" simple accents for nroff and troff
623 . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
624 . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
625 . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
626 . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
627 . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
628 . ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10'
629 . ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m'
630 . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
631 . ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10'
633 . \" troff and (daisy-wheel) nroff accents
634 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
635 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
636 .ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#]
637 .ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u'
638 .ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u'
639 .ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#]
640 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
641 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
642 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
643 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
644 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
645 .ds ae a\h'-(\w'a'u*4/10)'e
646 .ds Ae A\h'-(\w'A'u*4/10)'E
647 .ds oe o\h'-(\w'o'u*4/10)'e
648 .ds Oe O\h'-(\w'O'u*4/10)'E
649 . \" corrections for vroff
650 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
651 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
652 . \" for low resolution devices (crt and lpr)
653 .if \n(.H>23 .if \n(.V>19 \
657 . ds v \h'-1'\o'\(aa\(ga'
678 # Unrolling [^-=A-Z>]|[A-Z](?!<)|[-=](?![A-Z]<)[\x00-\xFF] gives: // MRE pp 165.
679 my $nonest = q{(?x) # Turn on /x mode.
681 [^-=A-Z>]* # Anything that isn't a dash, equal sign or
682 # closing hook isn't special. Eat as much as
686 [-=] # We want to recognize -> and =>.
687 (?![A-Z]<) # So, as long as it isn't followed by markup
688 [\x00-\xFF] # anything may follow - and =
690 [A-Z] # Capitals are fine too,
691 (?!<) # But not if they start markup.
692 ) # End of special sequences.
693 [^-=A-Z>]* # Followed by zero or more non-special chars.
694 )* # And we can repeat this as often as we can.
695 )}; # That's all folks.
703 if (/^=end\s+$begun/) {
706 elsif ($begun =~ /^(roff|man)$/) {
713 # Translate verbatim paragraph
716 @lines = split(/\n/);
719 {^( [^\t]* ) \t ( \t* ) }
720 { $1 . ' ' x (8 - (length($1)%8) + 8 * (length($2))) }ex;
725 makespace() unless $verbatim++;
726 print ".Vb $lines\n";
727 print join("\n", @lines), "\n";
735 if (/^=for\s+(\S+)\s*/s) {
736 if ($1 eq "man" or $1 eq "roff") {
737 print STDOUT $',"\n\n";
743 elsif (/^=begin\s+(\S+)\s*/s) {
745 if ($1 eq "man" or $1 eq "roff") {
746 print STDOUT $'."\n\n";
751 # check for things that'll hosed our noremap scheme; affects $_
756 # trofficate backslashes; must do it before what happens below
757 s/\\/noremap('\\e')/ge;
759 # protect leading periods and quotes against *roff
760 # mistaking them for directives
761 s/^(?:[A-Z]<)?[.']/\\&$&/gm;
763 # first hide the escapes in case we need to
764 # intuit something and get it wrong due to fmting
766 1 while s/([A-Z]<$nonest>)/noremap($1)/ge;
768 # func() is a reference to a perl function
776 # func(n) is a reference to a perl function or a man page
784 # convert simple variable references
785 s/(\s+)([\$\@%&*][\w:]+)(?!\()/${1}C<$2>/g;
795 }x && $` !~ /([LCI]<[^<>]*|-)$/ && !/^=\w/)
797 warn "$0: bad option in paragraph $. of $ARGV: ``$1'' should be [LCI]<$1>\n";
801 while (/(-[a-zA-Z])\b/g && $` !~ /[\w\-]$/) {
802 warn "$0: bad option in paragraph $. of $ARGV: ``$1'' should be [CB]<$1>\n";
806 # put it back so we get the <> processed again;
807 clear_noremap(0); # 0 means leave the E's
810 # trofficate backslashes
811 s/\\/noremap('\\e')/ge;
815 # need to hide E<> first; they're processed in clear_noremap
816 s/(E<[^<>]+>)/noremap($1)/ge;
820 while ($maxnest-- && /[A-Z]</) {
822 # can't do C font here
823 s/([BI])<($nonest)>/font($1) . $2 . font('R')/eg;
825 # files and filelike refs in italics
826 s/F<($nonest)>/I<$1>/g;
828 # no break -- usually we want C<> for this
829 s/S<($nonest)>/nobreak($1)/eg;
831 # LREF: a la HREF L<show this text|man/section>
832 s:L<([^|>]+)\|[^>]+>:$1:g;
834 # LREF: a manpage(3f)
835 s:L<([a-zA-Z][^\s\/]+)(\([^\)]+\))?>:the I<$1>$2 manpage:g;
837 # LREF: an =item on another manpage
847 } {the C<$2> entry in the I<$1> manpage}gx;
849 # LREF: an =item on this manpage
861 } { internal_lrefs($1) }gex;
863 # LREF: a =head2 (head1?), maybe on a manpage, maybe right here
864 # the "func" can disambiguate
874 $1 # if no $1, assume it means on this page.
875 ? "the section on I<$2> in the I<$1> manpage"
876 : "the section on I<$2>"
878 }gesx; # s in case it goes over multiple lines, so . matches \n
882 # comes last because not subject to reprocessing
883 s/C<($nonest)>/noremap("${CFont_embed}${1}\\fR")/eg;
887 $needspace = 0; # Assume this.
891 ($Cmd, $_) = split(' ', $_, 2);
894 if ($Cmd eq 'head1') {
897 elsif ($Cmd eq 'head2') {
900 elsif ($Cmd eq 'item') {
914 elsif ($Cmd eq 'head1') {
916 delete $wanna_see{$_} if exists $wanna_see{$_};
917 print qq{.SH "$_"\n};
918 push(@Indices, qq{.IX Header "$_"\n});
920 elsif ($Cmd eq 'head2') {
921 print qq{.Sh "$_"\n};
922 push(@Indices, qq{.IX Subsection "$_"\n});
924 elsif ($Cmd eq 'over') {
925 push(@indent,$indent);
926 $indent += ($_ + 0) || 5;
928 elsif ($Cmd eq 'back') {
929 $indent = pop(@indent);
930 warn "$0: Unmatched =back in paragraph $. of $ARGV\n" unless defined $indent;
933 elsif ($Cmd eq 'item') {
934 s/^\*( |$)/\\(bu$1/g;
935 # if you know how to get ":s please do
936 s/\\\*\(L"([^"]+?)\\\*\(R"/'$1'/g;
937 s/\\\*\(L"([^"]+?)""/'$1'/g;
938 s/[^"]""([^"]+?)""[^"]/'$1'/g;
939 # here do something about the $" in perlvar?
940 print STDOUT qq{.Ip "$_" $indent\n};
941 push(@Indices, qq{.IX Item "$_"\n});
943 elsif ($Cmd eq 'pod') {
944 # this is just a comment
947 warn "$0: Unrecognized pod directive in paragraph $. of $ARGV: $Cmd\n";
966 if (%wanna_see && !$lax) {
967 @missing = keys %wanna_see;
968 warn "$0: $Filename is missing required section"
969 . (@missing > 1 && "s")
974 foreach (@Indices) { print "$_\n"; }
979 #########################################################################
983 $string =~ s/ /\\ /g;
990 s/X<(.*?)>/mkindex($1)/ge;
992 # translate the minus in foo-bar into foo\-bar for roff
993 s/([^0-9a-z-])-([^-])/$1\\-$2/g;
995 # make -- into the string version \*(-- (defined above)
997 s/"--([^"])/"\\*(--$1/g; # should be a better way
998 s/([^"])--"/$1\\*(--"/g;
1000 # fix up quotes; this is somewhat tricky
1001 my $dotmacroL = 'L';
1002 my $dotmacroR = 'R';
1003 if ( $indot == 1 ) {
1007 elsif ( $indot >= 2 ) {
1012 s/(^|\s)(['"])/noremap("$1\\*($dotmacroL$2")/ge;
1013 s/(['"])($|[\-\s,;\\!?.])/noremap("\\*($dotmacroR$1$2")/ge;
1016 #s/(?!")(?:.)--(?!")(?:.)/\\*(--/g;
1017 #s/(?:(?!")(?:.)--(?:"))|(?:(?:")--(?!")(?:.))/\\*(--/g;
1020 # make sure that func() keeps a bit a space tween the parens
1021 ### s/\b\(\)/\\|()/g;
1022 ### s/\b\(\)/(\\|)/g;
1024 # make C++ into \*C+, which is a squinched version (defined above)
1027 # make double underbars have a little tiny space between them
1030 # PI goes to \*(PI (defined above)
1031 s/\bPI\b/noremap('\\*(PI')/ge;
1033 # make all caps a teeny bit smaller, but don't muck with embedded code literals
1034 my $hidCFont = font('C');
1035 if ($Cmd !~ /^head1/) { # SH already makes smaller
1036 # /g isn't enough; 1 while or we'll be off
1039 # (?!$hidCFont)(..|^.|^)
1042 # [A-Z][\/A-Z+:\-\d_$.]+
1046 # } {$1\\s-1$2\\s0}gmox;
1049 (?!$hidCFont)(..|^.|^)
1051 \b[A-Z]{2,}[\/A-Z+:\-\d_\$]*\b
1054 $1 . noremap( '\\s-1' . $2 . '\\s0' )
1060 # make troff just be normal, but make small nroff get quoted
1061 # decided to just put the quotes in the text; sigh;
1063 local($_,$prev) = @_;
1064 noremap(qq{.CQ "$_" \n\\&});
1078 my @entries = split m:\s*/\s*:, $entry;
1079 push @Indices, ".IX Xref " . join ' ', map {qq("$_")} @entries;
1084 local($font) = shift;
1085 return '\\f' . noremap($font);
1089 local($thing_to_hide) = shift;
1090 $thing_to_hide =~ tr/\000-\177/\200-\377/;
1091 return $thing_to_hide;
1095 # escape high bit characters in input stream
1096 s/([\200-\377])/"E<".ord($1).">"/ge;
1100 my $ready_to_print = $_[0];
1102 tr/\200-\377/\000-\177/;
1104 # trofficate backslashes
1105 # s/(?!\\e)(?:..|^.|^)\\/\\e/g;
1107 # now for the E<>s, which have been hidden until now
1108 # otherwise the interative \w<> processing would have
1109 # been hosed by the E<gt>
1122 exists $HTML_Escapes{$3}
1123 ? do { $HTML_Escapes{$3} }
1125 warn "$0: Unknown escape in paragraph $. of $ARGV: ``$&''\n";
1129 }egx if $ready_to_print;
1132 sub internal_lrefs {
1134 local $trailing_and = s/and\s+$// ? "and " : "";
1136 s{L</([^>]+)>}{$1}g;
1137 my(@items) = split( /(?:,?\s+(?:and\s+)?)/ );
1138 my $retstr = "the ";
1140 for ($i = 0; $i <= $#items; $i++) {
1141 $retstr .= "C<$items[$i]>";
1142 $retstr .= ", " if @items > 2 && $i != $#items;
1143 $retstr .= " and " if $i+2 == @items;
1146 $retstr .= " entr" . ( @items > 1 ? "ies" : "y" )
1147 . " elsewhere in this document";
1148 # terminal space to avoid words running together (pattern used
1149 # strips terminal spaces)
1150 $retstr .= " " if length $trailing_and;
1151 $retstr .= $trailing_and;
1159 'amp' => '&', # ampersand
1160 'lt' => '<', # left chevron, less-than
1161 'gt' => '>', # right chevron, greater-than
1162 'quot' => '"', # double quote
1164 "Aacute" => "A\\*'", # capital A, acute accent
1165 "aacute" => "a\\*'", # small a, acute accent
1166 "Acirc" => "A\\*^", # capital A, circumflex accent
1167 "acirc" => "a\\*^", # small a, circumflex accent
1168 "AElig" => '\*(AE', # capital AE diphthong (ligature)
1169 "aelig" => '\*(ae', # small ae diphthong (ligature)
1170 "Agrave" => "A\\*`", # capital A, grave accent
1171 "agrave" => "A\\*`", # small a, grave accent
1172 "Aring" => 'A\\*o', # capital A, ring
1173 "aring" => 'a\\*o', # small a, ring
1174 "Atilde" => 'A\\*~', # capital A, tilde
1175 "atilde" => 'a\\*~', # small a, tilde
1176 "Auml" => 'A\\*:', # capital A, dieresis or umlaut mark
1177 "auml" => 'a\\*:', # small a, dieresis or umlaut mark
1178 "Ccedil" => 'C\\*,', # capital C, cedilla
1179 "ccedil" => 'c\\*,', # small c, cedilla
1180 "Eacute" => "E\\*'", # capital E, acute accent
1181 "eacute" => "e\\*'", # small e, acute accent
1182 "Ecirc" => "E\\*^", # capital E, circumflex accent
1183 "ecirc" => "e\\*^", # small e, circumflex accent
1184 "Egrave" => "E\\*`", # capital E, grave accent
1185 "egrave" => "e\\*`", # small e, grave accent
1186 "ETH" => '\\*(D-', # capital Eth, Icelandic
1187 "eth" => '\\*(d-', # small eth, Icelandic
1188 "Euml" => "E\\*:", # capital E, dieresis or umlaut mark
1189 "euml" => "e\\*:", # small e, dieresis or umlaut mark
1190 "Iacute" => "I\\*'", # capital I, acute accent
1191 "iacute" => "i\\*'", # small i, acute accent
1192 "Icirc" => "I\\*^", # capital I, circumflex accent
1193 "icirc" => "i\\*^", # small i, circumflex accent
1194 "Igrave" => "I\\*`", # capital I, grave accent
1195 "igrave" => "i\\*`", # small i, grave accent
1196 "Iuml" => "I\\*:", # capital I, dieresis or umlaut mark
1197 "iuml" => "i\\*:", # small i, dieresis or umlaut mark
1198 "Ntilde" => 'N\*~', # capital N, tilde
1199 "ntilde" => 'n\*~', # small n, tilde
1200 "Oacute" => "O\\*'", # capital O, acute accent
1201 "oacute" => "o\\*'", # small o, acute accent
1202 "Ocirc" => "O\\*^", # capital O, circumflex accent
1203 "ocirc" => "o\\*^", # small o, circumflex accent
1204 "Ograve" => "O\\*`", # capital O, grave accent
1205 "ograve" => "o\\*`", # small o, grave accent
1206 "Oslash" => "O\\*/", # capital O, slash
1207 "oslash" => "o\\*/", # small o, slash
1208 "Otilde" => "O\\*~", # capital O, tilde
1209 "otilde" => "o\\*~", # small o, tilde
1210 "Ouml" => "O\\*:", # capital O, dieresis or umlaut mark
1211 "ouml" => "o\\*:", # small o, dieresis or umlaut mark
1212 "szlig" => '\*8', # small sharp s, German (sz ligature)
1213 "THORN" => '\\*(Th', # capital THORN, Icelandic
1214 "thorn" => '\\*(th',, # small thorn, Icelandic
1215 "Uacute" => "U\\*'", # capital U, acute accent
1216 "uacute" => "u\\*'", # small u, acute accent
1217 "Ucirc" => "U\\*^", # capital U, circumflex accent
1218 "ucirc" => "u\\*^", # small u, circumflex accent
1219 "Ugrave" => "U\\*`", # capital U, grave accent
1220 "ugrave" => "u\\*`", # small u, grave accent
1221 "Uuml" => "U\\*:", # capital U, dieresis or umlaut mark
1222 "uuml" => "u\\*:", # small u, dieresis or umlaut mark
1223 "Yacute" => "Y\\*'", # capital Y, acute accent
1224 "yacute" => "y\\*'", # small y, acute accent
1225 "yuml" => "y\\*:", # small y, dieresis or umlaut mark
1231 close OUT or die "Can't close $file: $!";
1232 chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
1233 exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';