From: Harlan Stenn Date: Tue, 25 Dec 2012 05:14:20 +0000 (+0000) Subject: mdoc2texi fixes: Handle_ArCmFlIc, Handle_Fn, HandleQ X-Git-Tag: NTP_4_2_7P338~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e535bcabd72fce96332990849c665d9f2b3395bd;p=thirdparty%2Fntp.git mdoc2texi fixes: Handle_ArCmFlIc, Handle_Fn, HandleQ bk: 50d9362c7CiZFA1s5TTrwdUuemn2LQ --- diff --git a/ChangeLog b/ChangeLog index ee9d68a7f..7e6790512 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* mdoc2texi fixes: Handle_ArCmFlIc, Handle_Fn, HandleQ. * ntp-keygen autogen documentation updates. * ntpq autogen docs. (4.2.7p337) 2012/12/22 Released by Harlan Stenn diff --git a/sntp/ag-tpl/mdoc2texi b/sntp/ag-tpl/mdoc2texi index 99ab8cd7c..3e654a0b1 100755 --- a/sntp/ag-tpl/mdoc2texi +++ b/sntp/ag-tpl/mdoc2texi @@ -259,7 +259,6 @@ sub Handle_Em # .Em word word # .Em or Ap ing or'ing # - my ($pa_path); print '@emph{'; do { @@ -298,19 +297,27 @@ sub Handle_ArCmFlIc $spacing = 1; do { - if ($words[0] eq '' || $words[0] =~ /^[-\w]+$/) - { - print " " if $didOne && $spacing; - print "$font", $dash, $words[0], '}'; - } +#print STDERR "Handle_ArCmFlIc: top of loop, seeing <$words[0]>\n"; # XXX + + if (0) + { + } elsif ($words[0] eq '|') { +#print STDERR "Handle_ArCmFlIc: |\n"; # XXX print " " if $didOne && $spacing; print '@code{', $dash, '} ' if ($dash ne ""); print "$words[0]"; } + elsif ($words[0] eq '-') + { +#print STDERR "Handle_ArCmFlIc: -\n"; # XXX + print " " if $didOne && $spacing; + print '@code{', $dash, $words[0], '}'; + } elsif ($words[0] =~ /^"/) { +#print STDERR "Handle_ArCmFlIc: Quoted string...\n"; # XXX print " " if $didOne && $spacing; print '@code{'; print $dash if ($dash ne ""); # Do we need this? @@ -320,30 +327,78 @@ sub Handle_ArCmFlIc } elsif ($words[0] eq 'Ar') # Argument { +#print STDERR "Handle_ArCmFlIc: Ar\n"; # XXX $font = '@kbd{'; # slanted tty } elsif ($words[0] eq 'Ic') # Interactive/internal command { +#print STDERR "Handle_ArCmFlIc: Ic\n"; # XXX $font = '@code{'; } elsif ($words[0] eq 'Xc') { +#print STDERR "Handle_ArCmFlIc: Xc\n"; # XXX $spacing = 1; } elsif ($words[0] eq 'Xo') { +#print STDERR "Handle_ArCmFlIc: Xo\n"; # XXX $spacing = 0; } - else + elsif ($words[0] =~ /^[[:punct:]]$/) { - print "$words[0]"; +#print STDERR 'Handle_ArCmFlIc: punctuation',"\n"; # XXX + # print " " if $didOne && $spacing; + print $words[0]; + } + else # Should be empty or a word + { +#print STDERR "Handle_ArCmFlIc: emitting <$words[0]>\n"; # XXX + print " " if $didOne && $spacing; + print '@code{'; + print $dash if ($dash ne ""); # Do we need this? + print $words[0]; + print '}'; } shift @words; $didOne = 1; } while scalar(@words); +#print STDERR "Handle_ArCmFlIc: done\n"; # XXX print " "; } +sub Handle_Fn +{ + # Usage: .Fn [] ... + # .Fn getchar getchar() + # .Fn strlen ) , strlen()), + # .Fn align "char *pt" , alignchar *pt), + # + my ($didArg, $isOpen); + + print '@code{', $words[0], "}("; + $isOpen = 1; + shift; + + $didArg = 0; + while ($_ = shift @words) + { + if ($words[0] =~ /^"/) { + # assert $isOpen == 1 + print '@code{, }' if ($didArg); + ParseQuote(\@words); + print '@emph{', $words[0], "}"; + $didArg = 1; + } else { + print ")" if ($isOpen); + $isOpen = 0; + print $words[0]; + } + } + + print "\n"; +} + sub Handle_Nm { # Usage: .Nm [] ... @@ -436,7 +491,9 @@ sub Handle_Pa } print '@file{',"$pa_path","}"; - print join('', @words) if (@words > 0); + while ($_ = shift @words) { + print; + } print "\n"; } @@ -454,7 +511,8 @@ sub Handle_Q # .Sq ... Single quote: ... # - my ($lq,$rq); + my ($lq, $rq, $wc); + $wc = 0; # print STDERR "Handle_Q: <", join(' ', @words), ">\n"; # XXX @@ -474,7 +532,9 @@ sub Handle_Q print "$lq"; do { # print STDERR "Handle_Q: <$words[0]>\n"; # XXX + print " " if ($wc); print shift @words; + ++$wc; } while (@words > 0 || $words[0] =~ /^[[:punct:]]$/); print "$rq"; print join('', @words) if (@words > 0); @@ -635,6 +695,7 @@ sub ParseMacro #line elsif (/^\.Em$/) { Handle_Em(); } elsif (/^\.Eq/) { Handle_Q(); } elsif (/^\.Fl$/) { Handle_ArCmFlIc(); } + elsif (/^\.Fn$/) { Handle_Fn(); } elsif (/^\.Ic$/) { Handle_ArCmFlIc(); } elsif ($optlist && /^\.It$/) { last if (Handle_It()); } elsif (/^\.Nm$/) { Handle_Nm(); }