- (tim) New version of mdoc2man.pl from Mark D. Roth <roth+openssh@feep.net>

This commit is contained in:
Tim Rice 2001-04-29 18:01:51 -07:00
Родитель f343674d5e
Коммит 4534492aec
2 изменённых файлов: 304 добавлений и 77 удалений

Просмотреть файл

@ -1,4 +1,4 @@
20010450 20010430
- OpenBSD CVS Sync - OpenBSD CVS Sync
- markus@cvs.openbsd.org 2001/04/29 18:32:52 - markus@cvs.openbsd.org 2001/04/29 18:32:52
[serverloop.c] [serverloop.c]
@ -6,6 +6,7 @@
- markus@cvs.openbsd.org 2001/04/29 19:16:52 - markus@cvs.openbsd.org 2001/04/29 19:16:52
[channels.c clientloop.c compat.c compat.h serverloop.c] [channels.c clientloop.c compat.c compat.h serverloop.c]
more ssh.com-2.0.x bug-compat; from per@appgate.com more ssh.com-2.0.x bug-compat; from per@appgate.com
- (tim) New version of mdoc2man.pl from Mark D. Roth <roth+openssh@feep.net>
20010429 20010429
- (bal) Updated INSTALL. PCRE moved to a new place. - (bal) Updated INSTALL. PCRE moved to a new place.
@ -5280,4 +5281,4 @@
- Wrote replacements for strlcpy and mkdtemp - Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1 - Released 1.0pre1
$Id: ChangeLog,v 1.1182 2001/04/29 19:52:00 mouring Exp $ $Id: ChangeLog,v 1.1183 2001/04/30 01:01:51 tim Exp $

Просмотреть файл

