From ba9375684d1cdbbd1dbacd2954b26c8dddd41c5e Mon Sep 17 00:00:00 2001
From: tg <tg@mirbsd.org>
Date: Tue, 17 Nov 2009 21:49:42 +0000
Subject: [PATCH] update portmdoc, sprinke a few more macros that now work

---
 mksh.1 | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 103 insertions(+), 8 deletions(-)

diff --git a/mksh.1 b/mksh.1
index 0932af3..0a65421 100644
--- a/mksh.1
+++ b/mksh.1
@@ -1,4 +1,4 @@
-.\" $MirOS: src/bin/mksh/mksh.1,v 1.195 2009/10/17 21:16:03 tg Exp $
+.\" $MirOS: src/bin/mksh/mksh.1,v 1.196 2009/11/17 21:49:42 tg Exp $
 .\" $OpenBSD: ksh.1,v 1.129 2009/05/28 06:09:06 jmc Exp $
 .\"-
 .\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
@@ -20,14 +20,31 @@
 .\" of said person’s immediate fault when using the work as intended.
 .\"-
 .\" Try to make GNU groff and AT&T nroff more compatible
-.\" * ` generates ‘ in groff, so use \`
-.\" * ' generates ’ in groff, \' generates ´, so use \*(aq
-.\" * - generates ‐ in groff, \- generates −, fixed in tmac/mdoc/doc-groff
+.\" * ` generates ‘ in gnroff, so use \`
+.\" * ' generates ’ in gnroff, \' generates ´, so use \*(aq
+.\" * - generates ‐ in gnroff, \- generates −, so .tr it to -
 .\"   thus use - for hyphens and \- for minus signs and option dashes
 .\" * ~ is size-reduced and placed atop in groff, so use \*(TI
 .\" * ^ is size-reduced and placed atop in groff, so use \*(ha
 .\" * \(en does not work in nroff, so use \*(en
+.\" The section after the "doc" macropackage has been loaded contains
+.\" additional code to convene between the UCB mdoc macropackage (and
+.\" its variant as BSD mdoc in groff) and the GNU mdoc macropackage.
+.\"
 .ie \n(.g \{\
+.	if \*[.T]ascii .tr \-\N'45'
+.	if \*[.T]latin1 .tr \-\N'45'
+.	if \*[.T]utf8 .tr \-\N'45'
+.	ds <= \[<=]
+.	ds >= \[>=]
+.	ds Rq \[rq]
+.	ds Lq \[lq]
+.	ds sL \(aq
+.	ds sR \(aq
+.	if \*[.T]utf8 .ds sL `
+.	if \*[.T]ps .ds sL `
+.	if \*[.T]utf8 .ds sR '
+.	if \*[.T]ps .ds sR '
 .	ds aq \(aq
 .	ds TI \(ti
 .	ds ha \(ha
@@ -39,7 +56,9 @@
 .	ds ha ^
 .	ds en \(em
 .\}
+.\"
 .\" Implement .Dd with the Mdocdate RCS keyword
+.\"
 .rn Dd xD
 .de Dd
 .ie \\$1$Mdocdate: \{\
@@ -47,8 +66,82 @@
 .\}
 .el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8
 ..
+.\"
+.\" .Dd must come before definition of .Mx, because when called
+.\" with -mandoc, it might implement .Mx itself, but we want to
+.\" use our own definition. And .Dd must come *first*, always.
+.\"
+.Dd $Mdocdate: November 17 2009 $
+.\"
+.\" Check which macro package we use
+.\"
+.ie \n(.g \{\
+.	ie d volume-ds-1 .ds tT gnu
+.	el .ds tT bsd
+.\}
+.el .ds tT ucb
+.\"
+.\" Implement .Mx (MirBSD)
+.\"
+.ie "\*(tT"gnu" \{\
+.	eo
+.	de Mx
+.	nr curr-font \n[.f]
+.	nr curr-size \n[.ps]
+.	ds str-Mx \f[\n[curr-font]]\s[\n[curr-size]u]
+.	ds str-Mx1 \*[Tn-font-size]\%MirOS\*[str-Mx]
+.	if !\n[arg-limit] \
+.	if \n[.$] \{\
+.	ds macro-name Mx
+.	parse-args \$@
+.	\}
+.	if (\n[arg-limit] > \n[arg-ptr]) \{\
+.	nr arg-ptr +1
+.	ie (\n[type\n[arg-ptr]] == 2) \
+.	as str-Mx1 \~\*[arg\n[arg-ptr]]
+.	el \
+.	nr arg-ptr -1
+.	\}
+.	ds arg\n[arg-ptr] "\*[str-Mx1]
+.	nr type\n[arg-ptr] 2
+.	ds space\n[arg-ptr] "\*[space]
+.	nr num-args (\n[arg-limit] - \n[arg-ptr])
+.	nr arg-limit \n[arg-ptr]
+.	if \n[num-args] \
+.	parse-space-vector
+.	print-recursive
+..
+.	ec
+.	ds sP \s0
+.	ds tN \*[Tn-font-size]
+.\}
+.el \{\
+.	de Mx
+.	nr cF \\n(.f
+.	nr cZ \\n(.s
+.	ds aa \&\f\\n(cF\s\\n(cZ
+.	if \\n(aC==0 \{\
+.		ie \\n(.$==0 \&MirOS\\*(aa
+.		el .aV \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
+.	\}
+.	if \\n(aC>\\n(aP \{\
+.		nr aP \\n(aP+1
+.		ie \\n(C\\n(aP==2 \{\
+.			as b1 \&MirOS\ #\&\\*(A\\n(aP\\*(aa
+.			ie \\n(aC>\\n(aP \{\
+.				nr aP \\n(aP+1
+.				nR
+.			\}
+.			el .aZ
+.		\}
+.		el \{\
+.			as b1 \&MirOS\\*(aa
+.			nR
+.		\}
+.	\}
+..
+.\}
 .\"-
-.Dd $Mdocdate: October 17 2009 $
 .Dt MKSH 1
 .Os MirBSD
 .Sh NAME
@@ -5767,7 +5860,7 @@ Privileged shell profile.
 .Rs
 .%A Stephen G. Kochan
 .%A Patrick H. Wood
-.%B "UNIX Shell Programming"
+.%B "\\*(tNUNIX\\*(sP Shell Programming"
 .%V "Revised Edition"
 .%D 1990
 .%I "Hayden"
@@ -5776,7 +5869,7 @@ Privileged shell profile.
 .Re
 .Rs
 .%A "IEEE Inc."
-.%B "IEEE Standard for Information Technology \*(en Portable Operating System Interface (POSIX)"
+.%B "\\*(tNIEEE\\*(sP Standard for Information Technology \*(en Portable Operating System Interface (POSIX)"
 .%V "Part 2: Shell and Utilities"
 .%D 1993
 .%I "IEEE Press"
@@ -5836,8 +5929,10 @@ for an operating environment supporting all of its advanced needs.
 Please report bugs in
 .Nm
 to the
+.Mx
+mailing list at
 .Aq miros\-discuss@mirbsd.org
-mailing list or in the
+or in the
 .Li \&#\&!/bin/mksh
 .Pq or Li \&#ksh
 IRC channel at