7 if ($ARGV[0] =~ s/-fc(.*)//) {
12 if (length($CFont) == 2) {
13 $CFont_embed = "\\f($CFont";
15 elsif (length($CFont) == 1) {
16 $CFont_embed = "\\f$CFont";
19 die "Roff font should be 1 or 2 chars, not `$CFont_embed'";
22 $name = @ARGV ? $ARGV[0] : "something";
27 ''' \$RCSfile\$\$Revision\$\$Date\$
45 .ie \\\\n(.\$>=3 .ne \\\\\$3
61 ''' Set up \\*(-- to give an unbreakable dash;
62 ''' string Tr holds user defined translation string.
63 ''' Bell System Logo is used as a dummy character.
65 .tr \\(*W-|\\(bv\\*(Tr
68 .if (\\n(.H=4u)&(1m=24u) .ds -- \\(*W\\h'-12u'\\(*W\\h'-12u'-\\" diablo 10 pitch
69 .if (\\n(.H=4u)&(1m=20u) .ds -- \\(*W\\h'-12u'\\(*W\\h'-8u'-\\" diablo 12 pitch
85 .TH \U$name\E 1 "\\*(RP"
92 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
93 .de CQ \" put $1 in typewriter font
101 \\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7
104 .\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2
105 . \" AM - accent mark definitions
107 . \" fudge factors for nroff and troff
116 . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
122 . \" simple accents for nroff and troff
135 . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
136 . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
137 . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
138 . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
139 . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
140 . ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10'
141 . ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m'
142 . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
143 . 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'
145 . \" troff and (daisy-wheel) nroff accents
146 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
147 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
148 .ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#]
149 .ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u'
150 .ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u'
151 .ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#]
152 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
153 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
154 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
155 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
156 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
157 .ds ae a\h'-(\w'a'u*4/10)'e
158 .ds Ae A\h'-(\w'A'u*4/10)'E
159 .ds oe o\h'-(\w'o'u*4/10)'e
160 .ds Oe O\h'-(\w'O'u*4/10)'E
161 . \" corrections for vroff
162 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
163 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
164 . \" for low resolution devices (crt and lpr)
165 .if \n(.H>23 .if \n(.V>19 \
169 . ds v \h'-1'\o'\(aa\(ga'
195 # Translate verbatim paragraph
198 @lines = split(/\n/);
201 {^( [^\t]* ) \t ( \t* ) }
202 { $1 . ' ' x (8 - (length($1)%8) + 8 * (length($2))) }ex;
207 makespace() unless $verbatim++;
208 print ".Vb $lines\n";
209 print join("\n", @lines), "\n";
217 # check for things that'll hosed our noremap scheme; affects $_
222 # trofficate backslashes; must do it before what happens below
223 s/\\/noremap('\\e')/ge;
225 # first hide the escapes in case we need to
226 # intuit something and get it wrong due to fmting
228 s/([A-Z]<[^<>]*>)/noremap($1)/ge;
230 # func() is a reference to a perl function
238 # func(n) is a reference to a man page
248 # convert simple variable references
249 s/(\s+)([\$\@%][\w:]+)/${1}C<$2>/g;
259 }x && $` !~ /([LCI]<[^<>]*|-)$/ && !/^=\w/)
261 warn "``$1'' should be a [LCI]<$1> ref";
264 while (/(-[a-zA-Z])\b/g && $` !~ /[\w\-]$/) {
265 warn "``$1'' should be [CB]<$1> ref";
268 # put it back so we get the <> processed again;
269 clear_noremap(0); # 0 means leave the E's
272 # trofficate backslashes
273 s/\\/noremap('\\e')/ge;
277 # need to hide E<> first; they're processed in clear_noremap
278 s/(E<[^<>]+>)/noremap($1)/ge;
282 while ($maxnest-- && /[A-Z]</) {
284 # can't do C font here
285 s/([BI])<([^<>]*)>/font($1) . $2 . font('R')/eg;
287 # files and filelike refs in italics
288 s/F<([^<>]*)>/I<$1>/g;
290 # no break -- usually we want C<> for this
291 s/S<([^<>]*)>/nobreak($1)/eg;
293 # LREF: a manpage(3f)
294 s:L<([a-zA-Z][^\s\/]+)(\([^\)]+\))?>:the I<$1>$2 manpage:g;
296 # LREF: an =item on another manpage
306 } {the C<$2> entry in the I<$1> manpage}gx;
308 # LREF: an =item on this manpage
320 } { internal_lrefs($1) }gex;
322 # LREF: a =head2 (head1?), maybe on a manpage, maybe right here
323 # the "func" can disambiguate
333 $1 # if no $1, assume it means on this page.
334 ? "the section on I<$2> in the I<$1> manpage"
335 : "the section on I<$2>"
341 # comes last because not subject to reprocessing
342 s/C<([^<>]*)>/noremap("${CFont_embed}${1}\\fR")/eg;
346 $needspace = 0; # Assume this.
350 ($Cmd, $_) = split(' ', $_, 2);
362 elsif ($Cmd eq 'head1') {
365 elsif ($Cmd eq 'head2') {
368 elsif ($Cmd eq 'over') {
369 push(@indent,$indent);
372 elsif ($Cmd eq 'back') {
373 $indent = pop(@indent);
374 warn "Unmatched =back\n" unless defined $indent;
377 elsif ($Cmd eq 'item') {
378 s/^\*( |$)/\\(bu$1/g;
379 print STDOUT qq{.Ip "$_" $indent\n};
382 warn "Unrecognized directive: $Cmd\n";
401 #########################################################################
405 $string =~ s/ /\\ /g;
411 # translate the minus in foo-bar into foo\-bar for roff
412 s/([^0-9a-z-])-([^-])/$1\\-$2/g;
414 # make -- into the string version \*(-- (defined above)
416 s/"--([^"])/"\\*(--$1/g; # should be a better way
417 s/([^"])--"/$1\\*(--"/g;
419 # fix up quotes; this is somewhat tricky
421 s/(^|\s)(['"])/noremap("$1\\*(L$2")/ge;
422 s/(['"])($|[\-\s,;\\!?.])/noremap("\\*(R$1$2")/ge;
425 #s/(?!")(?:.)--(?!")(?:.)/\\*(--/g;
426 #s/(?:(?!")(?:.)--(?:"))|(?:(?:")--(?!")(?:.))/\\*(--/g;
429 # make sure that func() keeps a bit a space tween the parens
430 ### s/\b\(\)/\\|()/g;
431 ### s/\b\(\)/(\\|)/g;
433 # make C++ into \*C+, which is a squinched version (defined above)
436 # make double underbars have a little tiny space between them
439 # PI goes to \*(-- (defined above)
440 s/\bPI\b/noremap('\\*(PI')/ge;
442 # make all caps a teeny bit smaller, but don't muck with embedded code literals
443 my $hidCFont = font('C');
444 if ($Cmd !~ /^head1/) { # SH already makes smaller
445 # /g isn't enough; 1 while or we'll be off
448 # (?!$hidCFont)(..|^.|^)
451 # [A-Z][\/A-Z+:\-\d_$.]+
455 # } {$1\\s-1$2\\s0}gmox;
458 (?!$hidCFont)(..|^.|^)
460 \b[A-Z]{2,}[\/A-Z+:\-\d_\$]*\b
463 $1 . noremap( '\\s-1' . $2 . '\\s0' )
469 # make troff just be normal, but make small nroff get quoted
470 # decided to just put the quotes in the text; sigh;
472 local($_,$prev) = @_;
473 if ( /^\W+$/ && !/^\$./ ) {
474 ($prev && "\n") . noremap(qq{.CQ $_ \n\\&});
477 noremap(qq{${CFont_embed}$_\\fR});
479 noremap(qq{.CQ "$_" \n\\&});
492 local($font) = shift;
493 return '\\f' . noremap($font);
497 local($thing_to_hide) = shift;
498 $thing_to_hide =~ tr/\000-\177/\200-\377/;
499 return $thing_to_hide;
503 if ( /[\200-\377]/ ) {
504 warn "hit bit char in input stream";
509 my $ready_to_print = $_[0];
511 tr/\200-\377/\000-\177/;
513 # trofficate backslashes
514 # s/(?!\\e)(?:..|^.|^)\\/\\e/g;
516 # now for the E<>s, which have been hidden until now
517 # otherwise the interative \w<> processing would have
518 # been hosed by the E<gt>
525 exists $HTML_Escapes{$1}
526 ? do { $HTML_Escapes{$1} }
528 warn "Unknown escape: $& in $_";
532 }egx if $ready_to_print;
539 my(@items) = split( /(?:,?\s+(?:and\s+)?)/ );
542 for ($i = 0; $i <= $#items; $i++) {
543 $retstr .= "C<$items[$i]>";
544 $retstr .= ", " if @items > 2 && $i != $#items;
545 $retstr .= " and " if $i+2 == @items;
548 $retstr .= " entr" . ( @items > 1 ? "ies" : "y" )
549 . " elsewhere in this document";
557 'amp' => '&', # ampersand
558 'lt' => '<', # left chevron, less-than
559 'gt' => '>', # right chevron, greater-than
560 'quot' => '"', # double quote
562 "Aacute" => "A\\*'", # capital A, acute accent
563 "aacute" => "a\\*'", # small a, acute accent
564 "Acirc" => "A\\*^", # capital A, circumflex accent
565 "acirc" => "a\\*^", # small a, circumflex accent
566 "AElig" => '\*(AE', # capital AE diphthong (ligature)
567 "aelig" => '\*(ae', # small ae diphthong (ligature)
568 "Agrave" => "A\\*`", # capital A, grave accent
569 "agrave" => "A\\*`", # small a, grave accent
570 "Aring" => 'A\\*o', # capital A, ring
571 "aring" => 'a\\*o', # small a, ring
572 "Atilde" => 'A\\*~', # capital A, tilde
573 "atilde" => 'a\\*~', # small a, tilde
574 "Auml" => 'A\\*:', # capital A, dieresis or umlaut mark
575 "auml" => 'a\\*:', # small a, dieresis or umlaut mark
576 "Ccedil" => 'C\\*,', # capital C, cedilla
577 "ccedil" => 'c\\*,', # small c, cedilla
578 "Eacute" => "E\\*'", # capital E, acute accent
579 "eacute" => "e\\*'", # small e, acute accent
580 "Ecirc" => "E\\*^", # capital E, circumflex accent
581 "ecirc" => "e\\*^", # small e, circumflex accent
582 "Egrave" => "E\\*`", # capital E, grave accent
583 "egrave" => "e\\*`", # small e, grave accent
584 "ETH" => '\\*(D-', # capital Eth, Icelandic
585 "eth" => '\\*(d-', # small eth, Icelandic
586 "Euml" => "E\\*:", # capital E, dieresis or umlaut mark
587 "euml" => "e\\*:", # small e, dieresis or umlaut mark
588 "Iacute" => "I\\*'", # capital I, acute accent
589 "iacute" => "i\\*'", # small i, acute accent
590 "Icirc" => "I\\*^", # capital I, circumflex accent
591 "icirc" => "i\\*^", # small i, circumflex accent
592 "Igrave" => "I\\*`", # capital I, grave accent
593 "igrave" => "i\\*`", # small i, grave accent
594 "Iuml" => "I\\*:", # capital I, dieresis or umlaut mark
595 "iuml" => "i\\*:", # small i, dieresis or umlaut mark
596 "Ntilde" => 'N\*~', # capital N, tilde
597 "ntilde" => 'n\*~', # small n, tilde
598 "Oacute" => "O\\*'", # capital O, acute accent
599 "oacute" => "o\\*'", # small o, acute accent
600 "Ocirc" => "O\\*^", # capital O, circumflex accent
601 "ocirc" => "o\\*^", # small o, circumflex accent
602 "Ograve" => "O\\*`", # capital O, grave accent
603 "ograve" => "o\\*`", # small o, grave accent
604 "Oslash" => "O\\*/", # capital O, slash
605 "oslash" => "o\\*/", # small o, slash
606 "Otilde" => "O\\*~", # capital O, tilde
607 "otilde" => "o\\*~", # small o, tilde
608 "Ouml" => "O\\*:", # capital O, dieresis or umlaut mark
609 "ouml" => "o\\*:", # small o, dieresis or umlaut mark
610 "szlig" => '\*8', # small sharp s, German (sz ligature)
611 "THORN" => '\\*(Th', # capital THORN, Icelandic
612 "thorn" => '\\*(th',, # small thorn, Icelandic
613 "Uacute" => "U\\*'", # capital U, acute accent
614 "uacute" => "u\\*'", # small u, acute accent
615 "Ucirc" => "U\\*^", # capital U, circumflex accent
616 "ucirc" => "u\\*^", # small u, circumflex accent
617 "Ugrave" => "U\\*`", # capital U, grave accent
618 "ugrave" => "u\\*`", # small u, grave accent
619 "Uuml" => "U\\*:", # capital U, dieresis or umlaut mark
620 "uuml" => "u\\*:", # small u, dieresis or umlaut mark
621 "Yacute" => "Y\\*'", # capital Y, acute accent
622 "yacute" => "y\\*'", # small y, acute accent
623 "yuml" => "y\\*:", # small y, dieresis or umlaut mark