@ -40,18 +40,28 @@ use strict;
my ($name, $date, $id); my ($name, $date, $id);
my ($line); my ($line);
my ($optlist, $nospace, $enum, $synopsis); my ($optlist, $oldoptlist, $nospace, $enum, $synopsis);
my ($reference, $block, $ext, $extopt, $literal);
my (@refauthors, $reftitle, $refissue, $refdate, $refopt);
$optlist = 0; ### 1 = bullet, 2 = enum, 3 = tag $optlist = 0; ### 1 = bullet, 2 = enum, 3 = tag, 4 = item
$oldoptlist = 0;
$nospace = 0; $nospace = 0;
$synopsis = 0; $synopsis = 0;
$reference = 0;
$block = 0;
$ext = 0;
$extopt = 0;
$literal = 0;
while ($line = <STDIN>) while ($line = <STDIN>)
{ {
if ($line !~ /^\./) if ($line !~ /^\./)
{ {
print $line; print $line;
print ".br\n"
if ($literal);
next; next;
} }
@ -70,13 +80,12 @@ while ($line = <STDIN>)
sub ParseMacro # ($line) sub ParseMacro # ($line)
{ {
my ($line) = @_; my ($line) = @_;
my (@words, $retval, $option, $parens, $arg); my (@words, $retval, $option, $parens);
@words = split(/\s+/, $line); @words = split(/\s+/, $line);
$retval = ''; $retval = '';
$option = 0; $option = 0;
$parens = 0; $parens = 0;
$arg = 0;
# print('@words = ', scalar(@words), ': ', join(' ', @words), "\n"); # print('@words = ', scalar(@words), ': ', join(' ', @words), "\n");
@ -85,9 +94,39 @@ sub ParseMacro # ($line)
# print "WORD: $_\n"; # print "WORD: $_\n";
next next
if (/^(Li|Pf|X[oc])$/); if (/^(Li|Pf)$/);
if (/^Ns/) if (/^Xo$/)
{
$ext = 1;
$retval .= ' '
if ($retval ne '' && $retval !~ m/[\n ]$/);
next;
}
if (/^Xc$/)
{
$ext = 0;
$retval .= "\n"
if (! $extopt);
last;
}
if (/^Bd$/)
{
$literal = 1
if ($words[0] eq '-literal');
$retval .= "\n";
last;
}
if (/^Ed$/)
{
$literal = 0;
last;
}
if (/^Ns$/)
{ {
$nospace = 1 $nospace = 1
if (! $nospace); if (! $nospace);
@ -95,43 +134,78 @@ sub ParseMacro # ($line)
next; next;
} }
if (/^No/) if (/^No$/)
{ {
$retval =~ s/ $//; $retval =~ s/ $//;
$retval .= shift @words; $retval .= shift @words;
next; next;
} }
if (/^Dq$/) { if (/^Dq$/)
$retval .= '``' . (shift @words) . '\'\''; {
$retval .= '``';
do
{
$retval .= (shift @words) . ' ';
}
while (@words > 0 && $words[0] !~ m/^[\.,]/);
$retval =~ s/ $//;
$retval .= '\'\'';
$nospace = 1 $nospace = 1
if (! $nospace && $words[0] =~ m/^[\.,]/); if (! $nospace && $words[0] =~ m/^[\.,]/);
next; next;
} }
if (/^(Sq|Ql)$/) { if (/^(Sq|Ql)$/)
{
$retval .= '`' . (shift @words) . '\''; $retval .= '`' . (shift @words) . '\'';
$nospace = 1 $nospace = 1
if (! $nospace && $words[0] =~ m/^[\.,]/); if (! $nospace && $words[0] =~ m/^[\.,]/);
next; next;
} }
# if (/^Ic$/)
# {
# $retval .= '\\fB' . shift(@words) . '\\fP';
# next;
# }
if (/^Oo$/)
{
# $retval .= "[\\c\n";
$extopt = 1;
$nospace = 1
if (! $nospace);
$retval .= '[';
next;
}
if (/^Oc$/)
{
$extopt = 0;
$retval .= ']';
next;
}
$retval .= ' ' $retval .= ' '
if (! $nospace && $retval ne '' && $retval !~ m/[\n ]$/); if (! $nospace && $retval ne '' && $retval !~ m/[\n ]$/);
$nospace = 0 $nospace = 0
if ($nospace == 1); if ($nospace == 1);
if (/^Dd$/) { if (/^Dd$/)
{
$date = join(' ', @words); $date = join(' ', @words);
return undef; return undef;
} }
if (/^Dt$/) { if (/^Dt$/)
{
$id = join(' ', @words); $id = join(' ', @words);
return undef; return undef;
} }
if (/^Os$/) { if (/^Os$/)
{
$retval .= '.TH ' $retval .= '.TH '
. $id . $id
. " \"$date\" \"" . " \"$date\" \""
@ -140,7 +214,8 @@ sub ParseMacro # ($line)
last; last;
} }
if (/^Sh$/) { if (/^Sh$/)
{
$retval .= '.SH'; $retval .= '.SH';
if ($words[0] eq 'SYNOPSIS') if ($words[0] eq 'SYNOPSIS')
{ {
@ -153,113 +228,213 @@ sub ParseMacro # ($line)
next; next;
} }
if (/^Xr$/) { if (/^Xr$/)
{
$retval .= '\\fB' . (shift @words) . $retval .= '\\fB' . (shift @words) .
'\\fR(' . (shift @words) . ')' '\\fP(' . (shift @words) . ')'
. (shift @words); . (shift @words);
last; last;
} }
if (/^Nm$/) { if (/^Rs/)
{
@refauthors = ();
$reftitle = '';
$refissue = '';
$refdate = '';
$refopt = '';
$reference = 1;
last;
}
if (/^Re/)
{
$retval .= "\n";
# authors
while (scalar(@refauthors) > 1)
{
$retval .= shift(@refauthors) . ', ';
}
$retval .= 'and '
if ($retval ne '');
$retval .= shift(@refauthors);
# title
$retval .= ', \\fI' . $reftitle . '\\fP';
# issue
$retval .= ', ' . $refissue
if ($refissue ne '');
# date
$retval .= ', ' . $refdate
if ($refdate ne '');
# optional info
$retval .= ', ' . $refopt
if ($refopt ne '');
$retval .= ".\n";
$reference = 0;
last;
}
if ($reference)
{
if (/^%A$/)
{
unshift(@refauthors, join(' ', @words));
last;
}
if (/^%T$/)
{
$reftitle = join(' ', @words);
$reftitle =~ s/^"//;
$reftitle =~ s/"$//;
last;
}
if (/^%N$/)
{
$refissue = join(' ', @words);
last;
}
if (/^%D$/)
{
$refdate = join(' ', @words);
last;
}
if (/^%O$/)
{
$refopt = join(' ', @words);
last;
}
}
if (/^Nm$/)
{
$name = shift @words $name = shift @words
if (@words > 0); if (@words > 0);
$retval .= ".br\n" $retval .= ".br\n"
if ($synopsis); if ($synopsis);
$retval .= "\\fB$name\\fR"; $retval .= "\\fB$name\\fP";
$nospace = 1 $nospace = 1
if (! $nospace && $words[0] =~ m/^[\.,]/); if (! $nospace && $words[0] =~ m/^[\.,]/);
next; next;
} }
if (/^Nd$/) { if (/^Nd$/)
{
$retval .= '\\-'; $retval .= '\\-';
next; next;
} }
if (/^Fl$/) { if (/^Fl$/)
$retval .= '\\fB\\-' . (shift @words) . '\\fR'; {
$retval .= '\\fB\\-' . (shift @words) . '\\fP';
$nospace = 1 $nospace = 1
if (! $nospace && $words[0] =~ m/^[\.,]/); if (! $nospace && $words[0] =~ m/^[\.,]/);
next; next;
} }
if (/^Ar$/) { if (/^Ar$/)
{
$retval .= '\\fI'; $retval .= '\\fI';
if (! defined $words[0]) if (! defined $words[0])
{ {
$retval .= 'file ...\\fR'; $retval .= 'file ...\\fP';
}
else
{
$retval .= shift(@words) . '\\fP';
while ($words[0] eq '|')
{
$retval .= ' ' . shift(@words);
$retval .= ' \\fI' . shift(@words);
$retval .= '\\fP';
}
} }
$arg = 1;
$nospace = 1 $nospace = 1
if (! $nospace); if (! $nospace && $words[0] =~ m/^[\.,]/);
next; next;
} }
if (/^Cm$/) { if (/^Cm$/)
$retval .= '\\fB' . (shift @words) . '\\fR'; {
$retval .= '\\fB' . (shift @words) . '\\fP';
while ($words[0] =~ m/^[\.,:)]$/)
{
$retval .= shift(@words);
}
next; next;
} }
if (/^Op$/) { if (/^Op$/)
{
$option = 1; $option = 1;
$nospace = 1 $nospace = 1
if (! $nospace); if (! $nospace);
$retval .= '['; $retval .= '[';
# my $tmp = pop(@words);
# $tmp .= ']';
# push(@words, $tmp);
next; next;
} }
if (/^Oo$/) { if (/^Pp$/)
$retval .= "[\\c\n"; {
$retval .= "\n";
next; next;
} }
if (/^Oc$/) { if (/^Ss$/)
$retval .= ']'; {
next;
}
if (/^Pp$/) {
if ($optlist) {
$retval .= "\n";
} else {
$retval .= '.LP';
}
next;
}
if (/^Ss$/) {
$retval .= '.SS'; $retval .= '.SS';
next; next;
} }
if (/^Pa$/ && ! $option) { if (/^Pa$/ && ! $option)
{
$retval .= '\\fI'; $retval .= '\\fI';
$retval .= '\\&' $retval .= '\\&'
if ($words[0] =~ m/^\./); if ($words[0] =~ m/^\./);
$retval .= (shift @words) . '\\fR'; $retval .= (shift @words) . '\\fP';
$nospace = 1 while ($words[0] =~ m/^[\.,:;)]$/)
if (! $nospace && $words[0] =~ m/^[\.,]/); {
$retval .= shift(@words);
}
# $nospace = 1
# if (! $nospace && $words[0] =~ m/^[\.,:)]/);
next; next;
} }
if (/^Dv$/) { if (/^Dv$/)
{
$retval .= '.BR'; $retval .= '.BR';
next; next;
} }
if (/^(Em|Ev)$/) { if (/^(Em|Ev)$/)
{
$retval .= '.IR'; $retval .= '.IR';
next; next;
} }
if (/^Pq$/) { if (/^Pq$/)
{
$retval .= '('; $retval .= '(';
$nospace = 1; $nospace = 1;
$parens = 1; $parens = 1;
next; next;
} }
if (/^(S[xy])$/) { if (/^(S[xy])$/)
{
$retval .= '.B ' . join(' ', @words); $retval .= '.B ' . join(' ', @words);
last; last;
} }
@ -270,48 +445,83 @@ sub ParseMacro # ($line)
while (defined $words[0] while (defined $words[0]
&& $words[0] !~ m/^[\.,]/) && $words[0] !~ m/^[\.,]/)
{ {
$retval .= shift @words; if ($words[0] eq 'Op')
{
shift(@words);
$retval .= '[';
my $tmp = pop(@words);
$tmp .= ']';
push(@words, $tmp);
next;
}
if ($words[0] eq 'Ar')
{
shift @words;
$retval .= '\\fI';
$retval .= shift @words;
$retval .= '\\fP';
}
else
{
$retval .= shift @words;
}
$retval .= ' ' $retval .= ' '
if (! $nospace); if (! $nospace);
} }
$retval =~ s/ $//; $retval =~ s/ $//;
$retval .= '\\fR'; $retval .= '\\fP';
$retval .= shift @words $retval .= shift @words
if (defined $words[0]); if (defined $words[0]);
last; last;
} }
if (/^Bl$/) { if (/^Bl$/)
if ($words[0] eq '-bullet') { {
$oldoptlist = $optlist;
if ($words[0] eq '-bullet')
{
$optlist = 1; $optlist = 1;
} elsif ($words[0] eq '-enum') { }
elsif ($words[0] eq '-enum')
{
$optlist = 2; $optlist = 2;
$enum = 0; $enum = 0;
} elsif ($words[0] eq '-tag') { }
elsif ($words[0] eq '-tag')
{
$optlist = 3; $optlist = 3;
} }
elsif ($words[0] eq '-item')
{
$optlist = 4;
}
last; last;
} }
if (/^El$/) { if (/^El$/)
$optlist = 0; {
$optlist = $oldoptlist;
next; next;
} }
if ($optlist && /^It$/) { if ($optlist && /^It$/)
if ($optlist == 1) { {
if ($optlist == 1)
{
# bullets # bullets
$retval .= '.IP \\(bu'; $retval .= '.IP \\(bu';
next; next;
} }
if ($optlist == 2) { if ($optlist == 2)
{
# enum # enum
$retval .= '.IP ' . (++$enum) . '.'; $retval .= '.IP ' . (++$enum) . '.';
next; next;
} }
if ($optlist == 3) { if ($optlist == 3)
{
# tags # tags
$retval .= ".TP\n"; $retval .= ".TP\n";
if ($words[0] =~ m/^(Pa|Ev)$/) if ($words[0] =~ m/^(Pa|Ev)$/)
@ -322,14 +532,25 @@ sub ParseMacro # ($line)
next; next;
} }
if ($optlist == 4)
{
# item
$retval .= ".IP\n";
next;
}
next; next;
} }
if (/^Sm$/) { if (/^Sm$/)
if ($words[0] eq 'off') { {
if ($words[0] eq 'off')
{
$nospace = 2; $nospace = 2;
} elsif ($words[0] eq 'on') { }
$retval .= "\n"; elsif ($words[0] eq 'on')
{
# $retval .= "\n";
$nospace = 0; $nospace = 0;
} }
shift @words; shift @words;
@ -343,7 +564,7 @@ sub ParseMacro # ($line)
if ($retval eq '.'); if ($retval eq '.');
$retval =~ s/^\.([^a-zA-Z])/$1/; $retval =~ s/^\.([^a-zA-Z])/$1/;
$retval =~ s/ $//; # $retval =~ s/ $//;
$retval .= ')' $retval .= ')'
if ($parens == 1); if ($parens == 1);
@ -351,14 +572,19 @@ sub ParseMacro # ($line)
$retval .= ']' $retval .= ']'
if ($option == 1); if ($option == 1);
$retval .= '\\fR' # $retval .= ' '
if ($arg); # if ($nospace && $retval ne '' && $retval !~ m/\n$/);
$retval .= '\\c' # $retval .= ' '
if ($nospace && $retval ne '' && $retval !~ m/\n$/); # if ($extended && $retval !~ m/ $/);
$retval .= ' '
if ($ext && ! $extopt && $retval !~ m/ $/);
$retval .= "\n" $retval .= "\n"
if ($retval ne '' && $retval !~ m/\n$/); if (! $ext && ! $extopt && $retval ne '' && $retval !~ m/\n$/);
return $retval; return $retval;
} }