--- old/usr/src/cmd/Makefile	Wed Jul 16 14:05:06 2014
+++ new/usr/src/cmd/Makefile	Wed Jul 16 14:05:06 2014
@@ -24,11 +24,12 @@
 # Copyright (c) 2012 Joyent, Inc.  All rights reserved.
 # Copyright (c) 2012 by Delphix. All rights reserved.
 # Copyright (c) 2013 DEY Storage Systems, Inc. All rights reserved.
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
 
 include ../Makefile.master
 
 #
-#	Note that the commands 'agents', 'lp', 'perl', and 'man' are first in
+#	Note that the commands 'lp', and 'perl' are first in
 #	the list, violating alphabetical order.  This is because they are very
 #	long-running and should be given the most wall-clock time for a
 #	parallel build.
@@ -52,7 +53,6 @@
 	availdevs	\
 	lp		\
 	perl		\
-	man		\
 	Adm		\
 	abi		\
 	adbgen		\
@@ -252,6 +252,8 @@
 	mail		\
 	mailx		\
 	makekey		\
+	man		\
+	mandoc		\
 	mdb		\
 	mesg		\
 	mkdir		\
@@ -498,12 +500,11 @@
 	vntsd
 
 #
-# Commands that are messaged.  Note that 'lp' and 'man' come first
-# (see previous comment about 'lp' and 'man').
+# Commands that are messaged.  Note that 'lp' comes first
+# (see previous comment about 'lp'.)
 #
 MSGSUBDIRS=		\
 	lp		\
-	man		\
 	abi		\
 	acctadm		\
 	allocate	\
@@ -617,6 +618,7 @@
 	luxadm		\
 	lvm		\
 	mailx		\
+	man		\
 	mesg		\
 	mkdir		\
 	mkpwdict	\
--- old/usr/src/cmd/man/Makefile	Wed Jul 16 14:05:06 2014
+++ new/usr/src/cmd/man/Makefile	Wed Jul 16 14:05:06 2014
@@ -1,61 +1,46 @@
 #
-# CDDL HEADER START
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
 #
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License").  You may not use this file except in compliance
-# with the License.
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
 #
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
+
 #
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
+# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
 #
-# CDDL HEADER END
-#
-#
-#ident	"%Z%%M%	%I%	%E% SMI"
-#
-# Copyright (c) 1990 by Sun Microsystems, Inc.
-#
-# cmd/man/Makefile
 
-include ../Makefile.cmd
-SUBDIRS = src
+PROG=		man
+LINKS=		apropos whatis catman
+LIBLINKS =	makewhatis
+OBJS=		makewhatis.o man.o stringlist.o
+SRCS=		$(OBJS:%.o=%.c)
 
-all :=		TARGET= all
-install :=	TARGET= install
-clean :=	TARGET= clean
-clobber :=	TARGET= clobber
-lint :=		TARGET= lint
-_msg :=         TARGET= catalog
+include		$(SRC)/cmd/Makefile.cmd
 
-#for message catalog files
-POFILE = man.po
-POFILES = src/src.po
+CFLAGS +=	$(CCVERBOSE)
 
-.KEEP_STATE:
+ROOTLINKS=	$(LINKS:%=$(ROOTBIN)/%) $(LIBLINKS:%=$(ROOTLIB)/%)
 
-all install clean lint: $(SUBDIRS)
+.KEEP_STATE :
 
-clobber: $(SUBDIRS)	local_clobber
+all:		$(PROG)
 
-local_clobber:
-	$(RM)	$(CLOBBERFILES)
+clean:
+		$(RM) $(OBJS)
 
-_msg:   $(SUBDIRS)
-	$(RM)	$(POFILE)
-	cat $(POFILES)      > $(POFILE)
-	$(RM)  $(MSGDOMAIN)/$(POFILE)
-	cp $(POFILE) $(MSGDOMAIN)
+install:	all $(ROOTPROG) $(ROOTLINKS)
 
-$(SUBDIRS): FRC
-	@cd $@; pwd; $(MAKE) $(TARGET)
+lint: 		lint_SRCS
 
-FRC:
+$(PROG):	$(OBJS)
+		$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
+		$(POST_PROCESS)
+
+$(ROOTLINKS):	$(ROOTPROG)
+		$(RM) $@; $(LN) $(ROOTPROG) $@
+
+include		$(SRC)/cmd/Makefile.targ
--- /dev/null	Wed Jul 16 14:05:06 2014
+++ new/usr/src/cmd/man/THIRDPARTYLICENSE	Wed Jul 16 14:05:06 2014
@@ -0,0 +1,92 @@
+man.c:
+
+Copyright (c) 1980 Regents of the University of California.  
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    1. Redistributions of source code must retain the above copyright
+       notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above
+       copyright notice, this list of conditions and the following
+       disclaimer in the documentation and/or other materials provided
+       with the distribution.
+    3. All advertising materials mentioning features or use of this
+       software must display the following acknowledgement:
+           This product includes software developed by the University
+           of California, Berkeley and its contributors.
+    4. Neither the name of the University nor the names of its
+       contributors may be used to endorse or promote products derived
+       from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+makewhatis.c:
+
+Copyright (c) 2002 John Rochester
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer,
+   in this position and unchanged.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+stringlist.c, stringlist.h:
+
+Copyright (c) 1994 Christos Zoulas
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+4. The name of the author may not be used to endorse or promote products
+   derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
--- old/usr/src/cmd/man/src/THIRDPARTYLICENSE.descrip	Wed Jul 16 14:05:07 2014
+++ /dev/null	Wed Jul 16 14:05:06 2014
@@ -1,1 +0,0 @@
-PORTIONS OF MAN COMMAND FUNCTIONALITY
--- /dev/null	Wed Jul 16 14:05:06 2014
+++ new/usr/src/cmd/man/THIRDPARTYLICENSE.descrip	Wed Jul 16 14:05:07 2014
@@ -0,0 +1,1 @@
+PORTIONS OF MAN COMMAND FUNCTIONALITY
--- /dev/null	Wed Jul 16 14:05:07 2014
+++ new/usr/src/cmd/man/makewhatis.c	Wed Jul 16 14:05:07 2014
@@ -0,0 +1,827 @@
+/*
+ * Copyright (c) 2002 John Rochester
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer,
+ *    in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+
+#include <ctype.h>
+#include <dirent.h>
+#include <err.h>
+#include <signal.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "man.h"
+#include "stringlist.h"
+
+
+/* Information collected about each man page in a section */
+struct page_info {
+	char	*filename;
+	char	*name;
+	char	*suffix;
+	ino_t	inode;
+};
+
+/* An expanding string */
+struct sbuf {
+	char	*content;	/* the start of the buffer */
+	char	*end;		/* just past the end of the content */
+	char	*last;		/* the last allocated character */
+};
+
+/* Remove the last amount characters from the sbuf */
+#define	sbuf_retract(sbuf, amount) ((sbuf)->end -= (amount))
+/* Return the length of the sbuf content */
+#define	sbuf_length(sbuf) ((sbuf)->end - (sbuf)->content)
+
+typedef char *edited_copy(char *from, char *to, int length);
+
+/*
+ * While the whatis line is being formed, it is stored in whatis_proto.
+ * When finished, it is reformatted into whatis_final and then appended
+ * to whatis_lines.
+ */
+static struct sbuf	*whatis_proto;
+static struct sbuf	*whatis_final;
+static stringlist	*whatis_lines;	/* collected output lines */
+
+static char tempfile[MAXPATHLEN];	/* path of temporary file, if any */
+
+#define	MDOC_COMMANDS	"ArDvErEvFlLiNmPa"
+
+
+/* Free a struct page_info and its content */
+static void
+free_page_info(struct page_info *info)
+{
+
+	free(info->filename);
+	free(info->name);
+	free(info->suffix);
+	free(info);
+}
+
+/*
+ * Allocate and fill in a new struct page_info given the
+ * name of the man section directory and the dirent of the file.
+ * If the file is not a man page, return NULL.
+ */
+static struct page_info *
+new_page_info(char *dir, struct dirent *dirent)
+{
+	struct page_info *info;
+	int		basename_length;
+	char		*suffix;
+	struct stat	st;
+
+	if ((info = malloc(sizeof (struct page_info))) == NULL)
+		err(1, "malloc");
+	basename_length = strlen(dirent->d_name);
+	suffix = &dirent->d_name[basename_length];
+	if (asprintf(&info->filename, "%s/%s", dir, dirent->d_name) == -1)
+		err(1, "asprintf");
+	for (;;) {
+		if (--suffix == dirent->d_name || !isalnum(*suffix)) {
+			if (*suffix == '.')
+				break;
+			free(info->filename);
+			free(info);
+			return (NULL);
+		}
+	}
+	*suffix++ = '\0';
+	info->name = strdup(dirent->d_name);
+	info->suffix = strdup(suffix);
+	if (stat(info->filename, &st) < 0) {
+		warn("%s", info->filename);
+		free_page_info(info);
+		return (NULL);
+	}
+	if (!S_ISREG(st.st_mode)) {
+		free_page_info(info);
+		return (NULL);
+	}
+	info->inode = st.st_ino;
+	return (info);
+}
+
+/*
+ * Reset sbuf length to 0.
+ */
+static void
+sbuf_clear(struct sbuf *sbuf)
+{
+
+	sbuf->end = sbuf->content;
+}
+
+/*
+ * Allocate a new sbuf.
+ */
+static struct sbuf *
+new_sbuf(void)
+{
+	struct sbuf	*sbuf;
+
+	if ((sbuf = malloc(sizeof (struct sbuf))) == NULL)
+		err(1, "malloc");
+	if ((sbuf->content = (char *)malloc(LINE_ALLOC)) == NULL)
+		err(1, "malloc");
+	sbuf->last = sbuf->content + LINE_ALLOC - 1;
+	sbuf_clear(sbuf);
+
+	return (sbuf);
+}
+
+/*
+ * Ensure that there is enough room in the sbuf
+ * for nchars more characters.
+ */
+static void
+sbuf_need(struct sbuf *sbuf, int nchars)
+{
+	char *new_content;
+	size_t size, cntsize;
+
+	/* Double the size of the allocation until the buffer is big enough */
+	while (sbuf->end + nchars > sbuf->last) {
+		size = sbuf->last + 1 - sbuf->content;
+		size *= 2;
+		cntsize = sbuf->end - sbuf->content;
+
+		new_content = (char *)malloc(size);
+		(void) memcpy(new_content, sbuf->content, cntsize);
+		free(sbuf->content);
+		sbuf->content = new_content;
+		sbuf->end = new_content + cntsize;
+		sbuf->last = new_content + size - 1;
+	}
+}
+
+/*
+ * Append a string of a given length to the sbuf.
+ */
+static void
+sbuf_append(struct sbuf *sbuf, const char *text, int length)
+{
+	if (length > 0) {
+		sbuf_need(sbuf, length);
+		(void) memcpy(sbuf->end, text, length);
+		sbuf->end += length;
+	}
+}
+
+/*
+ * Append a null-terminated string to the sbuf.
+ */
+static void
+sbuf_append_str(struct sbuf *sbuf, char *text)
+{
+
+	sbuf_append(sbuf, text, strlen(text));
+}
+
+/*
+ * Append an edited null-terminated string to the sbuf.
+ */
+static void
+sbuf_append_edited(struct sbuf *sbuf, char *text, edited_copy copy)
+{
+	int	length;
+
+	if ((length = strlen(text)) > 0) {
+		sbuf_need(sbuf, length);
+		sbuf->end = copy(text, sbuf->end, length);
+	}
+}
+
+/*
+ * Strip any of a set of chars from the end of the sbuf.
+ */
+static void
+sbuf_strip(struct sbuf *sbuf, const char *set)
+{
+
+	while (sbuf->end > sbuf->content && strchr(set, sbuf->end[-1]) != NULL)
+		sbuf->end--;
+}
+
+/*
+ * Return the null-terminated string built by the sbuf.
+ */
+static char *
+sbuf_content(struct sbuf *sbuf)
+{
+
+	*sbuf->end = '\0';
+	return (sbuf->content);
+}
+
+/*
+ * Return true if no man page exists in the directory with
+ * any of the names in the stringlist.
+ */
+static int
+no_page_exists(char *dir, stringlist *names, char *suffix)
+{
+	char	path[MAXPATHLEN];
+	size_t	i;
+
+	for (i = 0; i < names->sl_cur; i++) {
+		(void) snprintf(path, MAXPATHLEN, "%s/%s.%s.gz",
+		    dir, names->sl_str[i], suffix);
+		if (access(path, F_OK) < 0) {
+			path[strlen(path) - 3] = '\0';
+			if (access(path, F_OK) < 0)
+				continue;
+		}
+		return (0);
+	}
+	return (1);
+}
+
+/* ARGSUSED sig */
+static void
+trap_signal(int sig)
+{
+
+	if (tempfile[0] != '\0')
+		(void) unlink(tempfile);
+
+	exit(1);
+}
+
+/*
+ * Attempt to open an output file.
+ * Return NULL if unsuccessful.
+ */
+static FILE *
+open_output(char *name)
+{
+	FILE	*output;
+
+	whatis_lines = sl_init();
+	(void) snprintf(tempfile, MAXPATHLEN, "%s.tmp", name);
+	name = tempfile;
+	if ((output = fopen(name, "w")) == NULL) {
+		warn("%s", name);
+		return (NULL);
+	}
+	return (output);
+}
+
+static int
+linesort(const void *a, const void *b)
+{
+
+	return (strcmp((*(const char * const *)a), (*(const char * const *)b)));
+}
+
+/*
+ * Write the unique sorted lines to the output file.
+ */
+static void
+finish_output(FILE *output, char *name)
+{
+	size_t	i;
+	char	*prev = NULL;
+
+	qsort(whatis_lines->sl_str, whatis_lines->sl_cur, sizeof (char *),
+	    linesort);
+	for (i = 0; i < whatis_lines->sl_cur; i++) {
+		char *line = whatis_lines->sl_str[i];
+		if (i > 0 && strcmp(line, prev) == 0)
+			continue;
+		prev = line;
+		(void) fputs(line, output);
+		(void) putc('\n', output);
+	}
+	(void) fclose(output);
+	sl_free(whatis_lines, 1);
+	(void) rename(tempfile, name);
+	(void) unlink(tempfile);
+}
+
+static FILE *
+open_whatis(char *mandir)
+{
+	char	filename[MAXPATHLEN];
+
+	(void) snprintf(filename, MAXPATHLEN, "%s/%s", mandir, WHATIS);
+	return (open_output(filename));
+}
+
+static void
+finish_whatis(FILE *output, char *mandir)
+{
+	char	filename[MAXPATHLEN];
+
+	(void) snprintf(filename, MAXPATHLEN, "%s/%s", mandir, WHATIS);
+	finish_output(output, filename);
+}
+
+/*
+ * Remove trailing spaces from a string, returning a pointer to just
+ * beyond the new last character.
+ */
+static char *
+trim_rhs(char *str)
+{
+	char	*rhs;
+
+	rhs = &str[strlen(str)];
+	while (--rhs > str && isspace(*rhs))
+		;
+	*++rhs = '\0';
+	return (rhs);
+}
+
+/*
+ * Return a pointer to the next non-space character in the string.
+ */
+static char *
+skip_spaces(char *s)
+{
+
+	while (*s != '\0' && isspace(*s))
+		s++;
+
+	return (s);
+}
+
+/*
+ * Return whether the line is of one of the forms:
+ *	.Sh NAME
+ *	.Sh "NAME"
+ *	etc.
+ * assuming that section_start is ".Sh".
+ */
+static int
+name_section_line(char *line, const char *section_start)
+{
+	char		*rhs;
+
+	if (strncmp(line, section_start, 3) != 0)
+		return (0);
+	line = skip_spaces(line + 3);
+	rhs = trim_rhs(line);
+	if (*line == '"') {
+		line++;
+		if (*--rhs == '"')
+			*rhs = '\0';
+	}
+	if (strcmp(line, "NAME") == 0)
+		return (1);
+
+	return (0);
+}
+
+/*
+ * Copy characters while removing the most common nroff/troff markup:
+ *	\(em, \(mi, \s[+-N], \&
+ *	\fF, \f(fo, \f[font]
+ *	\*s, \*(st, \*[stringvar]
+ */
+static char *
+de_nroff_copy(char *from, char *to, int fromlen)
+{
+	char	*from_end = &from[fromlen];
+
+	while (from < from_end) {
+		switch (*from) {
+		case '\\':
+			switch (*++from) {
+			case '(':
+				if (strncmp(&from[1], "em", 2) == 0 ||
+				    strncmp(&from[1], "mi", 2) == 0) {
+					from += 3;
+					continue;
+				}
+				break;
+			case 's':
+				if (*++from == '-')
+					from++;
+				while (isdigit(*from))
+					from++;
+				continue;
+			case 'f':
+			case '*':
+				if (*++from == '(') {
+					from += 3;
+				} else if (*from == '[') {
+					while (*++from != ']' &&
+					    from < from_end)
+						;
+					from++;
+				} else {
+					from++;
+				}
+				continue;
+			case '&':
+				from++;
+				continue;
+			}
+			break;
+		}
+		*to++ = *from++;
+	}
+	return (to);
+}
+
+/*
+ * Append a string with the nroff formatting removed.
+ */
+static void
+add_nroff(char *text)
+{
+
+	sbuf_append_edited(whatis_proto, text, de_nroff_copy);
+}
+
+/*
+ * Appends "name(suffix), " to whatis_final
+ */
+static void
+add_whatis_name(char *name, char *suffix)
+{
+
+	if (*name != '\0') {
+		sbuf_append_str(whatis_final, name);
+		sbuf_append(whatis_final, "(", 1);
+		sbuf_append_str(whatis_final, suffix);
+		sbuf_append(whatis_final, "), ", 3);
+	}
+}
+
+/*
+ * Processes an old-style man(7) line. This ignores commands with only
+ * a single number argument.
+ */
+static void
+process_man_line(char *line)
+{
+	char	*p;
+
+	if (*line == '.') {
+		while (isalpha(*++line))
+			;
+		p = line = skip_spaces(line);
+		while (*p != '\0') {
+			if (!isdigit(*p))
+				break;
+			p++;
+		}
+		if (*p == '\0')
+			return;
+	} else
+		line = skip_spaces(line);
+	if (*line != '\0') {
+		add_nroff(line);
+		sbuf_append(whatis_proto, " ", 1);
+	}
+}
+
+/*
+ * Processes a new-style mdoc(7) line.
+ */
+static void
+process_mdoc_line(char *line)
+{
+	int	xref;
+	int	arg = 0;
+	char	*line_end = &line[strlen(line)];
+	int	orig_length = sbuf_length(whatis_proto);
+	char	*next;
+
+	if (*line == '\0')
+		return;
+	if (line[0] != '.' || !isupper(line[1]) || !islower(line[2])) {
+		add_nroff(skip_spaces(line));
+		sbuf_append(whatis_proto, " ", 1);
+		return;
+	}
+	xref = strncmp(line, ".Xr", 3) == 0;
+	line += 3;
+	while ((line = skip_spaces(line)) < line_end) {
+		if (*line == '"') {
+			next = ++line;
+			for (;;) {
+				next = strchr(next, '"');
+				if (next == NULL)
+					break;
+				(void) memmove(next, next + 1, strlen(next));
+				line_end--;
+				if (*next != '"')
+					break;
+				next++;
+			}
+		} else {
+			next = strpbrk(line, " \t");
+		}
+		if (next != NULL)
+			*next++ = '\0';
+		else
+			next = line_end;
+		if (isupper(*line) && islower(line[1]) && line[2] == '\0') {
+			if (strcmp(line, "Ns") == 0) {
+				arg = 0;
+				line = next;
+				continue;
+			}
+			if (strstr(line, MDOC_COMMANDS) != NULL) {
+				line = next;
+				continue;
+			}
+		}
+		if (arg > 0 && strchr(",.:;?!)]", *line) == 0) {
+			if (xref) {
+				sbuf_append(whatis_proto, "(", 1);
+				add_nroff(line);
+				sbuf_append(whatis_proto, ")", 1);
+				xref = 0;
+			} else {
+				sbuf_append(whatis_proto, " ", 1);
+			}
+		}
+		add_nroff(line);
+		arg++;
+		line = next;
+	}
+	if (sbuf_length(whatis_proto) > orig_length)
+		sbuf_append(whatis_proto, " ", 1);
+}
+
+/*
+ * Collect a list of comma-separated names from the text.
+ */
+static void
+collect_names(stringlist *names, char *text)
+{
+	char	*arg;
+
+	for (;;) {
+		arg = text;
+		text = strchr(text, ',');
+		if (text != NULL)
+			*text++ = '\0';
+		(void) sl_add(names, arg);
+		if (text == NULL)
+			return;
+		if (*text == ' ')
+			text++;
+	}
+}
+
+enum { STATE_UNKNOWN, STATE_MANSTYLE, STATE_MDOCNAME, STATE_MDOCDESC };
+
+/*
+ * Process a man page source into a single whatis line and add it
+ * to whatis_lines.
+ */
+static void
+process_page(struct page_info *page, char *section_dir)
+{
+	FILE		*fp;
+	stringlist	*names;
+	char		*descr;
+	int		state = STATE_UNKNOWN;
+	size_t		i;
+	char		*line = NULL;
+	size_t		linecap = 0;
+
+	sbuf_clear(whatis_proto);
+	if ((fp = fopen(page->filename, "r")) == NULL) {
+		warn("%s", page->filename);
+		return;
+	}
+	while (getline(&line, &linecap, fp) > 0) {
+		/* Skip comments */
+		if (strncmp(line, ".\\\"", 3) == 0)
+			continue;
+		switch (state) {
+		/* Haven't reached the NAME section yet */
+		case STATE_UNKNOWN:
+			if (name_section_line(line, ".SH"))
+				state = STATE_MANSTYLE;
+			else if (name_section_line(line, ".Sh"))
+				state = STATE_MDOCNAME;
+			continue;
+		/* Inside an old-style .SH NAME section */
+		case STATE_MANSTYLE:
+			if (strncmp(line, ".SH", 3) == 0 ||
+			    strncmp(line, ".SS", 3) == 0)
+				break;
+			(void) trim_rhs(line);
+			if (strcmp(line, ".") == 0)
+				continue;
+			if (strncmp(line, ".IX", 3) == 0) {
+				line += 3;
+				line = skip_spaces(line);
+			}
+			process_man_line(line);
+			continue;
+		/* Inside a new-style .Sh NAME section (the .Nm part) */
+		case STATE_MDOCNAME:
+			(void) trim_rhs(line);
+			if (strncmp(line, ".Nm", 3) == 0) {
+				process_mdoc_line(line);
+				continue;
+			} else {
+				if (strcmp(line, ".") == 0)
+					continue;
+				sbuf_append(whatis_proto, "- ", 2);
+				state = STATE_MDOCDESC;
+			}
+			/* FALLTHROUGH */
+		/* Inside a new-style .Sh NAME section (after the .Nm-s) */
+		case STATE_MDOCDESC:
+			if (strncmp(line, ".Sh", 3) == 0)
+				break;
+			(void) trim_rhs(line);
+			if (strcmp(line, ".") == 0)
+				continue;
+			process_mdoc_line(line);
+			continue;
+		}
+		break;
+	}
+	(void) fclose(fp);
+	sbuf_strip(whatis_proto, " \t.-");
+	line = sbuf_content(whatis_proto);
+	/*
+	 * Line now contains the appropriate data, but without the
+	 * proper indentation or the section appended to each name.
+	 */
+	descr = strstr(line, " - ");
+	if (descr == NULL) {
+		descr = strchr(line, ' ');
+		if (descr == NULL)
+			return;
+		*descr++ = '\0';
+	} else {
+		*descr = '\0';
+		descr += 3;
+	}
+	names = sl_init();
+	collect_names(names, line);
+	sbuf_clear(whatis_final);
+	if (!sl_find(names, page->name) &&
+	    no_page_exists(section_dir, names, page->suffix)) {
+		/*
+		 * Add the page name since that's the only
+		 * thing that man(1) will find.
+		 */
+		add_whatis_name(page->name, page->suffix);
+	}
+	for (i = 0; i < names->sl_cur; i++)
+		add_whatis_name(names->sl_str[i], page->suffix);
+	sl_free(names, 0);
+	/* Remove last ", " */
+	sbuf_retract(whatis_final, 2);
+	while (sbuf_length(whatis_final) < INDENT)
+		sbuf_append(whatis_final, " ", 1);
+	sbuf_append(whatis_final, " - ", 3);
+	sbuf_append_str(whatis_final, skip_spaces(descr));
+	(void) sl_add(whatis_lines, strdup(sbuf_content(whatis_final)));
+}
+
+/*
+ * Sort pages first by inode number, then by name.
+ */
+static int
+pagesort(const void *a, const void *b)
+{
+	const struct page_info *p1 = *(struct page_info * const *) a;
+	const struct page_info *p2 = *(struct page_info * const *) b;
+
+	if (p1->inode == p2->inode)
+		return (strcmp(p1->name, p2->name));
+
+	return (p1->inode - p2->inode);
+}
+
+/*
+ * Process a single man section.
+ */
+static void
+process_section(char *section_dir)
+{
+	struct dirent	**entries;
+	int		nentries;
+	struct page_info **pages;
+	int		npages = 0;
+	int		i;
+	ino_t		prev_inode = 0;
+
+	/* Scan the man section directory for pages */
+	nentries = scandir(section_dir, &entries, NULL, alphasort);
+
+	/* Collect information about man pages */
+	pages = (struct page_info **)calloc(nentries,
+	    sizeof (struct page_info *));
+	for (i = 0; i < nentries; i++) {
+		struct page_info *info = new_page_info(section_dir, entries[i]);
+		if (info != NULL)
+			pages[npages++] = info;
+		free(entries[i]);
+	}
+	free(entries);
+	qsort(pages, npages, sizeof (struct page_info *), pagesort);
+
+	/* Process each unique page */
+	for (i = 0; i < npages; i++) {
+		struct page_info *page = pages[i];
+		if (page->inode != prev_inode) {
+			prev_inode = page->inode;
+			process_page(page, section_dir);
+		}
+		free_page_info(page);
+	}
+	free(pages);
+}
+
+/*
+ * Return whether the directory entry is a man page section.
+ */
+static int
+select_sections(const struct dirent *entry)
+{
+	const char	*p = &entry->d_name[3];
+
+	if (strncmp(entry->d_name, "man", 3) != 0)
+		return (0);
+	while (*p != '\0') {
+		if (!isalnum(*p++))
+			return (0);
+	}
+	return (1);
+}
+
+/*
+ * Process a single top-level man directory by finding all the
+ * sub-directories named man* and processing each one in turn.
+ */
+void
+mwpath(char *path)
+{
+	FILE		*fp = NULL;
+	struct dirent	**entries;
+	int		nsections;
+	int		i;
+
+	(void) signal(SIGINT, trap_signal);
+	(void) signal(SIGHUP, trap_signal);
+	(void) signal(SIGQUIT, trap_signal);
+	(void) signal(SIGTERM, trap_signal);
+
+	whatis_proto = new_sbuf();
+	whatis_final = new_sbuf();
+
+	nsections = scandir(path, &entries, select_sections, alphasort);
+	if ((fp = open_whatis(path)) == NULL)
+		return;
+	for (i = 0; i < nsections; i++) {
+		char	section_dir[MAXPATHLEN];
+
+		(void) snprintf(section_dir, MAXPATHLEN, "%s/%s",
+		    path, entries[i]->d_name);
+		process_section(section_dir);
+		free(entries[i]);
+	}
+	free(entries);
+	finish_whatis(fp, path);
+}
--- /dev/null	Wed Jul 16 14:05:07 2014
+++ new/usr/src/cmd/man/man.c	Wed Jul 16 14:05:07 2014
@@ -0,0 +1,1603 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012, Josef 'Jeff' Sipek <jeffpc@31bits.net>. All rights reserved.
+ * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
+ */
+
+/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989  AT&T.	*/
+/*		All rights reserved.					*/
+
+/*
+ * University Copyright- Copyright (c) 1982, 1986, 1988
+ * The Regents of the University of California
+ * All Rights Reserved
+ *
+ * University Acknowledgment- Portions of this document are derived from
+ * software developed by the University of California, Berkeley, and its
+ * contributors.
+ */
+
+/*
+ * Find and display reference manual pages. This version includes makewhatis
+ * functionality as well.
+ */
+
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/termios.h>
+#include <sys/types.h>
+
+#include <ctype.h>
+#include <dirent.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <fnmatch.h>
+#include <limits.h>
+#include <locale.h>
+#include <malloc.h>
+#include <memory.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "man.h"
+
+
+/* Mapping of old directories to new directories */
+static const struct map_entry {
+	char	*old_name;
+	char	*new_name;
+} map[] = {
+	{ "3b",		"3ucb"		},
+	{ "3e",		"3elf"		},
+	{ "3g",		"3gen"		},
+	{ "3k",		"3kstat"	},
+	{ "3n",		"3socket"	},
+	{ "3r",		"3rt"		},
+	{ "3s",		"3c"		},
+	{ "3t",		"3thr"		},
+	{ "3x",		"3curses"	},
+	{ "3xc",	"3xcurses"	},
+	{ "3xn",	"3xnet"		}
+};
+
+struct suffix {
+	char *ds;
+	char *fs;
+};
+
+/*
+ * Flags that control behavior of build_manpath()
+ *
+ *   BMP_ISPATH 		pathv is a vector constructed from PATH.
+ *                		Perform appropriate path translations for
+ * 				manpath.
+ *   BMP_APPEND_DEFMANDIR	Add DEFMANDIR to the end if it hasn't
+ *				already appeared earlier.
+ *   BMP_FALLBACK_DEFMANDIR	Append /usr/share/man only if no other
+ *				manpath (including derived from PATH)
+ * 				elements are valid.
+ */
+#define	BMP_ISPATH		1
+#define	BMP_APPEND_DEFMANDIR	2
+#define	BMP_FALLBACK_DEFMANDIR	4
+
+/*
+ * When doing equality comparisons of directories, device and inode
+ * comparisons are done.  The secnode and dupnode structures are used
+ * to form a list of lists for this processing.
+ */
+struct secnode {
+	char		*secp;
+	struct secnode	*next;
+};
+struct dupnode {
+	dev_t		dev;	/* from struct stat st_dev */
+	ino_t		ino;	/* from struct stat st_ino */
+	struct secnode	*secl;	/* sections already considered */
+	struct dupnode	*next;
+};
+
+/*
+ * Map directories that may appear in PATH to the corresponding
+ * man directory.
+ */
+static struct pathmap {
+	char	*bindir;
+	char	*mandir;
+	dev_t	dev;
+	ino_t	ino;
+} bintoman[] = {
+	{ "/sbin",		"/usr/share/man,1m",		0, 0 },
+	{ "/usr/sbin",		"/usr/share/man,1m",		0, 0 },
+	{ "/usr/ucb",		"/usr/share/man,1b",		0, 0 },
+	{ "/usr/bin",		"/usr/share/man,1,1m,1s,1t,1c", 0, 0 },
+	{ "/usr/xpg4/bin",	"/usr/share/man,1",		0, 0 },
+	{ "/usr/xpg6/bin",	"/usr/share/man,1",		0, 0 },
+	{ NULL,			NULL,				0, 0 }
+};
+
+struct man_node {
+	char		*path;		/* mandir path */
+	char		**secv;		/* submandir suffices */
+	int		defsrch;	/* hint for man -p */
+	int		frompath;	/* hint for man -d */
+	struct man_node *next;
+};
+
+static int	all = 0;
+static int	apropos = 0;
+static int	debug = 0;
+static int	found = 0;
+static int	list = 0;
+static int	makewhatis = 0;
+static int	printmp = 0;
+static int	sargs = 0;
+static int	psoutput = 0;
+static int	whatis = 0;
+static int	makewhatishere = 0;
+
+static char	*mansec;
+static char	*pager;
+
+static char	*addlocale(char *);
+static struct man_node *build_manpath(char **, int);
+static void	do_makewhatis(struct man_node *);
+static char	*check_config(char *);
+static int	cmp(const void *, const void *);
+static int	dupcheck(struct man_node *, struct dupnode **);
+static int	format(char *, char *, char *, char *);
+static void	free_dupnode(struct dupnode *);
+static void	free_manp(struct man_node *manp);
+static void	freev(char **);
+static void	fullpaths(struct man_node **);
+static void	get_all_sect(struct man_node *);
+static int	getdirs(char *, char ***, int);
+static void	getpath(struct man_node *, char **);
+static void	getsect(struct man_node *, char **);
+static void	init_bintoman(void);
+static void	lower(char *);
+static void	mandir(char **, char *, char *, int);
+static int	manual(struct man_node *, char *);
+static char	*map_section(char *, char *);
+static char	*path_to_manpath(char *);
+static void	print_manpath(struct man_node *);
+static void	search_whatis(char *, char *);
+static int	searchdir(char *, char *, char *);
+static void	sortdir(DIR *, char ***);
+static char	**split(char *, char);
+static void	usage_man(void);
+static void	usage_whatapro(void);
+static void	usage_catman(void);
+static void	usage_makewhatis(void);
+static void	whatapro(struct man_node *, char *);
+
+static char	language[MAXPATHLEN]; 	/* LC_MESSAGES */
+static char	localedir[MAXPATHLEN];	/* locale specific path component */
+
+static char	*newsection = NULL;
+
+static int	manwidth = 0;
+
+extern const char	*__progname;
+
+int
+main(int argc, char **argv)
+{
+	int		c, i;
+	char		**pathv;
+	char		*manpath = NULL;
+	static struct man_node *mandirs = NULL;
+	int		bmp_flags = 0;
+	int		ret = 0;
+	char		*opts;
+	char		*mwstr;
+	int		catman = 0;
+
+	(void) setlocale(LC_ALL, "");
+	(void) strcpy(language, setlocale(LC_MESSAGES, (char *)NULL));
+	if (strcmp("C", language) != 0)
+		(void) strlcpy(localedir, language, MAXPATHLEN);
+
+#if !defined(TEXT_DOMAIN)
+#define	TEXT_DOMAIN "SYS_TEST"
+#endif
+	(void) textdomain(TEXT_DOMAIN);
+
+	if (strcmp(__progname, "apropos") == 0) {
+		apropos++;
+		opts = "M:ds:";
+	} else if (strcmp(__progname, "whatis") == 0) {
+		apropos++;
+		whatis++;
+		opts = "M:ds:";
+	} else if (strcmp(__progname, "catman") == 0) {
+		catman++;
+		makewhatis++;
+		opts = "M:w";
+	} else if (strcmp(__progname, "makewhatis") == 0) {
+		makewhatis++;
+		makewhatishere++;
+		manpath = ".";
+		opts = "";
+	} else {
+		opts = "M:adfklps:tw";
+	}
+
+	opterr = 0;
+	while ((c = getopt(argc, argv, opts)) != -1) {
+		switch (c) {
+		case 'M':	/* Respecify path for man pages */
+			manpath = optarg;
+			break;
+		case 'a':
+			all++;
+			break;
+		case 'd':
+			debug++;
+			break;
+		case 'f':
+			whatis++;
+			/*FALLTHROUGH*/
+		case 'k':
+			apropos++;
+			break;
+		case 'l':
+			list++;
+			/*FALLTHROUGH*/
+		case 'p':
+			printmp++;
+			break;
+		case 's':
+			mansec = optarg;
+			sargs++;
+			break;
+		case 't':
+			psoutput++;
+			break;
+		case 'w':
+			makewhatis++;
+			break;
+		case '?':
+		default:
+			if (apropos)
+				usage_whatapro();
+			else if (catman)
+				usage_catman();
+			else if (makewhatishere)
+				usage_makewhatis();
+			else
+				usage_man();
+		}
+	}
+	argc -= optind;
+	argv += optind;
+
+	if (argc == 0) {
+		if (apropos) {
+			(void) fprintf(stderr, gettext("%s what?\n"),
+			    __progname);
+			exit(1);
+		} else if (!printmp && !makewhatis) {
+			(void) fprintf(stderr,
+			    gettext("What manual page do you want?\n"));
+			exit(1);
+		}
+	}
+
+	init_bintoman();
+	if (manpath == NULL && (manpath = getenv("MANPATH")) == NULL) {
+		if ((manpath = getenv("PATH")) != NULL)
+			bmp_flags = BMP_ISPATH | BMP_APPEND_DEFMANDIR;
+		else
+			manpath = DEFMANDIR;
+	}
+	pathv = split(manpath, ':');
+	mandirs = build_manpath(pathv, bmp_flags);
+	freev(pathv);
+	fullpaths(&mandirs);
+
+	if (makewhatis) {
+		do_makewhatis(mandirs);
+		exit(0);
+	}
+
+	if (printmp) {
+		print_manpath(mandirs);
+		exit(0);
+	}
+
+	/* Collect environment information */
+	if (isatty(STDOUT_FILENO) && (mwstr = getenv("MANWIDTH")) != NULL &&
+	    *mwstr != '\0') {
+		if (strcasecmp(mwstr, "tty") == 0) {
+			struct winsize	ws;
+
+			if (ioctl(0, TIOCGWINSZ, &ws) != 0)
+				warn("TIOCGWINSZ");
+			else
+				manwidth = ws.ws_col;
+		} else {
+			manwidth = (int)strtol(mwstr, (char **)NULL, 10);
+			if (manwidth < 0)
+				manwidth = 0;
+		}
+	}
+	if (manwidth != 0) {
+		DPRINTF("-- Using non-standard page width: %d\n", manwidth);
+	}
+
+	if ((pager = getenv("PAGER")) == NULL || *pager == '\0')
+		pager = PAGER;
+	DPRINTF("-- Using pager: %s\n", pager);
+
+	for (i = 0; i < argc; i++) {
+		char		*cmd;
+		static struct man_node *mp;
+		char		*pv[2];
+
+		/*
+		 * If full path to command specified, customize
+		 * the manpath accordingly.
+		 */
+		if ((cmd = strrchr(argv[i], '/')) != NULL) {
+			*cmd = '\0';
+			if ((pv[0] = strdup(argv[i])) == NULL)
+				err(1, "strdup");
+			pv[1] = NULL;
+			*cmd = '/';
+			mp = build_manpath(pv,
+			    BMP_ISPATH | BMP_FALLBACK_DEFMANDIR);
+		} else {
+			mp = mandirs;
+		}
+
+		if (apropos)
+			whatapro(mp, argv[i]);
+		else
+			ret += manual(mp, argv[i]);
+
+		if (mp != NULL && mp != mandirs) {
+			free(pv[0]);
+			free_manp(mp);
+		}
+	}
+
+	return (ret == 0 ? 0 : 1);
+}
+
+/*
+ * This routine builds the manpage structure from MANPATH or PATH,
+ * depending on flags.  See BMP_* definitions above for valid
+ * flags.
+ */
+static struct man_node *
+build_manpath(char **pathv, int flags)
+{
+	struct man_node *manpage = NULL;
+	struct man_node *currp = NULL;
+	struct man_node *lastp = NULL;
+	char		**p;
+	char		**q;
+	char		*mand = NULL;
+	char		*mandir = DEFMANDIR;
+	int		s;
+	struct dupnode	*didup = NULL;
+	struct stat	sb;
+
+	s = sizeof (struct man_node);
+	for (p = pathv; *p != NULL; ) {
+		if (flags & BMP_ISPATH) {
+			if ((mand = path_to_manpath(*p)) == NULL)
+				goto next;
+			free(*p);
+			*p = mand;
+		}
+		q = split(*p, ',');
+		if (stat(q[0], &sb) != 0 || (sb.st_mode & S_IFDIR) == 0) {
+			freev(q);
+			goto next;
+		}
+
+		if (access(q[0], R_OK | X_OK) == 0) {
+			/*
+			 * Some element exists.  Do not append DEFMANDIR as a
+			 * fallback.
+			 */
+			flags &= ~BMP_FALLBACK_DEFMANDIR;
+
+			if ((currp = (struct man_node *)calloc(1, s)) == NULL)
+				err(1, "calloc");
+
+			currp->frompath = (flags & BMP_ISPATH);
+
+			if (manpage == NULL)
+				lastp = manpage = currp;
+
+			getpath(currp, p);
+			getsect(currp, p);
+
+			/*
+			 * If there are no new elements in this path,
+			 * do not add it to the manpage list.
+			 */
+			if (dupcheck(currp, &didup) != 0) {
+				freev(currp->secv);
+				free(currp);
+			} else {
+				currp->next = NULL;
+				if (currp != manpage)
+					lastp->next = currp;
+				lastp = currp;
+			}
+		}
+		freev(q);
+next:
+		/*
+		 * Special handling of appending DEFMANDIR. After all pathv
+		 * elements have been processed, append DEFMANDIR if needed.
+		 */
+		if (p == &mandir)
+			break;
+		p++;
+		if (*p != NULL)
+			continue;
+		if (flags & (BMP_APPEND_DEFMANDIR | BMP_FALLBACK_DEFMANDIR)) {
+			p = &mandir;
+			flags &= ~BMP_ISPATH;
+		}
+	}
+
+	free_dupnode(didup);
+
+	return (manpage);
+}
+
+/*
+ * Store the mandir path into the manp structure.
+ */
+static void
+getpath(struct man_node *manp, char **pv)
+{
+	char	*s = *pv;
+	int	i = 0;
+
+	while (*s != '\0' && *s != ',')
+		i++, s++;
+
+	if ((manp->path = (char *)malloc(i + 1)) == NULL)
+		err(1, "malloc");
+	(void) strlcpy(manp->path, *pv, i + 1);
+}
+
+/*
+ * Store the mandir's corresponding sections (submandir
+ * directories) into the manp structure.
+ */
+static void
+getsect(struct man_node *manp, char **pv)
+{
+	char	*sections;
+	char	**sectp;
+
+	/* Just store all sections when doing makewhatis or apropos/whatis */
+	if (makewhatis || apropos) {
+		manp->defsrch = 1;
+		DPRINTF("-- Adding %s\n", manp->path);
+		manp->secv = NULL;
+		get_all_sect(manp);
+	} else if (sargs) {
+		manp->secv = split(mansec, ',');
+		for (sectp = manp->secv; *sectp; sectp++)
+			lower(*sectp);
+	} else if ((sections = strchr(*pv, ',')) != NULL) {
+		DPRINTF("-- Adding %s: MANSECTS=%s\n", manp->path, sections);
+		manp->secv = split(++sections, ',');
+		for (sectp = manp->secv; *sectp; sectp++)
+			lower(*sectp);
+		if (*manp->secv == NULL)
+			get_all_sect(manp);
+	} else if ((sections = check_config(*pv)) != NULL) {
+		manp->defsrch = 1;
+		DPRINTF("-- Adding %s: from %s, MANSECTS=%s\n", manp->path,
+		    CONFIG, sections);
+		manp->secv = split(sections, ',');
+		for (sectp = manp->secv; *sectp; sectp++)
+			lower(*sectp);
+		if (*manp->secv == NULL)
+			get_all_sect(manp);
+	} else {
+		manp->defsrch = 1;
+		DPRINTF("-- Adding %s: default sort order\n", manp->path);
+		manp->secv = NULL;
+		get_all_sect(manp);
+	}
+}
+
+/*
+ * Get suffices of all sub-mandir directories in a mandir.
+ */
+static void
+get_all_sect(struct man_node *manp)
+{
+	DIR	*dp;
+	char	**dirv;
+	char	**dv;
+	char	**p;
+	char	*prev = NULL;
+	char 	*tmp = NULL;
+	int	maxentries = MAXTOKENS;
+	int	entries = 0;
+
+	if ((dp = opendir(manp->path)) == 0)
+		return;
+
+	sortdir(dp, &dirv);
+
+	(void) closedir(dp);
+
+	if (manp->secv == NULL) {
+		if ((manp->secv = malloc(maxentries * sizeof (char *))) == NULL)
+			err(1, "malloc");
+	}
+
+	for (dv = dirv, p = manp->secv; *dv; dv++) {
+		if (strcmp(*dv, CONFIG) == 0) {
+			free(*dv);
+			continue;
+		}
+
+		free(tmp);
+		if ((tmp = strdup(*dv + 3)) == NULL)
+			err(1, "strdup");
+
+		if (prev != NULL && strcmp(prev, tmp) == 0) {
+			free(*dv);
+			continue;
+		}
+
+		free(prev);
+		if ((prev = strdup(*dv + 3)) == NULL)
+			err(1, "strdup");
+
+		if ((*p = strdup(*dv + 3)) == NULL)
+			err(1, "strdup");
+
+		p++; entries++;
+
+		if (entries == maxentries) {
+			maxentries += MAXTOKENS;
+			if ((manp->secv = realloc(manp->secv,
+			    sizeof (char *) * maxentries)) == NULL)
+				err(1, "realloc");
+			p = manp->secv + entries;
+		}
+		free(*dv);
+	}
+	free(tmp);
+	free(prev);
+	*p = NULL;
+	free(dirv);
+}
+
+/*
+ * Build whatis databases.
+ */
+static void
+do_makewhatis(struct man_node *manp)
+{
+	struct man_node *p;
+	char		*ldir;
+
+	for (p = manp; p != NULL; p = p->next) {
+		ldir = addlocale(p->path);
+		if (*localedir != '\0' && getdirs(ldir, NULL, 0) > 0)
+			mwpath(ldir);
+		free(ldir);
+		mwpath(p->path);
+	}
+}
+
+/*
+ * Count mandirs under the given manpath
+ */
+static int
+getdirs(char *path, char ***dirv, int flag)
+{
+	DIR		*dp;
+	struct dirent	*d;
+	int		n = 0;
+	int		maxentries = MAXDIRS;
+	char		**dv = NULL;
+
+	if ((dp = opendir(path)) == NULL)
+		return (0);
+
+	if (flag) {
+		if ((*dirv = malloc(sizeof (char *) *
+		    maxentries)) == NULL)
+			err(1, "malloc");
+		dv = *dirv;
+	}
+	while ((d = readdir(dp))) {
+		if (strncmp(d->d_name, "man", 3) != 0)
+			continue;
+		n++;
+
+		if (flag) {
+			if ((*dv = strdup(d->d_name + 3)) == NULL)
+				err(1, "strdup");
+			dv++;
+			if ((dv - *dirv) == maxentries) {
+				int	entries = maxentries;
+
+				maxentries += MAXTOKENS;
+				if ((*dirv = realloc(*dirv,
+				    sizeof (char *) * maxentries)) == NULL)
+					err(1, "realloc");
+				dv = *dirv + entries;
+			}
+		}
+	}
+
+	(void) closedir(dp);
+	return (n);
+}
+
+
+/*
+ * Find matching whatis or apropos entries.
+ */
+static void
+whatapro(struct man_node *manp, char *word)
+{
+	char		whatpath[MAXPATHLEN];
+	struct man_node *b;
+	char		*ldir;
+
+	for (b = manp; b != NULL; b = b->next) {
+		if (*localedir != '\0') {
+			ldir = addlocale(b->path);
+			if (getdirs(ldir, NULL, 0) != 0) {
+				(void) snprintf(whatpath, sizeof (whatpath),
+				    "%s/%s", ldir, WHATIS);
+				search_whatis(whatpath, word);
+			}
+			free(ldir);
+		}
+		(void) snprintf(whatpath, sizeof (whatpath), "%s/%s", b->path,
+		    WHATIS);
+		search_whatis(whatpath, word);
+	}
+}
+
+static void
+search_whatis(char *whatpath, char *word)
+{
+	FILE		*fp;
+	char		*line = NULL;
+	size_t		linecap = 0;
+	char		*pkwd;
+	regex_t		preg;
+	char		**ss = NULL;
+	char		s[MAXNAMELEN];
+	int		i;
+
+	if ((fp = fopen(whatpath, "r")) == NULL) {
+		perror(whatpath);
+		return;
+	}
+
+	DPRINTF("-- Found %s: %s\n", WHATIS, whatpath);
+
+	/* Build keyword regex */
+	if (asprintf(&pkwd, "%s%s%s", (whatis) ? "\\<" : "",
+	    word, (whatis) ? "\\>" : "") == -1)
+		err(1, "asprintf");
+
+	if (regcomp(&preg, pkwd, REG_BASIC | REG_ICASE | REG_NOSUB) != 0)
+		err(1, "regcomp");
+
+	if (sargs)
+		ss = split(mansec, ',');
+
+	while (getline(&line, &linecap, fp) > 0) {
+		if (regexec(&preg, line, 0, NULL, 0) == 0) {
+			if (sargs) {
+				/* Section-restricted search */
+				for (i = 0; ss[i] != NULL; i++) {
+					(void) snprintf(s, sizeof (s), "(%s)",
+					    ss[i]);
+					if (strstr(line, s) != NULL) {
+						(void) printf("%s", line);
+						break;
+					}
+				}
+			} else {
+				(void) printf("%s", line);
+			}
+		}
+	}
+
+	if (ss != NULL)
+		freev(ss);
+	free(pkwd);
+	(void) fclose(fp);
+}
+
+
+/*
+ * Split a string by specified separator.
+ */
+static char **
+split(char *s1, char sep)
+{
+	char	**tokv, **vp;
+	char	*mp = s1, *tp;
+	int	maxentries = MAXTOKENS;
+	int	entries = 0;
+
+	if ((tokv = vp = malloc(maxentries * sizeof (char *))) == NULL)
+		err(1, "malloc");
+
+	for (; mp && *mp; mp = tp) {
+		tp = strchr(mp, sep);
+		if (mp == tp) {
+			tp++;
+			continue;
+		}
+		if (tp) {
+			size_t	len;
+
+			len = tp - mp;
+			if ((*vp = (char *)malloc(sizeof (char) *
+			    len + 1)) == NULL)
+				err(1, "malloc");
+			(void) strncpy(*vp, mp, len);
+			*(*vp + len) = '\0';
+			tp++;
+			vp++;
+		} else {
+			if ((*vp = strdup(mp)) == NULL)
+				err(1, "strdup");
+			vp++;
+		}
+		entries++;
+		if (entries == maxentries) {
+			maxentries += MAXTOKENS;
+			if ((tokv = realloc(tokv,
+			    maxentries * sizeof (char *))) == NULL)
+				err(1, "realloc");
+			vp = tokv + entries;
+		}
+	}
+	*vp = 0;
+
+	return (tokv);
+}
+
+/*
+ * Free a vector allocated by split()
+ */
+static void
+freev(char **v)
+{
+	int i;
+	if (v != NULL) {
+		for (i = 0; v[i] != NULL; i++) {
+			free(v[i]);
+		}
+		free(v);
+	}
+}
+
+/*
+ * Convert paths to full paths if necessary
+ */
+static void
+fullpaths(struct man_node **manp_head)
+{
+	char		*cwd = NULL;
+	char		*p;
+	int		cwd_gotten = 0;
+	struct man_node *manp = *manp_head;
+	struct man_node *b;
+	struct man_node *prev = NULL;
+
+	for (b = manp; b != NULL; b = b->next) {
+		if (*(b->path) == '/') {
+			prev = b;
+			continue;
+		}
+
+		if (!cwd_gotten) {
+			cwd = getcwd(NULL, MAXPATHLEN);
+			cwd_gotten = 1;
+		}
+
+		if (cwd) {
+			/* Relative manpath with cwd: make absolute */
+			if (asprintf(&p, "%s/%s", cwd, b->path) == -1)
+				err(1, "asprintf");
+			free(b->path);
+			b->path = p;
+		} else {
+			/* Relative manpath but no cwd: omit path entry */
+			if (prev)
+				prev->next = b->next;
+			else
+				*manp_head = b->next;
+
+			free_manp(b);
+		}
+	}
+	free(cwd);
+}
+
+/*
+ * Free a man_node structure and its contents
+ */
+static void
+free_manp(struct man_node *manp)
+{
+	char	**p;
+
+	free(manp->path);
+	p = manp->secv;
+	while ((p != NULL) && (*p != NULL)) {
+		free(*p);
+		p++;
+	}
+	free(manp->secv);
+	free(manp);
+}
+
+
+/*
+ * Map (in place) to lower case.
+ */
+static void
+lower(char *s)
+{
+
+	if (s == 0)
+		return;
+	while (*s) {
+		if (isupper(*s))
+			*s = tolower(*s);
+		s++;
+	}
+}
+
+
+/*
+ * Compare function for qsort().
+ * Sort first by section, then by prefix.
+ */
+static int
+cmp(const void *arg1, const void *arg2)
+{
+	int	n;
+	char	**p1 = (char **)arg1;
+	char	**p2 = (char **)arg2;
+
+	/* By section */
+	if ((n = strcmp(*p1 + 3, *p2 + 3)) != 0)
+		return (n);
+
+	/* By prefix reversed */
+	return (strncmp(*p2, *p1, 3));
+}
+
+
+/*
+ * Find a manpage.
+ */
+static int
+manual(struct man_node *manp, char *name)
+{
+	struct man_node *p;
+	struct man_node *local;
+	int		ndirs = 0;
+	char		*ldir;
+	char		*ldirs[2];
+	char		*fullname = name;
+	char		*slash;
+
+	if ((slash = strrchr(name, '/')) != NULL)
+		name = slash + 1;
+
+	/* For each path in MANPATH */
+	found = 0;
+
+	for (p = manp; p != NULL; p = p->next) {
+		DPRINTF("-- Searching mandir: %s\n", p->path);
+
+		if (*localedir != '\0') {
+			ldir = addlocale(p->path);
+			ndirs = getdirs(ldir, NULL, 0);
+			if (ndirs != 0) {
+				ldirs[0] = ldir;
+				ldirs[1] = NULL;
+				local = build_manpath(ldirs, 0);
+				DPRINTF("-- Locale specific subdir: %s\n",
+				    ldir);
+				mandir(local->secv, ldir, name, 1);
+				free_manp(local);
+			}
+			free(ldir);
+		}
+
+		/*
+		 * Locale mandir not valid, man page in locale
+		 * mandir not found, or -a option present
+		 */
+		if (ndirs == 0 || !found || all)
+			mandir(p->secv, p->path, name, 0);
+
+		if (found && !all)
+			break;
+	}
+
+	if (!found) {
+		if (sargs) {
+			(void) fprintf(stderr, gettext(
+			    "No manual entry for %s in section(s) %s\n"),
+			    fullname, mansec);
+		} else {
+			(void) fprintf(stderr,
+			    gettext("No manual entry for %s\n"), fullname);
+		}
+
+	}
+
+	return (!found);
+}
+
+
+/*
+ * For a specified manual directory, read, store and sort section subdirs.
+ * For each section specified, find and search matching subdirs.
+ */
+static void
+mandir(char **secv, char *path, char *name, int lspec)
+{
+	DIR	*dp;
+	char	**dirv;
+	char	**dv, **pdv;
+	int	len, dslen;
+
+	if ((dp = opendir(path)) == NULL)
+		return;
+
+	if (lspec)
+		DPRINTF("-- Searching mandir: %s\n", path);
+
+	sortdir(dp, &dirv);
+
+	/* Search in the order specified by MANSECTS */
+	for (; *secv; secv++) {
+		len = strlen(*secv);
+		for (dv = dirv; *dv; dv++) {
+			dslen = strlen(*dv + 3);
+			if (dslen > len)
+				len = dslen;
+			if (**secv == '\\') {
+				if (strcmp(*secv + 1, *dv + 3) != 0)
+					continue;
+			} else if (strncasecmp(*secv, *dv + 3, len) != 0) {
+				if (!all &&
+				    (newsection = map_section(*secv, path))
+				    == NULL) {
+					continue;
+				}
+				if (newsection == NULL)
+					newsection = "";
+				if (strncmp(newsection, *dv + 3, len) != 0) {
+					continue;
+				}
+			}
+
+			if (searchdir(path, *dv, name) == 0)
+				continue;
+
+			if (!all) {
+				pdv = dirv;
+				while (*pdv) {
+					free(*pdv);
+					pdv++;
+				}
+				(void) closedir(dp);
+				free(dirv);
+				return;
+			}
+
+			if (all && **dv == 'm' && *(dv + 1) &&
+			    strcmp(*(dv + 1) + 3, *dv + 3) == 0)
+					dv++;
+		}
+	}
+	pdv = dirv;
+	while (*pdv != NULL) {
+		free(*pdv);
+		pdv++;
+	}
+	free(dirv);
+	(void) closedir(dp);
+}
+
+/*
+ * Sort directories.
+ */
+static void
+sortdir(DIR *dp, char ***dirv)
+{
+	struct dirent	*d;
+	char		**dv;
+	int		maxentries = MAXDIRS;
+	int		entries = 0;
+
+	if ((dv = *dirv = malloc(sizeof (char *) *
+	    maxentries)) == NULL)
+		err(1, "malloc");
+	dv = *dirv;
+
+	while ((d = readdir(dp))) {
+		if (strcmp(d->d_name, ".") == 0 ||
+		    strcmp(d->d_name, "..") == 0)
+			continue;
+
+		if (strncmp(d->d_name, "man", 3) == 0 ||
+		    strncmp(d->d_name, "cat", 3) == 0) {
+			if ((*dv = strdup(d->d_name)) == NULL)
+				err(1, "strdup");
+			dv++;
+			entries++;
+			if (entries == maxentries) {
+				maxentries += MAXDIRS;
+				if ((*dirv = realloc(*dirv,
+				    sizeof (char *) * maxentries)) == NULL)
+					err(1, "realloc");
+				dv = *dirv + entries;
+			}
+		}
+	}
+	*dv = 0;
+
+	qsort((void *)*dirv, dv - *dirv, sizeof (char *), cmp);
+
+}
+
+
+/*
+ * Search a section subdir for a given manpage.
+ */
+static int
+searchdir(char *path, char *dir, char *name)
+{
+	DIR		*sdp;
+	struct dirent	*sd;
+	char		sectpath[MAXPATHLEN];
+	char		file[MAXNAMLEN];
+	char		dname[MAXPATHLEN];
+	char		*last;
+	int		nlen;
+
+	(void) snprintf(sectpath, sizeof (sectpath), "%s/%s", path, dir);
+	(void) snprintf(file, sizeof (file), "%s.", name);
+
+	if ((sdp = opendir(sectpath)) == NULL)
+		return (0);
+
+	while ((sd = readdir(sdp))) {
+		char	*pname;
+
+		if ((pname = strdup(sd->d_name)) == NULL)
+			err(1, "strdup");
+		if ((last = strrchr(pname, '.')) != NULL &&
+		    (strcmp(last, ".gz") == 0 || strcmp(last, ".bz2") == 0))
+			*last = '\0';
+		last = strrchr(pname, '.');
+		nlen = last - pname;
+		(void) snprintf(dname, sizeof (dname), "%.*s.", nlen, pname);
+		if (strcmp(dname, file) == 0 ||
+		    strcmp(pname, name) == 0) {
+			(void) format(path, dir, name, sd->d_name);
+			(void) closedir(sdp);
+			free(pname);
+			return (1);
+		}
+		free(pname);
+	}
+	(void) closedir(sdp);
+
+	return (0);
+}
+
+/*
+ * Check the hash table of old directory names to see if there is a
+ * new directory name.
+ */
+static char *
+map_section(char *section, char *path)
+{
+	int	i;
+	int	len;
+	char	fullpath[MAXPATHLEN];
+
+	if (list)  /* -l option fall through */
+		return (NULL);
+
+	for (i = 0; i <= ((sizeof (map)/sizeof (map[0]) - 1)); i++) {
+		if (strlen(section) > strlen(map[i].new_name)) {
+			len = strlen(section);
+		} else {
+			len = strlen(map[i].new_name);
+		}
+		if (strncmp(section, map[i].old_name, len) == 0) {
+			(void) snprintf(fullpath, sizeof (fullpath),
+			    "%s/sman%s", path, map[i].new_name);
+			if (!access(fullpath, R_OK | X_OK)) {
+				return (map[i].new_name);
+			} else {
+				return (NULL);
+			}
+		}
+	}
+
+	return (NULL);
+}
+
+/*
+ * Format the manpage.
+ */
+static int
+format(char *path, char *dir, char *name, char *pg)
+{
+	char		manpname[MAXPATHLEN], catpname[MAXPATHLEN];
+	char		cmdbuf[BUFSIZ], tmpbuf[BUFSIZ];
+	char		*cattool;
+	int		utf8 = 0;
+	struct stat	sbman, sbcat;
+
+	found++;
+
+	if (list) {
+		(void) printf(gettext("%s(%s)\t-M %s\n"), name, dir + 3, path);
+		return (-1);
+	}
+
+	(void) snprintf(manpname, sizeof (manpname), "%s/man%s/%s", path,
+	    dir + 3, pg);
+	(void) snprintf(catpname, sizeof (catpname), "%s/cat%s/%s", path,
+	    dir + 3, pg);
+
+	/* Can't do PS output if manpage doesn't exist */
+	if (stat(manpname, &sbman) != 0 && psoutput)
+		return (-1);
+
+	/*
+	 * If both manpage and catpage do not exist, manpname is
+	 * broken symlink, most likely.
+	 */
+	if (stat(catpname, &sbcat) != 0 && stat(manpname, &sbman) != 0)
+		err(1, "%s", manpname);
+
+	/* Setup cattool */
+	if (fnmatch("*.gz", manpname, 0) == 0)
+		cattool = "gzcat";
+	else if (fnmatch("*.bz2", manpname, 0) == 0)
+		cattool = "bzcat";
+	else
+		cattool = "gzcat -f";
+
+	/* Preprocess UTF-8 input with preconv (could be smarter) */
+	if (strstr(path, "UTF-8") != NULL)
+		utf8 = 1;
+
+	if (psoutput) {
+		(void) snprintf(cmdbuf, BUFSIZ,
+		    "cd %s; %s %s%s | mandoc -Tps | lp -Tpostscript",
+		    path, cattool, manpname,
+		    utf8 ? " | " PRECONV " -e UTF-8" : "");
+		DPRINTF("-- Using manpage: %s\n", manpname);
+		goto cmd;
+	}
+
+	/*
+	 * Output catpage if:
+	 * - manpage doesn't exist
+	 * - output width is standard and catpage is recent enough
+	 */
+	if (stat(manpname, &sbman) != 0 || (manwidth == 0 &&
+	    stat(catpname, &sbcat) == 0 && sbcat.st_mtime >= sbman.st_mtime)) {
+		DPRINTF("-- Using catpage: %s\n", catpname);
+		(void) snprintf(cmdbuf, BUFSIZ, "%s %s", pager, catpname);
+		goto cmd;
+	}
+
+	DPRINTF("-- Using manpage: %s\n", manpname);
+	if (manwidth > 0)
+		(void) snprintf(tmpbuf, BUFSIZ, "-Owidth=%d ", manwidth);
+	(void) snprintf(cmdbuf, BUFSIZ, "cd %s; %s %s%s | mandoc -T%s %s| %s",
+	    path, cattool, manpname,
+	    utf8 ? " | " PRECONV " -e UTF-8 " : "",
+	    utf8 ? "utf8" : "ascii", (manwidth > 0) ? tmpbuf : "", pager);
+
+cmd:
+	DPRINTF("-- Command: %s\n", cmdbuf);
+
+	if (!debug)
+		return (system(cmdbuf) == 0);
+	else
+		return (0);
+}
+
+/*
+ * Add <localedir> to the path.
+ */
+static char *
+addlocale(char *path)
+{
+	char	*tmp;
+
+	if (asprintf(&tmp, "%s/%s", path, localedir) == -1)
+		err(1, "asprintf");
+
+	return (tmp);
+}
+
+/*
+ * Get the order of sections from man.cf.
+ */
+static char *
+check_config(char *path)
+{
+	FILE		*fp;
+	char		*rc = NULL;
+	char		*sect;
+	char		fname[MAXPATHLEN];
+	char		*line = NULL;
+	size_t		linecap = 0;
+
+	(void) snprintf(fname, MAXPATHLEN, "%s/%s", path, CONFIG);
+
+	if ((fp = fopen(fname, "r")) == NULL)
+		return (NULL);
+
+	while (getline(&line, &linecap, fp) > 0) {
+		if ((rc = strstr(line, "MANSECTS")) != NULL)
+			break;
+	}
+
+	(void) fclose(fp);
+
+	if (rc == NULL || (sect = strchr(line, '=')) == NULL)
+		return (NULL);
+	else
+		return (++sect);
+}
+
+
+/*
+ * Initialize the bintoman array with appropriate device and inode info.
+ */
+static void
+init_bintoman(void)
+{
+	int i;
+	struct stat sb;
+
+	for (i = 0; bintoman[i].bindir != NULL; i++) {
+		if (stat(bintoman[i].bindir, &sb) == 0) {
+			bintoman[i].dev = sb.st_dev;
+			bintoman[i].ino = sb.st_ino;
+		} else {
+			bintoman[i].dev = NODEV;
+		}
+	}
+}
+
+/*
+ * If a duplicate is found, return 1.
+ * If a duplicate is not found, add it to the dupnode list and return 0.
+ */
+static int
+dupcheck(struct man_node *mnp, struct dupnode **dnp)
+{
+	struct dupnode	*curdnp;
+	struct secnode	*cursnp;
+	struct stat 	sb;
+	int 		i;
+	int		rv = 1;
+	int		dupfound;
+
+	/* If the path doesn't exist, treat it as a duplicate */
+	if (stat(mnp->path, &sb) != 0)
+		return (1);
+
+	/* If no sections were found in the man dir, treat it as duplicate */
+	if (mnp->secv == NULL)
+		return (1);
+
+	/*
+	 * Find the dupnode structure for the previous time this directory
+	 * was looked at.  Device and inode numbers are compared so that
+	 * directories that are reached via different paths (e.g. /usr/man and
+	 * /usr/share/man) are treated as equivalent.
+	 */
+	for (curdnp = *dnp; curdnp != NULL; curdnp = curdnp->next) {
+		if (curdnp->dev == sb.st_dev && curdnp->ino == sb.st_ino)
+			break;
+	}
+
+	/*
+	 * First time this directory has been seen. Add a new node to the
+	 * head of the list. Since all entries are guaranteed to be unique
+	 * copy all sections to new node.
+	 */
+	if (curdnp == NULL) {
+		if ((curdnp = calloc(1, sizeof (struct dupnode))) == NULL)
+			err(1, "calloc");
+		for (i = 0; mnp->secv[i] != NULL; i++) {
+			if ((cursnp = calloc(1, sizeof (struct secnode)))
+			    == NULL)
+				err(1, "calloc");
+			cursnp->next = curdnp->secl;
+			curdnp->secl = cursnp;
+			if ((cursnp->secp = strdup(mnp->secv[i])) == NULL)
+				err(1, "strdup");
+		}
+		curdnp->dev = sb.st_dev;
+		curdnp->ino = sb.st_ino;
+		curdnp->next = *dnp;
+		*dnp = curdnp;
+		return (0);
+	}
+
+	/*
+	 * Traverse the section vector in the man_node and the section list
+	 * in dupnode cache to eliminate all duplicates from man_node.
+	 */
+	for (i = 0; mnp->secv[i] != NULL; i++) {
+		dupfound = 0;
+		for (cursnp = curdnp->secl; cursnp != NULL;
+		    cursnp = cursnp->next) {
+			if (strcmp(mnp->secv[i], cursnp->secp) == 0) {
+				dupfound = 1;
+				break;
+			}
+		}
+		if (dupfound) {
+			mnp->secv[i][0] = '\0';
+			continue;
+		}
+
+
+		/*
+		 * Update curdnp and set return value to indicate that this
+		 * was not all duplicates.
+		 */
+		if ((cursnp = calloc(1, sizeof (struct secnode))) == NULL)
+			err(1, "calloc");
+		cursnp->next = curdnp->secl;
+		curdnp->secl = cursnp;
+		if ((cursnp->secp = strdup(mnp->secv[i])) == NULL)
+			err(1, "strdup");
+		rv = 0;
+	}
+
+	return (rv);
+}
+
+/*
+ * Given a bindir, return corresponding mandir.
+ */
+static char *
+path_to_manpath(char *bindir)
+{
+	char		*mand, *p;
+	int		i;
+	struct stat	sb;
+
+	/* First look for known translations for specific bin paths */
+	if (stat(bindir, &sb) != 0) {
+		return (NULL);
+	}
+	for (i = 0; bintoman[i].bindir != NULL; i++) {
+		if (sb.st_dev == bintoman[i].dev &&
+		    sb.st_ino == bintoman[i].ino) {
+			if ((mand = strdup(bintoman[i].mandir)) == NULL)
+				err(1, "strdup");
+			if ((p = strchr(mand, ',')) != NULL)
+				*p = '\0';
+			if (stat(mand, &sb) != 0) {
+				free(mand);
+				return (NULL);
+			}
+			if (p != NULL)
+				*p = ',';
+			return (mand);
+		}
+	}
+
+	/*
+	 * No specific translation found.  Try `dirname $bindir`/share/man
+	 * and `dirname $bindir`/man
+	 */
+	if ((mand = malloc(MAXPATHLEN)) == NULL)
+		err(1, "malloc");
+	if (strlcpy(mand, bindir, MAXPATHLEN) >= MAXPATHLEN) {
+		free(mand);
+		return (NULL);
+	}
+
+	/*
+	 * Advance to end of buffer, strip trailing /'s then remove last
+	 * directory component.
+	 */
+	for (p = mand; *p != '\0'; p++)
+		;
+	for (; p > mand && *p == '/'; p--)
+		;
+	for (; p > mand && *p != '/'; p--)
+		;
+	if (p == mand && *p == '.') {
+		if (realpath("..", mand) == NULL) {
+			free(mand);
+			return (NULL);
+		}
+		for (; *p != '\0'; p++)
+			;
+	} else {
+		*p = '\0';
+	}
+
+	if (strlcat(mand, "/share/man", MAXPATHLEN) >= MAXPATHLEN) {
+		free(mand);
+		return (NULL);
+	}
+
+	if ((stat(mand, &sb) == 0) && S_ISDIR(sb.st_mode)) {
+		return (mand);
+	}
+
+	/*
+	 * Strip the /share/man off and try /man
+	 */
+	*p = '\0';
+	if (strlcat(mand, "/man", MAXPATHLEN) >= MAXPATHLEN) {
+		free(mand);
+		return (NULL);
+	}
+	if ((stat(mand, &sb) == 0) && S_ISDIR(sb.st_mode)) {
+		return (mand);
+	}
+
+	/*
+	 * No man or share/man directory found
+	 */
+	free(mand);
+	return (NULL);
+}
+
+/*
+ * Free a linked list of dupnode structs.
+ */
+void
+free_dupnode(struct dupnode *dnp) {
+	struct dupnode *dnp2;
+	struct secnode *snp;
+
+	while (dnp != NULL) {
+		dnp2 = dnp;
+		dnp = dnp->next;
+		while (dnp2->secl != NULL) {
+			snp = dnp2->secl;
+			dnp2->secl = dnp2->secl->next;
+			free(snp->secp);
+			free(snp);
+		}
+		free(dnp2);
+	}
+}
+
+/*
+ * Print manp linked list to stdout.
+ */
+void
+print_manpath(struct man_node *manp)
+{
+	char	colon[2] = "\0\0";
+	char	**secp;
+
+	for (; manp != NULL; manp = manp->next) {
+		(void) printf("%s%s", colon, manp->path);
+		colon[0] = ':';
+
+		/*
+		 * If man.cf or a directory scan was used to create section
+		 * list, do not print section list again.  If the output of
+		 * man -p is used to set MANPATH, subsequent runs of man
+		 * will re-read man.cf and/or scan man directories as
+		 * required.
+		 */
+		if (manp->defsrch != 0)
+			continue;
+
+		for (secp = manp->secv; *secp != NULL; secp++) {
+			/*
+			 * Section deduplication may have eliminated some
+			 * sections from the vector. Avoid displaying this
+			 * detail which would appear as ",," in output
+			 */
+			if ((*secp)[0] != '\0')
+				(void) printf(",%s", *secp);
+		}
+	}
+	(void) printf("\n");
+}
+
+static void
+usage_man(void)
+{
+
+	(void) fprintf(stderr, gettext(
+"usage: man [-alptw] [-M path] [-s section] name ...\n"
+"       man [-M path] [-s section] -k keyword -- emulate apropos\n"
+"       man [-M path] [-s section] -f keyword -- emulate whatis\n"));
+
+	exit(1);
+}
+
+static void
+usage_whatapro(void)
+{
+
+	(void) fprintf(stderr, gettext(
+"usage: %s [-M path] [-s section] keyword ...\n"),
+	    whatis ? "whatis" : "apropos");
+
+	exit(1);
+}
+
+static void
+usage_catman(void)
+{
+	(void) fprintf(stderr, gettext(
+"usage: catman [-M path] [-w]\n"));
+
+	exit(1);
+}
+
+static void
+usage_makewhatis(void)
+{
+	(void) fprintf(stderr, gettext("usage: makewhatis\n"));
+
+	exit(1);
+}
--- /dev/null	Wed Jul 16 14:05:07 2014
+++ new/usr/src/cmd/man/man.h	Wed Jul 16 14:05:07 2014
@@ -0,0 +1,40 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2014 Garrett D'Amore <garrett@damore.org>
+ */
+
+/*
+ * Common definitions
+ */
+
+#ifndef _MAN_H_
+#define	_MAN_H_
+
+#define	CONFIG		"man.cf"
+#define	DEFMANDIR	"/usr/share/man"
+#define	INDENT		24
+#define	PAGER		"less -ins"
+#define	WHATIS		"whatis"
+#define	PRECONV		"/usr/lib/mandoc_preconv"
+
+#define	LINE_ALLOC	4096
+#define	MAXDIRS		128
+#define	MAXTOKENS	64
+
+#define	DPRINTF		if (debug) \
+				(void) printf
+
+void	mwpath(char *path);
+
+#endif	/* _MAN_H_ */
--- old/usr/src/cmd/man/src/Makefile	Wed Jul 16 14:05:07 2014
+++ /dev/null	Wed Jul 16 14:05:07 2014
@@ -1,88 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# Makefile for cmd/man/src
-#
-
-include		../../Makefile.cmd
-
-BINPROG =	man
-LIBPROG =	getNAME
-LIBSHELL =	makewhatis
-LNKPROG =	catman apropos whatis
-
-PROG =		$(BINPROG) $(LIBPROG)
-
-SRCS =		man.c getNAME.c
-
-SHSRCS =	makewhatis.sh
-
-OBJS =		$(SRCS:%.c=%.o)
-
-
-CLOBBERFILES +=	$(LNKPROG) $(LIBSHELL)
-
-ROOTPROG =	$(BINPROG:%=$(ROOTBIN)/%)
-ROOTLIBPROG =	$(LIBPROG:%=$(ROOTLIB)/%)
-ROOTLIBSHELL =	$(LIBSHELL:%=$(ROOTLIB)/%)
-ROOTLNKPROG =	$(LNKPROG:%=$(ROOTBIN)/%)
-
-CERRWARN += -_gcc=-Wno-implicit-function-declaration
-CERRWARN += -_gcc=-Wno-uninitialized
-CERRWARN += -_gcc=-Wno-unused-variable
-
-# for messaging catalog files
-POFILE= src.po
-POFILES= $(SRCS:%.c=%.po)
-
-.KEEP_STATE :
-
-all :		$(PROG) $(LIBSHELL) $(LNKPROG)
-
-makewhatis :	$$@.sh
-		cat $@.sh > $@
-
-install :	all $(ROOTPROG) $(ROOTLIBPROG)	\
-		$(ROOTLIBSHELL) $(ROOTLNKPROG)
-
-$(ROOTLNKPROG) :	$(ROOTBIN)/man
-		-$(RM) $@; $(LN) $(ROOTBIN)/man $@
-
-$(LNKPROG) :	man
-		-$(RM) $@; $(LN) man $@
-
-catalog:        $(POFILE)
-
-$(POFILE):      $(POFILES)
-	$(RM)	$@
-	cat     $(POFILES)      > $@
-
-
-clean :
-
-strip :
-		$(STRIP) $(PROG)
-
-lint : 		lint_SRCS
-
-include		../../Makefile.targ
--- old/usr/src/cmd/man/src/THIRDPARTYLICENSE	Wed Jul 16 14:05:07 2014
+++ /dev/null	Wed Jul 16 14:05:07 2014
@@ -1,32 +0,0 @@
-Copyright (c) 1980 Regents of the University of California.  
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    1. Redistributions of source code must retain the above copyright
-       notice, this list of conditions and the following disclaimer.
-    2. Redistributions in binary form must reproduce the above
-       copyright notice, this list of conditions and the following
-       disclaimer in the documentation and/or other materials provided
-       with the distribution.
-    3. All advertising materials mentioning features or use of this
-       software must display the following acknowledgement:
-           This product includes software developed by the University
-           of California, Berkeley and its contributors.
-    4. Neither the name of the University nor the names of its
-       contributors may be used to endorse or promote products derived
-       from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- old/usr/src/cmd/man/src/getNAME.c	Wed Jul 16 14:05:07 2014
+++ /dev/null	Wed Jul 16 14:05:07 2014
@@ -1,789 +0,0 @@
-/*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*	Copyright 1984, 1986, 1987, 1988, 1989 AT&T */
-/*	All Rights Reserved   */
-
-/*
- * Copyright 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-/*
- * Get name sections from manual pages.
- *	-t	for building toc
- *	-i	for building intro entries
- *	other	apropos database
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <unistd.h>
-#include <limits.h>
-#include <locale.h>
-#include <wchar.h>
-#include <errno.h>
-#include <sys/param.h>
-
-#define	PLEN	3	/* prefix length "man" */
-
-static char path[MAXPATHLEN+1];
-static int tocrc;
-static int intro;
-static char *progname;
-
-static void trimln(char *);
-static void roff_trim(char *cp);
-static void doname(char *);
-static void section(char *, char *);
-static void split(char *, char *);
-static void dorefname(char *);
-static void troffpage(char *);
-static void sgmlpage(char *);
-
-/*
- * Test to see if this is an SGML manpage or a regular manpage
- * Unless the first line begins with <!DOCTYPE, we assume it isn't.
- */
-static int
-issgml(FILE *fp)
-{
-	static const char magic[] = "<!DOCTYPE";
-	char buf[sizeof (magic)];
-	size_t n = sizeof (magic) - 1;
-
-	if (read(fileno(fp), buf, n) != n ||
-	    lseek(fileno(fp), 0, SEEK_SET) != 0)
-		return (0);
-	return (strncmp(magic, buf, n) == 0);
-}
-
-int
-main(int argc, char *argv[])
-{
-	int c;
-
-	(void) setlocale(LC_ALL, "");
-
-	progname = argv[0];
-
-	while ((c = getopt(argc, argv, "it")) != EOF)
-		switch (c) {
-		case 't':
-			tocrc++;
-			break;
-		case 'i':
-			intro++;
-			break;
-		case '?':
-		default:
-			(void) fprintf(stderr,
-			    "usage: %s [-i][-t] files..\n", progname);
-			exit(1);
-		}
-
-	if (getcwd(path, sizeof (path)) == NULL) {
-		(void) fprintf(stderr, "%s: getcwd: %s\n", progname, path);
-		exit(1);
-	}
-
-	for (; optind < argc; optind++) {
-		char *name = argv[optind];
-
-		if (freopen(name, "r", stdin) == 0) {
-			(void) fprintf(stderr,
-			    "%s: %s: %s\n", progname, name, strerror(errno));
-			continue;
-		}
-
-		/*
-		 * Most of the info we care about is in the first kbyte
-		 */
-		(void) setvbuf(stdin, NULL, _IOFBF, 1024);
-
-		if (issgml(stdin))
-			sgmlpage(name);
-		else
-			troffpage(name);
-	}
-
-	return (0);
-}
-
-/*
- * Parse a troff-format manpage
- */
-static void
-troffpage(char *name)
-{
-	char headbuf[BUFSIZ];
-	char linbuf[BUFSIZ];
-	char *strptr;
-	int i = 0;
-
-	for (;;) {
-		if (fgets(headbuf, sizeof (headbuf), stdin) == NULL)
-			return;
-		if (headbuf[0] != '.')
-			continue;
-		if (headbuf[1] == 'T' && headbuf[2] == 'H')
-			break;
-		if (headbuf[1] == 't' && headbuf[2] == 'h')
-			break;
-	}
-	for (;;) {
-		if (fgets(linbuf, sizeof (linbuf), stdin) == NULL)
-			return;
-		if (linbuf[0] != '.')
-			continue;
-		if (linbuf[1] == 'S' && linbuf[2] == 'H')
-			break;
-		if (linbuf[1] == 's' && linbuf[2] == 'h')
-			break;
-	}
-	trimln(headbuf);
-	if (tocrc)
-		doname(name);
-	if (!intro)
-		section(name, headbuf);
-	for (;;) {
-		if (fgets(linbuf, sizeof (linbuf), stdin) == NULL)
-			break;
-		if (linbuf[0] == '.') {
-			if (linbuf[1] == 'S' && linbuf[2] == 'H')
-				break;
-			if (linbuf[1] == 's' && linbuf[2] == 'h')
-				break;
-			if (linbuf[1] == '\\' && linbuf[2] == '"')
-				continue;
-		}
-		trimln(linbuf);
-		roff_trim(linbuf);
-		if (intro) {
-			split(linbuf, name);
-			continue;
-		}
-		if (i != 0)
-			(void) printf(" ");
-		i++;
-		(void) printf("%s", linbuf);
-	}
-	(void) printf("\n");
-}
-
-
-/*
- * Substitute section defined in page with new section spec
- * of the form xx/yy where xx is the section suffix of the
- * directory and yy is the filename extension (unless xx
- * and yy are equal, in which case xx is the section).
- * Pages should be placed in their proper directory with the
- * proper name to simplify things.
- *
- * For example take the following names:
- *    man1/ar.1v	(1/1V)
- *    man1/find.1	(1)
- *    man1/loco		(1/)
- *
- */
-static void
-section(char *name, char *buf)
-{
-	char scratch[MAXPATHLEN+1];
-	char *p = buf;
-	char *dir, *fname;
-	char *dp, *np;
-	int i;
-	int plen = PLEN;
-
-	/*
-	 * split dirname and filename
-	 */
-	(void) strcpy(scratch, name);
-	if ((fname = strrchr(scratch, '/')) == NULL) {
-		fname = name;
-		dir = path;
-	} else {
-		dir = scratch;
-		*fname = 0;
-		fname++;
-	}
-	dp = strrchr(dir, '/');
-
-	if (*(dp+1) == 's')
-		plen = PLEN + 1;
-
-	if (dp != NULL) {
-		dp = dp+plen+1;
-	} else {
-		dp = dir+plen;
-	}
-	np = strrchr(fname, '.');
-	if (np != NULL) {
-		++np;
-	} else {
-		np = "";
-	}
-	for (i = 0; i < 2; i++) {
-		while (*p && *p != ' ' && *p != '\t')
-			p++;
-		if (!*p)
-			break;
-		while (*p && (*p == ' ' || *p == '\t'))
-			p++;
-		if (!*p)
-			break;
-	}
-	*p++ = 0;
-	(void) printf("%s", buf);
-	if (strcmp(np, dp) == 0)
-		(void) printf("%s", dp);
-	else
-		(void) printf("%s/%s", dp, np);
-	while (*p && *p != ' ' && *p != '\t')
-		p++;
-	(void) printf("%s\t", p);
-}
-
-static void
-trimln(char *cp)
-{
-	while (*cp)
-		cp++;
-	if (*--cp == '\n')
-		*cp = 0;
-}
-
-static void
-roff_trim(char *cp)
-{
-	if (*cp == '.') {
-		while ((*cp != ' ') && (*cp != '\0')) {
-			strcpy(cp, cp+1);
-		}
-		strcpy(cp, cp+1);
-	}
-	while (*cp) {
-		if (strncmp(cp, "\\f", 2) == 0) {
-			if ((*(cp+2) >= 48) && (*(cp+2) <= 57)) {
-				strcpy(cp, cp+3);
-			}
-			if (*(cp+2) == '(') {
-				strcpy(cp, cp+5);
-			}
-		}
-		cp++;
-	}
-}
-
-static void
-doname(char *name)
-{
-	char *dp = name, *ep;
-
-again:
-	while (*dp && *dp != '.')
-		(void) putchar(*dp++);
-	if (*dp)
-		for (ep = dp+1; *ep; ep++)
-			if (*ep == '.') {
-				(void) putchar(*dp++);
-				goto again;
-			}
-	(void) putchar('(');
-	if (*dp)
-		dp++;
-	while (*dp)
-		(void) putchar(*dp++);
-	(void) putchar(')');
-	(void) putchar(' ');
-}
-
-static void
-split(char *line, char *name)
-{
-	char *cp, *dp;
-	char *sp, *sep;
-
-	cp = strchr(line, '-');
-	if (cp == 0)
-		return;
-	sp = cp + 1;
-	for (--cp; *cp == ' ' || *cp == '\t' || *cp == '\\'; cp--)
-		;
-	*++cp = '\0';
-	while (*sp && (*sp == ' ' || *sp == '\t'))
-		sp++;
-	for (sep = "", dp = line; dp && *dp; dp = cp, sep = "\n") {
-		cp = strchr(dp, ',');
-		if (cp) {
-			char *tp;
-
-			for (tp = cp - 1; *tp == ' ' || *tp == '\t'; tp--)
-				;
-			*++tp = '\0';
-			for (++cp; *cp == ' ' || *cp == '\t'; cp++)
-				;
-		}
-		(void) printf("%s%s\t", sep, dp);
-		dorefname(name);
-		(void) printf("\t%s", sp);
-	}
-}
-
-static void
-dorefname(char *name)
-{
-	char *dp = name, *ep;
-
-again:
-	while (*dp && *dp != '.')
-		(void) putchar(*dp++);
-	if (*dp)
-		for (ep = dp+1; *ep; ep++)
-			if (*ep == '.') {
-				(void) putchar(*dp++);
-				goto again;
-			}
-	(void) putchar('.');
-	if (*dp)
-		dp++;
-	while (*dp)
-		(void) putchar(*dp++);
-}
-
-/*
- * The rest of the routines in the file form a simplistic parser
- * for SGML manpages.  We assume the input is syntactically correct
- * SGML, and that the fields occur in the input file in order.
- */
-
-/*
- * Some utilities for constructing arbitrary length wide character strings
- */
-
-typedef struct {
-	wchar_t *str;
-	size_t size;
-	long index;
-} string_t;
-
-#define	DEF_STR_SIZE	16
-#define	DEF_STR_GROWTH	16
-
-static void
-outofspace(char *where)
-{
-	(void) fprintf(stderr, "%s: '%s' - out of memory\n", progname, where);
-	exit(1);
-}
-
-static string_t *
-newstring(size_t initial)
-{
-	string_t *s = malloc(sizeof (*s));
-
-	if (s == NULL)
-		outofspace("new s");
-
-	initial *= sizeof (wchar_t);
-	if (initial < DEF_STR_SIZE)
-		initial = DEF_STR_SIZE;
-
-	s->str = malloc(initial);
-	if (s->str == NULL)
-		outofspace("new str");
-
-	s->size = initial;
-	s->index = 0;
-	*s->str = L'\0';
-	return (s);
-}
-
-static void
-delstring(string_t **s)
-{
-	free((*s)->str);
-	(*s)->str = NULL;
-	free(*s);
-	*s = NULL;
-}
-
-static wchar_t *
-getwstring(string_t *s)
-{
-	static const wchar_t wnull = L'\0';
-
-	if (s)
-		return (s->str);
-	return ((wchar_t *)&wnull);
-}
-
-static char *
-getcstring(string_t *s)
-{
-	size_t len = (wcslen(s->str) + 1) * MB_CUR_MAX;
-	char *cstr = malloc(len);
-	char *p = cstr;
-	wchar_t *wp = s->str;
-
-	if (p == NULL)
-		outofspace("getc");
-	while (*wp)
-		p += wctomb(p, *wp++);
-	*p = '\0';
-	return (cstr);
-}
-
-static void
-appendwstring(string_t *s, const wchar_t *str)
-{
-	size_t len = wcslen(str) + 1;
-
-	s->size += sizeof (wchar_t) * len;
-	s->str = realloc(s->str, s->size);
-	if (s->str == NULL)
-		outofspace("appendw");
-	(void) wcscat(s->str, str);
-	s->index = wcslen(s->str) + 1;
-}
-
-static void
-putwstring(string_t *s, wchar_t wc)
-{
-	if ((s->index + 1) * sizeof (wchar_t) >= s->size) {
-		s->size += DEF_STR_GROWTH;
-		s->str = realloc(s->str, s->size);
-		if (s->str == NULL)
-			outofspace("put");
-	}
-	s->str[s->index++] = wc;
-}
-
-/*
- * Find the closing > of an SGML comment block
- * (allowing for multibyte, embedded, comments)
- */
-static void
-eatcomments(void)
-{
-	int pending = 1;
-
-	while (pending)
-		switch (getwchar()) {
-		default:
-			break;
-		case L'<':
-			pending++;
-			break;
-		case L'>':
-			pending--;
-			break;
-		case WEOF:
-			return;
-		}
-}
-
-/*
- * Find the next token on stdin.
- * Handles nested comment strings, and removes any trailing newlines
- * from the stream after the closing '>'.
- */
-static int
-find_token(char *tokbuf, size_t tokbuflen)
-{
-	int c;
-	wint_t wc;
-	char *tokp;
-
-top:
-	while ((wc = getwchar()) != WEOF)
-		if (wc == L'<')
-			break;
-
-	if (wc == WEOF && errno == EILSEQ)
-		return (0);
-
-	switch (c = getchar()) {
-	case EOF:
-		return (0);
-	default:
-		(void) ungetc(c, stdin);
-		break;
-	case '!':
-		eatcomments();
-		goto top;
-	}
-
-	tokp = tokbuf;
-
-	while ((c = getchar()) != EOF) {
-		if (c == '>') {
-			while ((c = getchar()) != EOF)
-				if (c != '\n') {
-					(void) ungetc(c, stdin);
-					break;
-				}
-			*tokp = '\0';
-			return (1);
-		}
-		if (tokp - tokbuf < tokbuflen)
-			*tokp++ = (char)c;
-	}
-
-	return (0);
-}
-
-/*
- * This structure is filled out during the parsing of each page we encounter
- */
-typedef struct {
-	char *name;
-	string_t *title;
-	string_t *volnum;
-	string_t *date;
-	string_t *names;
-	string_t *purpose;
-} manpage_t;
-
-static void
-warning(manpage_t *m, const char *fmt, ...)
-{
-	va_list ap;
-	va_start(ap, fmt);
-	(void) fprintf(stderr, "%s: %s - ", progname, m->name);
-	(void) vfprintf(stderr, fmt, ap);
-	va_end(ap);
-}
-
-/*
- * Fetch a string from stdin, terminated by the endtoken.
- * These strings may be localized, so do this with wide characters.
- * Hack: skip over (completely ignore) all other tokens
- * Hack: map all &blort; constructs to spaces.
- */
-static string_t *
-filestring(manpage_t *m, size_t initial, char *endtoken)
-{
-	char tokbuf[BUFSIZ * MB_LEN_MAX];
-	string_t *s = newstring(initial);
-	wint_t wc;
-
-	while ((wc = getwchar()) != WEOF)
-		switch (wc) {
-		case L'\n':
-			if ((wc = getwchar()) != WEOF)
-				(void) ungetwc(wc, stdin);
-			if (wc != L'<')
-				putwstring(s, L' ');
-			break;
-		case L'<':
-			(void) ungetwc(wc, stdin);
-			if (!find_token(tokbuf, sizeof (tokbuf)) ||
-			    strcasecmp(endtoken, tokbuf) == 0)
-				goto done;
-			break;
-		case L'&':
-			while ((wc = getwchar()) != WEOF)
-				if (wc == L';')
-					break;
-			wc = L' ';
-			/* FALLTHROUGH */
-		default:
-			putwstring(s, wc);
-			break;
-		}
-
-	if (errno == EILSEQ)
-		warning(m, "%s while parsing %s\n", strerror(errno), endtoken);
-done:
-	putwstring(s, L'\0');
-	return (s);
-}
-
-/*
- * <refentrytitle> TITLE </refentrytitle>
- */
-static int
-refentrytitle(manpage_t *m)
-{
-	if (m->title != NULL)
-		warning(m, "repeated refentrytitle\n");
-	m->title = filestring(m, 8, "/refentrytitle");
-	return (1);
-}
-
-/*
- * <manvolnum> MANVOLNUM </manvolnum>
- */
-static int
-manvolnum(manpage_t *m)
-{
-	if (m->volnum != NULL)
-		warning(m, "repeated manvolnum\n");
-	m->volnum = filestring(m, 3, "/manvolnum");
-	return (1);
-}
-
-/*
- * <refmiscinfo class="date"> DATE </refmiscinfo>
- */
-static int
-refmiscinfo_date(manpage_t *m)
-{
-	if (m->date != NULL)
-		warning(m, "repeated date\n");
-	m->date = filestring(m, 11, "/refmiscinfo");
-	return (1);
-}
-
-/*
- * .. </refmeta>
- */
-static int
-print_refmeta(manpage_t *m)
-{
-	char headbuf[BUFSIZ];
-
-	(void) snprintf(headbuf, sizeof (headbuf), ".TH %ws %ws \"%ws\"",
-	    getwstring(m->title), getwstring(m->volnum), getwstring(m->date));
-
-	trimln(headbuf);
-	if (tocrc)
-		doname(m->name);
-	if (!intro)
-		section(m->name, headbuf);
-
-	if (m->title)
-		delstring(&m->title);
-	if (m->volnum)
-		delstring(&m->volnum);
-	if (m->date)
-		delstring(&m->date);
-
-	return (1);
-}
-
-static int
-appendname(manpage_t *m, char *term)
-{
-	string_t *r = filestring(m, 0, term);
-
-	if (m->names) {
-		appendwstring(m->names, L", ");
-		appendwstring(m->names, getwstring(r));
-		delstring(&r);
-	} else
-		m->names = r;
-	return (1);
-}
-
-/*
- * <refdescriptor> REFDESCRIPTOR </refdescriptor>
- */
-static int
-refdescriptor(manpage_t *m)
-{
-	return (appendname(m, "/refdescriptor"));
-}
-
-/*
- * <refname> REFNAME </refname>
- */
-static int
-refname(manpage_t *m)
-{
-	return (appendname(m, "/refname"));
-}
-
-/*
- * <refpurpose> PURPOSE </refpurpose>
- */
-static int
-refpurpose(manpage_t *m)
-{
-	if (m->purpose != NULL)
-		warning(m, "repeated refpurpose\n");
-	m->purpose = filestring(m, 0, "/refpurpose");
-	return (1);
-}
-
-/*
- * .. </refnamediv> - this is our chance to bail out.
- */
-static int
-terminate(manpage_t *m)
-{
-	if (m->names) {
-		appendwstring(m->names, L" \\- ");
-		appendwstring(m->names, getwstring(m->purpose));
-		if (intro) {
-			char *buf = getcstring(m->names);
-			split(buf, m->name);
-			free(buf);
-		} else
-			(void) printf("%ws", getwstring(m->names));
-	}
-
-	if (m->names)
-		delstring(&m->names);
-	if (m->purpose)
-		delstring(&m->purpose);
-
-	(void) printf("\n");
-	return (0);
-}
-
-
-/*
- * Basic control structure of the SGML "parser".
- * It's very simplistic - when named tags are encountered in the
- * input stream, control is transferred to the corresponding routine.
- * No checking is done for correct pairing of tags.  A few other hacks
- * are sneaked into the lexical routines above.
- * Output is generated after seeing the /refmeta and /refnamediv
- * closing tags.
- */
-static const struct {
-	char *name;
-	int (*action)(manpage_t *);
-} acts[] = {
-	{ "refentrytitle",		refentrytitle },
-	{ "manvolnum",			manvolnum },
-	{ "refmiscinfo class=\"date\"",	refmiscinfo_date },
-	{ "/refmeta",			print_refmeta },
-	{ "refdescriptor",		refdescriptor },
-	{ "refname",			refname },
-	{ "refpurpose",			refpurpose },
-	{ "/refnamediv",		terminate },
-	{ 0 }
-};
-
-static void
-sgmlpage(char *name)
-{
-	int rc = 1, a;
-	char tokbuf[BUFSIZ];
-	manpage_t manpage, *m = &manpage;
-
-	(void) memset(m, 0, sizeof (*m));
-	m->name = name;
-
-	do {
-		if (!find_token(tokbuf, sizeof (tokbuf)))
-			break;
-		for (a = 0; acts[a].name; a++) {
-			if (strcasecmp(acts[a].name, tokbuf) != 0)
-				continue;
-			rc = acts[a].action(m);
-			break;
-		}
-	} while (rc);
-}
--- old/usr/src/cmd/man/src/makewhatis.sh	Wed Jul 16 14:05:07 2014
+++ /dev/null	Wed Jul 16 14:05:07 2014
@@ -1,85 +0,0 @@
-#!/bin/sh -
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-#	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
-#	  All Rights Reserved
-#
-
-# University Copyright- Copyright (c) 1982, 1986, 1988
-# The Regents of the University of California
-# All Rights Reserved
-#
-# University Acknowledgment- Portions of this document are derived from
-# software developed by the University of California, Berkeley, and its
-# contributors
-
-PATH=/usr/xpg4/bin:$PATH
-
-tmpdir=/tmp/whatis.$$
-trap "rm -rf $tmpdir; exit 1" 1 2 13 15
-
-mkdir -m 700 $tmpdir || {
-	echo "${0}: could not create temporary directory" 1&>2
-	exit 1
-}
-
-[ -d $1 ] || exit 1
-
-cd $1
-top=`pwd`
-for i in man?* sman?*
-do
-	if [ -d $i ] ; then
-		cd $i
-		if test "`echo *`" != "*" ; then
-			/usr/lib/getNAME *
-		fi
-		cd $top
-	fi
-done >$tmpdir/whatisx
-sed  <$tmpdir/whatisx \
-	-e 's/\\-/-/' \
-	-e 's/\\\*-/-/' \
-	-e 's/ VAX-11//' \
-	-e 's/\\f[PRIB01234]//g' \
-	-e 's/\\s[-+0-9]*//g' \
-	-e 's/\\&//g' \
-	-e '/ - /!d' \
-	-e 's/.TH [^ ]* \([^ 	]*\).*	\(.*\) -/\2 (\1)	 -/' \
-	-e 's/	 /	/g' | \
-awk '{	title = substr($0, 1, index($0, "- ") - 1)
-	synop = substr($0, index($0, "- "))
-	count = split(title, n, " ")
-	for (i=1; i<count; i++) {
-		if ( (pos = index(n[i], ",")) || (pos = index(n[i], ":")) )
-			n[i] = substr(n[i], 1, pos-1)
-		printf("%s\t%s %s\t%s\n", n[i], n[1], n[count], synop)
-	}
-}' >$tmpdir/whatis
-/usr/bin/expand -16,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100 \
-	$tmpdir/whatis | LC_CTYPE=C LC_COLLATE=C sort -u | \
-	/usr/bin/unexpand -a > windex
-chmod 644 windex >/dev/null 2>&1
-rm -rf $tmpdir
-exit 0
--- old/usr/src/cmd/man/src/man.c	Wed Jul 16 14:05:07 2014
+++ /dev/null	Wed Jul 16 14:05:07 2014
@@ -1,3336 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012, Josef 'Jeff' Sipek <jeffpc@31bits.net>. All rights reserved.
- */
-
-/*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989  AT&T.	*/
-/*		All rights reserved.					*/
-
-/*
- * University Copyright- Copyright (c) 1982, 1986, 1988
- * The Regents of the University of California
- * All Rights Reserved
- *
- * University Acknowledgment- Portions of this document are derived from
- * software developed by the University of California, Berkeley, and its
- * contributors.
- */
-
-
-/*
- * man
- * links to apropos, whatis, and catman
- * This version uses more for underlining and paging.
- */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <sgtty.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <signal.h>
-#include <string.h>
-#include <malloc.h>
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <locale.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <memory.h>
-#include <limits.h>
-#include <wchar.h>
-
-#define	MACROF 	"tmac.an"		/* name of <locale> macro file */
-#define	TMAC_AN	"-man"		/* default macro file */
-
-/*
- * The default search path for man subtrees.
- */
-
-#define	MANDIR		"/usr/share/man" 	/* default mandir */
-#define	MAKEWHATIS	"/usr/lib/makewhatis"
-#define	WHATIS		"windex"
-#define	TEMPLATE	"/tmp/mpXXXXXX"
-#define	CONFIG		"man.cf"
-
-/*
- * Names for formatting and display programs.  The values given
- * below are reasonable defaults, but sites with source may
- * wish to modify them to match the local environment.  The
- * value for TCAT is particularly problematic as there's no
- * accepted standard value available for it.  (The definition
- * below assumes C.A.T. troff output and prints it).
- */
-
-#define	MORE	"more -s" 		/* default paging filter */
-#define	CAT_S	"/usr/bin/cat -s"	/* for '-' opt (no more) */
-#define	CAT_	"/usr/bin/cat"		/* for when output is not a tty */
-#define	TROFF	"troff"			/* local name for troff */
-#define	TCAT	"lp -c -T troff"	/* command to "display" troff output */
-
-#define	SOLIMIT		10	/* maximum allowed .so chain length */
-#define	MAXDIRS		128	/* max # of subdirs per manpath */
-#define	MAXPAGES	128	/* max # for multiple pages */
-#define	PLEN		3	/* prefix length {man, cat, fmt} */
-#define	TMPLEN		7	/* length of tmpfile prefix */
-#define	MAXTOKENS 	64
-
-#define	DOT_SO		".so "
-#define	PREPROC_SPEC	"'\\\" "
-
-#define	DPRINTF		if (debug && !catmando) \
-				(void) printf
-
-#define	sys(s)		(debug ? ((void)puts(s), 0) : system(s))
-#define	eq(a, b)	(strcmp(a, b) == 0)
-#define	match(a, b, c)	(strncmp(a, b, c) == 0)
-
-#define	ISDIR(A)	((A.st_mode & S_IFMT) == S_IFDIR)
-
-#define	SROFF_CMD	"/usr/lib/sgml/sgml2roff" /* sgml converter */
-#define	MANDIRNAME	"man"			  /* man directory */
-#define	SGMLDIR		"sman"			  /* sman directory */
-#define	SGML_SYMBOL	"<!DOCTYPE"	/* a sgml file should contain this */
-#define	SGML_SYMBOL_LEN		9	/* length of SGML_SYMBOL */
-
-/*
- * Directory mapping of old directories to new directories
- */
-
-typedef struct {
-	char *old_name;
-	char *new_name;
-} map_entry;
-
-static const map_entry map[] = {
-					{ "3b", "3ucb" },
-					{ "3e", "3elf" },
-					{ "3g", "3gen" },
-					{ "3k", "3kstat" },
-					{ "3n", "3socket" },
-					{ "3r", "3rt" },
-					{ "3s", "3c" },
-					{ "3t", "3thr" },
-					{ "3x", "3curses" },
-					{ "3xc", "3xcurses" },
-					{ "3xn", "3xnet" }
-};
-
-/*
- * A list of known preprocessors to precede the formatter itself
- * in the formatting pipeline.  Preprocessors are specified by
- * starting a manual page with a line of the form:
- *	'\" X
- * where X is a string consisting of letters from the p_tag fields
- * below.
- */
-static const struct preprocessor {
-	char	p_tag;
-	char	*p_nroff,
-		*p_troff,
-		*p_stdin_char;
-} preprocessors [] = {
-	{'c',	"cw",				"cw",		"-"},
-	{'e',	"neqn /usr/share/lib/pub/eqnchar",
-			"eqn /usr/share/lib/pub/eqnchar",	"-"},
-	{'p',	"gpic",				"gpic",		"-"},
-	{'r',	"refer",			"refer",	"-"},
-	{'t',	"tbl",				"tbl",		""},
-	{'v',	"vgrind -f",			"vgrind -f",	"-"},
-	{0,	0,				0,		0}
-};
-
-struct suffix {
-	char *ds;
-	char *fs;
-};
-
-/*
- * Flags that control behavior of build_manpath()
- *
- *   BMP_ISPATH 	pathv is a vector constructed from PATH.
- *                	Perform appropriate path translations for
- * 			manpath.
- *   BMP_APPEND_MANDIR	Add /usr/share/man to the end if it
- *			hasn't already appeared earlier.
- *   BMP_FALLBACK_MANDIR Append /usr/share/man only if no other
- *			manpath (including derived from PATH)
- * 			elements are valid.
- */
-#define	BMP_ISPATH		1
-#define	BMP_APPEND_MANDIR	2
-#define	BMP_FALLBACK_MANDIR	4
-
-/*
- * When doing equality comparisons of directories, device and inode
- * comparisons are done.  The dupsec and dupnode structures are used
- * to form a list of lists for this processing.
- */
-struct secnode {
-	char		*secp;
-	struct secnode	*next;
-};
-struct dupnode {
-	dev_t		dev;	/* from struct stat st_dev */
-	ino_t		ino;	/* from struct stat st_ino */
-	struct secnode	*secl;	/* sections already considered */
-	struct dupnode	*next;
-};
-
-/*
- * Map directories that may appear in PATH to the corresponding
- * man directory
- */
-static struct pathmap {
-	char	*bindir;
-	char	*mandir;
-	dev_t	dev;
-	ino_t	ino;
-} bintoman[] = {
-	{"/sbin",		"/usr/share/man,1m",			0, 0},
-	{"/usr/sbin",		"/usr/share/man,1m",			0, 0},
-	{"/usr/ucb",		"/usr/share/man,1b",			0, 0},
-	{"/usr/bin/X11",	"/usr/X11/share/man",			0, 0},
-	/*
-	 * Restrict to section 1 so that whatis /usr/{,xpg4,xpg6}/bin/ls
-	 * does not confuse users with section 1 and 1b
-	 */
-	{"/usr/bin",		"/usr/share/man,1,1m,1s,1t,1c", 	0, 0},
-	{"/usr/xpg4/bin",	"/usr/share/man,1",			0, 0},
-	{"/usr/xpg6/bin",	"/usr/share/man,1",			0, 0},
-	{NULL,			NULL,					0, 0}
-};
-
-/*
- * Subdirectories to search for unformatted/formatted man page
- * versions, in nroff and troff variations.  The searching
- * code in manual() is structured to expect there to be two
- * subdirectories apiece, the first for unformatted files
- * and the second for formatted ones.
- */
-static char	*nroffdirs[] = { "man", "cat", 0 };
-static char	*troffdirs[] = { "man", "fmt", 0 };
-
-#define	MAN_USAGE "\
-usage:\tman [-] [-adFlprt] [-M path] [-T macro-package ] [ -s section ] \
-name ...\n\
-\tman [-M path] -k keyword ...\n\tman [-M path] -f file ..."
-#define	CATMAN_USAGE "\
-usage:\tcatman [-p] [-c|-ntw] [-M path] [-T macro-package ] [sections]"
-
-static char *opts[] = {
-	"FfkrpP:M:T:ts:lad",	/* man */
-	"wpnP:M:T:tc"		/* catman */
-};
-
-struct man_node {
-	char *path;		/* mandir path */
-	char **secv;		/* submandir suffices */
-	int  defsrch;		/* hint for man -p to avoid section list */
-	int  frompath;		/* hint for man -d and catman -p */
-	struct man_node *next;
-};
-
-static char	*pages[MAXPAGES];
-static char	**endp = pages;
-
-/*
- * flags (options)
- */
-static int	nomore;
-static int	troffit;
-static int	debug;
-static int	Tflag;
-static int	sargs;
-static int	margs;
-static int	force;
-static int	found;
-static int	list;
-static int	all;
-static int	whatis;
-static int	apropos;
-static int	catmando;
-static int	nowhatis;
-static int	whatonly;
-static int	compargs;	/* -c option for catman */
-static int	printmp;
-
-static char	*CAT	= CAT_;
-static char	macros[MAXPATHLEN];
-static char	*mansec;
-static char	*pager;
-static char	*troffcmd;
-static char	*troffcat;
-static char	**subdirs;
-
-static char *check_config(char *);
-static struct man_node *build_manpath(char **, int);
-static void getpath(struct man_node *, char **);
-static void getsect(struct man_node *, char **);
-static void get_all_sect(struct man_node *);
-static void catman(struct man_node *, char **, int);
-static int makecat(char *, char **, int);
-static int getdirs(char *, char ***, short);
-static void whatapro(struct man_node *, char *, int);
-static void lookup_windex(char *, char *, char **);
-static int icmp(wchar_t *, wchar_t *);
-static void more(char **, int);
-static void cleanup(char **);
-static void bye(int);
-static char **split(char *, char);
-static void freev(char **);
-static void fullpaths(struct man_node **);
-static void lower(char *);
-static int cmp(const void *, const void *);
-static int manual(struct man_node *, char *);
-static void mandir(char **, char *, char *);
-static void sortdir(DIR *, char ***);
-static int searchdir(char *, char *, char *);
-static int windex(char **, char *, char *);
-static void section(struct suffix *, char *);
-static int bfsearch(FILE *, char **, char *, char **);
-static int compare(char *, char *, char **);
-static int format(char *, char *, char *, char *);
-static char *addlocale(char *);
-static int get_manconfig(FILE *, char *);
-static void	malloc_error(void);
-static int	sgmlcheck(const char *);
-static char *map_section(char *, char *);
-static void free_manp(struct man_node *manp);
-static void init_bintoman(void);
-static char *path_to_manpath(char *);
-static int dupcheck(struct man_node *, struct dupnode **);
-static void free_dupnode(struct dupnode *);
-static void print_manpath(struct man_node *, char *);
-
-/*
- * This flag is used when the SGML-to-troff converter
- * is absent - all the SGML searches are bypassed.
- */
-static int no_sroff = 0;
-
-/*
- * This flag is used to describe the case where we've found
- * an SGML formatted manpage in the sman directory, we haven't
- * found a troff formatted manpage, and we don't have the SGML to troff
- * conversion utility on the system.
- */
-static int sman_no_man_no_sroff;
-
-static char language[PATH_MAX + 1]; 	/* LC_MESSAGES */
-static char localedir[PATH_MAX + 1];	/* locale specific path component */
-
-static int	defaultmandir = 1;	/* if processing default mandir, 1 */
-
-static char *newsection = NULL;
-
-int
-main(int argc, char *argv[])
-{
-	int badopts = 0;
-	int c;
-	char **pathv;
-	char *cmdname;
-	char *manpath = NULL;
-	static struct man_node	*manpage = NULL;
-	int bmp_flags = 0;
-	int err = 0;
-
-	if (access(SROFF_CMD, F_OK | X_OK) != 0)
-		no_sroff = 1;
-
-	(void) setlocale(LC_ALL, "");
-	(void) strcpy(language, setlocale(LC_MESSAGES, (char *)0));
-	if (strcmp("C", language) != 0)
-		(void) sprintf(localedir, "%s", language);
-
-#if !defined(TEXT_DOMAIN)
-#define	TEXT_DOMAIN "SYS_TEST"
-#endif
-	(void) textdomain(TEXT_DOMAIN);
-
-	(void) strcpy(macros, TMAC_AN);
-
-	/*
-	 * get base part of command name
-	 */
-	if ((cmdname = strrchr(argv[0], '/')) != NULL)
-		cmdname++;
-	else
-		cmdname = argv[0];
-
-	if (eq(cmdname, "apropos") || eq(cmdname, "whatis")) {
-		whatis++;
-		apropos = (*cmdname == 'a');
-		if ((optind = 1) == argc) {
-			(void) fprintf(stderr, gettext("%s what?\n"), cmdname);
-			exit(2);
-		}
-		goto doargs;
-	} else if (eq(cmdname, "catman"))
-		catmando++;
-
-	opterr = 0;
-	while ((c = getopt(argc, argv, opts[catmando])) != -1)
-		switch (c) {
-
-		/*
-		 * man specific options
-		 */
-		case 'k':
-			apropos++;
-			/*FALLTHROUGH*/
-		case 'f':
-			whatis++;
-			break;
-		case 'F':
-			force++;	/* do lookups the hard way */
-			break;
-		case 's':
-			mansec = optarg;
-			sargs++;
-			break;
-		case 'r':
-			nomore++, troffit++;
-			break;
-		case 'l':
-			list++;		/* implies all */
-			/*FALLTHROUGH*/
-		case 'a':
-			all++;
-			break;
-		case 'd':
-			debug++;
-			break;
-		/*
-		 * man and catman use -p differently.  In catman it
-		 * enables debug mode and in man it prints the (possibly
-		 * derived from PATH or name operand) MANPATH.
-		 */
-		case 'p':
-			if (catmando == 0) {
-				printmp++;
-			} else {
-				debug++;
-			}
-			break;
-		case 'n':
-			nowhatis++;
-			break;
-		case 'w':
-			whatonly++;
-			break;
-		case 'c':	/* n|troff compatibility */
-			if (no_sroff)
-				(void) fprintf(stderr, gettext(
-				    "catman: SGML conversion not "
-				    "available -- -c flag ignored\n"));
-			else
-				compargs++;
-			continue;
-
-		/*
-		 * shared options
-		 */
-		case 'P':	/* Backwards compatibility */
-		case 'M':	/* Respecify path for man pages. */
-			manpath = optarg;
-			margs++;
-			break;
-		case 'T':	/* Respecify man macros */
-			(void) strcpy(macros, optarg);
-			Tflag++;
-			break;
-		case 't':
-			troffit++;
-			break;
-		case '?':
-			badopts++;
-		}
-
-	/*
-	 *  Bad options or no args?
-	 *	(man -p and catman don't need args)
-	 */
-	if (badopts || (!catmando && !printmp && optind == argc)) {
-		(void) fprintf(stderr, "%s\n", catmando ?
-		    gettext(CATMAN_USAGE) : gettext(MAN_USAGE));
-		exit(2);
-	}
-
-	if (compargs && (nowhatis || whatonly || troffit)) {
-		(void) fprintf(stderr, "%s\n", gettext(CATMAN_USAGE));
-		(void) fprintf(stderr, gettext(
-		    "-c option cannot be used with [-w][-n][-t]\n"));
-		exit(2);
-	}
-
-	if (sargs && margs && catmando) {
-		(void) fprintf(stderr, "%s\n", gettext(CATMAN_USAGE));
-		exit(2);
-	}
-
-	if (troffit == 0 && nomore == 0 && !isatty(fileno(stdout)))
-		nomore++;
-
-	/*
-	 * Collect environment information.
-	 */
-	if (troffit) {
-		if ((troffcmd = getenv("TROFF")) == NULL)
-			troffcmd = TROFF;
-		if ((troffcat = getenv("TCAT")) == NULL)
-			troffcat = TCAT;
-	} else {
-		if (((pager = getenv("PAGER")) == NULL) ||
-		    (*pager == NULL))
-			pager = MORE;
-	}
-
-doargs:
-	subdirs = troffit ? troffdirs : nroffdirs;
-
-	init_bintoman();
-
-	if (manpath == NULL && (manpath = getenv("MANPATH")) == NULL) {
-		if ((manpath = getenv("PATH")) != NULL) {
-			bmp_flags = BMP_ISPATH | BMP_APPEND_MANDIR;
-		} else {
-			manpath = MANDIR;
-		}
-	}
-
-	pathv = split(manpath, ':');
-
-	manpage = build_manpath(pathv, bmp_flags);
-
-	/* release pathv allocated by split() */
-	freev(pathv);
-
-	/*
-	 * Since we can't make use of GNU troff, set the path to ensure we
-	 * find the one in /usr/bin first.
-	 */
-	if (putenv("PATH=/usr/bin") != 0) {
-		perror("putenv");
-		exit(1);
-	}
-
-	fullpaths(&manpage);
-
-	if (catmando) {
-		catman(manpage, argv+optind, argc-optind);
-		exit(0);
-	}
-
-	/*
-	 * The manual routine contains windows during which
-	 * termination would leave a temp file behind.  Thus
-	 * we blanket the whole thing with a clean-up routine.
-	 */
-	if (signal(SIGINT, SIG_IGN) == SIG_DFL) {
-		(void) signal(SIGINT, bye);
-		(void) signal(SIGQUIT, bye);
-		(void) signal(SIGTERM, bye);
-	}
-
-	/*
-	 * "man -p" without operands
-	 */
-	if ((printmp != 0) && (optind == argc)) {
-		print_manpath(manpage, NULL);
-		exit(0);
-	}
-
-	for (; optind < argc; optind++) {
-		if (strcmp(argv[optind], "-") == 0) {
-			nomore++;
-			CAT = CAT_S;
-		} else {
-			char *cmd;
-			static struct man_node *mp;
-			char *pv[2];
-
-			/*
-			 * If full path to command specified, customize
-			 * manpath accordingly
-			 */
-			if ((cmd = strrchr(argv[optind], '/')) != NULL) {
-				*cmd = '\0';
-				if ((pv[0] = strdup(argv[optind])) == NULL) {
-					malloc_error();
-				}
-				pv[1] = NULL;
-				*cmd = '/';
-				mp = build_manpath(pv,
-				    BMP_ISPATH|BMP_FALLBACK_MANDIR);
-			} else {
-				mp = manpage;
-			}
-
-			if (whatis) {
-				whatapro(mp, argv[optind], apropos);
-			} else if (printmp != 0) {
-				print_manpath(mp, argv[optind]);
-			} else {
-				err += manual(mp, argv[optind]);
-			}
-
-			if (mp != NULL && mp != manpage) {
-				free(pv[0]);
-				free_manp(mp);
-			}
-		}
-	}
-	return (err == 0 ? 0 : 1);
-	/*NOTREACHED*/
-}
-
-/*
- * This routine builds the manpage structure from MANPATH or PATH,
- * depending on flags.  See BMP_* definitions above for valid
- * flags.
- *
- * Assumes pathv elements were malloc'd, as done by split().
- * Elements may be freed and reallocated to have different contents.
- */
-
-static struct man_node *
-build_manpath(char **pathv, int flags)
-{
-	struct man_node *manpage = NULL;
-	struct man_node *currp = NULL;
-	struct man_node *lastp = NULL;
-	char **p;
-	char **q;
-	char *mand = NULL;
-	char *mandir = MANDIR;
-	int s;
-	struct dupnode *didup = NULL;
-	struct stat sb;
-
-	s = sizeof (struct man_node);
-	for (p = pathv; *p; ) {
-
-		if (flags & BMP_ISPATH) {
-			if ((mand = path_to_manpath(*p)) == NULL) {
-				goto next;
-			}
-			free(*p);
-			*p = mand;
-		}
-		q = split(*p, ',');
-		if (stat(q[0], &sb) != 0 || (sb.st_mode & S_IFDIR) == 0) {
-			freev(q);
-			goto next;
-		}
-
-		if (access(q[0], R_OK|X_OK) != 0) {
-			if (catmando) {
-				(void) fprintf(stderr,
-				    gettext("%s is not accessible.\n"),
-				    q[0]);
-				(void) fflush(stderr);
-			}
-		} else {
-
-			/*
-			 * Some element exists.  Do not append MANDIR as a
-			 * fallback.
-			 */
-			flags &= ~BMP_FALLBACK_MANDIR;
-
-			if ((currp = (struct man_node *)calloc(1, s)) == NULL) {
-				malloc_error();
-			}
-
-			currp->frompath = (flags & BMP_ISPATH);
-
-			if (manpage == NULL) {
-				lastp = manpage = currp;
-			}
-
-			getpath(currp, p);
-			getsect(currp, p);
-
-			/*
-			 * If there are no new elements in this path,
-			 * do not add it to the manpage list
-			 */
-			if (dupcheck(currp, &didup) != 0) {
-				freev(currp->secv);
-				free(currp);
-			} else {
-				currp->next = NULL;
-				if (currp != manpage) {
-					lastp->next = currp;
-				}
-				lastp = currp;
-			}
-		}
-		freev(q);
-next:
-		/*
-		 * Special handling of appending MANDIR.
-		 * After all pathv elements have been processed, append MANDIR
-		 * if needed.
-		 */
-		if (p == &mandir) {
-			break;
-		}
-		p++;
-		if (*p != NULL) {
-			continue;
-		}
-		if (flags & (BMP_APPEND_MANDIR|BMP_FALLBACK_MANDIR)) {
-			p = &mandir;
-			flags &= ~BMP_ISPATH;
-		}
-	}
-
-	free_dupnode(didup);
-
-	return (manpage);
-}
-
-/*
- * Stores the mandir path into the manp structure.
- */
-
-static void
-getpath(struct man_node *manp, char **pv)
-{
-	char *s;
-	int i = 0;
-
-	s = *pv;
-
-	while (*s != NULL && *s != ',')
-		i++, s++;
-
-	manp->path = (char *)malloc(i+1);
-	if (manp->path == NULL)
-		malloc_error();
-	(void) strncpy(manp->path, *pv, i);
-	*(manp->path + i) = '\0';
-}
-
-/*
- * Stores the mandir's corresponding sections (submandir
- * directories) into the manp structure.
- */
-
-static void
-getsect(struct man_node *manp, char **pv)
-{
-	char *sections;
-	char **sectp;
-
-	if (sargs) {
-		manp->secv = split(mansec, ',');
-
-		for (sectp = manp->secv; *sectp; sectp++)
-			lower(*sectp);
-	} else if ((sections = strchr(*pv, ',')) != NULL) {
-		if (debug) {
-			if (manp->frompath != 0) {
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * ex. /usr/share/man: derived from PATH, MANSECTS=,1b
- */
-				(void) printf(gettext(
-				    "%s: derived from PATH, MANSECTS=%s\n"),
-				    manp->path, sections);
-			} else {
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * ex. /usr/share/man: from -M option, MANSECTS=,1,2,3c
- */
-				(void) fprintf(stdout, gettext(
-				    "%s: from -M option, MANSECTS=%s\n"),
-				    manp->path, sections);
-			}
-		}
-		manp->secv = split(++sections, ',');
-		for (sectp = manp->secv; *sectp; sectp++)
-			lower(*sectp);
-
-		if (*manp->secv == NULL)
-			get_all_sect(manp);
-	} else if ((sections = check_config(*pv)) != NULL) {
-		manp->defsrch = 1;
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * ex. /usr/share/man: from man.cf, MANSECTS=1,1m,1c
- */
-		if (debug)
-			(void) fprintf(stdout, gettext(
-			    "%s: from %s, MANSECTS=%s\n"),
-			    manp->path, CONFIG, sections);
-		manp->secv = split(sections, ',');
-
-		for (sectp = manp->secv; *sectp; sectp++)
-			lower(*sectp);
-
-		if (*manp->secv == NULL)
-			get_all_sect(manp);
-	} else {
-		manp->defsrch = 1;
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * if man.cf has not been found or sections has not been specified
- * man/catman searches the sections lexicographically.
- */
-		if (debug)
-			(void) fprintf(stdout, gettext(
-			    "%s: search the sections lexicographically\n"),
-			    manp->path);
-		manp->secv = NULL;
-		get_all_sect(manp);
-	}
-}
-
-/*
- * Get suffices of all sub-mandir directories in a mandir.
- */
-
-static void
-get_all_sect(struct man_node *manp)
-{
-	DIR *dp;
-	char **dirv;
-	char **dv;
-	char **p;
-	char *prev = NULL;
-	char *tmp = NULL;
-	int  plen;
-	int	maxentries = MAXTOKENS;
-	int	entries = 0;
-
-	if ((dp = opendir(manp->path)) == 0)
-		return;
-
-	/*
-	 * sortdir() allocates memory for dirv and dirv[].
-	 */
-	sortdir(dp, &dirv);
-
-	(void) closedir(dp);
-
-	if (manp->secv == NULL) {
-		/*
-		 * allocates memory for manp->secv only if it's NULL
-		 */
-		manp->secv = (char **)malloc(maxentries * sizeof (char *));
-		if (manp->secv == NULL)
-			malloc_error();
-	}
-
-	for (dv = dirv, p = manp->secv; *dv; dv++) {
-		plen = PLEN;
-		if (match(*dv, SGMLDIR, PLEN+1))
-			++plen;
-
-		if (strcmp(*dv, CONFIG) == 0) {
-			/* release memory allocated by sortdir */
-			free(*dv);
-			continue;
-		}
-
-		if (tmp != NULL)
-			free(tmp);
-		tmp = strdup(*dv + plen);
-		if (tmp == NULL)
-			malloc_error();
-		(void) sprintf(tmp, "%s", *dv + plen);
-
-		if (prev != NULL) {
-			if (strcmp(prev, tmp) == 0) {
-				/* release memory allocated by sortdir */
-				free(*dv);
-				continue;
-			}
-		}
-
-		if (prev != NULL)
-			free(prev);
-		prev = strdup(*dv + plen);
-		if (prev == NULL)
-			malloc_error();
-		(void) sprintf(prev, "%s", *dv + plen);
-		/*
-		 * copy the string in (*dv + plen) to *p
-		 */
-		*p = strdup(*dv + plen);
-		if (*p == NULL)
-			malloc_error();
-		p++;
-		entries++;
-		if (entries == maxentries) {
-			maxentries += MAXTOKENS;
-			manp->secv = (char **)realloc(manp->secv,
-			    sizeof (char *) * maxentries);
-			if (manp->secv == NULL)
-				malloc_error();
-			p = manp->secv + entries;
-		}
-		/* release memory allocated by sortdir */
-		free(*dv);
-	}
-	*p = 0;
-	/* release memory allocated by sortdir */
-	free(dirv);
-}
-
-/*
- * Format man pages (build cat pages); if no
- * sections are specified, build all of them.
- * When building cat pages:
- *	catman() tries to build cat pages for locale specific
- *	man dirs first.  Then, catman() tries to build cat pages
- *	for the default man dir (for C locale like /usr/share/man)
- *	regardless of the locale.
- * When building windex file:
- *	catman() tries to build windex file for locale specific
- *	man dirs first.  Then, catman() tries to build windex file
- *	for the default man dir (for C locale like /usr/share/man)
- *	regardless of the locale.
- */
-
-static void
-catman(struct man_node *manp, char **argv, int argc)
-{
-	char cmdbuf[BUFSIZ];
-	char **dv;
-	int changed;
-	struct man_node *p;
-	int ndirs = 0;
-	char *ldir;
-	int	i;
-	struct dupnode *dnp = NULL;
-	char   **realsecv;
-	/*
-	 * May be overwritten in dupcheck() so must be kept out of .rodata.
-	 */
-	char	fakename[] = " catman ";
-	char	*fakesecv[2];
-
-	fakesecv[0] = fakename;
-	fakesecv[1] = NULL;
-
-	for (p = manp; p != NULL; p = p->next) {
-		/*
-		 * prevent catman from doing very heavy lifting multiple
-		 * times on some directory
-		 */
-		realsecv = p->secv;
-		p->secv = fakesecv;
-		if (dupcheck(p, &dnp) != 0) {
-			p->secv = realsecv;
-			continue;
-		}
-
-/*
- * TRANSLATION_NOTE - message for catman -p
- * ex. mandir path = /usr/share/man
- */
-		if (debug)
-			(void) fprintf(stdout, gettext(
-			    "\nmandir path = %s\n"), p->path);
-		ndirs = 0;
-
-		/*
-		 * Build cat pages
-		 * addlocale() allocates memory and returns it
-		 */
-		ldir = addlocale(p->path);
-		if (!whatonly) {
-			if (*localedir != '\0') {
-				if (defaultmandir)
-					defaultmandir = 0;
-				/* getdirs allocate memory for dv */
-				ndirs = getdirs(ldir, &dv, 1);
-				if (ndirs != 0) {
-					changed = argc ?
-					    makecat(ldir, argv, argc) :
-					    makecat(ldir, dv, ndirs);
-					/* release memory by getdirs */
-					for (i = 0; i < ndirs; i++) {
-						free(dv[i]);
-					}
-					free(dv);
-				}
-			}
-
-			/* default man dir is always processed */
-			defaultmandir = 1;
-			ndirs = getdirs(p->path, &dv, 1);
-			changed = argc ?
-			    makecat(p->path, argv, argc) :
-			    makecat(p->path, dv, ndirs);
-			/* release memory allocated by getdirs */
-			for (i = 0; i < ndirs; i++) {
-				free(dv[i]);
-			}
-			free(dv);
-		}
-		/*
-		 * Build whatis database
-		 *  print error message if locale is set and man dir not found
-		 *  won't build it at all if -c option is on
-		 */
-		if (!compargs && (whatonly || (!nowhatis && changed))) {
-			if (*localedir != '\0') {
-				/* just count the number of ndirs */
-				if ((ndirs = getdirs(ldir, NULL, 0)) != 0) {
-					(void) sprintf(cmdbuf,
-					    "/usr/bin/sh %s %s",
-					    MAKEWHATIS, ldir);
-					(void) sys(cmdbuf);
-				}
-			}
-			/* whatis database of the default man dir */
-			/* will be always built in C locale. */
-			(void) sprintf(cmdbuf,
-			    "/usr/bin/sh %s %s",
-			    MAKEWHATIS, p->path);
-			(void) sys(cmdbuf);
-		}
-		/* release memory allocated by addlocale() */
-		free(ldir);
-	}
-	free_dupnode(dnp);
-}
-
-/*
- * Build cat pages for given sections
- */
-
-static int
-makecat(char *path, char **dv, int ndirs)
-{
-	DIR *dp, *sdp;
-	struct dirent *d;
-	struct stat sbuf;
-	char mandir[MAXPATHLEN+1];
-	char smandir[MAXPATHLEN+1];
-	char catdir[MAXPATHLEN+1];
-	char *dirp, *sdirp;
-	int i, fmt;
-	int manflag, smanflag;
-
-	for (i = fmt = 0; i < ndirs; i++) {
-		(void) snprintf(mandir, MAXPATHLEN, "%s/%s%s",
-		    path, MANDIRNAME, dv[i]);
-		(void) snprintf(smandir, MAXPATHLEN, "%s/%s%s",
-		    path, SGMLDIR, dv[i]);
-		(void) snprintf(catdir, MAXPATHLEN, "%s/%s%s",
-		    path, subdirs[1], dv[i]);
-		dirp = strrchr(mandir, '/') + 1;
-		sdirp = strrchr(smandir, '/') + 1;
-
-		manflag = smanflag = 0;
-
-		if ((dp = opendir(mandir)) != NULL)
-			manflag = 1;
-
-		if (!no_sroff && (sdp = opendir(smandir)) != NULL)
-			smanflag = 1;
-
-		if (dp == 0 && sdp == 0) {
-			if (strcmp(mandir, CONFIG) == 0)
-				perror(mandir);
-			continue;
-		}
-/*
- * TRANSLATION_NOTE - message for catman -p
- * ex. Building cat pages for mandir = /usr/share/man/ja
- */
-		if (debug)
-			(void) fprintf(stdout, gettext(
-			    "Building cat pages for mandir = %s\n"), path);
-
-		if (!compargs && stat(catdir, &sbuf) < 0) {
-			(void) umask(02);
-/*
- * TRANSLATION_NOTE - message for catman -p
- * ex. mkdir /usr/share/man/ja/cat3c
- */
-			if (debug)
-				(void) fprintf(stdout, gettext("mkdir %s\n"),
-				    catdir);
-			else {
-				if (mkdir(catdir, 0755) < 0) {
-					perror(catdir);
-					continue;
-				}
-				(void) chmod(catdir, 0755);
-			}
-		}
-
-		/*
-		 * if it is -c option of catman, if there is no
-		 * coresponding man dir for sman files to go to,
-		 * make the man dir
-		 */
-
-		if (compargs && !manflag) {
-			if (mkdir(mandir, 0755) < 0) {
-				perror(mandir);
-				continue;
-			}
-			(void) chmod(mandir, 0755);
-		}
-
-		if (smanflag) {
-			while ((d = readdir(sdp))) {
-				if (eq(".", d->d_name) || eq("..", d->d_name))
-					continue;
-
-				if (format(path, sdirp, (char *)0, d->d_name)
-				    > 0)
-					fmt++;
-			}
-		}
-
-		if (manflag && !compargs) {
-			while ((d = readdir(dp))) {
-				if (eq(".", d->d_name) || eq("..", d->d_name))
-					continue;
-
-				if (format(path, dirp, (char *)0, d->d_name)
-				    > 0)
-					fmt++;
-			}
-		}
-
-		if (manflag)
-			(void) closedir(dp);
-
-		if (smanflag)
-			(void) closedir(sdp);
-
-	}
-	return (fmt);
-}
-
-
-/*
- * Get all "man" and "sman" dirs under a given manpath
- * and return the number found
- * If -c option is on, only count sman dirs
- */
-
-static int
-getdirs(char *path, char ***dirv, short flag)
-{
-	DIR *dp;
-	struct dirent *d;
-	int n = 0;
-	int plen, sgml_flag, man_flag;
-	int i = 0;
-	int	maxentries = MAXDIRS;
-	char	**dv;
-
-	if ((dp = opendir(path)) == 0) {
-		if (debug) {
-			if (*localedir != '\0')
-				(void) printf(gettext("\
-locale is %s, search in %s\n"), localedir, path);
-			perror(path);
-		}
-		return (0);
-	}
-
-	if (flag) {
-		/* allocate memory for dirv */
-		*dirv = (char **)malloc(sizeof (char *) *
-		    maxentries);
-		if (*dirv == NULL)
-			malloc_error();
-		dv = *dirv;
-	}
-	while ((d = readdir(dp))) {
-		plen = PLEN;
-		man_flag = sgml_flag = 0;
-		if (match(d->d_name, SGMLDIR, PLEN+1)) {
-			plen = PLEN + 1;
-			sgml_flag = 1;
-			i++;
-		}
-
-		if (match(subdirs[0], d->d_name, PLEN))
-			man_flag = 1;
-
-		if (compargs && sgml_flag) {
-			if (flag) {
-				*dv = strdup(d->d_name+plen);
-				if (*dv == NULL)
-					malloc_error();
-				dv++;
-				n = i;
-			}
-		} else if (!compargs && (sgml_flag || man_flag)) {
-			if (flag) {
-				*dv = strdup(d->d_name+plen);
-				if (*dv == NULL)
-					malloc_error();
-				dv++;
-			}
-			n++;
-		}
-		if (flag) {
-			if ((dv - *dirv) == maxentries) {
-				int entries = maxentries;
-				maxentries += MAXTOKENS;
-				*dirv = (char **)realloc(*dirv,
-				    sizeof (char *) * maxentries);
-				if (*dirv == NULL)
-					malloc_error();
-				dv = *dirv + entries;
-			}
-		}
-	}
-
-	(void) closedir(dp);
-	return (n);
-}
-
-
-/*
- * Find matching whatis or apropos entries
- * whatapro() tries to handle the windex file of the locale specific
- * man dirs first, then tries to handle the windex file of the default
- * man dir (of C locale like /usr/share/man).
- */
-
-static void
-whatapro(struct man_node *manp, char *word, int apropos)
-{
-	char whatpath[MAXPATHLEN+1];
-	char *p;
-	struct man_node *b;
-	int ndirs = 0;
-	char *ldir;
-
-
-/*
- * TRANSLATION_NOTE - message for man -d
- * %s takes a parameter to -k option.
- */
-	DPRINTF(gettext("word = %s \n"), word);
-
-	/*
-	 * get base part of name
-	 */
-	if (!apropos) {
-		if ((p = strrchr(word, '/')) == NULL)
-			p = word;
-		else
-			p++;
-	} else {
-		p = word;
-	}
-
-	for (b = manp; b != NULL; b = b->next) {
-
-		if (*localedir != '\0') {
-			/* addlocale() allocates memory and returns it */
-			ldir = addlocale(b->path);
-			if (defaultmandir)
-				defaultmandir = 0;
-			ndirs = getdirs(ldir, NULL, 0);
-			if (ndirs != 0) {
-				(void) sprintf(whatpath, "%s/%s", ldir, WHATIS);
-/*
- * TRANSLATION_NOTE - message for man -d
- * ex. mandir path = /usr/share/man/ja
- */
-				DPRINTF(gettext("\nmandir path = %s\n"), ldir);
-				lookup_windex(whatpath, p, b->secv);
-			}
-			/* release memory allocated by addlocale() */
-			free(ldir);
-		}
-
-		defaultmandir = 1;
-		(void) sprintf(whatpath, "%s/%s", b->path, WHATIS);
-/*
- * TRANSLATION_NOTE - message for man -d
- * ex. mandir path = /usr/share/man
- */
-		DPRINTF(gettext("\nmandir path = %s\n"), b->path);
-
-		lookup_windex(whatpath, p, b->secv);
-	}
-}
-
-
-static void
-lookup_windex(char *whatpath, char *word, char **secv)
-{
-	FILE *fp;
-	char *matches[MAXPAGES];
-	char **pp;
-	wchar_t	wbuf[BUFSIZ];
-	wchar_t *word_wchar = NULL;
-	wchar_t	*ws;
-	size_t	word_len, ret;
-
-	if ((fp = fopen(whatpath, "r")) == NULL) {
-		perror(whatpath);
-		return;
-	}
-
-	if (apropos) {
-		word_len = strlen(word) + 1;
-		if ((word_wchar = (wchar_t *)malloc(sizeof (wchar_t) *
-		    word_len)) == NULL) {
-			malloc_error();
-		}
-		ret = mbstowcs(word_wchar, (const char *)word, word_len);
-		if (ret == (size_t)-1) {
-			(void) fprintf(stderr, gettext(
-			    "Invalid character in keyword\n"));
-			exit(1);
-		}
-		while (fgetws(wbuf, BUFSIZ, fp) != NULL)
-			for (ws = wbuf; *ws; ws++)
-				if (icmp(word_wchar, ws) == 0) {
-					(void) printf("%ws", wbuf);
-					break;
-				}
-	} else {
-		if (bfsearch(fp, matches, word, secv))
-			for (pp = matches; *pp; pp++) {
-				(void) printf("%s", *pp);
-				/*
-				 * release memory allocated by
-				 * strdup() in bfsearch()
-				 */
-				free(*pp);
-			}
-	}
-	(void) fclose(fp);
-	if (word_wchar)
-		free(word_wchar);
-
-}
-
-
-/*
- * case-insensitive compare unless upper case is used
- * ie)	"mount" matches mount, Mount, MOUNT
- *	"Mount" matches Mount, MOUNT
- *	"MOUNT" matches MOUNT only
- *	If matched return 0.  Otherwise, return 1.
- */
-
-static int
-icmp(wchar_t *ws, wchar_t *wt)
-{
-	for (; (*ws == 0) ||
-	    (*ws == (iswupper(*ws) ? *wt: towlower(*wt)));
-	    ws++, wt++)
-		if (*ws == 0)
-			return (0);
-
-	return (1);
-}
-
-
-/*
- * Invoke PAGER with all matching man pages
- */
-
-static void
-more(char **pages, int plain)
-{
-	char cmdbuf[BUFSIZ];
-	char **vp;
-
-	/*
-	 * Dont bother.
-	 */
-	if (list || (*pages == 0))
-		return;
-
-	if (plain && troffit) {
-		cleanup(pages);
-		return;
-	}
-	(void) sprintf(cmdbuf, "%s", troffit ? troffcat :
-	    plain ? CAT : pager);
-
-	/*
-	 * Build arg list
-	 */
-	for (vp = pages; vp < endp; vp++) {
-		(void) strcat(cmdbuf, " ");
-		(void) strcat(cmdbuf, *vp);
-	}
-	(void) sys(cmdbuf);
-	cleanup(pages);
-}
-
-
-/*
- * Get rid of dregs.
- */
-
-static void
-cleanup(char **pages)
-{
-	char **vp;
-
-	for (vp = pages; vp < endp; vp++) {
-		if (match(TEMPLATE, *vp, TMPLEN))
-			(void) unlink(*vp);
-		free(*vp);
-	}
-
-	endp = pages;	/* reset */
-}
-
-
-/*
- * Clean things up after receiving a signal.
- */
-
-/*ARGSUSED*/
-static void
-bye(int sig)
-{
-	cleanup(pages);
-	exit(1);
-	/*NOTREACHED*/
-}
-
-
-/*
- * Split a string by specified separator.
- *    ignore empty components/adjacent separators.
- *    returns vector to all tokens
- */
-
-static char **
-split(char *s1, char sep)
-{
-	char **tokv, **vp;
-	char *mp, *tp;
-	int maxentries = MAXTOKENS;
-	int entries = 0;
-
-	tokv = vp = (char **)malloc(maxentries * sizeof (char *));
-	if (tokv == NULL)
-		malloc_error();
-	mp = s1;
-	for (; mp && *mp; mp = tp) {
-		tp = strchr(mp, sep);
-		if (mp == tp) {		/* empty component */
-			tp++;			/* ignore */
-			continue;
-		}
-		if (tp) {
-			/* a component found */
-			size_t	len;
-
-			len = tp - mp;
-			*vp = (char *)malloc(sizeof (char) * len + 1);
-			if (*vp == NULL)
-				malloc_error();
-			(void) strncpy(*vp, mp, len);
-			*(*vp + len) = '\0';
-			tp++;
-			vp++;
-		} else {
-			/* the last component */
-			*vp = strdup(mp);
-			if (*vp == NULL)
-				malloc_error();
-			vp++;
-		}
-		entries++;
-		if (entries == maxentries) {
-			maxentries += MAXTOKENS;
-			tokv = (char **)realloc(tokv,
-			    maxentries * sizeof (char *));
-			if (tokv == NULL)
-				malloc_error();
-			vp = tokv + entries;
-		}
-	}
-	*vp = 0;
-	return (tokv);
-}
-
-/*
- * Free a vector allocated by split();
- */
-static void
-freev(char **v)
-{
-	int i;
-	if (v != NULL) {
-		for (i = 0; v[i] != NULL; i++) {
-			free(v[i]);
-		}
-		free(v);
-	}
-}
-
-/*
- * Convert paths to full paths if necessary
- *
- */
-
-static void
-fullpaths(struct man_node **manp_head)
-{
-	char *cwd = NULL;
-	char *p;
-	char cwd_gotten = 0;
-	struct man_node *manp = *manp_head;
-	struct man_node *b;
-	struct man_node *prev = NULL;
-
-	for (b = manp; b != NULL; b = b->next) {
-		if (*(b->path) == '/') {
-			prev = b;
-			continue;
-		}
-
-		/* try to get cwd if haven't already */
-		if (!cwd_gotten) {
-			cwd = getcwd(NULL, MAXPATHLEN+1);
-			cwd_gotten = 1;
-		}
-
-		if (cwd) {
-			/* case: relative manpath with cwd: make absolute */
-			if ((p = malloc(strlen(b->path)+strlen(cwd)+2)) ==
-			    NULL) {
-				malloc_error();
-			}
-			(void) sprintf(p, "%s/%s", cwd, b->path);
-			/*
-			 * resetting b->path
-			 */
-			free(b->path);
-			b->path = p;
-		} else {
-			/* case: relative manpath but no cwd: omit path entry */
-			if (prev)
-				prev->next = b->next;
-			else
-				*manp_head = b->next;
-
-			free_manp(b);
-		}
-	}
-	/*
-	 * release memory allocated by getcwd()
-	 */
-	free(cwd);
-}
-
-/*
- * Free a man_node structure and its contents
- */
-
-static void
-free_manp(struct man_node *manp)
-{
-	char **p;
-
-	free(manp->path);
-	p = manp->secv;
-	while ((p != NULL) && (*p != NULL)) {
-		free(*p);
-		p++;
-	}
-	free(manp->secv);
-	free(manp);
-}
-
-
-/*
- * Map (in place) to lower case
- */
-
-static void
-lower(char *s)
-{
-	if (s == 0)
-		return;
-	while (*s) {
-		if (isupper(*s))
-			*s = tolower(*s);
-		s++;
-	}
-}
-
-
-/*
- * compare for sort()
- * sort first by section-spec, then by prefix {sman, man, cat, fmt}
- *	note: prefix is reverse sorted so that "sman" and "man" always
- * 	comes before {cat, fmt}
- */
-
-static int
-cmp(const void *arg1, const void *arg2)
-{
-	int n;
-	char **p1 = (char **)arg1;
-	char **p2 = (char **)arg2;
-
-
-	/* by section; sman always before man dirs */
-	if ((n = strcmp(*p1 + PLEN + (**p1 == 's' ? 1 : 0),
-	    *p2 + PLEN + (**p2 == 's' ? 1 : 0))))
-		return (n);
-
-	/* by prefix reversed */
-	return (strncmp(*p2, *p1, PLEN));
-}
-
-
-/*
- * Find a man page ...
- *   Loop through each path specified,
- *   first try the lookup method (whatis database),
- *   and if it doesn't exist, do the hard way.
- */
-
-static int
-manual(struct man_node *manp, char *name)
-{
-	struct man_node *p;
-	struct man_node *local;
-	int ndirs = 0;
-	char *ldir;
-	char *ldirs[2];
-	char *fullname = name;
-	char *slash;
-
-	if ((slash = strrchr(name, '/')) != NULL) {
-		name = slash + 1;
-	}
-
-	/*
-	 *  for each path in MANPATH
-	 */
-	found = 0;
-
-	for (p = manp; p != NULL; p = p->next) {
-/*
- * TRANSLATION_NOTE - message for man -d
- * ex. mandir path = /usr/share/man
- */
-		DPRINTF(gettext("\nmandir path = %s\n"), p->path);
-
-		if (*localedir != '\0') {
-			/* addlocale() allocates memory and returns it */
-			ldir = addlocale(p->path);
-			if (defaultmandir)
-				defaultmandir = 0;
-/*
- * TRANSLATION_NOTE - message for man -d
- * ex. localedir = ja, ldir = /usr/share/man/ja
- */
-			if (debug)
-				(void) printf(gettext(
-				    "localedir = %s, ldir = %s\n"),
-				    localedir, ldir);
-			ndirs = getdirs(ldir, NULL, 0);
-			if (ndirs != 0) {
-				ldirs[0] = ldir;
-				ldirs[1] = NULL;
-				local = build_manpath(ldirs, 0);
-				if (force ||
-				    windex(local->secv, ldir, name) < 0)
-					mandir(local->secv, ldir, name);
-				free_manp(local);
-			}
-			/* release memory allocated by addlocale() */
-			free(ldir);
-		}
-
-		defaultmandir = 1;
-		/*
-		 * locale mandir not valid, man page in locale
-		 * mandir not found, or -a option present
-		 */
-		if (ndirs == 0 || !found || all) {
-			if (force || windex(p->secv, p->path, name) < 0)
-				mandir(p->secv, p->path, name);
-		}
-
-		if (found && !all)
-			break;
-	}
-
-	if (found) {
-		more(pages, nomore);
-	} else {
-		if (sargs) {
-			(void) fprintf(stderr, gettext("No entry for %s in "
-			    "section(s) %s of the manual.\n"),
-			    fullname, mansec);
-		} else {
-			(void) fprintf(stderr, gettext(
-			    "No manual entry for %s.\n"), fullname, mansec);
-		}
-
-		if (sman_no_man_no_sroff)
-			(void) fprintf(stderr, gettext("(An SGML manpage was "
-			    "found for '%s' but it cannot be displayed.)\n"),
-			    fullname, mansec);
-	}
-	sman_no_man_no_sroff = 0;
-	return (!found);
-}
-
-
-/*
- * For a specified manual directory,
- *	read, store, & sort section subdirs,
- *	for each section specified
- *		find and search matching subdirs
- */
-
-static void
-mandir(char **secv, char *path, char *name)
-{
-	DIR *dp;
-	char **dirv;
-	char **dv, **pdv;
-	int len, dslen, plen = PLEN;
-
-	if ((dp = opendir(path)) == 0) {
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * opendir(%s) returned 0
- */
-		if (debug)
-			(void) fprintf(stdout, gettext(
-			    " opendir on %s failed\n"), path);
-		return;
-	}
-
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * ex. mandir path = /usr/share/man/ja
- */
-	if (debug)
-		(void) printf(gettext("mandir path = %s\n"), path);
-
-	/*
-	 * sordir() allocates memory for dirv and dirv[].
-	 */
-	sortdir(dp, &dirv);
-	/*
-	 * Search in the order specified by MANSECTS
-	 */
-	for (; *secv; secv++) {
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * ex.  section = 3c
- */
-		DPRINTF(gettext("  section = %s\n"), *secv);
-		len = strlen(*secv);
-		for (dv = dirv; *dv; dv++) {
-			plen = PLEN;
-			if (*dv[0] == 's')
-				plen++;
-			dslen = strlen(*dv+plen);
-			if (dslen > len)
-				len = dslen;
-			if (**secv == '\\') {
-				if (!eq(*secv + 1, *dv+plen))
-					continue;
-			} else if (strncasecmp(*secv, *dv+plen, len) != 0) {
-				/* check to see if directory name changed */
-				if (!all &&
-				    (newsection = map_section(*secv, path))
-				    == NULL) {
-					continue;
-				}
-				if (newsection == NULL)
-					newsection = "";
-				if (!match(newsection, *dv+plen, len)) {
-					continue;
-				}
-			}
-
-			if (searchdir(path, *dv, name) == 0)
-				continue;
-
-			if (!all) {
-				/* release memory allocated by sortdir() */
-				pdv = dirv;
-				while (*pdv) {
-					free(*pdv);
-					pdv++;
-				}
-				(void) closedir(dp);
-				/* release memory allocated by sortdir() */
-				free(dirv);
-				return;
-			}
-			/*
-			 * if we found a match in the man dir skip
-			 * the corresponding cat dir if it exists
-			 */
-			if (all && **dv == 'm' && *(dv+1) &&
-			    eq(*(dv+1)+plen, *dv+plen))
-					dv++;
-		}
-	}
-	/* release memory allocated by sortdir() */
-	pdv = dirv;
-	while (*pdv) {
-		free(*pdv);
-		pdv++;
-	}
-	free(dirv);
-	(void) closedir(dp);
-}
-
-/*
- * Sort directories.
- */
-
-static void
-sortdir(DIR *dp, char ***dirv)
-{
-	struct dirent *d;
-	char **dv;
-	int	maxentries = MAXDIRS;
-	int	entries = 0;
-
-	*dirv = (char **)malloc(sizeof (char *) * maxentries);
-	dv = *dirv;
-	while ((d = readdir(dp))) {	/* store dirs */
-		if (eq(d->d_name, ".") || eq(d->d_name, ".."))	/* ignore */
-			continue;
-
-		/* check if it matches sman, man, cat format */
-		if (match(d->d_name, SGMLDIR, PLEN+1) ||
-		    match(d->d_name, subdirs[0], PLEN) ||
-		    match(d->d_name, subdirs[1], PLEN)) {
-			*dv = malloc(strlen(d->d_name) + 1);
-			if (*dv == NULL)
-				malloc_error();
-			(void) strcpy(*dv, d->d_name);
-			dv++;
-			entries++;
-			if (entries == maxentries) {
-				maxentries += MAXDIRS;
-				*dirv = (char **)realloc(*dirv,
-				    sizeof (char *) * maxentries);
-				if (*dirv == NULL)
-					malloc_error();
-				dv = *dirv + entries;
-			}
-		}
-	}
-	*dv = 0;
-
-	qsort((void *)*dirv, dv - *dirv, sizeof (char *), cmp);
-
-}
-
-
-/*
- * Search a section subdirectory for a
- * given man page, return 1 for success
- */
-
-static int
-searchdir(char *path, char *dir, char *name)
-{
-	DIR *sdp;
-	struct dirent *sd;
-	char sectpath[MAXPATHLEN+1];
-	char file[MAXNAMLEN+1];
-	char dname[MAXPATHLEN+1];
-	char *last;
-	int nlen;
-
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * ex.   scanning = man3c
- */
-	DPRINTF(gettext("    scanning = %s\n"), dir);
-	(void) sprintf(sectpath, "%s/%s", path, dir);
-	(void) snprintf(file, MAXPATHLEN, "%s.", name);
-
-	if ((sdp = opendir(sectpath)) == 0) {
-		if (errno != ENOTDIR)	/* ignore matching cruft */
-			perror(sectpath);
-		return (0);
-	}
-	while ((sd = readdir(sdp))) {
-		last = strrchr(sd->d_name, '.');
-		nlen = last - sd->d_name;
-		(void) sprintf(dname, "%.*s.", nlen, sd->d_name);
-		if (eq(dname, file) || eq(sd->d_name, name)) {
-			if (no_sroff && *dir == 's') {
-				sman_no_man_no_sroff = 1;
-				return (0);
-			}
-			(void) format(path, dir, name, sd->d_name);
-			(void) closedir(sdp);
-			return (1);
-		}
-	}
-	(void) closedir(sdp);
-	return (0);
-}
-
-/*
- * Check the hash table of old directory names to see if there is a
- * new directory name.
- * Returns new directory name if a match; after checking to be sure
- * directory exists.
- * Otherwise returns NULL
- */
-
-static char *
-map_section(char *section, char *path)
-{
-	int i;
-	int len;
-	char fullpath[MAXPATHLEN];
-
-	if (list)  /* -l option fall through */
-		return (NULL);
-
-	for (i = 0; i <= ((sizeof (map)/sizeof (map[0]) - 1)); i++) {
-		if (strlen(section) > strlen(map[i].new_name)) {
-			len = strlen(section);
-		} else {
-			len = strlen(map[i].new_name);
-		}
-		if (match(section, map[i].old_name, len)) {
-			(void) sprintf(fullpath,
-			    "%s/sman%s", path, map[i].new_name);
-			if (!access(fullpath, R_OK | X_OK)) {
-				return (map[i].new_name);
-			} else {
-				return (NULL);
-			}
-		}
-	}
-
-	return (NULL);
-}
-
-
-/*
- * Use windex database for quick lookup of man pages
- * instead of mandir() (brute force search)
- */
-
-static int
-windex(char **secv, char *path, char *name)
-{
-	FILE *fp;
-	struct stat sbuf;
-	struct suffix *sp;
-	struct suffix	psecs[MAXPAGES+1];
-	char whatfile[MAXPATHLEN+1];
-	char page[MAXPATHLEN+1];
-	char *matches[MAXPAGES];
-	char *file, *dir;
-	char **sv, **vp;
-	int len, dslen, exist, i;
-	int	found_in_windex = 0;
-	char *tmp[] = {0, 0, 0, 0};
-
-
-	(void) sprintf(whatfile, "%s/%s", path, WHATIS);
-	if ((fp = fopen(whatfile, "r")) == NULL) {
-		if (errno == ENOENT)
-			return (-1);
-		return (0);
-	}
-
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * ex. search in = /usr/share/man/ja/windex file
- */
-	if (debug)
-		(void) fprintf(stdout, gettext(
-		    " search in = %s file\n"), whatfile);
-
-	if (bfsearch(fp, matches, name, NULL) == 0) {
-		(void) fclose(fp);
-		return (-1); /* force search in mandir */
-	}
-
-	(void) fclose(fp);
-
-	/*
-	 * Save and split sections
-	 * section() allocates memory for sp->ds
-	 */
-	for (sp = psecs, vp = matches; *vp; vp++, sp++) {
-		if ((sp - psecs) < MAXPAGES) {
-			section(sp, *vp);
-		} else {
-			if (debug)
-				(void) fprintf(stderr, gettext(
-				    "too many sections in %s windex entry\n"),
-				    name);
-
-			/* Setting sp->ds to NULL signifies end-of-data. */
-			sp->ds = 0;
-			goto finish;
-		}
-	}
-
-	sp->ds = 0;
-
-	/*
-	 * Search in the order specified
-	 * by MANSECTS
-	 */
-	for (; *secv; secv++) {
-		len = strlen(*secv);
-
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * ex.  search an entry to match printf.3c
- */
-		if (debug)
-			(void) fprintf(stdout, gettext(
-			    "  search an entry to match %s.%s\n"), name, *secv);
-		/*
-		 * For every whatis entry that
-		 * was matched
-		 */
-		for (sp = psecs; sp->ds; sp++) {
-			dslen = strlen(sp->ds);
-			if (dslen > len)
-				len = dslen;
-			if (**secv == '\\') {
-				if (!eq(*secv + 1, sp->ds))
-					continue;
-			} else if (!match(*secv, sp->ds, len)) {
-				/* check to see if directory name changed */
-				if (!all &&
-				    (newsection = map_section(*secv, path))
-				    == NULL) {
-					continue;
-				}
-				if (newsection == NULL)
-					newsection = "";
-				if (!match(newsection, sp->ds, len)) {
-					continue;
-				}
-			}
-			/*
-			 * here to form "sman", "man", "cat"|"fmt" in
-			 * order
-			 */
-			if (!no_sroff) {
-				tmp[0] = SGMLDIR;
-				for (i = 1; i < 4; i++)
-					tmp[i] = subdirs[i-1];
-			} else {
-				for (i = 0; i < 3; i++)
-					tmp[i] = subdirs[i];
-			}
-
-			for (sv = tmp; *sv; sv++) {
-				(void) sprintf(page,
-				    "%s/%s%s/%s%s%s", path, *sv,
-				    sp->ds, name, *sp->fs ? "." : "",
-				    sp->fs);
-				exist = (stat(page, &sbuf) == 0);
-				if (exist)
-					break;
-			}
-			if (!exist) {
-				(void) fprintf(stderr, gettext(
-				    "%s entry incorrect:  %s(%s) not found.\n"),
-				    WHATIS, name, sp->ds);
-				continue;
-			}
-
-			file = strrchr(page, '/'), *file = 0;
-			dir = strrchr(page, '/');
-
-			/*
-			 * By now we have a match
-			 */
-			found_in_windex = 1;
-			(void) format(path, ++dir, name, ++file);
-
-			if (!all)
-				goto finish;
-		}
-	}
-finish:
-	/*
-	 * release memory allocated by section()
-	 */
-	sp = psecs;
-	while (sp->ds) {
-		free(sp->ds);
-		sp->ds = NULL;
-		sp++;
-	}
-
-	/*
-	 * If we didn't find a match, return failure as if we didn't find
-	 * the windex at all. Why? Well, if you create a windex, then upgrade
-	 * to a later release that contains new man pages, and forget to
-	 * recreate the windex (since we don't do that automatically), you
-	 * won't see any new man pages since they aren't in the windex.
-	 * Pretending we didn't see a windex at all if there are no matches
-	 * forces a search of the underlying directory. After all, the
-	 * goal of the windex is to enable searches (man -k) and speed things
-	 * up, not to _prevent_ you from seeing new man pages, so this seems
-	 * ok. The only problem is when there are multiple entries (different
-	 * sections), and some are in and some are out. Say you do 'man ls',
-	 * and ls(1) isn't in the windex, but ls(1B) is. In that case, we
-	 * will find a match in ls(1B), and you'll see that man page.
-	 * That doesn't seem bad since if you specify the section the search
-	 * will be restricted too. So in the example above, if you do
-	 * 'man -s 1 ls' you'll get ls(1).
-	 */
-	if (found_in_windex)
-		return (0);
-	else
-		return (-1);
-}
-
-
-/*
- * Return pointers to the section-spec
- * and file-suffix of a whatis entry
- */
-
-static void
-section(struct suffix *sp, char *s)
-{
-	char *lp, *p;
-
-	lp = strchr(s, '(');
-	p = strchr(s, ')');
-
-	if (++lp == 0 || p == 0 || lp == p) {
-		(void) fprintf(stderr,
-		    gettext("mangled windex entry:\n\t%s\n"), s);
-		return;
-	}
-	*p = 0;
-
-	/*
-	 * copy the string pointed to by lp
-	 */
-	lp = strdup(lp);
-	if (lp == NULL)
-		malloc_error();
-	/*
-	 * release memory in s
-	 * s has been allocated memory in bfsearch()
-	 */
-	free(s);
-
-	lower(lp);
-
-	/*
-	 * split section-specifier if file-name
-	 * suffix differs from section-suffix
-	 */
-	sp->ds = lp;
-	if ((p = strchr(lp, '/'))) {
-		*p++ = 0;
-		sp->fs = p;
-	} else
-		sp->fs = lp;
-}
-
-
-/*
- * Binary file search to find matching man
- *   pages in whatis database.
- */
-
-static int
-bfsearch(FILE *fp, char **matchv, char *key, char **secv)
-{
-	char entry[BUFSIZ];
-	char **vp;
-	long top, bot, mid;
-	int	c;
-
-	vp = matchv;
-	bot = 0;
-	(void) fseek(fp, 0L, 2);
-	top = ftell(fp);
-	for (;;) {
-		mid = (top+bot)/2;
-		(void) fseek(fp, mid, 0);
-		do {
-			c = getc(fp);
-			mid++;
-		} while (c != EOF && c != '\n');
-		if (fgets(entry, sizeof (entry), fp) == NULL)
-			break;
-		switch (compare(key, entry, secv)) {
-		case -2:
-		case -1:
-		case 0:
-			if (top <= mid)
-				break;
-			top = mid;
-			continue;
-		case 1:
-		case 2:
-			bot = mid;
-			continue;
-		}
-		break;
-	}
-	(void) fseek(fp, bot, 0);
-	while (ftell(fp) < top) {
-		if (fgets(entry, sizeof (entry), fp) == NULL) {
-			*matchv = 0;
-			return (matchv - vp);
-		}
-		switch (compare(key, entry, secv)) {
-		case -2:
-			*matchv = 0;
-			return (matchv - vp);
-		case -1:
-		case 0:
-			*matchv = strdup(entry);
-			if (*matchv == NULL)
-				malloc_error();
-			else
-				matchv++;
-			break;
-		case 1:
-		case 2:
-			continue;
-		}
-		break;
-	}
-	while (fgets(entry, sizeof (entry), fp)) {
-		switch (compare(key, entry, secv)) {
-		case -1:
-		case 0:
-			*matchv = strdup(entry);
-			if (*matchv == NULL)
-				malloc_error();
-			else
-				matchv++;
-			continue;
-		}
-		break;
-	}
-	*matchv = 0;
-	return (matchv - vp);
-}
-
-static int
-compare(char *key, char *entry, char **secv)
-{
-	char	*entbuf;
-	char	*s;
-	int	comp, mlen;
-	int	mbcurmax = MB_CUR_MAX;
-	char 	*secp = NULL;
-	int	rv;
-	int	eblen;
-
-	entbuf = strdup(entry);
-	if (entbuf == NULL) {
-		malloc_error();
-	}
-	eblen = strlen(entbuf);
-
-	s = entbuf;
-	while (*s) {
-		if (*s == '\t' || *s == ' ') {
-			*s = '\0';
-			break;
-		}
-		mlen = mblen(s, mbcurmax);
-		if (mlen == -1) {
-			(void) fprintf(stderr, gettext(
-			    "Invalid character in windex file.\n"));
-			exit(1);
-		}
-		s += mlen;
-	}
-	/*
-	 * Find the section within parantheses
-	 */
-	if (secv != NULL && (s - entbuf) < eblen) {
-		if ((secp = strchr(s + 1, ')')) != NULL) {
-			*secp = '\0';
-			if ((secp = strchr(s + 1, '(')) != NULL) {
-				secp++;
-			}
-		}
-	}
-
-	comp = strcmp(key, entbuf);
-	if (comp == 0) {
-		if (secp == NULL) {
-			rv = 0;
-		} else {
-			while (*secv != NULL) {
-				if ((strcmp(*secv, secp)) == 0) {
-					rv = 0;
-					break;
-				}
-				secv++;
-			}
-		}
-	} else if (comp < 0) {
-		rv = -2;
-	} else {
-		rv = 2;
-	}
-	free(entbuf);
-	return (rv);
-}
-
-
-/*
- * Format a man page and follow .so references
- * if necessary.
- */
-
-static int
-format(char *path, char *dir, char *name, char *pg)
-{
-	char manpname[MAXPATHLEN+1], catpname[MAXPATHLEN+1];
-	char manpname_sgml[MAXPATHLEN+1], smantmpname[MAXPATHLEN+1];
-	char soed[MAXPATHLEN+1], soref[MAXPATHLEN+1];
-	char manbuf[BUFSIZ], cmdbuf[BUFSIZ], tmpbuf[BUFSIZ];
-	char tmpdir[MAXPATHLEN+1];
-	int socount, updatedcat, regencat;
-	struct stat mansb, catsb, smansb;
-	char *tmpname;
-	int catonly = 0;
-	struct stat statb;
-	int plen = PLEN;
-	FILE *md;
-	int tempfd;
-	ssize_t	count;
-	int	temp, sgml_flag = 0, check_flag = 0;
-	char prntbuf[BUFSIZ + 1];
-	char *ptr;
-	char *new_m;
-	char	*tmpsubdir;
-
-	found++;
-
-	if (*dir != 'm' && *dir != 's')
-		catonly++;
-
-
-	if (*dir == 's') {
-		tmpsubdir = SGMLDIR;
-		++plen;
-		(void) sprintf(manpname_sgml, "%s/man%s/%s",
-		    path, dir+plen, pg);
-	} else
-		tmpsubdir = MANDIRNAME;
-
-	if (list) {
-		(void) printf(gettext("%s (%s)\t-M %s\n"),
-		    name, dir+plen, path);
-		return (-1);
-	}
-
-	(void) sprintf(manpname, "%s/%s%s/%s", path, tmpsubdir, dir+plen, pg);
-	(void) sprintf(catpname, "%s/%s%s/%s", path, subdirs[1], dir+plen, pg);
-
-	(void) sprintf(smantmpname, "%s/%s%s/%s", path, SGMLDIR, dir+plen, pg);
-
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * ex.  unformatted = /usr/share/man/ja/man3s/printf.3s
- */
-	DPRINTF(gettext(
-	    "      unformatted = %s\n"), catonly ? "" : manpname);
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * ex.  formatted = /usr/share/man/ja/cat3s/printf.3s
- */
-	DPRINTF(gettext(
-	    "      formatted = %s\n"), catpname);
-
-	/*
-	 * Take care of indirect references to other man pages;
-	 * i.e., resolve files containing only ".so manx/file.x".
-	 * We follow .so chains, replacing title with the .so'ed
-	 * file at each stage, and keeping track of how many times
-	 * we've done so, so that we can avoid looping.
-	 */
-	*soed = 0;
-	socount = 0;
-	for (;;) {
-		FILE *md;
-		char *cp;
-		char *s;
-		char *new_s;
-
-		if (catonly)
-			break;
-		/*
-		 * Grab manpname's first line, stashing it in manbuf.
-		 */
-
-
-		if ((md = fopen(manpname, "r")) == NULL) {
-			if (*soed && errno == ENOENT) {
-				(void) fprintf(stderr,
-				    gettext("Can't find referent of "
-				    ".so in %s\n"), soed);
-				(void) fflush(stderr);
-				return (-1);
-			}
-			perror(manpname);
-			return (-1);
-		}
-
-		/*
-		 * If this is a directory, just ignore it.
-		 */
-		if (fstat(fileno(md), &statb) == NULL) {
-			if (S_ISDIR(statb.st_mode)) {
-				if (debug) {
-					(void) fprintf(stderr,
-					    "\tignoring directory %s\n",
-					    manpname);
-					(void) fflush(stderr);
-				}
-				(void) fclose(md);
-				return (-1);
-			}
-		}
-
-		if (fgets(manbuf, BUFSIZ-1, md) == NULL) {
-			(void) fclose(md);
-			(void) fprintf(stderr, gettext("%s: null file\n"),
-			    manpname);
-			(void) fflush(stderr);
-			return (-1);
-		}
-		(void) fclose(md);
-
-		if (strncmp(manbuf, DOT_SO, sizeof (DOT_SO) - 1))
-			break;
-so_again:	if (++socount > SOLIMIT) {
-			(void) fprintf(stderr, gettext(".so chain too long\n"));
-			(void) fflush(stderr);
-			return (-1);
-		}
-		s = manbuf + sizeof (DOT_SO) - 1;
-		if ((check_flag == 1) && ((new_s = strrchr(s, '/')) != NULL)) {
-				new_s++;
-				(void) sprintf(s, "%s%s/%s",
-				    tmpsubdir, dir+plen, new_s);
-		}
-
-		cp = strrchr(s, '\n');
-		if (cp)
-			*cp = '\0';
-		/*
-		 * Compensate for sloppy typists by stripping
-		 * trailing white space.
-		 */
-		cp = s + strlen(s);
-		while (--cp >= s && (*cp == ' ' || *cp == '\t'))
-			*cp = '\0';
-
-		/*
-		 * Go off and find the next link in the chain.
-		 */
-		(void) strcpy(soed, manpname);
-		(void) strcpy(soref, s);
-		(void) sprintf(manpname, "%s/%s", path, s);
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * ex.  .so ref = man3c/string.3c
- */
-		DPRINTF(gettext(".so ref = %s\n"), s);
-	}
-
-	/*
-	 * Make symlinks if so'ed and cattin'
-	 */
-	if (socount && catmando) {
-		(void) sprintf(cmdbuf, "cd %s; rm -f %s; ln -s ../%s%s %s",
-		    path, catpname, subdirs[1], soref+plen, catpname);
-		(void) sys(cmdbuf);
-		return (1);
-	}
-
-	/*
-	 * Obtain the cat page that corresponds to the man page.
-	 * If it already exists, is up to date, and if we haven't
-	 * been told not to use it, use it as it stands.
-	 */
-	regencat = updatedcat = 0;
-	if (compargs || (!catonly && stat(manpname, &mansb) >= 0 &&
-	    (stat(catpname, &catsb) < 0 || catsb.st_mtime < mansb.st_mtime)) ||
-	    (access(catpname, R_OK) != 0)) {
-		/*
-		 * Construct a shell command line for formatting manpname.
-		 * The resulting file goes initially into /tmp.  If possible,
-		 * it will later be moved to catpname.
-		 */
-
-		int pipestage = 0;
-		int needcol = 0;
-		char *cbp = cmdbuf;
-
-		regencat = updatedcat = 1;
-
-		if (!catmando && !debug && !check_flag) {
-			(void) fprintf(stderr, gettext(
-			    "Reformatting page.  Please Wait..."));
-			if (sargs && (newsection != NULL) &&
-			    (*newsection != '\0')) {
-				(void) fprintf(stderr, gettext(
-				    "\nThe directory name has been changed "
-				    "to %s\n"), newsection);
-			}
-			(void) fflush(stderr);
-		}
-
-		/*
-		 * in catman command, if the file exists in sman dir already,
-		 * don't need to convert the file in man dir to cat dir
-		 */
-
-		if (!no_sroff && catmando &&
-		    match(tmpsubdir, MANDIRNAME, PLEN) &&
-		    stat(smantmpname, &smansb) >= 0)
-			return (1);
-
-		/*
-		 * cd to path so that relative .so commands will work
-		 * correctly
-		 */
-		(void) sprintf(cbp, "cd %s; ", path);
-		cbp += strlen(cbp);
-
-
-		/*
-		 * check to see whether it is a sgml file
-		 * assume sgml symbol(>!DOCTYPE) can be found in the first
-		 * BUFSIZ bytes
-		 */
-
-		if ((temp = open(manpname, 0)) == -1) {
-				perror(manpname);
-				return (-1);
-		}
-
-		if ((count = read(temp, prntbuf, BUFSIZ)) <= 0) {
-				perror(manpname);
-				return (-1);
-		}
-
-		prntbuf[count] = '\0';	/* null terminate */
-		ptr = prntbuf;
-		if (sgmlcheck((const char *)ptr) == 1) {
-			sgml_flag = 1;
-			if (defaultmandir && *localedir) {
-				(void) sprintf(cbp, "LC_MESSAGES=C %s %s ",
-				    SROFF_CMD, manpname);
-			} else {
-				(void) sprintf(cbp, "%s %s ",
-				    SROFF_CMD, manpname);
-			}
-			cbp += strlen(cbp);
-		} else if (*dir == 's') {
-			(void) close(temp);
-			return (-1);
-		}
-		(void) close(temp);
-
-		/*
-		 * Check for special formatting requirements by examining
-		 * manpname's first line preprocessor specifications.
-		 */
-
-		if (strncmp(manbuf, PREPROC_SPEC,
-		    sizeof (PREPROC_SPEC) - 1) == 0) {
-			char *ptp;
-
-			ptp = manbuf + sizeof (PREPROC_SPEC) - 1;
-			while (*ptp && *ptp != '\n') {
-				const struct preprocessor *pp;
-
-				/*
-				 * Check for a preprocessor we know about.
-				 */
-				for (pp = preprocessors; pp->p_tag; pp++) {
-					if (pp->p_tag == *ptp)
-						break;
-				}
-				if (pp->p_tag == 0) {
-					(void) fprintf(stderr,
-					    gettext("unknown preprocessor "
-					    "specifier %c\n"), *ptp);
-					(void) fflush(stderr);
-					return (-1);
-				}
-
-				/*
-				 * Add it to the pipeline.
-				 */
-				(void) sprintf(cbp, "%s %s |",
-				    troffit ? pp->p_troff : pp->p_nroff,
-				    pipestage++ == 0 ? manpname :
-				    pp->p_stdin_char);
-				cbp += strlen(cbp);
-
-				/*
-				 * Special treatment: if tbl is among the
-				 * preprocessors and we'll process with
-				 * nroff, we have to pass things through
-				 * col at the end of the pipeline.
-				 */
-				if (pp->p_tag == 't' && !troffit)
-					needcol++;
-
-				ptp++;
-			}
-		}
-
-		/*
-		 * if catman, use the cat page name
-		 * otherwise, dup template and create another
-		 * (needed for multiple pages)
-		 */
-		if (catmando)
-			tmpname = catpname;
-		else {
-			tmpname = strdup(TEMPLATE);
-			if (tmpname == NULL)
-				malloc_error();
-			(void) close(mkstemp(tmpname));
-		}
-
-		if (! Tflag) {
-			if (*localedir != '\0') {
-				(void) sprintf(macros, "%s/%s", path, MACROF);
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * ex.  locale macros = /usr/share/man/ja/tmac.an
- */
-				if (debug)
-					(void) printf(gettext(
-					    "\nlocale macros = %s "),
-					    macros);
-				if (stat(macros, &statb) < 0)
-					(void) strcpy(macros, TMAC_AN);
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * ex.  macros = /usr/share/man/ja/tman.an
- */
-				if (debug)
-					(void) printf(gettext(
-					    "\nmacros = %s\n"),
-					    macros);
-			}
-		}
-
-		tmpdir[0] = '\0';
-		if (sgml_flag == 1) {
-			if (check_flag == 0) {
-				strcpy(tmpdir, "/tmp/sman_XXXXXX");
-				if ((tempfd = mkstemp(tmpdir)) == -1) {
-					(void) fprintf(stderr, gettext(
-					    "%s: null file\n"), tmpdir);
-					(void) fflush(stderr);
-					return (-1);
-				}
-
-				if (debug)
-					close(tempfd);
-
-				(void) sprintf(tmpbuf, "%s > %s",
-				    cmdbuf, tmpdir);
-				if (sys(tmpbuf)) {
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * Error message if sys(%s) failed
- */
-					(void) fprintf(stderr, gettext(
-					    "sys(%s) fail!\n"), tmpbuf);
-					(void) fprintf(stderr,
-					    gettext(" aborted (sorry)\n"));
-					(void) fflush(stderr);
-					/* release memory for tmpname */
-					if (!catmando) {
-						(void) unlink(tmpdir);
-						(void) unlink(tmpname);
-						free(tmpname);
-					}
-					return (-1);
-				} else if (debug == 0) {
-					if ((md = fdopen(tempfd, "r"))
-					    == NULL) {
-						(void) fprintf(stderr, gettext(
-						    "%s: null file\n"), tmpdir);
-						(void) fflush(stderr);
-						close(tempfd);
-						/* release memory for tmpname */
-						if (!catmando)
-							free(tmpname);
-						return (-1);
-					}
-
-					/* if the file is empty, */
-					/* it's a fragment, do nothing */
-					if (fgets(manbuf, BUFSIZ-1, md)
-					    == NULL) {
-						(void) fclose(md);
-						/* release memory for tmpname */
-						if (!catmando)
-							free(tmpname);
-						return (1);
-					}
-					(void) fclose(md);
-
-					if (strncmp(manbuf, DOT_SO,
-					    sizeof (DOT_SO) - 1) == 0) {
-						if (!compargs) {
-						check_flag = 1;
-						(void) unlink(tmpdir);
-						(void) unlink(tmpname);
-						/* release memory for tmpname */
-						if (!catmando)
-							free(tmpname);
-						goto so_again;
-						} else {
-							(void) unlink(tmpdir);
-						strcpy(tmpdir,
-						    "/tmp/sman_XXXXXX");
-						tempfd = mkstemp(tmpdir);
-						if ((tempfd == -1) ||
-						    (md = fdopen(tempfd, "w"))
-						    == NULL) {
-							(void) fprintf(stderr,
-							    gettext(
-							    "%s: null file\n"),
-							    tmpdir);
-							(void) fflush(stderr);
-							if (tempfd != -1)
-								close(tempfd);
-						/* release memory for tmpname */
-							if (!catmando)
-								free(tmpname);
-							return (-1);
-						}
-				if ((new_m = strrchr(manbuf, '/')) != NULL) {
-		(void) fprintf(md, ".so man%s%s\n", dir+plen, new_m);
-							} else {
-/*
- * TRANSLATION_NOTE - message for catman -c
- * Error message if unable to get file name
- */
-				(void) fprintf(stderr,
-				    gettext("file not found\n"));
-				(void) fflush(stderr);
-				return (-1);
-				}
-							(void) fclose(md);
-						}
-					}
-				}
-				if (catmando && compargs)
-					(void) sprintf(cmdbuf, "cat %s > %s",
-					    tmpdir, manpname_sgml);
-				else
-	(void) sprintf(cmdbuf, " cat %s | tbl | eqn | %s %s - %s > %s",
-	    tmpdir, troffit ? troffcmd : "nroff -u0 -Tlp",
-	    macros, troffit ? "" : " | col -x", tmpname);
-			} else
-				if (catmando && compargs)
-					(void) sprintf(cbp, " > %s",
-					    manpname_sgml);
-				else
-	(void) sprintf(cbp, " | tbl | eqn | %s %s - %s > %s",
-	    troffit ? troffcmd : "nroff -u0 -Tlp",
-	    macros, troffit ? "" : " | col -x", tmpname);
-
-		} else
-	(void) sprintf(cbp, "%s %s %s%s > %s",
-	    troffit ? troffcmd : "nroff -u0 -Tlp",
-	    macros, pipestage == 0 ? manpname : "-",
-	    troffit ? "" : " | col -x", tmpname);
-
-		/* Reformat the page. */
-		if (sys(cmdbuf)) {
-/*
- * TRANSLATION_NOTE - message for man -d or catman -p
- * Error message if sys(%s) failed
- */
-			(void) fprintf(stderr, gettext(
-			    "sys(%s) fail!\n"), cmdbuf);
-			(void) fprintf(stderr, gettext(" aborted (sorry)\n"));
-			(void) fflush(stderr);
-			(void) unlink(tmpname);
-			/* release memory for tmpname */
-			if (!catmando)
-				free(tmpname);
-			return (-1);
-		}
-
-		if (tmpdir[0] != '\0')
-			(void) unlink(tmpdir);
-
-		if (catmando)
-			return (1);
-
-		/*
-		 * Attempt to move the cat page to its proper home.
-		 */
-		(void) sprintf(cmdbuf,
-		    "trap '' 1 15; /usr/bin/mv -f %s %s 2> /dev/null",
-		    tmpname,
-		    catpname);
-		if (sys(cmdbuf))
-			updatedcat = 0;
-		else if (debug == 0)
-			(void) chmod(catpname, 0644);
-
-		if (debug) {
-			/* release memory for tmpname */
-			if (!catmando)
-				free(tmpname);
-			(void) unlink(tmpname);
-			return (1);
-		}
-
-		(void) fprintf(stderr, gettext(" done\n"));
-		(void) fflush(stderr);
-	}
-
-	/*
-	 * Save file name (dup if necessary)
-	 * to view later
-	 * fix for 1123802 - don't save names if we are invoked as catman
-	 */
-	if (!catmando) {
-		char	**tmpp;
-		int	dup;
-		char	*newpage;
-
-		if (regencat && !updatedcat)
-			newpage = tmpname;
-		else {
-			newpage = strdup(catpname);
-			if (newpage == NULL)
-				malloc_error();
-		}
-		/* make sure we don't add a dup */
-		dup = 0;
-		for (tmpp = pages; tmpp < endp; tmpp++) {
-			if (strcmp(*tmpp, newpage) == 0) {
-				dup = 1;
-				break;
-			}
-		}
-		if (!dup)
-			*endp++ = newpage;
-		if (endp >= &pages[MAXPAGES]) {
-			fprintf(stderr,
-			    gettext("Internal pages array overflow!\n"));
-			exit(1);
-		}
-	}
-
-	return (regencat);
-}
-
-/*
- * Add <localedir> to the path.
- */
-
-static char *
-addlocale(char *path)
-{
-
-	char *tmp;
-
-	tmp = malloc(strlen(path) + strlen(localedir) + 2);
-	if (tmp == NULL)
-		malloc_error();
-	(void) sprintf(tmp, "%s/%s", path, localedir);
-	return (tmp);
-
-}
-
-/*
- * From the configuration file "man.cf", get the order of suffices of
- * sub-mandirs to be used in the search path for a given mandir.
- */
-
-static char *
-check_config(char *path)
-{
-	FILE *fp;
-	static char submandir[BUFSIZ];
-	char *sect;
-	char fname[MAXPATHLEN];
-
-	(void) sprintf(fname, "%s/%s", path, CONFIG);
-
-	if ((fp = fopen(fname, "r")) == NULL)
-		return (NULL);
-	else {
-		if (get_manconfig(fp, submandir) == -1) {
-			(void) fclose(fp);
-			return (NULL);
-		}
-
-		(void) fclose(fp);
-
-		sect = strchr(submandir, '=');
-		if (sect != NULL)
-			return (++sect);
-		else
-			return (NULL);
-	}
-}
-
-/*
- *  This routine is for getting the MANSECTS entry from man.cf.
- *  It sets submandir to the line in man.cf that contains
- *	MANSECTS=sections[,sections]...
- */
-
-static int
-get_manconfig(FILE *fp, char *submandir)
-{
-	char *s, *t, *rc;
-	char buf[BUFSIZ];
-
-	while ((rc = fgets(buf, sizeof (buf), fp)) != NULL) {
-
-		/*
-		 * skip leading blanks
-		 */
-		for (t = buf; *t != '\0'; t++) {
-			if (!isspace(*t))
-				break;
-		}
-		/*
-		 * skip line that starts with '#' or empty line
-		 */
-		if (*t == '#' || *t == '\0')
-			continue;
-
-		if (strstr(buf, "MANSECTS") != NULL)
-			break;
-	}
-
-	/*
-	 * the man.cf file doesn't have a MANSECTS entry
-	 */
-	if (rc == NULL)
-		return (-1);
-
-	s = strchr(buf, '\n');
-	*s = '\0';	/* replace '\n' with '\0' */
-
-	(void) strcpy(submandir, buf);
-	return (0);
-}
-
-static void
-malloc_error(void)
-{
-	(void) fprintf(stderr, gettext(
-	    "Memory allocation failed.\n"));
-	exit(1);
-}
-
-static int
-sgmlcheck(const char *s1)
-{
-	const char	*s2 = SGML_SYMBOL;
-	int	len;
-
-	while (*s1) {
-		/*
-		 * Assume the first character of SGML_SYMBOL(*s2) is '<'.
-		 * Therefore, not necessary to do toupper(*s1) here.
-		 */
-		if (*s1 == *s2) {
-			/*
-			 * *s1 is '<'.  Check the following substring matches
-			 * with "!DOCTYPE".
-			 */
-			s1++;
-			if (strncasecmp(s1, s2 + 1, SGML_SYMBOL_LEN - 1)
-			    == 0) {
-				/*
-				 * SGML_SYMBOL found
-				 */
-				return (1);
-			}
-			continue;
-		} else if (isascii(*s1)) {
-			/*
-			 * *s1 is an ASCII char
-			 * Skip one character
-			 */
-			s1++;
-			continue;
-		} else {
-			/*
-			 * *s1 is a non-ASCII char or
-			 * the first byte of the multibyte char.
-			 * Skip one character
-			 */
-			len = mblen(s1, MB_CUR_MAX);
-			if (len == -1)
-				len = 1;
-			s1 += len;
-			continue;
-		}
-	}
-	/*
-	 * SGML_SYMBOL not found
-	 */
-	return (0);
-}
-
-/*
- * Initializes the bintoman array with appropriate device and inode info
- */
-
-static void
-init_bintoman(void)
-{
-	int i;
-	struct stat sb;
-
-	for (i = 0; bintoman[i].bindir != NULL; i++) {
-		if (stat(bintoman[i].bindir, &sb) == 0) {
-			bintoman[i].dev = sb.st_dev;
-			bintoman[i].ino = sb.st_ino;
-		} else {
-			bintoman[i].dev = NODEV;
-		}
-	}
-}
-
-/*
- * If a duplicate is found, return 1
- * If a duplicate is not found, add it to the dupnode list and return 0
- */
-static int
-dupcheck(struct man_node *mnp, struct dupnode **dnp)
-{
-	struct dupnode	*curdnp;
-	struct secnode	*cursnp;
-	struct stat 	sb;
-	int 		i;
-	int		rv = 1;
-	int		dupfound;
-
-	/*
-	 * If the path doesn't exist, treat it as a duplicate
-	 */
-	if (stat(mnp->path, &sb) != 0) {
-		return (1);
-	}
-
-	/*
-	 * If no sections were found in the man dir, treat it as duplicate
-	 */
-	if (mnp->secv == NULL) {
-		return (1);
-	}
-
-	/*
-	 * Find the dupnode structure for the previous time this directory
-	 * was looked at.  Device and inode numbers are compared so that
-	 * directories that are reached via different paths (e.g. /usr/man vs.
-	 * /usr/share/man) are treated as equivalent.
-	 */
-	for (curdnp = *dnp; curdnp != NULL; curdnp = curdnp->next) {
-		if (curdnp->dev == sb.st_dev && curdnp->ino == sb.st_ino) {
-			break;
-		}
-	}
-
-	/*
-	 * First time this directory has been seen.  Add a new node to the
-	 * head of the list.  Since all entries are guaranteed to be unique
-	 * copy all sections to new node.
-	 */
-	if (curdnp == NULL) {
-		if ((curdnp = calloc(1, sizeof (struct dupnode))) == NULL) {
-			malloc_error();
-		}
-		for (i = 0; mnp->secv[i] != NULL; i++) {
-			if ((cursnp = calloc(1, sizeof (struct secnode)))
-			    == NULL) {
-				malloc_error();
-			}
-			cursnp->next = curdnp->secl;
-			curdnp->secl = cursnp;
-			if ((cursnp->secp = strdup(mnp->secv[i])) == NULL) {
-				malloc_error();
-			}
-		}
-		curdnp->dev = sb.st_dev;
-		curdnp->ino = sb.st_ino;
-		curdnp->next = *dnp;
-		*dnp = curdnp;
-		return (0);
-	}
-
-	/*
-	 * Traverse the section vector in the man_node and the section list
-	 * in dupnode cache to eliminate all duplicates from man_node
-	 */
-	for (i = 0; mnp->secv[i] != NULL; i++) {
-		dupfound = 0;
-		for (cursnp = curdnp->secl; cursnp != NULL;
-		    cursnp = cursnp->next) {
-			if (strcmp(mnp->secv[i], cursnp->secp) == 0) {
-				dupfound = 1;
-				break;
-			}
-		}
-		if (dupfound) {
-			mnp->secv[i][0] = '\0';
-			continue;
-		}
-
-
-		/*
-		 * Update curdnp and set return value to indicate that this
-		 * was not all duplicates.
-		 */
-		if ((cursnp = calloc(1, sizeof (struct secnode))) == NULL) {
-			malloc_error();
-		}
-		cursnp->next = curdnp->secl;
-		curdnp->secl = cursnp;
-		if ((cursnp->secp = strdup(mnp->secv[i])) == NULL) {
-			malloc_error();
-		}
-		rv = 0;
-	}
-
-	return (rv);
-}
-
-/*
- * Given a bin directory, return the corresponding man directory.
- * Return string must be free()d by the caller.
- *
- * NULL will be returned if no matching man directory can be found.
- */
-
-static char *
-path_to_manpath(char *bindir)
-{
-	char	*mand, *p;
-	int	i;
-	struct stat	sb;
-
-	/*
-	 * First look for known translations for specific bin paths
-	 */
-	if (stat(bindir, &sb) != 0) {
-		return (NULL);
-	}
-	for (i = 0; bintoman[i].bindir != NULL; i++) {
-		if (sb.st_dev == bintoman[i].dev &&
-		    sb.st_ino == bintoman[i].ino) {
-			if ((mand = strdup(bintoman[i].mandir)) == NULL) {
-				malloc_error();
-			}
-			if ((p = strchr(mand, ',')) != NULL) {
-				*p = '\0';
-			}
-			if (stat(mand, &sb) != 0) {
-				free(mand);
-				return (NULL);
-			}
-			if (p != NULL) {
-				*p = ',';
-			}
-			return (mand);
-		}
-	}
-
-	/*
-	 * No specific translation found.  Try `dirname $bindir`/man
-	 * and `dirname $bindir`/share/man
-	 */
-	if ((mand = malloc(PATH_MAX)) == NULL) {
-		malloc_error();
-	}
-
-	if (strlcpy(mand, bindir, PATH_MAX) >= PATH_MAX) {
-		free(mand);
-		return (NULL);
-	}
-
-	/*
-	 * Advance to end of buffer, strip trailing /'s then remove last
-	 * directory component.
-	 */
-	for (p = mand; *p != '\0'; p++)
-		;
-	for (; p > mand && *p == '/'; p--)
-		;
-	for (; p > mand && *p != '/'; p--)
-		;
-	if (p == mand && *p == '.') {
-		if (realpath("..", mand) == NULL) {
-			free(mand);
-			return (NULL);
-		}
-		for (; *p != '\0'; p++)
-			;
-	} else {
-		*p = '\0';
-	}
-
-	if (strlcat(mand, "/man", PATH_MAX) >= PATH_MAX) {
-		free(mand);
-		return (NULL);
-	}
-
-	if ((stat(mand, &sb) == 0) && S_ISDIR(sb.st_mode)) {
-		return (mand);
-	}
-
-	/*
-	 * Strip the /man off and try /share/man
-	 */
-	*p = '\0';
-	if (strlcat(mand, "/share/man", PATH_MAX) >= PATH_MAX) {
-		free(mand);
-		return (NULL);
-	}
-	if ((stat(mand, &sb) == 0) && S_ISDIR(sb.st_mode)) {
-		return (mand);
-	}
-
-	/*
-	 * No man or share/man directory found
-	 */
-	free(mand);
-	return (NULL);
-}
-
-/*
- * Free a linked list of dupnode structs
- */
-void
-free_dupnode(struct dupnode *dnp) {
-	struct dupnode *dnp2;
-	struct secnode *snp;
-
-	while (dnp != NULL) {
-		dnp2 = dnp;
-		dnp = dnp->next;
-		while (dnp2->secl != NULL) {
-			snp = dnp2->secl;
-			dnp2->secl = dnp2->secl->next;
-			free(snp->secp);
-			free(snp);
-		}
-		free(dnp2);
-	}
-}
-
-/*
- * prints manp linked list to stdout.
- *
- * If namep is NULL, output can be used for setting MANPATH.
- *
- * If namep is not NULL output is two columns.  First column is the string
- * pointed to by namep.  Second column is a MANPATH-compatible representation
- * of manp linked list.
- */
-void
-print_manpath(struct man_node *manp, char *namep)
-{
-	char colon[2];
-	char **secp;
-
-	if (namep != NULL) {
-		(void) printf("%s ", namep);
-	}
-
-	colon[0] = '\0';
-	colon[1] = '\0';
-
-	for (; manp != NULL; manp = manp->next) {
-		(void) printf("%s%s", colon, manp->path);
-		colon[0] = ':';
-
-		/*
-		 * If man.cf or a directory scan was used to create section
-		 * list, do not print section list again.  If the output of
-		 * man -p is used to set MANPATH, subsequent runs of man
-		 * will re-read man.cf and/or scan man directories as
-		 * required.
-		 */
-		if (manp->defsrch != 0) {
-			continue;
-		}
-
-		for (secp = manp->secv; *secp != NULL; secp++) {
-			/*
-			 * Section deduplication may have eliminated some
-			 * sections from the vector. Avoid displaying this
-			 * detail which would appear as ",," in output
-			 */
-			if ((*secp)[0] != '\0') {
-				(void) printf(",%s", *secp);
-			}
-		}
-	}
-	(void) printf("\n");
-}
--- /dev/null	Wed Jul 16 14:05:07 2014
+++ new/usr/src/cmd/man/stringlist.c	Wed Jul 16 14:05:07 2014
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 1994 Christos Zoulas
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "stringlist.h"
+
+#define	_SL_CHUNKSIZE	20
+
+stringlist *
+sl_init(void)
+{
+	stringlist	*sl;
+
+	if ((sl = malloc(sizeof (stringlist))) == NULL)
+		err(1, "malloc");
+
+	sl->sl_cur = 0;
+	sl->sl_max = _SL_CHUNKSIZE;
+	sl->sl_str = malloc(sl->sl_max * sizeof (char *));
+	if (sl->sl_str == NULL)
+		err(1, "malloc");
+
+	return (sl);
+}
+
+int
+sl_add(stringlist *sl, char *name)
+{
+
+	if (sl->sl_cur == sl->sl_max - 1) {
+		sl->sl_max += _SL_CHUNKSIZE;
+		sl->sl_str = realloc(sl->sl_str, sl->sl_max * sizeof (char *));
+		if (sl->sl_str == NULL)
+			return (-1);
+	}
+	sl->sl_str[sl->sl_cur++] = name;
+
+	return (0);
+}
+
+
+void
+sl_free(stringlist *sl, int all)
+{
+	size_t i;
+
+	if (sl == NULL)
+		return;
+	if (sl->sl_str) {
+		if (all)
+			for (i = 0; i < sl->sl_cur; i++)
+				free(sl->sl_str[i]);
+		free(sl->sl_str);
+	}
+	free(sl);
+}
+
+
+char *
+sl_find(stringlist *sl, char *name)
+{
+	size_t	i;
+
+	for (i = 0; i < sl->sl_cur; i++)
+		if (strcmp(sl->sl_str[i], name) == 0)
+			return (sl->sl_str[i]);
+
+	return (NULL);
+}
--- /dev/null	Wed Jul 16 14:05:07 2014
+++ new/usr/src/cmd/man/stringlist.h	Wed Jul 16 14:05:07 2014
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 1994 Christos Zoulas
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by Christos Zoulas.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+ */
+
+#ifndef _STRINGLIST_H_
+#define	_STRINGLIST_H_
+
+#include <sys/types.h>
+
+typedef struct _stringlist {
+	char	**sl_str;
+	size_t	sl_max;
+	size_t	sl_cur;
+} stringlist;
+
+stringlist	*sl_init(void);
+int		sl_add(stringlist *, char *);
+void		sl_free(stringlist *, int);
+char		*sl_find(stringlist *, char *);
+
+#endif	/* _STRINGLIST_H_ */
--- /dev/null	Wed Jul 16 14:05:07 2014
+++ new/usr/src/cmd/mandoc/Makefile	Wed Jul 16 14:05:07 2014
@@ -0,0 +1,62 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+#
+
+PROGS=		mandoc mandoc_preconv
+mandoc_OBJS =	arch.o att.o chars.o eqn.o eqn_html.o eqn_term.o 	\
+		html.o lib.o main.o man.o man_hash.o man_html.o		\
+		man_macro.o man_term.o man_validate.o mandoc.o mdoc.o	\
+		mdoc_argv.o mdoc_hash.o mdoc_html.o mdoc_macro.o	\
+		mdoc_man.o mdoc_term.o mdoc_validate.o msec.o out.o	\
+		read.o roff.o st.o tbl.o tbl_data.o tbl_html.o		\
+		tbl_layout.o tbl_opts.o tbl_term.o term.o term_ascii.o	\
+		term_ps.o tree.o vol.o
+
+preconv_OBJS =	preconv.o
+
+# We place preconv in /usr/lib.  This is done to avoid conflicting with
+# GNU groff, which puts it into /usr/bin.  We also rename it so that it
+# will only be seen by mandoc -- it isn't intended for general end-user use.
+
+ROOTPROGS =	$(ROOTBIN)/mandoc $(ROOTLIB)/mandoc_preconv
+
+OBJS=		$(preconv_OBJS) $(mandoc_OBJS)
+
+include		$(SRC)/cmd/Makefile.cmd
+
+CFLAGS +=	$(CC_VERBOSE)
+
+CPPFLAGS +=	-DHAVE_CONFIG_H -DUSE_WCHAR	\
+		-DOSNAME="\"illumos\""	\
+		-DVERSION="\"1.12.1\""
+
+.KEEP_STATE:
+
+all:		$(PROGS)
+
+mandoc_preconv:	$(preconv_OBJS)
+		$(LINK.c) $(preconv_OBJS) -o $@ $(LDLIBS)
+		$(POST_PROCESS)
+
+mandoc:		$(mandoc_OBJS)
+		$(LINK.c) $(mandoc_OBJS) -o $@ $(LDLIBS)
+		$(POST_PROCESS)
+
+clean:
+		$(RM) $(OBJS)
+
+install:	all $(ROOTPROGS)
+
+include		$(SRC)/cmd/Makefile.targ
--- /dev/null	Wed Jul 16 14:05:07 2014
+++ new/usr/src/cmd/mandoc/THIRDPARTYLICENSE	Wed Jul 16 14:05:07 2014
@@ -0,0 +1,14 @@
+Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--- /dev/null	Wed Jul 16 14:05:07 2014
+++ new/usr/src/cmd/mandoc/THIRDPARTYLICENSE.descrip	Wed Jul 16 14:05:07 2014
@@ -0,0 +1,1 @@
+MANDOC - FORMAT AND DISPLAY UNIX MANUALS
--- /dev/null	Wed Jul 16 14:05:07 2014
+++ new/usr/src/cmd/mandoc/config.h	Wed Jul 16 14:05:07 2014
@@ -0,0 +1,56 @@
+#ifndef	MANDOC_CONFIG_H
+#define	MANDOC_CONFIG_H
+
+#if defined(__linux__) || defined(__MINT__)
+# define _GNU_SOURCE /* strptime(), getsubopt() */
+#endif
+
+#include <stdio.h>
+
+#define HAVE_STRPTIME
+#define HAVE_GETSUBOPT
+#define HAVE_STRLCAT
+#define HAVE_STRLCPY
+
+#include <sys/types.h>
+
+#if !defined(__BEGIN_DECLS)
+#  ifdef __cplusplus
+#  define	__BEGIN_DECLS		extern "C" {
+#  else
+#  define	__BEGIN_DECLS
+#  endif
+#endif
+#if !defined(__END_DECLS)
+#  ifdef __cplusplus
+#  define	__END_DECLS		}
+#  else
+#  define	__END_DECLS
+#  endif
+#endif
+
+#if defined(__APPLE__)
+# define htobe32(x) OSSwapHostToBigInt32(x)
+# define betoh32(x) OSSwapBigToHostInt32(x)
+# define htobe64(x) OSSwapHostToBigInt64(x)
+# define betoh64(x) OSSwapBigToHostInt64(x)
+#elif defined(__linux__)
+# define betoh32(x) be32toh(x)
+# define betoh64(x) be64toh(x)
+#endif
+
+#ifndef HAVE_STRLCAT
+extern	size_t	  strlcat(char *, const char *, size_t);
+#endif
+#ifndef HAVE_STRLCPY
+extern	size_t	  strlcpy(char *, const char *, size_t);
+#endif
+#ifndef HAVE_GETSUBOPT
+extern	int	  getsubopt(char **, char * const *, char **);
+extern	char	 *suboptarg;
+#endif
+#ifndef HAVE_FGETLN
+extern	char	 *fgetln(FILE *, size_t *);
+#endif
+
+#endif /* MANDOC_CONFIG_H */
--- /dev/null	Wed Jul 16 14:05:07 2014
+++ new/usr/src/cmd/mandoc/lib.in	Wed Jul 16 14:05:07 2014
@@ -0,0 +1,18 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+ */
+
+/*
+ * TBD
+ */
--- /dev/null	Wed Jul 16 14:05:07 2014
+++ new/usr/src/cmd/mandoc/msec.in	Wed Jul 16 14:05:07 2014
@@ -0,0 +1,244 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+ */
+
+LINE("1",		"User Commands")
+LINE("1B",		"illumos/BSD Compatibility Package Commands")
+LINE("1b",		"illumos/BSD Compatibility Package Commands")
+LINE("1C",		"Communication Commands")
+LINE("1c",		"Communication Commands")
+LINE("1F",		"FMLI Commands")
+LINE("1f",		"FMLI Commands")
+LINE("1G",		"Graphics and CAD Commands")
+LINE("1g",		"Graphics and CAD Commands")
+LINE("1HAS",		"User Commands")
+LINE("1has",		"User Commands")
+LINE("1M",		"Maintenance Commands")
+LINE("1m",		"Maintenance Commands")
+LINE("1S",		"illumos Specific Commands")
+LINE("1s",		"illumos Specific Commands")
+LINE("2",		"System Calls")
+LINE("3",		"Introduction to Library Functions")
+LINE("3AIO",		"Asynchronous I/O Library Functions")
+LINE("3aio",		"Asynchronous I/O Library Functions")
+LINE("3BSM",		"Security and Auditing Library Functions")
+LINE("3bsm",		"Security and Auditing Library Functions")
+LINE("3C",		"Standard C Library Functions")
+LINE("3c",		"Standard C Library Functions")
+LINE("3C_DB",		"Threads Debugging Library Functions")
+LINE("3C_db",		"Threads Debugging Library Functions")
+LINE("3CFGADM",		"Configuration Administration Library Functions")
+LINE("3cfgadm",		"Configuration Administration Library Functions")
+LINE("3COMPPUTIL",	"Communication Protocol Parser Utilities Library Functions")
+LINE("3compputil",	"Communication Protocol Parser Utilities Library Functions")
+LINE("3CONTRACT",	"Contract Management Library Functions")
+LINE("3contract",	"Contract Management Library Functions")
+LINE("3CPC",		"CPU Performance Counters Library Functions")
+LINE("3cpc",		"CPU Performance Counters Library Functions")
+LINE("3CURSES",		"Curses Library Functions")
+LINE("3curses",		"Curses Library Functions")
+LINE("3DAT",		"Direct Access Transport Library Functions")
+LINE("3dat",		"Direct Access Transport Library Functions")
+LINE("3DEVID",		"Device ID Library Functions")
+LINE("3devid",		"Device ID Library Functions")
+LINE("3DEVINFO",	"Device Information Library Functions")
+LINE("3devinfo",	"Device Information Library Functions")
+LINE("3DL",		"Dynamic Linking Library Functions")
+LINE("3dl",		"Dynamic Linking Library Functions")
+LINE("3DLPI",		"Data Link Provider Interface Library Functions")
+LINE("3dlpi",		"Data Link Provider Interface Library Functions")
+LINE("3DMI",		"DMI Library Functions")
+LINE("3dmi",		"DMI Library Functions")
+LINE("3DNS_SD",		"DNS Service Discovery Library Functions")
+LINE("3dns_sd",		"DNS Service Discovery Library Functions")
+LINE("3DOOR",		"Door Library Functions")
+LINE("3door",		"Door Library Functions")
+LINE("3ELF",		"ELF Library Functions")
+LINE("3elf",		"ELF Library Functions")
+LINE("3EXACCT",		"Extended Accounting File Access Library Functions")
+LINE("3exacct",		"Extended Accounting File Access Library Functions")
+LINE("3EXT",		"Extended Library Functions")
+LINE("3ext",		"Extended Library Functions")
+LINE("3FCOE",		"FCoE Port Management Library Functions")
+LINE("3fcoe",		"FCoE Port Management Library Functions")
+LINE("3FSTYP",		"File System Type Identification Library Functions")
+LINE("3fstyp",		"File System Type Identification Library Functions")
+LINE("3GEN",		"String Pattern-Matching Library Functions")
+LINE("3gen",		"String Pattern-Matching Library Functions")
+LINE("3GSS",		"Generic Security Services API Library Functions")
+LINE("3gss",		"Generic Security Services API Library Functions")
+LINE("3HEAD",		"Headers")
+LINE("3head",		"Headers")
+LINE("3ISCSIT",		"iSCSI Management Library Functions")
+LINE("3iscsit",		"iSCSI Management Library Functions")
+LINE("3KRB",		"Kerberos Library Functions")
+LINE("3krb",		"Kerberos Library Functions")
+LINE("3KSTAT",		"Kernel Statistics Library Functions")
+LINE("3kstat",		"Kernel Statistics Library Functions")
+LINE("3KVM",		"Kernel VM Library Functions")
+LINE("3kvm",		"Kernel VM Library Functions")
+LINE("3LDAP",		"LDAP Library Functions")
+LINE("3ldap",		"LDAP Library Functions")
+LINE("3LGRP",		"Locality Group Library Functions")
+LINE("3lgrp",		"Locality Group Library Functions")
+LINE("3LIB",		"Interface Libraries")
+LINE("3lib",		"Interface Libraries")
+LINE("3LIBUCB",		"illumos/BSD Compatibility Interface Libraries")
+LINE("3libucb",		"illumos/BSD Compatibility Interface Libraries")
+LINE("3M",		"Mathematical Library Functions")
+LINE("3m",		"Mathematical Library Functions")
+LINE("3MAIL",		"User Mailbox Library Functions")
+LINE("3mail",		"User Mailbox Library Functions")
+LINE("3MALLOC",		"Memory Allocation Library Functions")
+LINE("3malloc",		"Memory Allocation Library Functions")
+LINE("3MP",		"Multiple Precision Library Functions")
+LINE("3mp",		"Multiple Precision Library Functions")
+LINE("3MPAPI",		"Common Multipath Management Library Functions")
+LINE("3mpapi",		"Common Multipath Management Library Functions")
+LINE("3NSL",		"Networking Services Library Functions")
+LINE("3nsl",		"Networking Services Library Functions")
+LINE("3NVPAIR",		"Name-value Pair Library Functions")
+LINE("3nvpair",		"Name-value Pair Library Functions")
+LINE("3PAM",		"PAM Library Functions")
+LINE("3pam",		"PAM Library Functions")
+LINE("3PAPI",		"PAPI Library Functions")
+LINE("3papi",		"PAPI Library Functions")
+LINE("3PERL",		"Perl Library Functions")
+LINE("3perl",		"Perl Library Functions")
+LINE("3PICL",		"PICL Library Functions")
+LINE("3picl",		"PICL Library Functions")
+LINE("3PICLTREE",	"PICL Plug-In Library Functions")
+LINE("3picltree",	"PICL Plug-In Library Functions")
+LINE("3PLOT",		"Graphics Interface Library Functions")
+LINE("3plot",		"Graphics Interface Library Functions")
+LINE("3POOL",		"Pool Configuration Manipulation Library Functions")
+LINE("3pool",		"Pool Configuration Manipulation Library Functions")
+LINE("3PROC",		"Process Control Library Functions")
+LINE("3proc",		"Process Control Library Functions")
+LINE("3PROJECT",	"Project Database Access Library Functions")
+LINE("3project",	"Project Database Access Library Functions")
+LINE("3RAC",		"Remote Asynchronous Calls Library Functions")
+LINE("3rac",		"Remote Asynchronous Calls Library Functions")
+LINE("3RESOLV",		"Resolver Library Functions")
+LINE("3resolv",		"Resolver Library Functions")
+LINE("3RPC",		"RPC Library Functions")
+LINE("3rpc",		"RPC Library Functions")
+LINE("3RSM",		"Remote Shared Memory Library Functions")
+LINE("3rsm",		"Remote Shared Memory Library Functions")
+LINE("3RT",		"Realtime Library Functions")
+LINE("3rt",		"Realtime Library Functions")
+LINE("3SASL",		"Simple Authentication Security Layer Library Functions")
+LINE("3sasl",		"Simple Authentication Security Layer Library Functions")
+LINE("3SCF",		"Service Configuration Facility Library Functions")
+LINE("3scf",		"Service Configuration Facility Library Functions")
+LINE("3SCHED",		"LWP Scheduling Library Functions")
+LINE("3sched",		"LWP Scheduling Library Functions")
+LINE("3SEC",		"File Access Control Library Functions")
+LINE("3sec",		"File Access Control Library Functions")
+LINE("3SECDB",		"Security Attributes Database Library Functions")
+LINE("3secdb",		"Security Attributes Database Library Functions")
+LINE("3SIP",		"Session Initiation Protocol Library Functions")
+LINE("3sip",		"Session Initiation Protocol Library Functions")
+LINE("3SLP",		"Service Location Protocol Library Functions")
+LINE("3slp",		"Service Location Protocol Library Functions")
+LINE("3SNMP",		"SNMP Library Functions")
+LINE("3snmp",		"SNMP Library Functions")
+LINE("3SOCKET",		"Sockets Library Functions")
+LINE("3socket",		"Sockets Library Functions")
+LINE("3STMF",		"SCSI Target Mode Framework Library Functions")
+LINE("3stmf",		"SCSI Target Mode Framework Library Functions")
+LINE("3SYSEVENT",	"System Event Library Functions")
+LINE("3sysevent",	"System Event Library Functions")
+LINE("3TECLA",		"Interactive Command-line Input Library Functions")
+LINE("3tecla",		"Interactive Command-line Input Library Functions")
+LINE("3THR",		"Threads Library Functions")
+LINE("3thr",		"Threads Library Functions")
+LINE("3TNF",		"TNF Library Functions")
+LINE("3tnf",		"TNF Library Functions")
+LINE("3TSOL",		"Trusted Extensions Library Functions")
+LINE("3tsol",		"Trusted Extensions Library Functions")
+LINE("3UCB",		"illumos/BSD Compatibility Library Functions")
+LINE("3ucb",		"illumos/BSD Compatibility Library Functions")
+LINE("3UUID",		"Universally Unique Identifier Library Functions")
+LINE("3uuid",		"Universally Unique Identifier Library Functions")
+LINE("3VOLMGT",		"Volume Management Library Functions")
+LINE("3volmgt",		"Volume Management Library Functions")
+LINE("3XCURSES",	"X/Open Curses Library Functions")
+LINE("3xcurses",	"X/Open Curses Library Functions")
+LINE("3XFN",		"XFN Interface Library Functions")
+LINE("3xfn",		"XFN Interface Library Functions")
+LINE("3XNET",		"X/Open Networking Services Library Functions")
+LINE("3xnet",		"X/Open Networking Services Library Functions")
+LINE("3B",		"illumos/BSD Compatibility Library Functions")
+LINE("3b",		"illumos/BSD Compatibility Library Functions")
+LINE("3E",		"C Library Functions")
+LINE("3e",		"C Library Functions")
+LINE("3F",		"Fortran Library Routines")
+LINE("3f",		"Fortran Library Routines")
+LINE("3G",		"C Library Functions")
+LINE("3g",		"C Library Functions")
+LINE("3K",		"Kernel VM Library Functions")
+LINE("3k",		"Kernel VM Library Functions")
+LINE("3L",		"Lightweight Processes Library")
+LINE("3l",		"Lightweight Processes Library")
+LINE("3N",		"Network Functions")
+LINE("3n",		"Network Functions")
+LINE("3R",		"Realtime Library")
+LINE("3r",		"Realtime Library")
+LINE("3S",		"Standard I/O Functions")
+LINE("3s",		"Standard I/O Functions")
+LINE("3T",		"Threads Library")
+LINE("3t",		"Threads Library")
+LINE("3W",		"C Library Functions")
+LINE("3w",		"C Library Functions")
+LINE("3X",		"Miscellaneous Library Functions")
+LINE("3x",		"Miscellaneous Library Functions")
+LINE("3XC",		"X/Open Curses Library Functions")
+LINE("3xc",		"X/Open Curses Library Functions")
+LINE("3XN",		"X/Open Networking Services Library Functions")
+LINE("3xn",		"X/Open Networking Services Library Functions")
+LINE("4",		"File Formats")
+LINE("4B",		"illumos/BSD Compatibility Package File Formats")
+LINE("4b",		"illumos/BSD Compatibility Package File Formats")
+LINE("5",		"Standards, Environments, and Macros")
+LINE("6",		"Games and Demos")
+LINE("7",		"Device and Network Interfaces")
+LINE("7B",		"illumos/BSD Compatibility Special Files")
+LINE("7b",		"illumos/BSD Compatibility Special Files")
+LINE("7D",		"Devices")
+LINE("7d",		"Devices")
+LINE("7FS",		"File Systems")
+LINE("7fs",		"File Systems")
+LINE("7I",		"Ioctl Requests")
+LINE("7i",		"Ioctl Requests")
+LINE("7IPP",		"IP Quality of Service Modules")
+LINE("7ipp",		"IP Quality of Service Modules")
+LINE("7M",		"STREAMS Modules")
+LINE("7m",		"STREAMS Modules")
+LINE("7P",		"Protocols")
+LINE("7p",		"Protocols")
+LINE("8",		"Maintenance Procedures")
+LINE("8C",		"Maintenance Procedures")
+LINE("8c",		"Maintenance Procedures")
+LINE("8S",		"Maintenance Procedures")
+LINE("8s",		"Maintenance Procedures")
+LINE("9",		"Device Driver Interfaces")
+LINE("9E",		"Driver Entry Points")
+LINE("9e",		"Driver Entry Points")
+LINE("9F",		"Kernel Functions for Drivers")
+LINE("9f",		"Kernel Functions for Drivers")
+LINE("9P",		"Kernel Properties for Drivers")
+LINE("9p",		"Kernel Properties for Drivers")
+LINE("9S",		"Data Structures for Drivers")
+LINE("9s",		"Data Structures for Drivers")
--- old/usr/src/man/man1/Makefile	Wed Jul 16 14:05:08 2014
+++ new/usr/src/man/man1/Makefile	Wed Jul 16 14:05:08 2014
@@ -12,6 +12,7 @@
 #
 # Copyright 2011, Richard Lowe
 # Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
 #
 
 include		$(SRC)/Makefile.master
@@ -228,6 +229,7 @@
 	 	mailx.1				\
 	 	makekey.1			\
 	 	man.1				\
+	 	mandoc.1			\
 	 	mconnect.1			\
 	 	mcs.1				\
 	 	mdb.1				\
@@ -410,7 +412,6 @@
 	 	w.1				\
 	 	wait.1				\
 	 	wc.1				\
-		whatis.1			\
 	 	which.1				\
 	 	who.1				\
 	 	whocalls.1			\
@@ -555,6 +556,7 @@
 		valyorn.1	\
 		vax.1		\
 		vedit.1		\
+		whatis.1	\
 		whence.1	\
 		while.1		\
 		zcat.1
@@ -561,6 +563,8 @@
 
 intro.1		:= LINKSRC = Intro.1
 
+whatis.1	:= LINKSRC = apropos.1
+
 unalias.1	:= LINKSRC = alias.1
 
 batch.1		:= LINKSRC = at.1
--- old/usr/src/man/man1/apropos.1	Wed Jul 16 14:05:08 2014
+++ new/usr/src/man/man1/apropos.1	Wed Jul 16 14:05:08 2014
@@ -1,142 +1,78 @@
-'\" te
-.\"  Copyright (c) 1996, Sun Microsystems, Inc.  All Rights Reserved
-.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
-.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
-.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH APROPOS 1 "Dec 20, 1996"
-.SH NAME
-apropos \- locate commands by keyword lookup
-.SH SYNOPSIS
-.LP
-.nf
-\fBapropos\fR \fIkeyword\fR...
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-The \fBapropos\fR utility displays the man page name, section number, and a
-short description for each man page whose \fBNAME\fR line contains
-\fIkeyword\fR. This information is contained in the \fB/usr/share/man/windex\fR
-database created by \fBcatman\fR(1M). If \fBcatman\fR(1M) was not run, or was
-run with the \fB-n\fR option, \fBapropos\fR fails. Each word is considered
-separately and the case of letters is ignored. Words which are part of other
-words are considered; for example, when looking for `compile', \fBapropos\fR
-finds all instances of `compiler' also.
-.sp
-.LP
-\fBapropos\fR is actually just the \fB-k\fR option to the \fBman\fR(1) command.
-.SH EXAMPLES
-.LP
-\fBExample 1 \fRTo find a man page whose NAME line contains a keyword
-.sp
-.LP
-Try
-
-.sp
-.in +2
-.nf
-example% \fBapropos password\fR
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-and
-
-.sp
-.in +2
-.nf
-example% \fBapropos editor\fR
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-If the line starts `\fIfilename\fR(\fIsection\fR) .\|.\|.' you can run
-
-.sp
-.in +2
-.nf
-man -s \fIsection filename\fR
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-to display the man page for \fIfilename\fR.
-
-.LP
-\fBExample 2 \fRTo find the man page for the subroutine \fBprintf()\fR
-.sp
-.LP
-Try
-
-.sp
-.in +2
-.nf
-example% \fBapropos format\fR
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-and then
-
-.sp
-.in +2
-.nf
-example% \fBman -s 3s printf\fR
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-to get the manual page on the subroutine \fBprintf()\fR.
-
-.SH FILES
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/man/windex\fR \fR
-.ad
-.RS 26n
-table of contents and keyword database
-.RE
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(5) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE	ATTRIBUTE VALUE
-_
-CSI	Enabled
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-\fBman\fR(1), \fBwhatis\fR(1), \fBcatman\fR(1M), \fBattributes\fR(5)
-.SH DIAGNOSTICS
-.sp
-.ne 2
-.na
-\fB\f(CW/usr/share/man/windex: No such file or directory\fR\fR
-.ad
-.sp .6
-.RS 4n
-This database does not exist. \fBcatman\fR(1M) must be run to create it.
-.RE
-
+.\"
+.\" This file and its contents are supplied under the terms of the
+.\" Common Development and Distribution License ("CDDL"), version 1.0.
+.\" You may only use this file in accordance with the terms of version
+.\" 1.0 of the CDDL.
+.\"
+.\" A full copy of the text of the CDDL should have accompanied this
+.\" source.  A copy of the CDDL is also available via the Internet at
+.\" http://www.illumos.org/license/CDDL.
+.\"
+.\"
+.\" Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+.\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
+.\"
+.Dd Jul 13, 2014
+.Dt APROPOS 1
+.Os
+.Sh NAME
+.Nm apropos ,
+.Nm whatis
+.Nd keyword search in
+.Nm whatis
+database files
+.Sh SYNOPSIS
+.Nm
+.Op Fl M Ar path
+.Op Fl s Ar section
+.Ar keyword ...
+.Nm whatis
+.Op Fl M Ar path
+.Op Fl s Ar section
+.Ar keyword ...
+.Sh DESCRIPTION
+The
+.Nm
+utility searches a set of
+.Nm whatis
+database files matching each
+.Ar keyword .
+The
+.Nm whatis
+utility does the same search but only on complete words. The
+.Nm whatis
+database files are created using
+.Xr man 1
+command.
+.Bl -tag -width ".Fl d"
+.It Fl M Ar path
+Force a specific colon separated manual path instead of the default search path.
+Overrides the
+.Ev MANPATH
+environment variable.
+.It Fl s Ar section
+Restrict search to specified
+.Ar section .
+.El
+.Sh ENVIRONMENT
+The following environment variables affect the execution of
+.Nm :
+.Bl -tag -width ".Ev MANPATH , PATH"
+.It Ev MANPATH , PATH
+Used to find the location of the
+.Nm whatis
+database files.
+.El
+.Sh DIAGNOSTICS
+The
+.Nm
+utility exits 0 if a keyword matched and 1 if no keywords are matched or no
+.Nm whatis
+databases are found.
+.Sh INTERFACE STABILITY
+.Nm Committed .
+.Sh CODE SET INDEPENDENCE
+Enabled.
+.Sh SEE ALSO
+.Xr man 1 ,
+.Xr mandoc 1
--- old/usr/src/man/man1/man.1	Wed Jul 16 14:05:08 2014
+++ new/usr/src/man/man1/man.1	Wed Jul 16 14:05:08 2014
@@ -1,664 +1,137 @@
-'\" te
-.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
-.\" Copyright (c) 1980 Regents of the University of California. The Berkeley software License Agreement specifies the terms and conditions for redistribution.
-.TH MAN 1 "May 8, 2008"
-.SH NAME
-man \- find and display reference manual pages
-.SH SYNOPSIS
-.LP
-.nf
-\fBman\fR [\fB-\fR] [\fB-adFlrt\fR] [\fB-M\fR \fIpath\fR] [\fB-T\fR \fImacro-package\fR] [\fB-s\fR \fIsection\fR] \fIname\fR...
-.fi
-
-.LP
-.nf
-\fBman\fR [\fB-M\fR \fIpath\fR] \fB-k\fR \fIkeyword\fR...
-.fi
-
-.LP
-.nf
-\fBman\fR [\fB-M\fR \fIpath\fR] \fB-f\fR \fIfile\fR...
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-The \fBman\fR command displays information from the reference manuals. It
-displays complete manual pages that you select by \fIname\fR, or one-line
-summaries selected either by \fIkeyword\fR (\fB-k\fR), or by the name of an
-associated file (\fB-f\fR). If no manual page is located, \fBman\fR prints an
-error message.
-.SS "Source Format"
-.sp
-.LP
-Reference Manual pages are marked up with either \fBnroff\fR (see
-\fBnroff\fR(1)) or \fBSGML\fR (Standard Generalized Markup Language) tags (see
-\fBsgml\fR(5)). The \fBman\fR command recognizes the type of markup and
-processes the file accordingly. The various source files are kept in separate
-directories depending on the type of markup.
-.SS "Location of Manual Pages"
-.sp
-.LP
-The online Reference Manual page directories are conventionally located in
-\fB/usr/share/man\fR. The nroff sources are located in the
-\fB/usr/share/man/man\fR* directories. The \fBSGML\fR sources are located in
-the \fB/usr/share/man/sman\fR* directories. Each directory corresponds to a
-section of the manual. Since these directories are optionally installed, they
-might not reside on your host. You might have to mount \fB/usr/share/man\fR
-from a host on which they do reside.
-.sp
-.LP
-If there are preformatted, up-to-date versions in the corresponding \fBcat\fR*
-or \fBfmt\fR* directories, \fBman\fR simply displays or prints those versions.
-If the preformatted version of interest is out of date or missing, \fBman\fR
-reformats it prior to display and stores the preformatted version if \fBcat\fR*
-or \fBfmt\fR* is writable. The \fBwindex\fR database is not updated. See
-\fBcatman\fR(1M). If directories for the preformatted versions are not
-provided, \fBman\fR reformats a page whenever it is requested. \fBman\fR uses a
-temporary file to store the formatted text during display.
-.sp
-.LP
-If the standard output is not a terminal, or if the `\fB-\fR' flag is given,
-\fBman\fR pipes its output through \fBcat\fR(1). Otherwise, \fBman\fR pipes its
-output through \fBmore\fR(1) to handle paging and underlining on the screen.
-.SH OPTIONS
-.sp
-.LP
-The following options are supported:
-.sp
-.ne 2
-.na
-\fB\fB-a\fR\fR
-.ad
-.RS 20n
-Shows all manual pages matching \fIname\fR within the \fBMANPATH\fR search
-path. Manual pages are displayed in the order found.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-d\fR\fR
-.ad
-.RS 20n
-Debugs. Displays what a section-specifier evaluates to, method used for
-searching, and paths searched by \fBman\fR.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-f\fR \fIfile ...\fR\fR
-.ad
-.RS 20n
-\fBman\fR attempts to locate manual pages related to any of the given
-\fIfile\fRs. It strips the leading path name components from each \fIfile\fR,
-and then prints one-line summaries containing the resulting basename or names.
-This option also uses the \fBwindex\fR database.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-F\fR\fR
-.ad
-.RS 20n
-Forces \fBman\fR to search all directories specified by \fBMANPATH\fR or the
-\fBman.cf\fR file, rather than using the \fBwindex\fR lookup database. This
-option is useful if the database is not up to date and it has been made the
-default behavior of the \fBman\fR command. The option therefore does not have
-to be invoked and is documented here for reference only.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-k\fR \fIkeyword ...\fR\fR
-.ad
-.RS 20n
-Prints out one-line summaries from the \fBwindex\fR database (table of
-contents) that contain any of the given \fIkeyword\fRs. The \fBwindex\fR
-database is created using \fBcatman\fR(1M).
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-l\fR\fR
-.ad
-.RS 20n
-Lists all manual pages found matching \fIname\fR within the search path.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-M\fR \fIpath\fR\fR
-.ad
-.RS 20n
-Specifies an alternate search path for manual pages. \fIpath\fR is a
-colon-separated list of directories that contain manual page directory
-subtrees. For example, if \fIpath\fR is \fB/usr/share/man:/usr/local/man\fR,
-\fBman\fR searches for \fIname\fR in the standard location, and then
-\fB/usr/local/man\fR. When used with the \fB-k\fR or \fB-f\fR options, the
-\fB-M\fR option must appear first. Each directory in the \fIpath\fR is assumed
-to contain subdirectories of the form \fBman\fR* or \fBsman\fR* , one for each
-section. This option overrides the \fBMANPATH\fR environment variable.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-r\fR\fR
-.ad
-.RS 20n
-Reformats the manual page, but does not display it. This replaces the \fBman\fR
-\fB-\fR \fB-t\fR \fIname\fR combination.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-s\fR \fIsection ...\fR\fR
-.ad
-.RS 20n
-Specifies sections of the manual for \fBman\fR to search. The directories
-searched for \fIname\fR are limited to those specified by \fIsection\fR.
-\fIsection\fR can be a numerical digit, perhaps followed by one or more letters
-to match the desired section of the manual, for example, "\fB3libucb\fR". Also,
-\fIsection\fR can be a word, for example, \fBlocal\fR, \fBnew\fR, \fBold\fR,
-\fBpublic\fR. \fIsection\fR can also be a letter. To specify multiple sections,
-separate each section with a comma. This option overrides the \fBMANPATH\fR
-environment variable and the \fBman.cf\fR file. See \fBSearch\fR \fBPath\fR
-below for an explanation of how \fBman\fR conducts its search.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-t\fR\fR
-.ad
-.RS 20n
-\fBman\fR arranges for the specified manual pages to be \fBtroff\fRed to a
-suitable raster output device (see \fBtroff\fR(1)). If both the \fB-\fR and
-\fB-t\fR flags are given, \fBman\fR updates the \fBtroff\fRed versions of each
-named \fIname\fR (if necessary), but does not display them.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-T\fR \fImacro-package\fR\fR
-.ad
-.RS 20n
-Formats manual pages using \fImacro-package\fR rather than the standard
-\fB-man\fR macros defined in \fB/usr/share/lib/tmac/an\fR. See \fBSearch
-Path\fR under USAGE for a complete explanation of the default search path
-order.
-.RE
-
-.SH OPERANDS
-.sp
-.LP
-The following operand is supported:
-.sp
-.ne 2
-.na
-\fB\fIname\fR\fR
-.ad
-.RS 8n
-The name of a standard utility or a keyword.
-.RE
-
-.SH USAGE
-.sp
-.LP
-The usage of \fBman\fR is described below:
-.SS "Manual Page Sections"
-.sp
-.LP
-Entries in the reference manuals are organized into \fIsection\fRs. A section
-name consists of a major section name, typically a single digit, optionally
-followed by a subsection name, typically one or more letters. An unadorned
-major section name, for example, "\fB9\fR", does not act as an abbreviation for
-the subsections of that name, such as "\fB9e\fR", "\fB9f\fR", or "\fB9s\fR".
-That is, each subsection must be searched separately by \fBman\fR \fB-s\fR.
-Each section contains descriptions apropos to a particular reference category,
-with subsections refining these distinctions. See the \fBintro\fR manual pages
-for an explanation of the classification used in this release.
-.SS "Search Path"
-.sp
-.LP
-Before searching for a given \fIname\fR, \fBman\fR constructs a list of
-candidate directories and sections. \fBman\fR searches for \fIname\fR in the
-directories specified by the \fBMANPATH\fR environment variable.
-.sp
-.LP
-In the absence of \fBMANPATH\fR, \fBman\fR constructs its search path based
-upon the \fBPATH\fR environment variable, primarily by substituting \fBman\fR
-for the last component of the \fBPATH\fR element. Special provisions are added
-to account for unique characteristics of directories such as \fB/sbin\fR,
-\fB/usr/ucb\fR, \fB/usr/xpg4/bin\fR, and others. If the file argument contains
-a \fB/\fR character, the \fIdirname\fR portion of the argument is used in place
-of \fBPATH\fR elements to construct the search path.
-.sp
-.LP
-Within the manual page directories, \fBman\fR confines its search to the
-sections specified in the following order:
-.RS +4
-.TP
-.ie t \(bu
-.el o
-\fIsection\fRs specified on the command line with the \fB-s\fR option
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-\fIsection\fRs embedded in the \fBMANPATH\fR environment variable
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-\fIsection\fRs specified in the \fBman.cf\fR file for each directory specified
-in the \fBMANPATH\fR environment variable
-.RE
-.sp
-.LP
-If none of the above exist, \fBman\fR searches each directory in the manual
-page path, and displays the first matching manual page found.
-.sp
-.LP
-The \fBman.cf\fR file has the following format:
-.sp
-.in +2
-.nf
-MANSECTS=\fIsection\fR[,\fIsection\fR]...
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-Lines beginning with `\fB#\fR' and blank lines are considered comments, and are
-ignored. Each directory specified in \fBMANPATH\fR can contain a manual page
-configuration file, specifying the default search order for that directory.
-.SH FORMATTING MANUAL PAGES
-.sp
-.LP
-Manual pages are marked up in \fBnroff\fR(1) or \fBsgml\fR(5). Nroff manual
-pages are processed by \fBnroff\fR(1) or \fBtroff\fR(1) with the \fB-man\fR
-macro package. Please refer to \fBman\fR(5) for information on macro usage.
-\fBSGML\fR\(emtagged manual pages are processed by an \fBSGML\fR parser and
-passed to the formatter.
-.SS "Preprocessing Nroff Manual Pages"
-.sp
-.LP
-When formatting an nroff manual page, \fBman\fR examines the first line to
-determine whether it requires special processing. If the first line is a string
-of the form:
-.sp
-.in +2
-.nf
-\&'\e" \fIX\fR
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-where \fIX\fR is separated from the `\fB"\fR' by a single SPACE and consists of
-any combination of characters in the following list, \fBman\fR pipes its input
-to \fBtroff\fR(1) or \fBnroff\fR(1) through the corresponding preprocessors.
-.sp
-.ne 2
-.na
-\fB\fBe\fR\fR
-.ad
-.RS 5n
-\fBeqn\fR(1), or \fBneqn\fR for \fBnroff\fR
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBr\fR\fR
-.ad
-.RS 5n
-\fBrefer\fR(1)
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBt\fR\fR
-.ad
-.RS 5n
-\fBtbl\fR(1)
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBv\fR\fR
-.ad
-.RS 5n
-\fBvgrind\fR(1)
-.RE
-
-.sp
-.LP
-If \fBeqn\fR or \fBneqn\fR is invoked, it automatically reads the file
-\fB/usr/pub/eqnchar\fR (see \fBeqnchar\fR(5)). If \fBnroff\fR(1) is invoked,
-\fBcol\fR(1) is automatically used.
-.SS "Referring to Other nroff Manual Pages"
-.sp
-.LP
-If the first line of the nroff manual page is a reference to another manual
-page entry fitting the pattern:
-.sp
-.in +2
-.nf
-\&.so man*/\fIsourcefile\fR
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-\fBman\fR processes the indicated file in place of the current one. The
-reference must be expressed as a path name relative to the root of the manual
-page directory subtree.
-.sp
-.LP
-When the second or any subsequent line starts with \fB\&.so\fR, \fBman\fR
-ignores it; \fBtroff\fR(1) or \fBnroff\fR(1) processes the request in the usual
-manner.
-.SS "Processing SGML Manual Pages"
-.sp
-.LP
-Manual pages are identified as being marked up in SGML by the presence of the
-string \fB<!DOCTYPE\fR\&. If the file also contains the string
-\fBSHADOW_PAGE\fR, the file refers to another manual page for the content. The
-reference is made with a file entity reference to the manual page that contains
-the text. This is similar to the \fB\&.so\fR mechanism used in the nroff
-formatted man pages.
-.SH ENVIRONMENT VARIABLES
-.sp
-.LP
-See \fBenviron\fR(5) for descriptions of the following environment variables
-that affect the execution of \fBman\fR: \fBLANG\fR, \fBLC_ALL\fR,
-\fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
-.sp
-.ne 2
-.na
-\fB\fBMANPATH\fR\fR
-.ad
-.RS 11n
-A colon-separated list of directories; each directory can be followed by a
-comma-separated list of sections. If set, its value overrides
-\fB/usr/share/man\fR as the default directory search path, and the \fBman.cf\fR
-file as the default section search path. The \fB-M\fR and \fB-s\fR flags, in
-turn, override these values.)
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBPAGER\fR\fR
-.ad
-.RS 11n
-A program to use for interactively delivering \fBman\fR's output to the screen.
-If not set, `\fBmore\fR \fB-s\fR' is used. See \fBmore\fR(1).
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBTCAT\fR\fR
-.ad
-.RS 11n
-The name of the program to use to display \fBtroff\fRed manual pages.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBTROFF\fR\fR
-.ad
-.RS 11n
-The name of the formatter to use when the \fB-t\fR flag is given. If not set,
-\fBtroff\fR(1) is used.
-.RE
-
-.SH EXAMPLES
-.LP
-\fBExample 1 \fRCreating a PostScript Version of a man page
-.sp
-.LP
-The following example creates the \fBpipe\fR(2) man page in postscript for csh,
-tcsh, ksh and sh users:
-
-.sp
-.in +2
-.nf
-	% env TCAT=/usr/lib/lp/postscript/dpost man -t -s 2 pipe > pipe.ps
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-This is an alternative to using \fBman\fR \fB-t\fR, which sends the man page to
-the default printer, if the user wants a postscript file version of the man
-page.
-
-.LP
-\fBExample 2 \fRCreating a Text Version of a man page
-.sp
-.LP
-The following example creates the \fBpipe\fR(2) man page in ascii text:
-
-.sp
-.in +2
-.nf
-man pipe.2 | col -x -b > pipe.text
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-This is an alternative to using \fBman\fR \fB-t\fR, which sends the man page to
-the default printer, if the user wants a text file version of the man page.
-
-.SH EXIT STATUS
-.sp
-.LP
-The following exit values are returned:
-.sp
-.ne 2
-.na
-\fB\fB0\fR\fR
-.ad
-.RS 6n
-Successful completion.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB>0\fR\fR
-.ad
-.RS 6n
-An error occurred.
-.RE
-
-.SH FILES
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/man\fR\fR
-.ad
-.sp .6
-.RS 4n
-Root of the standard manual page directory subtree
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/man/man?/*\fR\fR
-.ad
-.sp .6
-.RS 4n
-Unformatted nroff manual entries
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/man/sman?/*\fR\fR
-.ad
-.sp .6
-.RS 4n
-Unformatted \fBSGML\fR manual entries
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/man/cat?/*\fR\fR
-.ad
-.sp .6
-.RS 4n
-\fBnroff\fRed manual entries
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/man/fmt?/*\fR\fR
-.ad
-.sp .6
-.RS 4n
-\fBtroff\fRed manual entries
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/man/windex\fR\fR
-.ad
-.sp .6
-.RS 4n
-Table of contents and keyword database
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/lib/tmac/an\fR\fR
-.ad
-.sp .6
-.RS 4n
-Standard \fB-man\fR macro package
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/lib/sgml/locale/C/dtd/*\fR\fR
-.ad
-.sp .6
-.RS 4n
-\fBSGML\fR document type definition files
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/lib/sgml/locale/C/solbook/*\fR\fR
-.ad
-.sp .6
-.RS 4n
-\fBSGML\fR style sheet and entity definitions directories
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/lib/pub/eqnchar\fR\fR
-.ad
-.sp .6
-.RS 4n
-Standard definitions for \fBeqn\fR and \fBneqn\fR
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBman.cf\fR\fR
-.ad
-.sp .6
-.RS 4n
-Default search order by section
-.RE
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(5) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE	ATTRIBUTE VALUE
-_
-CSI	Enabled, see \fBNOTES\fR.
-_
-Interface Stability	Committed
-_
-Standard	See \fBstandards\fR(5).
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-\fBapropos\fR(1), \fBcat\fR(1), \fBcol\fR(1), \fBdpost\fR(1), \fBeqn\fR(1),
-\fBmore\fR(1), \fBnroff\fR(1), \fBrefer\fR(1), \fBtbl\fR(1), \fBtroff\fR(1),
-\fBvgrind\fR(1), \fBwhatis\fR(1), \fBcatman\fR(1M), \fBattributes\fR(5),
-\fBenviron\fR(5), \fBeqnchar\fR(5), \fBman\fR(5), \fBsgml\fR(5),
-\fBstandards\fR(5)
-.SH NOTES
-.sp
-.LP
-The \fB-f\fR and \fB-k\fR options use the \fBwindex\fR database, which is
-created by \fBcatman\fR(1M).
-.sp
-.LP
-The \fBman\fR command is CSI-capable. However, some utilities invoked by the
-\fBman\fR command, namely, \fBtroff\fR, \fBeqn\fR, \fBneqn\fR, \fBrefer\fR,
-\fBtbl\fR, and \fBvgrind\fR, are not verified to be CSI-capable. Because of
-this, the man command with the \fB-t\fR option can not handle non-EUC data.
-Also, using the \fBman\fR command to display man pages that require special
-processing through \fBeqn\fR, \fBneqn\fR, \fBrefer\fR, \fBtbl\fR, or
-\fBvgrind\fR can not be CSI-capable.
-.SH BUGS
-.sp
-.LP
-The manual is supposed to be reproducible either on a phototypesetter or on an
-\fBASCII\fR terminal. However, on a terminal some information (indicated by
-font changes, for instance) is lost.
-.sp
-.LP
-Some dumb terminals cannot process the vertical motions produced by the \fBe\fR
-(see \fBeqn\fR(1)) preprocessing flag. To prevent garbled output on these
-terminals, when you use \fBe\fR, also use \fBt\fR, to invoke \fBcol\fR(1)
-implicitly. This workaround has the disadvantage of eliminating superscripts
-and subscripts, even on those terminals that can display them. Control-q clears
-a terminal that gets confused by \fBeqn\fR(1) output.
+.\"
+.\" This file and its contents are supplied under the terms of the
+.\" Common Development and Distribution License ("CDDL"), version 1.0.
+.\" You may only use this file in accordance with the terms of version
+.\" 1.0 of the CDDL.
+.\"
+.\" A full copy of the text of the CDDL should have accompanied this
+.\" source.  A copy of the CDDL is also available via the Internet at
+.\" http://www.illumos.org/license/CDDL.
+.\"
+.\"
+.\" Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+.\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
+.\"
+.Dd October 18, 2012
+.Dt MAN 1
+.Os
+.Sh NAME
+.Nm man
+.Nd find and display reference manual pages
+.Sh SYNOPSIS
+.Nm
+.Op Fl alptw
+.Op Fl M Ar manpath
+.Op Fl s Ar mansect
+.Ar page ...
+.Nm
+.Op Fl s Ar mansect
+.Fl f
+.Ar keyword ...
+.Nm
+.Op Fl s Ar mansect
+.Fl k
+.Ar keyword ...
+.Sh DESCRIPTION
+The
+.Nm
+utility finds and displays reference manual pages.
+.Pp
+Options that
+.Nm
+understands:
+.Bl -tag -width indent
+.It Fl M Ar manpath
+Forces a specific colon separated manual path instead of the default
+search path.
+Overrides the
+.Ev MANPATH
+environment variable.
+.It Fl a
+Display all manual pages instead of just the first found for each
+.Ar page
+argument.
+.It Fl f
+Emulate
+.Xr whatis 1 .
+.It Fl k
+Emulate
+.Xr apropos 1 .
+.It Fl l
+Display the location of the manual page instead of the contents of
+the manual page.
+.It Fl p
+Output current path used for searching.
+.It Fl s Ar mansect
+Restrict manual sections searched to the specified colon delimited list.
+.It Fl t
+Send the content formatted as PostScript to the default printer.
+.It Fl w
+Create
+.Nm whatis
+databases used by
+.Xr apropos 1
+and
+.Xr whatis 1 .
+.El
+.Sh ENVIRONMENT
+The following environment variables affect the execution of
+.Nm :
+.Bl -tag -width ".Ev MANPATH"
+.It Ev LC_ALL , LC_CTYPE , LANG
+Used to find locale-specific manual pages.
+.It Ev MANPATH
+Used to find the location of the manual files.
+Corresponds to the
+.Fl M
+option.
+.It Ev MANWIDTH
+Defines the width of output. If set to
+.Dq Li tty ,
+and output is to a terminal, full width of terminal is used.
+.It Ev PAGER
+Program used to display files. If unset,
+.Dq Li "less -ins"
+is used.
+.It Ev PATH
+Used to find location of manual files if
+.Ev MANPATH
+and
+.Fl M
+are not specified.
+.El
+.Sh FILES
+.Bl -tag -width indent -compact
+.It Pa man.cf
+Per-manpath configuration settings.  The file is formatted as follows:
+.Bd -literal -offset indent
+MANSECT=\fIsection\fR[,\fIsection\fR]...
+.Ed
+.Pp
+Each section consists of a section in the reference manual.  The file
+may also contain comment blank lines or lines consisting of comments, where
+the first character in the line is `#'.  Both blank lines and comment lines are
+ignored.
+.El
+.Sh CODE SET INDEPENDENCE
+Enabled.
+.Sh INTERFACE STABILITY
+The
+.Nm 
+utility is
+.Nm Standard ,
+as is the
+.Fl k
+option. The other options are
+.Nm Committed .
+.Sh SEE ALSO
+.Xr apropos 1 ,
+.Xr intro 1 ,
+.Xr mandoc 1 ,
+.Xr whatis 1 ,
+.Xr man 5 ,
+.Xr mdoc 5 ,
+.Xr standards 5
+.Sh NOTES
+Some pages may contain information which cannot be properly displayed on
+all terminals.  In such cases, some information may be lost.
--- /dev/null	Wed Jul 16 14:05:08 2014
+++ new/usr/src/man/man1/mandoc.1	Wed Jul 16 14:05:08 2014
@@ -0,0 +1,678 @@
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.\"
+.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+.\" Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+.\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
+.\"
+.Dd Jul 16, 2014
+.Dt MANDOC 1
+.Os
+.Sh NAME
+.Nm mandoc
+.Nd format and display UNIX manuals
+.Sh SYNOPSIS
+.Nm mandoc
+.Op Fl V
+.Op Fl m Ns Ar format
+.Op Fl O Ns Ar option
+.Op Fl T Ns Ar output
+.Op Fl W Ns Ar level
+.Op Ar
+.Sh DESCRIPTION
+The
+.Nm
+utility formats
+.Ux
+manual pages for display.
+.Pp
+By default,
+.Nm
+reads
+.Xr mdoc 5
+or
+.Xr man 5
+text from stdin, implying
+.Fl m Ns Cm andoc ,
+and produces
+.Fl T Ns Cm ascii
+output.
+.Pp
+The arguments are as follows:
+.Bl -tag -width Ds
+.It Fl m Ns Ar format
+Input format.
+See
+.Sx Input Formats
+for available formats.
+Defaults to
+.Fl m Ns Cm andoc .
+.It Fl O Ns Ar option
+Comma-separated output options.
+.It Fl T Ns Ar output
+Output format.
+See
+.Sx Output Formats
+for available formats.
+Defaults to
+.Fl T Ns Cm ascii .
+.It Fl V
+Print version and exit.
+.It Fl W Ns Ar level
+Specify the minimum message
+.Ar level
+to be reported on the standard error output and to affect the exit status.
+The
+.Ar level
+can be
+.Cm warning ,
+.Cm error ,
+or
+.Cm fatal .
+The default is
+.Fl W Ns Cm fatal ;
+.Fl W Ns Cm all
+is an alias for
+.Fl W Ns Cm warning .
+See
+.Sx EXIT STATUS
+and
+.Sx DIAGNOSTICS
+for details.
+.Pp
+The special option
+.Fl W Ns Cm stop
+tells
+.Nm
+to exit after parsing a file that causes warnings or errors of at least
+the requested level.
+No formatted output will be produced from that file.
+If both a
+.Ar level
+and
+.Cm stop
+are requested, they can be joined with a comma, for example
+.Fl W Ns Cm error , Ns Cm stop .
+.It Ar file
+Read input from zero or more files.
+If unspecified, reads from stdin.
+If multiple files are specified,
+.Nm
+will halt with the first failed parse.
+.El
+.Ss Input Formats
+The
+.Nm
+utility accepts
+.Xr mdoc 5
+and
+.Xr man 5
+input with
+.Fl m Ns Cm doc
+and
+.Fl m Ns Cm an ,
+respectively.
+The
+.Xr mdoc 5
+format is
+.Em strongly
+recommended;
+.Xr man 5
+should only be used for legacy manuals.
+.Pp
+A third option,
+.Fl m Ns Cm andoc ,
+which is also the default, determines encoding on-the-fly: if the first
+non-comment macro is
+.Sq \&Dd
+or
+.Sq \&Dt ,
+the
+.Xr mdoc 5
+parser is used; otherwise, the
+.Xr man 5
+parser is used.
+.Pp
+If multiple
+files are specified with
+.Fl m Ns Cm andoc ,
+each has its file-type determined this way.
+If multiple files are
+specified and
+.Fl m Ns Cm doc
+or
+.Fl m Ns Cm an
+is specified, then this format is used exclusively.
+.Ss Output Formats
+The
+.Nm
+utility accepts the following
+.Fl T
+arguments, which correspond to output modes:
+.Bl -tag -width "-Tlocale"
+.It Fl T Ns Cm ascii
+Produce 7-bit ASCII output.
+This is the default.
+See
+.Sx ASCII Output .
+.It Fl T Ns Cm html
+Produce strict CSS1/HTML-4.01 output.
+See
+.Sx HTML Output .
+.It Fl T Ns Cm lint
+Parse only: produce no output.
+Implies
+.Fl W Ns Cm warning .
+.It Fl T Ns Cm locale
+Encode output using the current locale.
+See
+.Sx Locale Output .
+.It Fl T Ns Cm man
+Produce
+.Xr man 5
+format output.
+See
+.Sx Man Output .
+.It Fl T Ns Cm pdf
+Produce PDF output.
+See
+.Sx PDF Output .
+.It Fl T Ns Cm ps
+Produce PostScript output.
+See
+.Sx PostScript Output .
+.It Fl T Ns Cm tree
+Produce an indented parse tree.
+.It Fl T Ns Cm utf8
+Encode output in the UTF\-8 multi-byte format.
+See
+.Sx UTF\-8 Output .
+.It Fl T Ns Cm xhtml
+Produce strict CSS1/XHTML-1.0 output.
+See
+.Sx XHTML Output .
+.El
+.Pp
+If multiple input files are specified, these will be processed by the
+corresponding filter in-order.
+.Ss ASCII Output
+Output produced by
+.Fl T Ns Cm ascii ,
+which is the default, is rendered in standard 7-bit ASCII documented in
+.Xr ascii 5 .
+.Pp
+Font styles are applied by using back-spaced encoding such that an
+underlined character
+.Sq c
+is rendered as
+.Sq _ Ns \e[bs] Ns c ,
+where
+.Sq \e[bs]
+is the back-space character number 8.
+Emboldened characters are rendered as
+.Sq c Ns \e[bs] Ns c .
+.Pp
+The special characters documented in
+.Xr mandoc_char 5
+are rendered best-effort in an ASCII equivalent.
+If no equivalent is found,
+.Sq \&?
+is used instead.
+.Pp
+Output width is limited to 78 visible columns unless literal input lines
+exceed this limit.
+.Pp
+The following
+.Fl O
+arguments are accepted:
+.Bl -tag -width Ds
+.It Cm indent Ns = Ns Ar indent
+The left margin for normal text is set to
+.Ar indent
+blank characters instead of the default of five for
+.Xr mdoc 5
+and seven for
+.Xr man 5 .
+Increasing this is not recommended; it may result in degraded formatting,
+for example overfull lines or ugly line breaks.
+.It Cm width Ns = Ns Ar width
+The output width is set to
+.Ar width ,
+which will normalise to \(>=60.
+.El
+.Ss HTML Output
+Output produced by
+.Fl T Ns Cm html
+conforms to HTML-4.01 strict.
+.Pp
+The
+.Pa example.style.css
+file documents style-sheet classes available for customising output.
+If a style-sheet is not specified with
+.Fl O Ns Ar style ,
+.Fl T Ns Cm html
+defaults to simple output readable in any graphical or text-based web
+browser.
+.Pp
+Special characters are rendered in decimal-encoded UTF\-8.
+.Pp
+The following
+.Fl O
+arguments are accepted:
+.Bl -tag -width Ds
+.It Cm fragment
+Omit the
+.Aq !DOCTYPE
+declaration and the
+.Aq html ,
+.Aq head ,
+and
+.Aq body
+elements and only emit the subtree below the
+.Aq body
+element.
+The
+.Cm style
+argument will be ignored.
+This is useful when embedding manual content within existing documents.
+.It Cm includes Ns = Ns Ar fmt
+The string
+.Ar fmt ,
+for example,
+.Ar ../src/%I.html ,
+is used as a template for linked header files (usually via the
+.Sq \&In
+macro).
+Instances of
+.Sq \&%I
+are replaced with the include filename.
+The default is not to present a
+hyperlink.
+.It Cm man Ns = Ns Ar fmt
+The string
+.Ar fmt ,
+for example,
+.Ar ../html%S/%N.%S.html ,
+is used as a template for linked manuals (usually via the
+.Sq \&Xr
+macro).
+Instances of
+.Sq \&%N
+and
+.Sq %S
+are replaced with the linked manual's name and section, respectively.
+If no section is included, section 1 is assumed.
+The default is not to
+present a hyperlink.
+.It Cm style Ns = Ns Ar style.css
+The file
+.Ar style.css
+is used for an external style-sheet.
+This must be a valid absolute or
+relative URI.
+.El
+.Ss Locale Output
+Locale-depending output encoding is triggered with
+.Fl T Ns Cm locale .
+This option is not available on all systems: systems without locale
+support, or those whose internal representation is not natively UCS-4,
+will fall back to
+.Fl T Ns Cm ascii .
+See
+.Sx ASCII Output
+for font style specification and available command-line arguments.
+.Ss Man Output
+Translate input format into
+.Xr man 5
+output format.
+This is useful for distributing manual sources to legacy systems
+lacking
+.Xr mdoc 5
+formatters.
+.Pp
+If
+.Xr mdoc 5
+is passed as input, it is translated into
+.Xr man 5 .
+If the input format is
+.Xr man 5 ,
+the input is copied to the output, expanding any
+.Xr mandoc_roff 5
+.Sq so
+requests.
+The parser is also run, and as usual, the
+.Fl W
+level controls which
+.Sx DIAGNOSTICS
+are displayed before copying the input to the output.
+.Ss PDF Output
+PDF-1.1 output may be generated by
+.Fl T Ns Cm pdf .
+See
+.Sx PostScript Output
+for
+.Fl O
+arguments and defaults.
+.Ss PostScript Output
+PostScript
+.Qq Adobe-3.0
+Level-2 pages may be generated by
+.Fl T Ns Cm ps .
+Output pages default to letter sized and are rendered in the Times font
+family, 11-point.
+Margins are calculated as 1/9 the page length and width.
+Line-height is 1.4m.
+.Pp
+Special characters are rendered as in
+.Sx ASCII Output .
+.Pp
+The following
+.Fl O
+arguments are accepted:
+.Bl -tag -width Ds
+.It Cm paper Ns = Ns Ar name
+The paper size
+.Ar name
+may be one of
+.Ar a3 ,
+.Ar a4 ,
+.Ar a5 ,
+.Ar legal ,
+or
+.Ar letter .
+You may also manually specify dimensions as
+.Ar NNxNN ,
+width by height in millimetres.
+If an unknown value is encountered,
+.Ar letter
+is used.
+.El
+.Ss UTF\-8 Output
+Use
+.Fl T Ns Cm utf8
+to force a UTF\-8 locale.
+See
+.Sx Locale Output
+for details and options.
+.Ss XHTML Output
+Output produced by
+.Fl T Ns Cm xhtml
+conforms to XHTML-1.0 strict.
+.Pp
+See
+.Sx HTML Output
+for details; beyond generating XHTML tags instead of HTML tags, these
+output modes are identical.
+.Sh EXIT STATUS
+The
+.Nm
+utility exits with one of the following values, controlled by the message
+.Ar level
+associated with the
+.Fl W
+option:
+.Pp
+.Bl -tag -width Ds -compact
+.It 0
+No warnings or errors occurred, or those that did were ignored because
+they were lower than the requested
+.Ar level .
+.It 2
+At least one warning occurred, but no error, and
+.Fl W Ns Cm warning
+was specified.
+.It 3
+At least one parsing error occurred, but no fatal error, and
+.Fl W Ns Cm error
+or
+.Fl W Ns Cm warning
+was specified.
+.It 4
+A fatal parsing error occurred.
+.It 5
+Invalid command line arguments were specified.
+No input files have been read.
+.It 6
+An operating system error occurred, for example memory exhaustion or an
+error accessing input files.
+Such errors cause
+.Nm
+to exit at once, possibly in the middle of parsing or formatting a file.
+.El
+.Pp
+Note that selecting
+.Fl T Ns Cm lint
+output mode implies
+.Fl W Ns Cm warning .
+.Sh EXAMPLES
+To page manuals to the terminal:
+.Pp
+.Dl $ mandoc \-Wall,stop mandoc.1 2\*(Gt&1 | less
+.Dl $ mandoc mandoc.1 mdoc.5 | less
+.Pp
+To produce HTML manuals with
+.Ar style.css
+as the style-sheet:
+.Pp
+.Dl $ mandoc \-Thtml -Ostyle=style.css mdoc.5 \*(Gt mdoc.5.html
+.Pp
+To check over a large set of manuals:
+.Pp
+.Dl $ mandoc \-Tlint `find /usr/src -name \e*\e.[1-9]`
+.Pp
+To produce a series of PostScript manuals for A4 paper:
+.Pp
+.Dl $ mandoc \-Tps \-Opaper=a4 mdoc.5 man.5 \*(Gt manuals.ps
+.Pp
+Convert a modern
+.Xr mdoc 5
+manual to the older
+.Xr man 5
+format, for use on systems lacking an
+.Xr mdoc 5
+parser:
+.Pp
+.Dl $ mandoc \-Tman foo.mdoc \*(Gt foo.man
+.Sh DIAGNOSTICS
+Standard error messages reporting parsing errors are prefixed by
+.Pp
+.Sm off
+.D1 Ar file : line : column : \ level :
+.Sm on
+.Pp
+where the fields have the following meanings:
+.Bl -tag -width "column"
+.It Ar file
+The name of the input file causing the message.
+.It Ar line
+The line number in that input file.
+Line numbering starts at 1.
+.It Ar column
+The column number in that input file.
+Column numbering starts at 1.
+If the issue is caused by a word, the column number usually
+points to the first character of the word.
+.It Ar level
+The message level, printed in capital letters.
+.El
+.Pp
+Message levels have the following meanings:
+.Bl -tag -width "warning"
+.It Cm fatal
+The parser is unable to parse a given input file at all.
+No formatted output is produced from that input file.
+.It Cm error
+An input file contains syntax that cannot be safely interpreted,
+either because it is invalid or because
+.Nm
+does not implement it yet.
+By discarding part of the input or inserting missing tokens,
+the parser is able to continue, and the error does not prevent
+generation of formatted output, but typically, preparing that
+output involves information loss, broken document structure
+or unintended formatting.
+.It Cm warning
+An input file uses obsolete, discouraged or non-portable syntax.
+All the same, the meaning of the input is unambiguous and a correct
+rendering can be produced.
+Documents causing warnings may render poorly when using other
+formatting tools instead of
+.Nm .
+.El
+.Pp
+Messages of the
+.Cm warning
+and
+.Cm error
+levels are hidden unless their level, or a lower level, is requested using a
+.Fl W
+option or
+.Fl T Ns Cm lint
+output mode.
+.Pp
+The
+.Nm
+utility may also print messages related to invalid command line arguments
+or operating system errors, for example when memory is exhausted or
+input files cannot be read.
+Such messages do not carry the prefix described above.
+.Sh COMPATIBILITY
+This section summarises
+.Nm
+compatibility with GNU troff.
+Each input and output format is separately noted.
+.Ss ASCII Compatibility
+.Bl -bullet -compact
+.It
+Unrenderable unicode codepoints specified with
+.Sq \e[uNNNN]
+escapes are printed as
+.Sq \&?
+in mandoc.
+In GNU troff, these raise an error.
+.It
+The
+.Sq \&Bd \-literal
+and
+.Sq \&Bd \-unfilled
+macros of
+.Xr mdoc 5
+in
+.Fl T Ns Cm ascii
+are synonyms, as are \-filled and \-ragged.
+.It
+In historic GNU troff, the
+.Sq \&Pa
+.Xr mdoc 5
+macro does not underline when scoped under an
+.Sq \&It
+in the FILES section.
+This behaves correctly in
+.Nm .
+.It
+A list or display following the
+.Sq \&Ss
+.Xr mdoc 5
+macro in
+.Fl T Ns Cm ascii
+does not assert a prior vertical break, just as it doesn't with
+.Sq \&Sh .
+.It
+The
+.Sq \&na
+.Xr man 5
+macro in
+.Fl T Ns Cm ascii
+has no effect.
+.It
+Words aren't hyphenated.
+.El
+.Ss HTML/XHTML Compatibility
+.Bl -bullet -compact
+.It
+The
+.Sq \efP
+escape will revert the font to the previous
+.Sq \ef
+escape, not to the last rendered decoration, which is now dictated by
+CSS instead of hard-coded.
+It also will not span past the current scope,
+for the same reason.
+Note that in
+.Sx ASCII Output
+mode, this will work fine.
+.It
+The
+.Xr mdoc 5
+.Sq \&Bl \-hang
+and
+.Sq \&Bl \-tag
+list types render similarly (no break following overreached left-hand
+side) due to the expressive constraints of HTML.
+.It
+The
+.Xr man 5
+.Sq IP
+and
+.Sq TP
+lists render similarly.
+.El
+.Sh INTERFACE STABILITY
+The
+.Nm 
+utility is
+.Nm Committed ,
+but the details of specific output formats other than ASCII are
+.Nm Uncommitted .
+.Sh SEE ALSO
+.Xr eqn 5 ,
+.Xr man 5 ,
+.Xr mandoc_char 5 ,
+.Xr mdoc 5 ,
+.Xr mandoc_roff 5 ,
+.Xr tbl 5
+.Sh AUTHORS
+The
+.Nm
+utility was written by
+.An Kristaps Dzonsons ,
+.Mt kristaps@bsd.lv .
+.Sh CAVEATS
+In
+.Fl T Ns Cm html
+and
+.Fl T Ns Cm xhtml ,
+the maximum size of an element attribute is determined by
+.Dv BUFSIZ ,
+which is usually 1024 bytes.
+Be aware of this when setting long link
+formats such as
+.Fl O Ns Cm style Ns = Ns Ar really/long/link .
+.Pp
+Nesting elements within next-line element scopes of
+.Fl m Ns Cm an ,
+such as
+.Sq br
+within an empty
+.Sq B ,
+will confuse
+.Fl T Ns Cm html
+and
+.Fl T Ns Cm xhtml
+and cause them to forget the formatting of the prior next-line scope.
+.Pp
+The
+.Sq \(aq
+control character is an alias for the standard macro control character
+and does not emit a line-break as stipulated in GNU troff.
--- old/usr/src/man/man1/whatis.1	Wed Jul 16 14:05:08 2014
+++ /dev/null	Wed Jul 16 14:05:08 2014
@@ -1,61 +0,0 @@
-'\" te
-.\" Copyright (c) 1992, Sun Microsystems, Inc.
-.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
-.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
-.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH WHATIS 1 "Sep 14, 1992"
-.SH NAME
-whatis \- display a one-line summary about a keyword
-.SH SYNOPSIS
-.LP
-.nf
-\fBwhatis\fR \fIcommand\fR...
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-\fBwhatis\fR looks up a given \fIcommand\fR and displays the header line from
-the manual section. You can then run the \fBman\fR(1) command to get more
-information. If the line starts \fBname(\fIsection\fR)\fR.\|.\|. you can do
-\fBman\fR \fB-s\fR\fB\fIsection\fR name\fR to get the documentation for it.
-Try \fBwhatis ed\fR and then you should do \fBman\fR \fB-s\fR \fB1 ed\fR to get
-the manual page for \fBed\fR(1).
-.sp
-.LP
-\fBwhatis\fR is actually just the \fB-f\fR option to the \fBman\fR(1) command.
-.sp
-.LP
-\fBwhatis\fR uses the \fB/usr/share/man/windex\fR database.  This database is
-created by \fBcatman\fR(1M). If this database does not exist, \fBwhatis\fR will
-fail.
-.SH FILES
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/man/windex\fR\fR
-.ad
-.RS 25n
-Table of contents and keyword database
-.RE
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(5) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE	ATTRIBUTE VALUE
-_
-CSI	Enabled
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-\fBapropos\fR(1), \fBman\fR(1), \fBcatman\fR(1M), \fBattributes\fR(5)
--- old/usr/src/man/man1m/catman.1m	Wed Jul 16 14:05:08 2014
+++ new/usr/src/man/man1m/catman.1m	Wed Jul 16 14:05:08 2014
@@ -1,373 +1,70 @@
-'\" te
-.\"  Copyright (c) 1998 Sun Microsystems, Inc.  All Rights Reserved.
-.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
-.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
-.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH CATMAN 1M "Feb 27, 1998"
-.SH NAME
-catman \- create the formatted files for the reference manual
-.SH SYNOPSIS
-.LP
-.nf
-\fB/usr/bin/catman\fR [\fB-c\fR] [\fB-n\fR] [\fB-p\fR] [\fB-t\fR] [\fB-w\fR] [\fB-M\fR \fIdirectory\fR]
-     [\fB-T\fR \fImacro-package\fR] [\fIsections\fR]
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-The \fBcatman\fR utility creates the preformatted versions of the on-line
-manual from the \fBnroff\fR(1) or \fBsgml\fR(5) input files. This feature
-allows easy distribution of the preformatted manual pages among a group of
-associated machines (for example, with \fBrdist\fR(1)), since it makes the
-directories of preformatted manual pages self-contained and independent of the
-unformatted entries.
-.sp
-.LP
-\fBcatman\fR also creates the  \fBwindex\fR database file in the directories
-specified by the  \fBMANPATH\fR or the  \fB-M\fR option. The \fBwindex\fR
-database file is a three column list consisting of a keyword, the reference
-page that the keyword points to, and a line of text that describes the purpose
-of the utility or interface  documented on the reference page. Each keyword is
-taken from the comma separated list of words on the \fBNAME\fR line before the
-`\(mi' (dash). The reference page that the keyword points to is the first word
-on the  \fBNAME\fR line. The text after the \(mi on the \fBNAME\fR line is the
-descriptive text in the third column. The \fBNAME\fR line must be immediately
-preceded by the page heading line created by the \fB\&.TH\fR macro (see
-\fBNOTES\fR for required format).
-.sp
-.LP
-Each manual page is examined and those whose preformatted versions are missing
-or out of date are recreated. If any changes are made, \fBcatman\fR recreates
-the \fBwindex\fR database.
-.sp
-.LP
-If a manual page is a \fIshadow\fR page, that is, it sources another manual
-page for its contents, a symbolic link is made in the \fBcat\fR\fIx\fR or
-\fBfmt\fR\fIx\fR directory to the appropriate preformatted manual page.
-.sp
-.LP
-Shadow files in an unformatted nroff source file are identified by the first
-line being of the form \fB\&.so man\fR\fIx\fR\fB/yyy.\fR\fIx\fR\fB\&.\fR
-.sp
-.LP
-Shadow files in the \fBSGML\fR sources are identified by the string
-\fBSHADOW_PAGE\fR. The file entity declared in the shadow file identifies the
-file to be sourced.
-.SH OPTIONS
-.sp
-.LP
-The following options are supported:
-.sp
-.ne 2
-.na
-\fB\fB-c\fR\fR
-.ad
-.RS 20n
-Create unformatted nroff source files in the appropriate \fBman\fR
-subdirectories from the  \fBSGML\fR sources. This option will overwrite any
-existing file in the \fBman\fR directory of the same name as the  \fBSGML\fR
-file.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-n\fR\fR
-.ad
-.RS 20n
-Do not create (or recreate) the \fBwindex\fR database. If the \fB-n\fR option
-is specified, the \fBwindex\fR database is not created and the \fBapropos\fR,
-\fBwhatis\fR, \fBman\fR \fB-f\fR, and \fBman\fR \fB-k\fR commands will fail.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-p\fR\fR
-.ad
-.RS 20n
-Print what would be done instead of doing it.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-t\fR\fR
-.ad
-.RS 20n
-Create \fBtroff\fRed entries in the appropriate \fBfmt\fR subdirectories
-instead of \fBnroff\fRing into the \fBcat\fR subdirectories.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-w\fR\fR
-.ad
-.RS 20n
-Only create the \fBwindex\fR database that is used by \fBwhatis\fR(1) and the
-\fBman\fR(1) \fB-f\fR and \fB-k\fR options.  No manual reformatting is done.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-M\fR\fI directory\fR\fR
-.ad
-.RS 20n
-Update manual pages located in the specified \fIdirectory\fR,
-(\fB/usr/share/man\fR by default). If the  \fB-M\fR option is specified, the
-directory argument must not contain a `,' (comma), since a comma is used to
-delineate section numbers. See \fBman\fR(1).
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-T\fR\fI macro-package\fR\fR
-.ad
-.RS 20n
-Use \fImacro-package\fR in place of the standard manual page macros, (
-\fBman\fR(5) by default).
-.RE
-
-.SH OPERANDS
-.sp
-.LP
-The following operand is supported:
-.sp
-.ne 2
-.na
-\fB\fIsections\fR\fR
-.ad
-.RS 12n
-If there is one parameter not starting with a `\fB\(mi\fR\&', it is taken to be
-a space separated list of manual sections to be processed by \fBcatman\fR. If
-this operand is specified, only the manual sections in the list will be
-processed.  For example,
-.sp
-.in +2
-.nf
-\fBcatman 1 2 3\fR
-.fi
-.in -2
-.sp
-
-only updates manual sections \fB1\fR, \fB2\fR, and \fB3\fR. If specific
-sections are not listed, all sections in the  \fBman\fR directory specified by
-the environment variable \fBMANPATH\fR are processed.
-.RE
-
-.SH ENVIRONMENT VARIABLES
-.sp
-.ne 2
-.na
-\fB\fBTROFF\fR\fR
-.ad
-.RS 11n
-The name of the formatter to use when the \fB-t\fR flag is given. If not set,
-\fBtroff\fR(1) is used.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBMANPATH\fR\fR
-.ad
-.RS 11n
-A colon-separated list of directories that are processed by \fBcatman\fR and
-\fBman\fR(1). Each directory can be followed by a comma-separated list of
-sections. If set, its value overrides \fB/usr/share/man\fR as the default
-directory search path, and the \fBman.cf\fR file as the default section search
-path. The \fB-M\fR and \fB-s\fR flags, in turn, override these values.
-.RE
-
-.SH FILES
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/man\fR\fR
-.ad
-.RS 28n
-default manual directory location
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/man/man*/*.*\fR\fR
-.ad
-.RS 28n
-raw nroff input files
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/man/sman*/*.*\fR\fR
-.ad
-.RS 28n
-raw  \fBSGML\fR input files
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/man/cat*/*.*\fR\fR
-.ad
-.RS 28n
-preformatted \fBnroff\fRed manual pages
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/man/fmt*/*.*\fR\fR
-.ad
-.RS 28n
-preformatted \fBtroff\fRed manual pages
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/man/windex\fR\fR
-.ad
-.RS 28n
-table of contents and keyword database
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/lib/makewhatis\fR\fR
-.ad
-.RS 28n
-command script to make  \fBwindex\fR database
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/lib/tmac/an\fR\fR
-.ad
-.RS 28n
-default macro package
-.RE
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(5) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE	ATTRIBUTE VALUE
-_
-CSI	Enabled
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-\fBapropos\fR(1), \fBman\fR(1), \fBnroff\fR(1), \fBrdist\fR(1), \fBrm\fR(1),
-\fBtroff\fR(1), \fBwhatis\fR(1), \fBattributes\fR(5), \fBman\fR(5),
-\fBsgml\fR(5)
-.SH DIAGNOSTICS
-.sp
-.ne 2
-.na
-\fB\fBman?/xxx.? (.so'ed from man?/yyy.?): No such file or directory\fR\fR
-.ad
-.sp .6
-.RS 4n
-The file outside the parentheses is missing, and is referred to by the file
-inside them.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBtarget of .so in man?/xxx.? must be relative to /usr/man\fR\fR
-.ad
-.sp .6
-.RS 4n
-\fBcatman\fR only allows references to filenames that are relative to the
-directory \fB/usr/man\fR.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBopendir:man?:\fR \fBNo\fR \fBsuch\fR \fBfile\fR \fBor\fR
-\fBdirectory\fR\fR
-.ad
-.sp .6
-.RS 4n
-A harmless warning message indicating that one of the directories \fBcatman\fR
-normally looks for is missing.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB*.*:\fR \fBNo\fR \fBsuch\fR \fBfile\fR \fBor\fR \fBdirectory\fR\fR
-.ad
-.sp .6
-.RS 4n
-A harmless warning message indicating \fBcatman\fR came across an empty
-directory.
-.RE
-
-.SH WARNINGS
-.sp
-.LP
-If a user, who has previously run \fBcatman\fR to install the \fBcat*\fR
-directories, upgrades the operating system, the entire \fBcat*\fR directory
-structure should be removed prior to running \fBcatman\fR. See \fBrm\fR(1).
-.sp
-.LP
-Do not re-run \fBcatman\fR to re-build the \fBwhatis\fR database unless the
-complete set of \fBman*\fR directories is present. \fBcatman\fR builds this
-\fBwindex\fR file based on the  \fBman*\fR directories.
-.SH NOTES
-.sp
-.LP
-To generate a valid windex index file, \fBcatman\fR has certain requirements.
-Within the individual man page file, \fBcatman\fR requires two macro lines to
-have a specific format. These are the \fB\&.TH \fRpage heading line and the
-\fB\&.SH NAME \fRline.
-.sp
-.LP
-The \fB\&.TH \fRmacro requires at least the first three arguments, that is, the
-filename, section number, and the date.  The \fB\&.TH \fRline starts off with
-the \fB\&.TH \fRmacro, followed by a space, the man page filename, a single
-space, the section number, another single space, and the date. The date should
-appear in double quotes and is specified as "day month year," with the month
-always abbreviated to the first three letters (Jan, Feb, Mar, and so forth).
-.sp
-.LP
-The \fB\&.SH NAME \fRmacro, also known as the \fBNAME \fRline, must immediately
-follow the \fB\&.TH \fRline, with nothing in between those lines. No font
-changes are permitted in the \fBNAME \fRline. The \fBNAME \fRline is
-immediately followed by a line containing the man page filename; then shadow
-page names, if applicable, separated by commas; a dash; and a brief summary
-statement. These elements should all be on one line; no carriage returns are
-permitted.
-.sp
-.LP
-An example of proper coding of these lines is:
-.sp
-.in +2
-.nf
-\&.TH NISMATCH 1M "Apr "10, 1998""
-\&.SH NAME
-nismatch, nisgrep \e- utilities for searching NIS+ tables
-.fi
-.in -2
-
+.\"
+.\" This file and its contents are supplied under the terms of the
+.\" Common Development and Distribution License ("CDDL"), version 1.0.
+.\" You may only use this file in accordance with the terms of version
+.\" 1.0 of the CDDL.
+.\"
+.\" A full copy of the text of the CDDL should have accompanied this
+.\" source.  A copy of the CDDL is also available via the Internet at
+.\" http://www.illumos.org/license/CDDL.
+.\"
+.\"
+.\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
+.\"
+.Dd Jul 16, 2014
+.Dt CATAMN 1M
+.Os
+.Sh NAME
+.Nm catman
+.Nd generate
+.Nm whatis
+database files
+.Sh SYNOPSIS
+.Nm
+.Op Fl M Ar path
+.Sh DESCRIPTION
+The
+.Nm
+utility generates a set of
+.Nm whatis
+database files suitable for use with
+.Xr apropos 1
+and
+.Xr whatis 1 .
+It is supplied for compatibility reasons.  The same databases can
+be generated using the
+.Fl w
+option with
+.Xr man 1 ,
+and that command should be used instead.
+.Bl -tag -width ".Fl d"
+.It Fl M Ar path
+Generate the
+.Nm whatis
+database files within the specified colon separated manual paths.
+Overrides the
+.Ev MANPATH
+environment variable.
+.El
+.Sh ENVIRONMENT
+The following environment variables affect the execution of
+.Nm :
+.Bl -tag -width ".Ev MANPATH"
+.It Ev MANPATH
+Used to specify a colon seperated list of manual paths within
+which to generate
+.Nm whatis
+database files.
+.El
+.Sh DIAGNOSTICS
+The
+.Nm
+utility exits 0 on success, and non-zero otherwise.
+.Sh INTERFACE STABILITY
+.Nm "Obsolete Committed" .
+.Sh CODE SET INDEPENDENCE
+Enabled.
+.Sh SEE ALSO
+.Xr apropos 1 ,
+.Xr man 1 ,
+.Xr whatis 1
--- old/usr/src/man/man5/Makefile	Wed Jul 16 14:05:08 2014
+++ new/usr/src/man/man5/Makefile	Wed Jul 16 14:05:08 2014
@@ -13,6 +13,7 @@
 # Copyright 2011, Richard Lowe
 # Copyright (c) 2012 by Delphix. All rights reserved.
 # Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
 #
 
 include		$(SRC)/Makefile.master
@@ -41,6 +42,7 @@
 		dhcp.5			\
 		dhcp_modules.5		\
 		environ.5		\
+		eqn.5			\
 		eqnchar.5		\
 		extendedFILE.5		\
 		filesystem.5		\
@@ -64,7 +66,9 @@
 		lfcompile64.5		\
 		locale.5		\
 		man.5			\
-		mansun.5		\
+		mandoc_char.5		\
+		mandoc_roff.5		\
+		mdoc.5			\
 		me.5			\
 		mech_spnego.5		\
 		mm.5			\
@@ -110,6 +114,7 @@
 		smf_template.5		\
 		standards.5		\
 		sticky.5		\
+		tbl.5			\
 		tecla.5			\
 		term.5			\
 		threads.5		\
--- /dev/null	Wed Jul 16 14:05:08 2014
+++ new/usr/src/man/man5/eqn.5	Wed Jul 16 14:05:08 2014
@@ -0,0 +1,281 @@
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.\"
+.\" Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+.\" Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+.\"
+.Dd Sep 25, 2011
+.Dt EQN 5
+.Os
+.Sh NAME
+.Nm eqn
+.Nd eqn language reference for mandoc
+.Sh DESCRIPTION
+The
+.Nm eqn
+language is an equation-formatting language.
+It is used within
+.Xr mdoc 5
+and
+.Xr man 5
+.Ux
+manual pages.
+It describes the
+.Em structure
+of an equation, not its mathematical meaning.
+This manual describes the
+.Nm
+language accepted by the
+.Xr mandoc 1
+utility, which corresponds to the Second Edition eqn specification (see
+.Sx SEE ALSO
+for references).
+.Pp
+Equations within
+.Xr mdoc 5
+or
+.Xr man 5
+documents are enclosed by the standalone
+.Sq \&.EQ
+and
+.Sq \&.EN
+tags.
+Equations are multi-line blocks consisting of formulas and control
+statements.
+.Sh EQUATION STRUCTURE
+Each equation is bracketed by
+.Sq \&.EQ
+and
+.Sq \&.EN
+strings.
+.Em Note :
+these are not the same as
+.Xr roff 5
+macros, and may only be invoked as
+.Sq \&.EQ .
+.Pp
+The equation grammar is as follows, where quoted strings are
+case-sensitive literals in the input:
+.Bd -literal -offset indent
+eqn     : box | eqn box
+box     : text
+        | \*q{\*q eqn \*q}\*q
+        | \*qdefine\*q text text
+        | \*qndefine\*q text text
+        | \*qtdefine\*q text text
+        | \*qgfont\*q text
+        | \*qgsize\*q text
+        | \*qset\*q text text
+        | \*qundef\*q text
+        | box pos box
+        | box mark
+        | \*qmatrix\*q \*q{\*q [col \*q{\*q list \*q}\*q ]*
+        | pile \*q{\*q list \*q}\*q
+        | font box
+        | \*qsize\*q text box
+        | \*qleft\*q text eqn [\*qright\*q text]
+col     : \*qlcol\*q | \*qrcol\*q | \*qccol\*q | \*qcol\*q
+text    : [^space\e\*q]+ | \e\*q.*\e\*q
+pile    : \*qlpile\*q | \*qcpile\*q | \*qrpile\*q | \*qpile\*q
+pos     : \*qover\*q | \*qsup\*q | \*qsub\*q | \*qto\*q | \*qfrom\*q
+mark	: \*qdot\*q | \*qdotdot\*q | \*qhat\*q | \*qtilde\*q | \*qvec\*q
+        | \*qdyad\*q | \*qbar\*q | \*qunder\*q
+font    : \*qroman\*q | \*qitalic\*q | \*qbold\*q | \*qfat\*q
+list    : eqn
+        | list \*qabove\*q eqn
+space   : [\e^~ \et]
+.Ed
+.Pp
+White-space consists of the space, tab, circumflex, and tilde
+characters.
+If within a quoted string, these space characters are retained.
+Quoted strings are also not scanned for replacement definitions.
+.Pp
+The following text terms are translated into a rendered glyph, if
+available: alpha, beta, chi, delta, epsilon, eta, gamma, iota, kappa,
+lambda, mu, nu, omega, omicron, phi, pi, psi, rho, sigma, tau, theta,
+upsilon, xi, zeta, DELTA, GAMMA, LAMBDA, OMEGA, PHI, PI, PSI, SIGMA,
+THETA, UPSILON, XI, inter (intersection), union (union), prod (product),
+int (integral), sum (summation), grad (gradient), del (vector
+differential), times (multiply), cdot (centre-dot), nothing (zero-width
+space), approx (approximately equals), prime (prime), half (one-half),
+partial (partial differential), inf (infinity), >> (much greater), <<
+(much less), \-> (left arrow), <\- (right arrow), += (plus-minus), !=
+(not equal), == (equivalence), <= (less-than-equal), and >=
+(more-than-equal).
+.Pp
+The following control statements are available:
+.Bl -tag -width Ds
+.It Cm define
+Replace all occurrences of a key with a value.
+Its syntax is as follows:
+.Pp
+.D1 define Ar key cvalc
+.Pp
+The first character of the value string,
+.Ar c ,
+is used as the delimiter for the value
+.Ar val .
+This allows for arbitrary enclosure of terms (not just quotes), such as
+.Pp
+.D1 define Ar foo 'bar baz'
+.D1 define Ar foo cbar bazc
+.Pp
+It is an error to have an empty
+.Ar key
+or
+.Ar val .
+Note that a quoted
+.Ar key
+causes errors in some
+.Nm
+implementations and should not be considered portable.
+It is not expanded for replacements.
+Definitions may refer to other definitions; these are evaluated
+recursively when text replacement occurs and not when the definition is
+created.
+.Pp
+Definitions can create arbitrary strings, for example, the following is
+a legal construction.
+.Bd -literal -offset indent
+define foo 'define'
+foo bar 'baz'
+.Ed
+.Pp
+Self-referencing definitions will raise an error.
+The
+.Cm ndefine
+statement is a synonym for
+.Cm define ,
+while
+.Cm tdefine
+is discarded.
+.It Cm gfont
+Set the default font of subsequent output.
+Its syntax is as follows:
+.Pp
+.D1 gfont Ar font
+.Pp
+In mandoc, this value is discarded.
+.It Cm gsize
+Set the default size of subsequent output.
+Its syntax is as follows:
+.Pp
+.D1 gsize Ar size
+.Pp
+The
+.Ar size
+value should be an integer.
+.It Cm set
+Set an equation mode.
+In mandoc, both arguments are thrown away.
+Its syntax is as follows:
+.Pp
+.D1 set Ar key val
+.Pp
+The
+.Ar key
+and
+.Ar val
+are not expanded for replacements.
+This statement is a GNU extension.
+.It Cm undef
+Unset a previously-defined key.
+Its syntax is as follows:
+.Pp
+.D1 define Ar key
+.Pp
+Once invoked, the definition for
+.Ar key
+is discarded.
+The
+.Ar key
+is not expanded for replacements.
+This statement is a GNU extension.
+.El
+.Sh COMPATIBILITY
+This section documents the compatibility of mandoc
+.Nm
+and the troff
+.Nm
+implementation (including GNU troff).
+.Pp
+.Bl -dash -compact
+.It
+The text string
+.Sq \e\*q
+is interpreted as a literal quote in troff.
+In mandoc, this is interpreted as a comment.
+.It
+In troff, The circumflex and tilde white-space symbols map to
+fixed-width spaces.
+In mandoc, these characters are synonyms for the space character.
+.It
+The troff implementation of
+.Nm
+allows for equation alignment with the
+.Cm mark
+and
+.Cm lineup
+tokens.
+mandoc discards these tokens.
+The
+.Cm back Ar n ,
+.Cm fwd Ar n ,
+.Cm up Ar n ,
+and
+.Cm down Ar n
+commands are also ignored.
+.El
+.Sh SEE ALSO
+.Xr mandoc 1 ,
+.Xr man 7 ,
+.Xr mandoc_char 5 ,
+.Xr mdoc 5 ,
+.Xr roff 5
+.Rs
+.%A Brian W. Kernighan
+.%A Lorinda L. Cherry
+.%T System for Typesetting Mathematics
+.%J Communications of the ACM
+.%V 18
+.%P 151\(en157
+.%D March, 1975
+.Re
+.Rs
+.%A Brian W. Kernighan
+.%A Lorinda L. Cherry
+.%T Typesetting Mathematics, User's Guide
+.%D 1976
+.Re
+.Rs
+.%A Brian W. Kernighan
+.%A Lorinda L. Cherry
+.%T Typesetting Mathematics, User's Guide (Second Edition)
+.%D 1978
+.Re
+.Sh HISTORY
+The eqn utility, a preprocessor for troff, was originally written by
+Brian W. Kernighan and Lorinda L. Cherry in 1975.
+The GNU reimplementation of eqn, part of the GNU troff package, was
+released in 1989 by James Clark.
+The eqn component of
+.Xr mandoc 1
+was added in 2011.
+.Sh AUTHORS
+This
+.Nm
+reference was written by
+.An Kristaps Dzonsons ,
+.Mt kristaps@bsd.lv .
--- old/usr/src/man/man5/man.5	Wed Jul 16 14:05:08 2014
+++ new/usr/src/man/man5/man.5	Wed Jul 16 14:05:08 2014
@@ -1,342 +1,913 @@
-'\" te
-.\" Copyright (c) 1995, Sun Microsystems, Inc.
-.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
-.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
-.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
-.TH MAN 5 "Jan 30, 1995"
-.SH NAME
-man \- macros to format Reference Manual pages
-.SH SYNOPSIS
-.LP
-.nf
-\fBnroff\fR \fB-man\fR \fIfilename\fR...
-.fi
-
-.LP
-.nf
-\fBtroff\fR  \fB-man\fR \fIfilename\fR...
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-These macros are used to lay out the reference pages in this manual. Note: if
-\fIfilename\fR contains format input for a preprocessor, the commands shown
-above must be piped through the appropriate preprocessor. This is handled
-automatically by the \fBman\fR(1) command. See the ``Conventions'' section.
-.sp
-.LP
-Any text argument \fIt\fR may be zero to six words. Quotes may be used to
-include SPACE characters in a "word".  If \fItext\fR is empty, the special
-treatment is applied to the next input line with text to be printed. In this
-way \fB\&.I\fR may be used to italicize a whole line, or \fB\&.SB\fR may be
-used to make small bold letters.
-.sp
-.LP
-A prevailing indent distance is remembered between successive indented
-paragraphs, and is reset to default value upon reaching a non-indented
-paragraph.  Default units for indents \fIi\fR are ens.
-.sp
-.LP
-Type font and size are reset to default values before each paragraph, and after
-processing font and size setting macros.
-.sp
-.LP
-These strings are predefined by \fB-man\fR:
-.sp
-.ne 2
-.na
-\fB\fB\e*R\fR\fR
-.ad
-.RS 8n
-`\(rg', `(Reg)' in \fBnroff\fR.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB\e*S\fR\fR
-.ad
-.RS 8n
-Change to default type size.
-.RE
-
-.SS "Requests"
-.sp
-.LP
-* n.t.l. = next text line; p.i. = prevailing indent
-.sp
-
-.sp
-.TS
-c c c c
-c c c c .
-\fIRequest\fR	\fICause\fR	\fIIf no\fR	\fIExplanation\fR
-	\fIBreak\fR	\fIArgument\fR	
-\fB\&.B \fR\fIt\fR	no	\fIt\fR=n.t.l.*	Text is in bold font.
-\fB\&.BI \fR\fIt\fR	no	\fIt\fR=n.t.l.	Join words, alternating bold and italic.
-\fB\&.BR \fR\fIt\fR	no	\fIt\fR=n.t.l.	Join words, alternating bold and roman.
-\fB\&.DT\fR	no	\&.5i 1i...	Restore default tabs.
-\fB\&.HP \fR\fIi\fR	yes	\fIi\fR=p.i.*	T{
-Begin paragraph with hanging indent. Set prevailing indent to \fIi\fR.
-T}
-\fB\&.I \fR\fIt\fR	no	\fIt\fR=n.t.l.	Text is italic.
-\fB\&.IB \fR\fIt\fR	no	\fIt\fR=n.t.l.	Join words, alternating italic and bold.
-\fB\&.IP \fR\fIx i\fR	yes	\fIx\fR=""	Same as \fB\&.TP\fR with tag \fIx\fR.
-\fB\&.IR \fR\fIt\fR	no	\fIt\fR=n.t.l.	T{
-Join words, alternating italic and roman.
-T}
-\fB\&.IX \fR\fIt\fR	no	-	Index macro, for SunSoft internal use.
-\fB\&.LP\fR	yes	-	T{
-Begin left-aligned paragraph. Set prevailing indent to .5i.
-T}
-\fB\&.P\fR	yes	-	Same as \fB\&.LP\fR.
-\fB\&.PD \fR\fId\fR	no	\fId\fR=.4v	T{
-Set vertical distance between paragraphs.
-T}
-\fB\&.PP\fR	yes	-	Same as \fB\&.LP\fR.
-\fB\&.RE\fR	yes	-	T{
-End of relative indent. Restores prevailing indent.
-T}
-\fB\&.RB \fR\fIt\fR	no	\fIt\fR=n.t.l.	Join words, alternating roman and bold.
-\fB\&.RI \fR\fIt\fR	no	\fIt\fR=n.t.l.	T{
-Join words, alternating roman and italic.
-T}
-\fB\&.RS \fR\fIi\fR	yes	\fIi\fR=p.i.	T{
-Start relative indent, increase indent by \fIi\fR. Sets prevailing indent to .5i for nested indents.
-T}
-\fB\&.SB \fR\fIt\fR	no	-	T{
-Reduce size of text by 1 point, make text bold.
-T}
-\fB\&.SH \fR\fIt\fR	yes	-	Section Heading.
-\fB\&.SM \fR\fIt\fR	no	\fIt\fR=n.t.l.	Reduce size of text by 1 point.
-\fB\&.SS \fR\fIt\fR	yes	\fIt\fR=n.t.l.	Section Subheading.
-\fB\&.TH \FR\FIN S "f d, m\fR"
-\fB\&.TH \fR\fIn s d f m\fR	yes	-	T{
-Begin reference page \fIn\fR, of of section \fIs\fR; \fId\fR is the date of the most recent change.  If present, \fIf\fR is the left page footer; \fIm\fR is the main page (center) header.  Sets prevailing indent and tabs to .5i.
-T}
-\fB\&.TP \fR\fIi\fR	yes	\fIi\fR=p.i.	T{
-Begin indented paragraph, with the tag given on the next text line. Set prevailing indent to \fIi\fR.
-T}
-\fB\&.TX \fR\fIt \fR\fIp\fR	no	-	T{
-Resolve the title abbreviation \fIt\fR; join to punctuation mark (or text) \fIp\fR.
-T}
-.TE
-
-.SS "Conventions"
-.sp
-.LP
-When formatting a manual page, \fBman\fR examines the first line to determine
-whether it requires special processing. For example a first line consisting of:
-.sp
-.LP
-\fB\&'\e" t\fR
-.sp
-.LP
-indicates that the manual page must be run through the \fBtbl\fR(1)
-preprocessor.
-.sp
-.LP
-A typical manual page for a command or function is laid out as follows:
-.sp
-.ne 2
-.na
-\fB\&.TH\fI TITLE \FR[1-9]\FR " , "
-.ad
-.RS 23n
-The name of the command or function, which serves as the title of the manual
-page. This is followed by the number of the section in which it appears.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\&.SH NAME\fR
-.ad
-.RS 23n
-The name, or list of names, by which the command is called, followed by a dash
-and then a one-line summary of the action performed. All in roman font, this
-section contains no \fBtroff\fR(1) commands or escapes, and no macro requests.
-It is used to generate the \fBwindex\fR database, which is used by the
-\fBwhatis\fR(1) command.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\&.SH SYNOPSIS\fR
-.ad
-.RS 23n
-.sp
-.ne 2
-.na
-\fBCommands:\fR
-.ad
-.RS 13n
-The syntax of the command and its arguments, as typed on the command line.
-When in boldface, a word must be typed exactly as printed.  When in italics, a
-word can be replaced with an argument that you supply. References to bold or
-italicized items are not capitalized in other sections, even when they begin a
-sentence.
-.sp
-Syntactic symbols appear in roman face:
-.sp
-.ne 2
-.na
-\fB[ ]\fR
-.ad
-.RS 13n
-An argument, when surrounded by brackets is optional.
-.RE
-
-.sp
-.ne 2
-.na
-\fB|\fR
-.ad
-.RS 13n
-Arguments separated by a vertical bar are exclusive. You can supply only one
-item from such a list.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\&.\|.\|.\fR
-.ad
-.RS 13n
-Arguments followed by an ellipsis can be repeated. When an ellipsis follows a
-bracketed set, the expression within the brackets can be repeated.
-.RE
-
-.RE
-
-.sp
-.ne 2
-.na
-\fBFunctions:\fR
-.ad
-.RS 14n
-If required, the data declaration, or \fB#include\fR directive, is shown first,
-followed by the  function declaration. Otherwise, the function declaration is
-shown.
-.RE
-
-.RE
-
-.sp
-.ne 2
-.na
-\fB\&.SH DESCRIPTION\fR
-.ad
-.RS 23n
-A narrative overview of the command or function's external behavior. This
-includes how it interacts with files or data, and how it handles the standard
-input, standard output and standard error. Internals and implementation details
-are normally omitted. This section attempts to provide a succinct overview in
-answer to the question, "what does it do?"
-.sp
-Literal text from the synopsis appears in constant width, as do literal
-filenames and references to items that appear elsewhere in the  reference
-manuals. Arguments are italicized.
-.sp
-If a command interprets either subcommands or an input grammar, its command
-interface or input grammar is normally described in a \fBUSAGE\fR section,
-which follows the \fBOPTIONS\fR section.  The  \fBDESCRIPTION\fR section only
-describes the behavior of the command itself, not that of subcommands.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\&.SH OPTIONS\fR
-.ad
-.RS 23n
-The list of options along with a description of how each affects the command's
-operation.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\&.SH RETURN VALUES\fR
-.ad
-.RS 23n
-A list of the values the library routine will return to the calling  program
-and the conditions that cause these values to be returned.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\&.SH EXIT STATUS\fR
-.ad
-.RS 23n
-A list of the values the utility will return to the calling  program or shell,
-and the conditions that cause these values to be  returned.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\&.SH FILES\fR
-.ad
-.RS 23n
-A list of files associated with the command or function.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\&.SH SEE ALSO\fR
-.ad
-.RS 23n
-A comma-separated list of related manual pages, followed by references to other
-published materials.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\&.SH DIAGNOSTICS\fR
-.ad
-.RS 23n
-A list of diagnostic messages and an explanation of each.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\&.SH BUGS\fR
-.ad
-.RS 23n
-A description of limitations, known defects, and possible problems associated
-with the command or function.
-.RE
-
-.SH FILES
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/lib/tmac/an\fR \fR
-.ad
-.RS 27n
-
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/usr/share/man/windex\fR\fR
-.ad
-.RS 27n
-
-.RE
-
-.SH SEE ALSO
-.sp
-.LP
-\fBman\fR(1), \fBnroff\fR(1), \fBtroff\fR(1), \fBwhatis\fR(1)
-.sp
-.LP
-Dale Dougherty and   Tim O'Reilly, \fIUnix\fR \fIText\fR \fIProcessing\fR
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.\"
+.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+.\" Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
+.\" Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+.\"
+.Dd Jan 3, 2012
+.Dt MAN 5
+.Os
+.Sh NAME
+.Nm man
+.Nd legacy formatting language for manual pages
+.Sh DESCRIPTION
+Traditionally, the
+.Nm man
+language has been used to write
+.Ux
+manuals for the
+.Xr man 1
+utility.
+It supports limited control of presentational details like fonts,
+indentation and spacing.
+This reference document describes the structure of manual pages
+and the syntax and usage of the man language.
+.Pp
+.Bf -emphasis
+Do not use
+.Nm
+to write your manuals:
+.Ef
+It lacks support for semantic markup.
+Use the
+.Xr mdoc 5
+language, instead.
+.Pp
+In a
+.Nm
+document, lines beginning with the control character
+.Sq \&.
+are called
+.Dq macro lines .
+The first word is the macro name.
+It usually consists of two capital letters.
+For a list of available macros, see
+.Sx MACRO OVERVIEW .
+The words following the macro name are arguments to the macro.
+.Pp
+Lines not beginning with the control character are called
+.Dq text lines .
+They provide free-form text to be printed; the formatting of the text
+depends on the respective processing context:
+.Bd -literal -offset indent
+\&.SH Macro lines change control state.
+Text lines are interpreted within the current state.
+.Ed
+.Pp
+Many aspects of the basic syntax of the
+.Nm
+language are based on the
+.Xr roff 5
+language; see the
+.Em LANGUAGE SYNTAX
+and
+.Em MACRO SYNTAX
+sections in the
+.Xr roff 5
+manual for details, in particular regarding
+comments, escape sequences, whitespace, and quoting.
+.Sh MANUAL STRUCTURE
+Each
+.Nm
+document must contain the
+.Sx \&TH
+macro describing the document's section and title.
+It may occur anywhere in the document, although conventionally it
+appears as the first macro.
+.Pp
+Beyond
+.Sx \&TH ,
+at least one macro or text line must appear in the document.
+.Pp
+The following is a well-formed skeleton
+.Nm
+file for a utility
+.Qq progname :
+.Bd -literal -offset indent
+\&.TH PROGNAME 1 "Oct 10, 2009"
+\&.SH NAME
+\efBprogname\efR \e(en a description goes here
+\&.\e\(dq .SH LIBRARY
+\&.\e\(dq For sections 2 & 3 only.
+\&.SH SYNOPSIS
+\efBprogname\efR [\efB\e-options\efR] arguments...
+\&.SH DESCRIPTION
+The \efBfoo\efR utility processes files...
+\&.\e\(dq .SH IMPLEMENTATION NOTES
+\&.\e\(dq .SH RETURN VALUES
+\&.\e\(dq For sections 2, 3, & 9 only.
+\&.\e\(dq .SH ENVIRONMENT
+\&.\e\(dq For sections 1, 1M, 5, & 6 only.
+\&.\e\(dq .SH FILES
+\&.\e\(dq .SH EXIT STATUS
+\&.\e\(dq For sections 1, 1M, & 6 only.
+\&.\e\(dq .SH EXAMPLES
+\&.\e\(dq .SH DIAGNOSTICS
+\&.\e\(dq For sections 1, 1M, 5, 6, & 7 only.
+\&.\e\(dq .SH ERRORS
+\&.\e\(dq For sections 2, 3, & 9 only.
+\&.\e\(dq .SH SEE ALSO
+\&.\e\(dq .BR foo ( 1 )
+\&.\e\(dq .SH STANDARDS
+\&.\e\(dq .SH HISTORY
+\&.\e\(dq .SH AUTHORS
+\&.\e\(dq .SH CAVEATS
+\&.\e\(dq .SH BUGS
+\&.\e\(dq .SH SECURITY CONSIDERATIONS
+.Ed
+.Pp
+The sections in a
+.Nm
+document are conventionally ordered as they appear above.
+Sections should be composed as follows:
+.Bl -ohang -offset indent
+.It Em NAME
+The name(s) and a short description of the documented material.
+The syntax for this is generally as follows:
+.Pp
+.D1 \efBname\efR \e(en description
+.It Em LIBRARY
+The name of the library containing the documented material, which is
+assumed to be a function in a section 2 or 3 manual.
+For functions in the C library, this may be as follows:
+.Pp
+.D1 Standard C Library (libc, -lc)
+.It Em SYNOPSIS
+Documents the utility invocation syntax, function call syntax, or device
+configuration.
+.Pp
+For the first, utilities (sections 1, 1M, and 6), this is
+generally structured as follows:
+.Pp
+.D1 \efBname\efR [-\efBab\efR] [-\efBc\efR\efIarg\efR] \efBpath\efR...
+.Pp
+For the second, function calls (sections 2, 3, 9):
+.Pp
+.D1 \&.B char *name(char *\efIarg\efR);
+.Pp
+And for the third, configurations (section 7):
+.Pp
+.D1 \&.B name* at cardbus ? function ?
+.Pp
+Manuals not in these sections generally don't need a
+.Em SYNOPSIS .
+.It Em DESCRIPTION
+This expands upon the brief, one-line description in
+.Em NAME .
+It usually contains a break-down of the options (if documenting a
+command).
+.It Em IMPLEMENTATION NOTES
+Implementation-specific notes should be kept here.
+This is useful when implementing standard functions that may have side
+effects or notable algorithmic implications.
+.It Em RETURN VALUES
+This section documents the return values of functions in sections 2, 3, and 9.
+.It Em ENVIRONMENT
+Documents any usages of environment variables, e.g.,
+.Xr environ 5 .
+.It Em FILES
+Documents files used.
+It's helpful to document both the file name and a short description of how
+the file is used (created, modified, etc.).
+.It Em EXIT STATUS
+This section documents the command exit status for
+section 1, 6, and 8 utilities.
+Historically, this information was described in
+.Em DIAGNOSTICS ,
+a practise that is now discouraged.
+.It Em EXAMPLES
+Example usages.
+This often contains snippets of well-formed,
+well-tested invocations.
+Make sure that examples work properly!
+.It Em DIAGNOSTICS
+Documents error conditions.
+This is most useful in section 4 manuals.
+Historically, this section was used in place of
+.Em EXIT STATUS
+for manuals in sections 1, 6, and 8; however, this practise is
+discouraged.
+.It Em ERRORS
+Documents error handling in sections 2, 3, and 9.
+.It Em SEE ALSO
+References other manuals with related topics.
+This section should exist for most manuals.
+.Pp
+.D1 \&.BR bar \&( 1 \&),
+.Pp
+Cross-references should conventionally be ordered
+first by section, then alphabetically.
+.It Em STANDARDS
+References any standards implemented or used, such as
+.Pp
+.D1 IEEE Std 1003.2 (\e(lqPOSIX.2\e(rq)
+.Pp
+If not adhering to any standards, the
+.Em HISTORY
+section should be used.
+.It Em HISTORY
+A brief history of the subject, including where support first appeared.
+.It Em AUTHORS
+Credits to the person or persons who wrote the code and/or documentation.
+Authors should generally be noted by both name and email address.
+.It Em CAVEATS
+Common misuses and misunderstandings should be explained
+in this section.
+.It Em BUGS
+Known bugs, limitations, and work-arounds should be described
+in this section.
+.It Em SECURITY CONSIDERATIONS
+Documents any security precautions that operators should consider.
+.El
+.Sh MACRO OVERVIEW
+This overview is sorted such that macros of similar purpose are listed
+together, to help find the best macro for any given purpose.
+Deprecated macros are not included in the overview, but can be found
+in the alphabetical reference below.
+.Ss Page header and footer meta-data
+.Bl -column "PP, LP, P" description
+.It Sx TH Ta set the title: Ar title section date Op Ar source Op Ar volume
+.It Sx AT Ta display AT&T UNIX version in the page footer (<= 1 argument)
+.It Sx UC Ta display BSD version in the page footer (<= 1 argument)
+.El
+.Ss Sections and paragraphs
+.Bl -column "PP, LP, P" description
+.It Sx SH Ta section header (one line)
+.It Sx SS Ta subsection header (one line)
+.It Sx PP , LP , P Ta start an undecorated paragraph (no arguments)
+.It Sx RS , RE Ta reset the left margin: Op Ar width
+.It Sx IP Ta indented paragraph: Op Ar head Op Ar width
+.It Sx TP Ta tagged paragraph: Op Ar width
+.It Sx HP Ta hanged paragraph: Op Ar width
+.It Sx \&br Ta force output line break in text mode (no arguments)
+.It Sx \&sp Ta force vertical space: Op Ar height
+.It Sx fi , nf Ta fill mode and no-fill mode (no arguments)
+.It Sx in Ta additional indent: Op Ar width
+.El
+.Ss Physical markup
+.Bl -column "PP, LP, P" description
+.It Sx B Ta boldface font
+.It Sx I Ta italic font
+.It Sx R Ta roman (default) font
+.It Sx SB Ta small boldface font
+.It Sx SM Ta small roman font
+.It Sx BI Ta alternate between boldface and italic fonts
+.It Sx BR Ta alternate between boldface and roman fonts
+.It Sx IB Ta alternate between italic and boldface fonts
+.It Sx IR Ta alternate between italic and roman fonts
+.It Sx RB Ta alternate between roman and boldface fonts
+.It Sx RI Ta alternate between roman and italic fonts
+.El
+.Ss Semantic markup
+.Bl -column "PP, LP, P" description
+.It Sx OP Ta optional arguments
+.El
+.Sh MACRO REFERENCE
+This section is a canonical reference to all macros, arranged
+alphabetically.
+For the scoping of individual macros, see
+.Sx MACRO SYNTAX .
+.Ss \&AT
+Sets the volume for the footer for compatibility with man pages from
+.Tn AT&T UNIX
+releases.
+The optional arguments specify which release it is from.
+.Ss \&B
+Text is rendered in bold face.
+.Pp
+See also
+.Sx \&I
+and
+.Sx \&R .
+.Ss \&BI
+Text is rendered alternately in bold face and italic.
+Thus,
+.Sq .BI this word and that
+causes
+.Sq this
+and
+.Sq and
+to render in bold face, while
+.Sq word
+and
+.Sq that
+render in italics.
+Whitespace between arguments is omitted in output.
+.Pp
+Examples:
+.Pp
+.Dl \&.BI bold italic bold italic
+.Pp
+The output of this example will be emboldened
+.Dq bold
+and italicised
+.Dq italic ,
+with spaces stripped between arguments.
+.Pp
+See also
+.Sx \&IB ,
+.Sx \&BR ,
+.Sx \&RB ,
+.Sx \&RI ,
+and
+.Sx \&IR .
+.Ss \&BR
+Text is rendered alternately in bold face and roman (the default font).
+Whitespace between arguments is omitted in output.
+.Pp
+See
+.Sx \&BI
+for an equivalent example.
+.Pp
+See also
+.Sx \&BI ,
+.Sx \&IB ,
+.Sx \&RB ,
+.Sx \&RI ,
+and
+.Sx \&IR .
+.Ss \&DT
+Has no effect.
+Included for compatibility.
+.Ss \&HP
+Begin a paragraph whose initial output line is left-justified, but
+subsequent output lines are indented, with the following syntax:
+.Bd -filled -offset indent
+.Pf \. Sx \&HP
+.Op Cm width
+.Ed
+.Pp
+The
+.Cm width
+argument must conform to
+.Sx Scaling Widths .
+If specified, it's saved for later paragraph left-margins; if unspecified, the
+saved or default width is used.
+.Pp
+See also
+.Sx \&IP ,
+.Sx \&LP ,
+.Sx \&P ,
+.Sx \&PP ,
+and
+.Sx \&TP .
+.Ss \&I
+Text is rendered in italics.
+.Pp
+See also
+.Sx \&B
+and
+.Sx \&R .
+.Ss \&IB
+Text is rendered alternately in italics and bold face.
+Whitespace between arguments is omitted in output.
+.Pp
+See
+.Sx \&BI
+for an equivalent example.
+.Pp
+See also
+.Sx \&BI ,
+.Sx \&BR ,
+.Sx \&RB ,
+.Sx \&RI ,
+and
+.Sx \&IR .
+.Ss \&IP
+Begin an indented paragraph with the following syntax:
+.Bd -filled -offset indent
+.Pf \. Sx \&IP
+.Op Cm head Op Cm width
+.Ed
+.Pp
+The
+.Cm width
+argument defines the width of the left margin and is defined by
+.Sx Scaling Widths .
+It's saved for later paragraph left-margins; if unspecified, the saved or
+default width is used.
+.Pp
+The
+.Cm head
+argument is used as a leading term, flushed to the left margin.
+This is useful for bulleted paragraphs and so on.
+.Pp
+See also
+.Sx \&HP ,
+.Sx \&LP ,
+.Sx \&P ,
+.Sx \&PP ,
+and
+.Sx \&TP .
+.Ss \&IR
+Text is rendered alternately in italics and roman (the default font).
+Whitespace between arguments is omitted in output.
+.Pp
+See
+.Sx \&BI
+for an equivalent example.
+.Pp
+See also
+.Sx \&BI ,
+.Sx \&IB ,
+.Sx \&BR ,
+.Sx \&RB ,
+and
+.Sx \&RI .
+.Ss \&LP
+Begin an undecorated paragraph.
+The scope of a paragraph is closed by a subsequent paragraph,
+sub-section, section, or end of file.
+The saved paragraph left-margin width is reset to the default.
+.Pp
+See also
+.Sx \&HP ,
+.Sx \&IP ,
+.Sx \&P ,
+.Sx \&PP ,
+and
+.Sx \&TP .
+.Ss \&OP
+Optional command-line argument.
+This has the following syntax:
+.Bd -filled -offset indent
+.Pf \. Sx \&OP
+.Cm key Op Cm value
+.Ed
+.Pp
+The
+.Cm key
+is usually a command-line flag and
+.Cm value
+its argument.
+.Ss \&P
+Synonym for
+.Sx \&LP .
+.Pp
+See also
+.Sx \&HP ,
+.Sx \&IP ,
+.Sx \&LP ,
+.Sx \&PP ,
+and
+.Sx \&TP .
+.Ss \&PP
+Synonym for
+.Sx \&LP .
+.Pp
+See also
+.Sx \&HP ,
+.Sx \&IP ,
+.Sx \&LP ,
+.Sx \&P ,
+and
+.Sx \&TP .
+.Ss \&R
+Text is rendered in roman (the default font).
+.Pp
+See also
+.Sx \&I
+and
+.Sx \&B .
+.Ss \&RB
+Text is rendered alternately in roman (the default font) and bold face.
+Whitespace between arguments is omitted in output.
+.Pp
+See
+.Sx \&BI
+for an equivalent example.
+.Pp
+See also
+.Sx \&BI ,
+.Sx \&IB ,
+.Sx \&BR ,
+.Sx \&RI ,
+and
+.Sx \&IR .
+.Ss \&RE
+Explicitly close out the scope of a prior
+.Sx \&RS .
+The default left margin is restored to the state of the original
+.Sx \&RS
+invocation.
+.Ss \&RI
+Text is rendered alternately in roman (the default font) and italics.
+Whitespace between arguments is omitted in output.
+.Pp
+See
+.Sx \&BI
+for an equivalent example.
+.Pp
+See also
+.Sx \&BI ,
+.Sx \&IB ,
+.Sx \&BR ,
+.Sx \&RB ,
+and
+.Sx \&IR .
+.Ss \&RS
+Temporarily reset the default left margin.
+This has the following syntax:
+.Bd -filled -offset indent
+.Pf \. Sx \&RS
+.Op Cm width
+.Ed
+.Pp
+The
+.Cm width
+argument must conform to
+.Sx Scaling Widths .
+If not specified, the saved or default width is used.
+.Pp
+See also
+.Sx \&RE .
+.Ss \&SB
+Text is rendered in small size (one point smaller than the default font)
+bold face.
+.Ss \&SH
+Begin a section.
+The scope of a section is only closed by another section or the end of
+file.
+The paragraph left-margin width is reset to the default.
+.Ss \&SM
+Text is rendered in small size (one point smaller than the default
+font).
+.Ss \&SS
+Begin a sub-section.
+The scope of a sub-section is closed by a subsequent sub-section,
+section, or end of file.
+The paragraph left-margin width is reset to the default.
+.Ss \&TH
+Sets the title of the manual page with the following syntax:
+.Bd -filled -offset indent
+.Pf \. Sx \&TH
+.Ar title section date
+.Op Ar source Op Ar volume
+.Ed
+.Pp
+Conventionally, the document
+.Ar title
+is given in all caps.
+The recommended
+.Ar date
+format is
+.Sy YYYY-MM-DD
+as specified in the ISO-8601 standard;
+if the argument does not conform, it is printed verbatim.
+If the
+.Ar date
+is empty or not specified, the current date is used.
+The optional
+.Ar source
+string specifies the organisation providing the utility.
+The
+.Ar volume
+string replaces the default rendered volume, which is dictated by the
+manual section.
+.Pp
+Examples:
+.Pp
+.Dl \&.TH CVS 5 "1992-02-12" GNU
+.Ss \&TP
+Begin a paragraph where the head, if exceeding the indentation width, is
+followed by a newline; if not, the body follows on the same line after a
+buffer to the indentation width.
+Subsequent output lines are indented.
+The syntax is as follows:
+.Bd -filled -offset indent
+.Pf \. Sx \&TP
+.Op Cm width
+.Ed
+.Pp
+The
+.Cm width
+argument must conform to
+.Sx Scaling Widths .
+If specified, it's saved for later paragraph left-margins; if
+unspecified, the saved or default width is used.
+.Pp
+See also
+.Sx \&HP ,
+.Sx \&IP ,
+.Sx \&LP ,
+.Sx \&P ,
+and
+.Sx \&PP .
+.Ss \&UC
+Sets the volume for the footer for compatibility with man pages from
+BSD releases.
+The optional first argument specifies which release it is from.
+.Ss \&br
+Breaks the current line.
+Consecutive invocations have no further effect.
+.Pp
+See also
+.Sx \&sp .
+.Ss \&fi
+End literal mode begun by
+.Sx \&nf .
+.Ss \&ft
+Change the current font mode.
+See
+.Sx Text Decoration
+for a listing of available font modes.
+.Ss \&in
+Indent relative to the current indentation:
+.Pp
+.D1 Pf \. Sx \&in Op Cm width
+.Pp
+If
+.Cm width
+is signed, the new offset is relative.
+Otherwise, it is absolute.
+This value is reset upon the next paragraph, section, or sub-section.
+.Ss \&na
+Don't align to the right margin.
+.Ss \&nf
+Begin literal mode: all subsequent free-form lines have their end of
+line boundaries preserved.
+May be ended by
+.Sx \&fi .
+Literal mode is implicitly ended by
+.Sx \&SH
+or
+.Sx \&SS .
+.Ss \&sp
+Insert vertical spaces into output with the following syntax:
+.Bd -filled -offset indent
+.Pf \. Sx \&sp
+.Op Cm height
+.Ed
+.Pp
+Insert
+.Cm height
+spaces, which must conform to
+.Sx Scaling Widths .
+If 0, this is equivalent to the
+.Sx \&br
+macro.
+Defaults to 1, if unspecified.
+.Pp
+See also
+.Sx \&br .
+.Sh MACRO SYNTAX
+The
+.Nm
+macros are classified by scope: line scope or block scope.
+Line macros are only scoped to the current line (and, in some
+situations, the subsequent line).
+Block macros are scoped to the current line and subsequent lines until
+closed by another block macro.
+.Ss Line Macros
+Line macros are generally scoped to the current line, with the body
+consisting of zero or more arguments.
+If a macro is scoped to the next line and the line arguments are empty,
+the next line, which must be text, is used instead.
+Thus:
+.Bd -literal -offset indent
+\&.I
+foo
+.Ed
+.Pp
+is equivalent to
+.Sq \&.I foo .
+If next-line macros are invoked consecutively, only the last is used.
+If a next-line macro is followed by a non-next-line macro, an error is
+raised, except for
+.Sx \&br ,
+.Sx \&sp ,
+and
+.Sx \&na .
+.Pp
+The syntax is as follows:
+.Bd -literal -offset indent
+\&.YO \(lBbody...\(rB
+\(lBbody...\(rB
+.Ed
+.Bl -column "MacroX" "ArgumentsX" "ScopeXXXXX" "CompatX" -offset indent
+.It Em Macro Ta Em Arguments Ta Em Scope     Ta Em Notes
+.It Sx \&AT  Ta    <=1       Ta    current   Ta    \&
+.It Sx \&B   Ta    n         Ta    next-line Ta    \&
+.It Sx \&BI  Ta    n         Ta    current   Ta    \&
+.It Sx \&BR  Ta    n         Ta    current   Ta    \&
+.It Sx \&DT  Ta    0         Ta    current   Ta    \&
+.It Sx \&I   Ta    n         Ta    next-line Ta    \&
+.It Sx \&IB  Ta    n         Ta    current   Ta    \&
+.It Sx \&IR  Ta    n         Ta    current   Ta    \&
+.It Sx \&OP  Ta    0, 1      Ta    current   Ta    compat
+.It Sx \&R   Ta    n         Ta    next-line Ta    \&
+.It Sx \&RB  Ta    n         Ta    current   Ta    \&
+.It Sx \&RI  Ta    n         Ta    current   Ta    \&
+.It Sx \&SB  Ta    n         Ta    next-line Ta    \&
+.It Sx \&SM  Ta    n         Ta    next-line Ta    \&
+.It Sx \&TH  Ta    >1, <6    Ta    current   Ta    \&
+.It Sx \&UC  Ta    <=1       Ta    current   Ta    \&
+.It Sx \&br  Ta    0         Ta    current   Ta    compat
+.It Sx \&fi  Ta    0         Ta    current   Ta    compat
+.It Sx \&ft  Ta    1         Ta    current   Ta    compat
+.It Sx \&in  Ta    1         Ta    current   Ta    compat
+.It Sx \&na  Ta    0         Ta    current   Ta    compat
+.It Sx \&nf  Ta    0         Ta    current   Ta    compat
+.It Sx \&sp  Ta    1         Ta    current   Ta    compat
+.El
+.Pp
+Macros marked as
+.Qq compat
+are included for compatibility with the significant corpus of existing
+manuals that mix dialects of roff.
+These macros should not be used for portable
+.Nm
+manuals.
+.Ss Block Macros
+Block macros comprise a head and body.
+As with in-line macros, the head is scoped to the current line and, in
+one circumstance, the next line (the next-line stipulations as in
+.Sx Line Macros
+apply here as well).
+.Pp
+The syntax is as follows:
+.Bd -literal -offset indent
+\&.YO \(lBhead...\(rB
+\(lBhead...\(rB
+\(lBbody...\(rB
+.Ed
+.Pp
+The closure of body scope may be to the section, where a macro is closed
+by
+.Sx \&SH ;
+sub-section, closed by a section or
+.Sx \&SS ;
+part, closed by a section, sub-section, or
+.Sx \&RE ;
+or paragraph, closed by a section, sub-section, part,
+.Sx \&HP ,
+.Sx \&IP ,
+.Sx \&LP ,
+.Sx \&P ,
+.Sx \&PP ,
+or
+.Sx \&TP .
+No closure refers to an explicit block closing macro.
+.Pp
+As a rule, block macros may not be nested; thus, calling a block macro
+while another block macro scope is open, and the open scope is not
+implicitly closed, is syntactically incorrect.
+.Bl -column "MacroX" "ArgumentsX" "Head ScopeX" "sub-sectionX" "compatX" -offset indent
+.It Em Macro Ta Em Arguments Ta Em Head Scope Ta Em Body Scope  Ta Em Notes
+.It Sx \&HP  Ta    <2        Ta    current    Ta    paragraph   Ta    \&
+.It Sx \&IP  Ta    <3        Ta    current    Ta    paragraph   Ta    \&
+.It Sx \&LP  Ta    0         Ta    current    Ta    paragraph   Ta    \&
+.It Sx \&P   Ta    0         Ta    current    Ta    paragraph   Ta    \&
+.It Sx \&PP  Ta    0         Ta    current    Ta    paragraph   Ta    \&
+.It Sx \&RE  Ta    0         Ta    current    Ta    none        Ta    compat
+.It Sx \&RS  Ta    1         Ta    current    Ta    part        Ta    compat
+.It Sx \&SH  Ta    >0        Ta    next-line  Ta    section     Ta    \&
+.It Sx \&SS  Ta    >0        Ta    next-line  Ta    sub-section Ta    \&
+.It Sx \&TP  Ta    n         Ta    next-line  Ta    paragraph   Ta    \&
+.El
+.Pp
+Macros marked
+.Qq compat
+are as mentioned in
+.Sx Line Macros .
+.Pp
+If a block macro is next-line scoped, it may only be followed by in-line
+macros for decorating text.
+.Ss Font handling
+In
+.Nm
+documents, both
+.Sx Physical markup
+macros and
+.Xr roff 5
+.Ql \ef
+font escape sequences can be used to choose fonts.
+In text lines, the effect of manual font selection by escape sequences
+only lasts until the next macro invocation; in macro lines, it only lasts
+until the end of the macro scope.
+Note that macros like
+.Sx \&BR
+open and close a font scope for each argument.
+.Sh COMPATIBILITY
+This section documents areas of questionable portability between
+implementations of the
+.Nm
+language.
+.Pp
+.Bl -dash -compact
+.It
+Do not depend on
+.Sx \&SH
+or
+.Sx \&SS
+to close out a literal context opened with
+.Sx \&nf .
+This behaviour may not be portable.
+.It
+In quoted literals, GNU troff allowed pair-wise double-quotes to produce
+a standalone double-quote in formatted output.
+It is not known whether this behaviour is exhibited by other formatters.
+.It
+troff suppresses a newline before
+.Sq \(aq
+macro output; in mandoc, it is an alias for the standard
+.Sq \&.
+control character.
+.It
+The
+.Sq \eh
+.Pq horizontal position ,
+.Sq \ev
+.Pq vertical position ,
+.Sq \em
+.Pq text colour ,
+.Sq \eM
+.Pq text filling colour ,
+.Sq \ez
+.Pq zero-length character ,
+.Sq \ew
+.Pq string length ,
+.Sq \ek
+.Pq horizontal position marker ,
+.Sq \eo
+.Pq text overstrike ,
+and
+.Sq \es
+.Pq text size
+escape sequences are all discarded in mandoc.
+.It
+The
+.Sq \ef
+scaling unit is accepted by mandoc, but rendered as the default unit.
+.It
+The
+.Sx \&sp
+macro does not accept negative values in mandoc.
+In GNU troff, this would result in strange behaviour.
+.It
+In page header lines, GNU troff versions up to and including 1.21
+only print
+.Ar volume
+names explicitly specified in the
+.Sx \&TH
+macro; mandoc and newer groff print the default volume name
+corresponding to the
+.Ar section
+number when no
+.Ar volume
+is given, like in
+.Xr mdoc 5 .
+.El
+.Pp
+The
+.Sx OP
+macro is part of the extended
+.Nm
+macro set, and may not be portable to non-GNU troff implementations.
+.Sh INTERFACE STABILITY
+.Nm "Obsolete Committed" .
+.Sh SEE ALSO
+.Xr man 1 ,
+.Xr mandoc 1 ,
+.Xr eqn 5 ,
+.Xr mandoc_char 5 ,
+.Xr mdoc 5 ,
+.Xr roff 5 ,
+.Xr tbl 5
+.Sh HISTORY
+The
+.Nm
+language first appeared as a macro package for the roff typesetting
+system in
+.At v7 .
+It was later rewritten by James Clark as a macro package for groff.
+Eric S. Raymond wrote the extended
+.Nm
+macros for groff in 2007.
+The stand-alone implementation that is part of the
+.Xr mandoc 1
+utility written by Kristaps Dzonsons appeared in
+.Ox 4.6 .
+.Sh AUTHORS
+This
+.Nm
+reference was written by
+.An Kristaps Dzonsons ,
+.Mt kristaps@bsd.lv .
+.Sh CAVEATS
+Do not use this language.
+Use
+.Xr mdoc 5 ,
+instead.
--- /dev/null	Wed Jul 16 14:05:09 2014
+++ new/usr/src/man/man5/mandoc_char.5	Wed Jul 16 14:05:09 2014
@@ -0,0 +1,744 @@
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.\"
+.\" Copyright (c) 2003 Jason McIntyre <jmc@openbsd.org>
+.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+.\" Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
+.\" Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+.\"
+.Dd Nov 23, 2011
+.Dt MANDOC_CHAR 5
+.Os
+.Sh NAME
+.Nm mandoc_char
+.Nd mandoc special characters
+.Sh DESCRIPTION
+This page documents the
+.Xr roff 5
+escape sequences accepted by
+.Xr mandoc 1
+to represent special characters in
+.Xr mdoc 5
+and
+.Xr man 5
+documents.
+.Pp
+The rendering depends on the
+.Xr mandoc 1
+output mode; in ASCII output, most characters are completely
+unintelligible.
+For that reason, using any of the special characters documented here,
+except those discussed in the
+.Sx DESCRIPTION ,
+is strongly discouraged; they are supported merely for backwards
+compatibility with existing documents.
+.Pp
+In particular, in English manual pages, do not use special-character
+escape sequences to represent national language characters in author
+names; instead, provide ASCII transcriptions of the names.
+.Ss Dashes and Hyphens
+In typography there are different types of dashes of various width:
+the hyphen (-),
+the minus sign (\-),
+the en-dash (\(en),
+and the em-dash (\(em).
+.Pp
+Hyphens are used for adjectives;
+to separate the two parts of a compound word;
+or to separate a word across two successive lines of text.
+The hyphen does not need to be escaped:
+.Bd -unfilled -offset indent
+blue-eyed
+lorry-driver
+.Ed
+.Pp
+The mathematical minus sign is used for negative numbers or subtraction.
+It should be written as
+.Sq \e- :
+.Bd -unfilled -offset indent
+a = 3 \e- 1;
+b = \e-2;
+.Ed
+.Pp
+The en-dash is used to separate the two elements of a range,
+or can be used the same way as an em-dash.
+It should be written as
+.Sq \e(en :
+.Bd -unfilled -offset indent
+pp. 95\e(en97.
+Go away \e(en or else!
+.Ed
+.Pp
+The em-dash can be used to show an interruption
+or can be used the same way as colons, semi-colons, or parentheses.
+It should be written as
+.Sq \e(em :
+.Bd -unfilled -offset indent
+Three things \e(em apples, oranges, and bananas.
+This is not that \e(em rather, this is that.
+.Ed
+.Pp
+Note:
+hyphens, minus signs, and en-dashes look identical under normal ASCII output.
+Other formats, such as PostScript, render them correctly,
+with differing widths.
+.Ss Spaces
+To separate words in normal text, for indenting and alignment
+in literal context, and when none of the following special cases apply,
+just use the normal space character
+.Pq Sq \  .
+.Pp
+When filling text, lines may be broken between words, i.e. at space
+characters.
+To prevent a line break between two particular words,
+use the non-breaking space escape sequence
+.Pq Sq \e~
+instead of the normal space character.
+For example, the input string
+.Dq number\e~1
+will be kept together as
+.Dq number\~1
+on the same output line.
+.Pp
+On request and macro lines, the normal space character serves as an
+argument delimiter.
+To include whitespace into arguments, quoting is usually the best choice.
+In some cases, using either the non-breaking
+.Pq Sq \e~
+or the breaking
+.Pq Sq \e\ \&
+space escape sequence may be preferable.
+To escape macro names and to protect whitespace at the end
+of input lines, the zero-width space
+.Pq Sq \e&
+is often useful.
+For example, in
+.Xr mdoc 5 ,
+a normal space character can be displayed in single quotes in either
+of the following ways:
+.Pp
+.Dl .Sq \(dq \(dq
+.Dl .Sq \e \e&
+.Ss Quotes
+On request and macro lines, the double-quote character
+.Pq Sq \(dq
+is handled specially to allow quoting.
+One way to prevent this special handling is by using the
+.Sq \e(dq
+escape sequence.
+.Pp
+Note that on text lines, literal double-quote characters can be used
+verbatim.
+All other quote-like characters can be used verbatim as well,
+even on request and macro lines.
+.Ss Periods
+The period
+.Pq Sq \&.
+is handled specially at the beginning of an input line,
+where it introduces a
+.Xr roff 5
+request or a macro, and when appearing alone as a macro argument in
+.Xr mdoc 5 .
+In such situations, prepend a zero-width space
+.Pq Sq \e&.
+to make it behave like normal text.
+.Pp
+Do not use the
+.Sq \e.
+escape sequence.
+It does not prevent special handling of the period.
+.Ss Backslashes
+To include a literal backslash
+.Pq Sq \e
+into the output, use the
+.Pq Sq \ee
+escape sequence.
+.Pp
+Note that doubling it
+.Pq Sq \e\e
+is not the right way to output a backslash.
+Because
+.Xr mandoc 1
+does not implement full
+.Xr roff 5
+functionality, it may work with
+.Xr mandoc 1 ,
+but it may have weird effects on complete
+.Xr roff 5
+implementations.
+.Sh SPECIAL CHARACTERS
+Special characters are encoded as
+.Sq \eX
+.Pq for a one-character escape ,
+.Sq \e(XX
+.Pq two-character ,
+and
+.Sq \e[N]
+.Pq N-character .
+For details, see the
+.Em Special Characters
+subsection of the
+.Xr roff 5
+manual.
+.Pp
+Spacing:
+.Bl -column "Input" "Description" -offset indent -compact
+.It Em Input Ta Em Description
+.It \e~      Ta non-breaking, non-collapsing space
+.It \e       Ta breaking, non-collapsing n-width space
+.It \e^      Ta zero-width space
+.It \e%      Ta zero-width space
+.It \e&      Ta zero-width space
+.It \e|      Ta zero-width space
+.It \e0      Ta breaking, non-collapsing digit-width space
+.It \ec      Ta removes any trailing space (if applicable)
+.El
+.Pp
+Lines:
+.Bl -column "Input" "Rendered" "Description" -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e(ba    Ta \(ba        Ta bar
+.It \e(br    Ta \(br        Ta box rule
+.It \e(ul    Ta \(ul        Ta underscore
+.It \e(rl    Ta \(rl        Ta overline
+.It \e(bb    Ta \(bb        Ta broken bar
+.It \e(sl    Ta \(sl        Ta forward slash
+.It \e(rs    Ta \(rs        Ta backward slash
+.El
+.Pp
+Text markers:
+.Bl -column "Input" "Rendered" "Description" -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e(ci    Ta \(ci        Ta circle
+.It \e(bu    Ta \(bu        Ta bullet
+.It \e(dd    Ta \(dd        Ta double dagger
+.It \e(dg    Ta \(dg        Ta dagger
+.It \e(lz    Ta \(lz        Ta lozenge
+.It \e(sq    Ta \(sq        Ta white square
+.It \e(ps    Ta \(ps        Ta paragraph
+.It \e(sc    Ta \(sc        Ta section
+.It \e(lh    Ta \(lh        Ta left hand
+.It \e(rh    Ta \(rh        Ta right hand
+.It \e(at    Ta \(at        Ta at
+.It \e(sh    Ta \(sh        Ta hash (pound)
+.It \e(CR    Ta \(CR        Ta carriage return
+.It \e(OK    Ta \(OK        Ta check mark
+.El
+.Pp
+Legal symbols:
+.Bl -column "Input" "Rendered" "Description" -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e(co    Ta \(co        Ta copyright
+.It \e(rg    Ta \(rg        Ta registered
+.It \e(tm    Ta \(tm        Ta trademarked
+.El
+.Pp
+Punctuation:
+.Bl -column "Input" "Rendered" "Description" -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e(em    Ta \(em        Ta em-dash
+.It \e(en    Ta \(en        Ta en-dash
+.It \e(hy    Ta \(hy        Ta hyphen
+.It \ee      Ta \e          Ta back-slash
+.It \e.      Ta \.          Ta period
+.It \e(r!    Ta \(r!        Ta upside-down exclamation
+.It \e(r?    Ta \(r?        Ta upside-down question
+.El
+.Pp
+Quotes:
+.Bl -column "Input" "Rendered" "Description" -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e(Bq    Ta \(Bq        Ta right low double-quote
+.It \e(bq    Ta \(bq        Ta right low single-quote
+.It \e(lq    Ta \(lq        Ta left double-quote
+.It \e(rq    Ta \(rq        Ta right double-quote
+.It \e(oq    Ta \(oq        Ta left single-quote
+.It \e(cq    Ta \(cq        Ta right single-quote
+.It \e(aq    Ta \(aq        Ta apostrophe quote (text)
+.It \e(dq    Ta \(dq        Ta double quote (text)
+.It \e(Fo    Ta \(Fo        Ta left guillemet
+.It \e(Fc    Ta \(Fc        Ta right guillemet
+.It \e(fo    Ta \(fo        Ta left single guillemet
+.It \e(fc    Ta \(fc        Ta right single guillemet
+.El
+.Pp
+Brackets:
+.Bl -column "xxbracketrightbpx" Rendered Description -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e(lB    Ta \(lB        Ta left bracket
+.It \e(rB    Ta \(rB        Ta right bracket
+.It \e(lC    Ta \(lC        Ta left brace
+.It \e(rC    Ta \(rC        Ta right brace
+.It \e(la    Ta \(la        Ta left angle
+.It \e(ra    Ta \(ra        Ta right angle
+.It \e(bv    Ta \(bv        Ta brace extension
+.It \e[braceex] Ta \[braceex] Ta brace extension
+.It \e[bracketlefttp] Ta \[bracketlefttp] Ta top-left hooked bracket
+.It \e[bracketleftbp] Ta \[bracketleftbp] Ta bottom-left hooked bracket
+.It \e[bracketleftex] Ta \[bracketleftex] Ta left hooked bracket extension
+.It \e[bracketrighttp] Ta \[bracketrighttp] Ta top-right hooked bracket
+.It \e[bracketrightbp] Ta \[bracketrightbp] Ta bottom-right hooked bracket
+.It \e[bracketrightex] Ta \[bracketrightex] Ta right hooked bracket extension
+.It \e(lt    Ta \(lt        Ta top-left hooked brace
+.It \e[bracelefttp] Ta \[bracelefttp] Ta top-left hooked brace
+.It \e(lk    Ta \(lk        Ta mid-left hooked brace
+.It \e[braceleftmid] Ta \[braceleftmid] Ta mid-left hooked brace
+.It \e(lb    Ta \(lb        Ta bottom-left hooked brace
+.It \e[braceleftbp] Ta \[braceleftbp] Ta bottom-left hooked brace
+.It \e[braceleftex] Ta \[braceleftex] Ta left hooked brace extension
+.It \e(rt    Ta \(rt        Ta top-left hooked brace
+.It \e[bracerighttp] Ta \[bracerighttp] Ta top-right hooked brace
+.It \e(rk    Ta \(rk        Ta mid-right hooked brace
+.It \e[bracerightmid] Ta \[bracerightmid] Ta mid-right hooked brace
+.It \e(rb    Ta \(rb        Ta bottom-right hooked brace
+.It \e[bracerightbp] Ta \[bracerightbp] Ta bottom-right hooked brace
+.It \e[bracerightex] Ta \[bracerightex] Ta right hooked brace extension
+.It \e[parenlefttp] Ta \[parenlefttp] Ta top-left hooked parenthesis
+.It \e[parenleftbp] Ta \[parenleftbp] Ta bottom-left hooked parenthesis
+.It \e[parenleftex] Ta \[parenleftex] Ta left hooked parenthesis extension
+.It \e[parenrighttp] Ta \[parenrighttp] Ta top-right hooked parenthesis
+.It \e[parenrightbp] Ta \[parenrightbp] Ta bottom-right hooked parenthesis
+.It \e[parenrightex] Ta \[parenrightex] Ta right hooked parenthesis extension
+.El
+.Pp
+Arrows:
+.Bl -column "Input" "Rendered" "Description" -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e(<-    Ta \(<-        Ta left arrow
+.It \e(->    Ta \(->        Ta right arrow
+.It \e(<>    Ta \(<>        Ta left-right arrow
+.It \e(da    Ta \(da        Ta down arrow
+.It \e(ua    Ta \(ua        Ta up arrow
+.It \e(va    Ta \(va        Ta up-down arrow
+.It \e(lA    Ta \(lA        Ta left double-arrow
+.It \e(rA    Ta \(rA        Ta right double-arrow
+.It \e(hA    Ta \(hA        Ta left-right double-arrow
+.It \e(uA    Ta \(uA        Ta up double-arrow
+.It \e(dA    Ta \(dA        Ta down double-arrow
+.It \e(vA    Ta \(vA        Ta up-down double-arrow
+.El
+.Pp
+Logical:
+.Bl -column "Input" "Rendered" "Description" -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e(AN    Ta \(AN        Ta logical and
+.It \e(OR    Ta \(OR        Ta logical or
+.It \e(no    Ta \(no        Ta logical not
+.It \e[tno]  Ta \[tno]      Ta logical not (text)
+.It \e(te    Ta \(te        Ta existential quantifier
+.It \e(fa    Ta \(fa        Ta universal quantifier
+.It \e(st    Ta \(st        Ta such that
+.It \e(tf    Ta \(tf        Ta therefore
+.It \e(3d    Ta \(3d        Ta therefore
+.It \e(or    Ta \(or        Ta bitwise or
+.El
+.Pp
+Mathematical:
+.Bl -column "xxcoproductxx" "Rendered" "Description" -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e(pl    Ta \(pl        Ta plus
+.It \e(mi    Ta \(mi        Ta minus
+.It \e-      Ta \-          Ta minus (text)
+.It \e(-+    Ta \(-+        Ta minus-plus
+.It \e(+-    Ta \(+-        Ta plus-minus
+.It \e[t+-]  Ta \[t+-]      Ta plus-minus (text)
+.It \e(pc    Ta \(pc        Ta centre-dot
+.It \e(mu    Ta \(mu        Ta multiply
+.It \e[tmu]  Ta \[tmu]      Ta multiply (text)
+.It \e(c*    Ta \(c*        Ta circle-multiply
+.It \e(c+    Ta \(c+        Ta circle-plus
+.It \e(di    Ta \(di        Ta divide
+.It \e[tdi]  Ta \[tdi]      Ta divide (text)
+.It \e(f/    Ta \(f/        Ta fraction
+.It \e(**    Ta \(**        Ta asterisk
+.It \e(<=    Ta \(<=        Ta less-than-equal
+.It \e(>=    Ta \(>=        Ta greater-than-equal
+.It \e(<<    Ta \(<<        Ta much less
+.It \e(>>    Ta \(>>        Ta much greater
+.It \e(eq    Ta \(eq        Ta equal
+.It \e(!=    Ta \(!=        Ta not equal
+.It \e(==    Ta \(==        Ta equivalent
+.It \e(ne    Ta \(ne        Ta not equivalent
+.It \e(=~    Ta \(=~        Ta congruent
+.It \e(-~    Ta \(-~        Ta asymptotically congruent
+.It \e(ap    Ta \(ap        Ta asymptotically similar
+.It \e(~~    Ta \(~~        Ta approximately similar
+.It \e(~=    Ta \(~=        Ta approximately equal
+.It \e(pt    Ta \(pt        Ta proportionate
+.It \e(es    Ta \(es        Ta empty set
+.It \e(mo    Ta \(mo        Ta element
+.It \e(nm    Ta \(nm        Ta not element
+.It \e(sb    Ta \(sb        Ta proper subset
+.It \e(nb    Ta \(nb        Ta not subset
+.It \e(sp    Ta \(sp        Ta proper superset
+.It \e(nc    Ta \(nc        Ta not superset
+.It \e(ib    Ta \(ib        Ta reflexive subset
+.It \e(ip    Ta \(ip        Ta reflexive superset
+.It \e(ca    Ta \(ca        Ta intersection
+.It \e(cu    Ta \(cu        Ta union
+.It \e(/_    Ta \(/_        Ta angle
+.It \e(pp    Ta \(pp        Ta perpendicular
+.It \e(is    Ta \(is        Ta integral
+.It \e[integral] Ta \[integral] Ta integral
+.It \e[sum]    Ta \[sum]   Ta summation
+.It \e[product] Ta \[product] Ta product
+.It \e[coproduct] Ta \[coproduct] Ta coproduct
+.It \e(gr    Ta \(gr        Ta gradient
+.It \e(sr    Ta \(sr        Ta square root
+.It \e[sqrt] Ta \[sqrt]     Ta square root
+.It \e(lc    Ta \(lc        Ta left-ceiling
+.It \e(rc    Ta \(rc        Ta right-ceiling
+.It \e(lf    Ta \(lf        Ta left-floor
+.It \e(rf    Ta \(rf        Ta right-floor
+.It \e(if    Ta \(if        Ta infinity
+.It \e(Ah    Ta \(Ah        Ta aleph
+.It \e(Im    Ta \(Im        Ta imaginary
+.It \e(Re    Ta \(Re        Ta real
+.It \e(pd    Ta \(pd        Ta partial differential
+.It \e(-h    Ta \(-h        Ta Planck constant over 2\(*p
+.It \e[12]   Ta \[12]       Ta one-half
+.It \e[14]   Ta \[14]       Ta one-fourth
+.It \e[34]   Ta \[34]       Ta three-fourths
+.El
+.Pp
+Ligatures:
+.Bl -column "Input" "Rendered" "Description" -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e(ff    Ta \(ff        Ta ff ligature
+.It \e(fi    Ta \(fi        Ta fi ligature
+.It \e(fl    Ta \(fl        Ta fl ligature
+.It \e(Fi    Ta \(Fi        Ta ffi ligature
+.It \e(Fl    Ta \(Fl        Ta ffl ligature
+.It \e(AE    Ta \(AE        Ta AE
+.It \e(ae    Ta \(ae        Ta ae
+.It \e(OE    Ta \(OE        Ta OE
+.It \e(oe    Ta \(oe        Ta oe
+.It \e(ss    Ta \(ss        Ta German eszett
+.It \e(IJ    Ta \(IJ        Ta IJ ligature
+.It \e(ij    Ta \(ij        Ta ij ligature
+.El
+.Pp
+Accents:
+.Bl -column "Input" "Rendered" "Description" -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e(a"    Ta \(a"        Ta Hungarian umlaut
+.It \e(a-    Ta \(a-        Ta macron
+.It \e(a.    Ta \(a.        Ta dotted
+.It \e(a^    Ta \(a^        Ta circumflex
+.It \e(aa    Ta \(aa        Ta acute
+.It \e'      Ta \'          Ta acute
+.It \e(ga    Ta \(ga        Ta grave
+.It \e`      Ta \`          Ta grave
+.It \e(ab    Ta \(ab        Ta breve
+.It \e(ac    Ta \(ac        Ta cedilla
+.It \e(ad    Ta \(ad        Ta dieresis
+.It \e(ah    Ta \(ah        Ta caron
+.It \e(ao    Ta \(ao        Ta ring
+.It \e(a~    Ta \(a~        Ta tilde
+.It \e(ho    Ta \(ho        Ta ogonek
+.It \e(ha    Ta \(ha        Ta hat (text)
+.It \e(ti    Ta \(ti        Ta tilde (text)
+.El
+.Pp
+Accented letters:
+.Bl -column "Input" "Rendered" "Description" -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e('A    Ta \('A        Ta acute A
+.It \e('E    Ta \('E        Ta acute E
+.It \e('I    Ta \('I        Ta acute I
+.It \e('O    Ta \('O        Ta acute O
+.It \e('U    Ta \('U        Ta acute U
+.It \e('a    Ta \('a        Ta acute a
+.It \e('e    Ta \('e        Ta acute e
+.It \e('i    Ta \('i        Ta acute i
+.It \e('o    Ta \('o        Ta acute o
+.It \e('u    Ta \('u        Ta acute u
+.It \e(`A    Ta \(`A        Ta grave A
+.It \e(`E    Ta \(`E        Ta grave E
+.It \e(`I    Ta \(`I        Ta grave I
+.It \e(`O    Ta \(`O        Ta grave O
+.It \e(`U    Ta \(`U        Ta grave U
+.It \e(`a    Ta \(`a        Ta grave a
+.It \e(`e    Ta \(`e        Ta grave e
+.It \e(`i    Ta \(`i        Ta grave i
+.It \e(`o    Ta \(`i        Ta grave o
+.It \e(`u    Ta \(`u        Ta grave u
+.It \e(~A    Ta \(~A        Ta tilde A
+.It \e(~N    Ta \(~N        Ta tilde N
+.It \e(~O    Ta \(~O        Ta tilde O
+.It \e(~a    Ta \(~a        Ta tilde a
+.It \e(~n    Ta \(~n        Ta tilde n
+.It \e(~o    Ta \(~o        Ta tilde o
+.It \e(:A    Ta \(:A        Ta dieresis A
+.It \e(:E    Ta \(:E        Ta dieresis E
+.It \e(:I    Ta \(:I        Ta dieresis I
+.It \e(:O    Ta \(:O        Ta dieresis O
+.It \e(:U    Ta \(:U        Ta dieresis U
+.It \e(:a    Ta \(:a        Ta dieresis a
+.It \e(:e    Ta \(:e        Ta dieresis e
+.It \e(:i    Ta \(:i        Ta dieresis i
+.It \e(:o    Ta \(:o        Ta dieresis o
+.It \e(:u    Ta \(:u        Ta dieresis u
+.It \e(:y    Ta \(:y        Ta dieresis y
+.It \e(^A    Ta \(^A        Ta circumflex A
+.It \e(^E    Ta \(^E        Ta circumflex E
+.It \e(^I    Ta \(^I        Ta circumflex I
+.It \e(^O    Ta \(^O        Ta circumflex O
+.It \e(^U    Ta \(^U        Ta circumflex U
+.It \e(^a    Ta \(^a        Ta circumflex a
+.It \e(^e    Ta \(^e        Ta circumflex e
+.It \e(^i    Ta \(^i        Ta circumflex i
+.It \e(^o    Ta \(^o        Ta circumflex o
+.It \e(^u    Ta \(^u        Ta circumflex u
+.It \e(,C    Ta \(,C        Ta cedilla C
+.It \e(,c    Ta \(,c        Ta cedilla c
+.It \e(/L    Ta \(/L        Ta stroke L
+.It \e(/l    Ta \(/l        Ta stroke l
+.It \e(/O    Ta \(/O        Ta stroke O
+.It \e(/o    Ta \(/o        Ta stroke o
+.It \e(oA    Ta \(oA        Ta ring A
+.It \e(oa    Ta \(oa        Ta ring a
+.El
+.Pp
+Special letters:
+.Bl -column "Input" "Rendered" "Description" -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e(-D    Ta \(-D        Ta Eth
+.It \e(Sd    Ta \(Sd        Ta eth
+.It \e(TP    Ta \(TP        Ta Thorn
+.It \e(Tp    Ta \(Tp        Ta thorn
+.It \e(.i    Ta \(.i        Ta dotless i
+.It \e(.j    Ta \(.j        Ta dotless j
+.El
+.Pp
+Currency:
+.Bl -column "Input" "Rendered" "Description" -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e(Do    Ta \(Do        Ta dollar
+.It \e(ct    Ta \(ct        Ta cent
+.It \e(Eu    Ta \(Eu        Ta Euro symbol
+.It \e(eu    Ta \(eu        Ta Euro symbol
+.It \e(Ye    Ta \(Ye        Ta yen
+.It \e(Po    Ta \(Po        Ta pound
+.It \e(Cs    Ta \(Cs        Ta Scandinavian
+.It \e(Fn    Ta \(Fn        Ta florin
+.El
+.Pp
+Units:
+.Bl -column "Input" "Rendered" "Description" -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e(de    Ta \(de        Ta degree
+.It \e(%0    Ta \(%0        Ta per-thousand
+.It \e(fm    Ta \(fm        Ta minute
+.It \e(sd    Ta \(sd        Ta second
+.It \e(mc    Ta \(mc        Ta micro
+.El
+.Pp
+Greek letters:
+.Bl -column "Input" "Rendered" "Description" -offset indent -compact
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e(*A    Ta \(*A        Ta Alpha
+.It \e(*B    Ta \(*B        Ta Beta
+.It \e(*G    Ta \(*G        Ta Gamma
+.It \e(*D    Ta \(*D        Ta Delta
+.It \e(*E    Ta \(*E        Ta Epsilon
+.It \e(*Z    Ta \(*Z        Ta Zeta
+.It \e(*Y    Ta \(*Y        Ta Eta
+.It \e(*H    Ta \(*H        Ta Theta
+.It \e(*I    Ta \(*I        Ta Iota
+.It \e(*K    Ta \(*K        Ta Kappa
+.It \e(*L    Ta \(*L        Ta Lambda
+.It \e(*M    Ta \(*M        Ta Mu
+.It \e(*N    Ta \(*N        Ta Nu
+.It \e(*C    Ta \(*C        Ta Xi
+.It \e(*O    Ta \(*O        Ta Omicron
+.It \e(*P    Ta \(*P        Ta Pi
+.It \e(*R    Ta \(*R        Ta Rho
+.It \e(*S    Ta \(*S        Ta Sigma
+.It \e(*T    Ta \(*T        Ta Tau
+.It \e(*U    Ta \(*U        Ta Upsilon
+.It \e(*F    Ta \(*F        Ta Phi
+.It \e(*X    Ta \(*X        Ta Chi
+.It \e(*Q    Ta \(*Q        Ta Psi
+.It \e(*W    Ta \(*W        Ta Omega
+.It \e(*a    Ta \(*a        Ta alpha
+.It \e(*b    Ta \(*b        Ta beta
+.It \e(*g    Ta \(*g        Ta gamma
+.It \e(*d    Ta \(*d        Ta delta
+.It \e(*e    Ta \(*e        Ta epsilon
+.It \e(*z    Ta \(*z        Ta zeta
+.It \e(*y    Ta \(*y        Ta eta
+.It \e(*h    Ta \(*h        Ta theta
+.It \e(*i    Ta \(*i        Ta iota
+.It \e(*k    Ta \(*k        Ta kappa
+.It \e(*l    Ta \(*l        Ta lambda
+.It \e(*m    Ta \(*m        Ta mu
+.It \e(*n    Ta \(*n        Ta nu
+.It \e(*c    Ta \(*c        Ta xi
+.It \e(*o    Ta \(*o        Ta omicron
+.It \e(*p    Ta \(*p        Ta pi
+.It \e(*r    Ta \(*r        Ta rho
+.It \e(*s    Ta \(*s        Ta sigma
+.It \e(*t    Ta \(*t        Ta tau
+.It \e(*u    Ta \(*u        Ta upsilon
+.It \e(*f    Ta \(*f        Ta phi
+.It \e(*x    Ta \(*x        Ta chi
+.It \e(*q    Ta \(*q        Ta psi
+.It \e(*w    Ta \(*w        Ta omega
+.It \e(+h    Ta \(+h        Ta theta variant
+.It \e(+f    Ta \(+f        Ta phi variant
+.It \e(+p    Ta \(+p        Ta pi variant
+.It \e(+e    Ta \(+e        Ta epsilon variant
+.It \e(ts    Ta \(ts        Ta sigma terminal
+.El
+.Sh PREDEFINED STRINGS
+Predefined strings are inherited from the macro packages of historical
+troff implementations.
+They are
+.Em not recommended
+for use, as they differ across implementations.
+Manuals using these predefined strings are almost certainly not
+portable.
+.Pp
+Their syntax is similar to special characters, using
+.Sq \e*X
+.Pq for a one-character escape ,
+.Sq \e*(XX
+.Pq two-character ,
+and
+.Sq \e*[N]
+.Pq N-character .
+For details, see the
+.Em Predefined Strings
+subsection of the
+.Xr roff 5
+manual.
+.Bl -column "Input" "Rendered" "Description" -offset indent
+.It Em Input Ta Em Rendered Ta Em Description
+.It \e*(Ba   Ta \*(Ba       Ta vertical bar
+.It \e*(Ne   Ta \*(Ne       Ta not equal
+.It \e*(Ge   Ta \*(Ge       Ta greater-than-equal
+.It \e*(Le   Ta \*(Le       Ta less-than-equal
+.It \e*(Gt   Ta \*(Gt       Ta greater-than
+.It \e*(Lt   Ta \*(Lt       Ta less-than
+.It \e*(Pm   Ta \*(Pm       Ta plus-minus
+.It \e*(If   Ta \*(If       Ta infinity
+.It \e*(Pi   Ta \*(Pi       Ta pi
+.It \e*(Na   Ta \*(Na       Ta NaN
+.It \e*(Am   Ta \*(Am       Ta ampersand
+.It \e*R     Ta \*R         Ta restricted mark
+.It \e*(Tm   Ta \*(Tm       Ta trade mark
+.It \e*q     Ta \*q         Ta double-quote
+.It \e*(Rq   Ta \*(Rq       Ta right-double-quote
+.It \e*(Lq   Ta \*(Lq       Ta left-double-quote
+.It \e*(lp   Ta \*(lp       Ta right-parenthesis
+.It \e*(rp   Ta \*(rp       Ta left-parenthesis
+.It \e*(lq   Ta \*(lq       Ta left double-quote
+.It \e*(rq   Ta \*(rq       Ta right double-quote
+.It \e*(ua   Ta \*(ua       Ta up arrow
+.It \e*(va   Ta \*(va       Ta up-down arrow
+.It \e*(<=   Ta \*(<=       Ta less-than-equal
+.It \e*(>=   Ta \*(>=       Ta greater-than-equal
+.It \e*(aa   Ta \*(aa       Ta acute
+.It \e*(ga   Ta \*(ga       Ta grave
+.It \e*(Px   Ta \*(Px       Ta POSIX standard name
+.It \e*(Ai   Ta \*(Ai       Ta ANSI standard name
+.El
+.Sh UNICODE CHARACTERS
+The escape sequence
+.Pp
+.Dl \e[uXXXX]
+.Pp
+is interpreted as a Unicode codepoint.
+The codepoint must be in the range above U+0080 and less than U+10FFFF.
+For compatibility, points must be zero-padded to four characters; if
+greater than four characters, no zero padding is allowed.
+Unicode surrogates are not allowed.
+.\" .Pp
+.\" Unicode glyphs attenuate to the
+.\" .Sq \&?
+.\" character if invalid or not rendered by current output media.
+.Sh NUMBERED CHARACTERS
+For backward compatibility with existing manuals,
+.Xr mandoc 1
+also supports the
+.Pp
+.Dl \eN\(aq Ns Ar number Ns \(aq
+.Pp
+escape sequence, inserting the character
+.Ar number
+from the current character set into the output.
+Of course, this is inherently non-portable and is already marked
+as deprecated in the Heirloom roff manual.
+For example, do not use \eN'34', use \e(dq, or even the plain
+.Sq \(dq
+character where possible.
+.Sh COMPATIBILITY
+This section documents compatibility between mandoc and other other
+troff implementations, at this time limited to GNU troff
+.Pq Qq groff .
+.Pp
+.Bl -dash -compact
+.It
+The \eN\(aq\(aq escape sequence is limited to printable characters; in
+groff, it accepts arbitrary character numbers.
+.It
+In
+.Fl T Ns Cm ascii ,
+the
+\e(ss, \e(nm, \e(nb, \e(nc, \e(ib, \e(ip, \e(pp, \e[sum], \e[product],
+\e[coproduct], \e(gr, \e(\-h, and \e(a. special characters render
+differently between mandoc and groff.
+.It
+In
+.Fl T Ns Cm html
+and
+.Fl T Ns Cm xhtml ,
+the \e(~=, \e(nb, and \e(nc special characters render differently
+between mandoc and groff.
+.It
+The
+.Fl T Ns Cm ps
+and
+.Fl T Ns Cm pdf
+modes format like
+.Fl T Ns Cm ascii
+instead of rendering glyphs as in groff.
+.It
+The \e[radicalex], \e[sqrtex], and \e(ru special characters have been omitted
+from mandoc either because they are poorly documented or they have no
+known representation.
+.El
+.Sh SEE ALSO
+.Xr mandoc 1 ,
+.Xr man 5 ,
+.Xr mdoc 5 ,
+.Xr roff 5
+.Sh AUTHORS
+The
+.Nm
+manual page was written by
+.An Kristaps Dzonsons ,
+.Mt kristaps@bsd.lv .
+.Sh CAVEATS
+The
+.Sq \e*(Ba
+escape mimics the behaviour of the
+.Sq \&|
+character in
+.Xr mdoc 5 ;
+thus, if you wish to render a vertical bar with no side effects, use
+the
+.Sq \e(ba
+escape.
--- /dev/null	Wed Jul 16 14:05:09 2014
+++ new/usr/src/man/man5/mandoc_roff.5	Wed Jul 16 14:05:09 2014
@@ -0,0 +1,991 @@
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.\"
+.\" Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+.\" Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
+.\" Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+.\" Copyright 2014 Garrett D'Amore <garrett@damore.org>
+.\"
+.Dd Jul 13, 2014
+.Dt MANDOC_ROFF 5
+.Os
+.Sh NAME
+.Nm mandoc_roff
+.Nd roff language reference for mandoc
+.Sh DESCRIPTION
+The
+.Nm roff
+language is a general purpose text formatting language.
+Since traditional implementations of the
+.Xr mdoc 5
+and
+.Xr man 5
+manual formatting languages are based on it,
+many real-world manuals use small numbers of
+.Nm
+requests intermixed with their
+.Xr mdoc 5
+or
+.Xr man 5
+code.
+To properly format such manuals, the
+.Xr mandoc 1
+utility supports a tiny subset of
+.Nm
+requests.
+Only these requests supported by
+.Xr mandoc 1
+are documented in the present manual,
+together with the basic language syntax shared by
+.Nm ,
+.Xr mdoc 5 ,
+and
+.Xr man 5 .
+For complete
+.Nm
+manuals, consult the
+.Sx SEE ALSO
+section.
+.Pp
+Input lines beginning with the control character
+.Sq \&.
+are parsed for requests and macros.
+Such lines are called
+.Dq request lines
+or
+.Dq macro lines ,
+respectively.
+Requests change the processing state and manipulate the formatting;
+some macros also define the document structure and produce formatted
+output.
+The single quote
+.Pq Qq \(aq
+is accepted as an alternative control character,
+treated by
+.Xr mandoc 1
+just like
+.Ql \&.
+.Pp
+Lines not beginning with control characters are called
+.Dq text lines .
+They provide free-form text to be printed; the formatting of the text
+depends on the respective processing context.
+.Sh LANGUAGE SYNTAX
+.Nm
+documents may contain only graphable 7-bit ASCII characters, the space
+character, and, in certain circumstances, the tab character.
+The back-space character
+.Sq \e
+indicates the start of an escape sequence for
+.Sx Comments ,
+.Sx Special Characters ,
+.Sx Predefined Strings ,
+and
+user-defined strings defined using the
+.Sx ds
+request.
+.Ss Comments
+Text following an escaped double-quote
+.Sq \e\(dq ,
+whether in a request, macro, or text line, is ignored to the end of the line.
+A request line beginning with a control character and comment escape
+.Sq \&.\e\(dq
+is also ignored.
+Furthermore, request lines with only a control character and optional
+trailing whitespace are stripped from input.
+.Pp
+Examples:
+.Bd -literal -offset indent -compact
+\&.\e\(dq This is a comment line.
+\&.\e\(dq The next line is ignored:
+\&.
+\&.Sh EXAMPLES \e\(dq This is a comment, too.
+\&example text \e\(dq And so is this.
+.Ed
+.Ss Special Characters
+Special characters are used to encode special glyphs and are rendered
+differently across output media.
+They may occur in request, macro, and text lines.
+Sequences begin with the escape character
+.Sq \e
+followed by either an open-parenthesis
+.Sq \&(
+for two-character sequences; an open-bracket
+.Sq \&[
+for n-character sequences (terminated at a close-bracket
+.Sq \&] ) ;
+or a single one character sequence.
+.Pp
+Examples:
+.Bl -tag -width Ds -offset indent -compact
+.It Li \e(em
+Two-letter em dash escape.
+.It Li \ee
+One-letter backslash escape.
+.El
+.Pp
+See
+.Xr mandoc_char 5
+for a complete list.
+.Ss Text Decoration
+Terms may be text-decorated using the
+.Sq \ef
+escape followed by an indicator: B (bold), I (italic), R (regular), or P
+(revert to previous mode).
+A numerical representation 3, 2, or 1 (bold, italic, and regular,
+respectively) may be used instead.
+The indicator or numerical representative may be preceded by C
+(constant-width), which is ignored.
+.Pp
+Examples:
+.Bl -tag -width Ds -offset indent -compact
+.It Li \efBbold\efR
+Write in bold, then switch to regular font mode.
+.It Li \efIitalic\efP
+Write in italic, then return to previous font mode.
+.El
+.Pp
+Text decoration is
+.Em not
+recommended for
+.Xr mdoc 5 ,
+which encourages semantic annotation.
+.Ss Predefined Strings
+Predefined strings, like
+.Sx Special Characters ,
+mark special output glyphs.
+Predefined strings are escaped with the slash-asterisk,
+.Sq \e* :
+single-character
+.Sq \e*X ,
+two-character
+.Sq \e*(XX ,
+and N-character
+.Sq \e*[N] .
+.Pp
+Examples:
+.Bl -tag -width Ds -offset indent -compact
+.It Li \e*(Am
+Two-letter ampersand predefined string.
+.It Li \e*q
+One-letter double-quote predefined string.
+.El
+.Pp
+Predefined strings are not recommended for use,
+as they differ across implementations.
+Those supported by
+.Xr mandoc 1
+are listed in
+.Xr mandoc_char 5 .
+Manuals using these predefined strings are almost certainly not portable.
+.Ss Whitespace
+Whitespace consists of the space character.
+In text lines, whitespace is preserved within a line.
+In request and macro lines, whitespace delimits arguments and is discarded.
+.Pp
+Unescaped trailing spaces are stripped from text line input unless in a
+literal context.
+In general, trailing whitespace on any input line is discouraged for
+reasons of portability.
+In the rare case that a blank character is needed at the end of an
+input line, it may be forced by
+.Sq \e\ \e& .
+.Pp
+Literal space characters can be produced in the output
+using escape sequences.
+In macro lines, they can also be included in arguments using quotation; see
+.Sx MACRO SYNTAX
+for details.
+.Pp
+Blank text lines, which may include whitespace, are only permitted
+within literal contexts.
+If the first character of a text line is a space, that line is printed
+with a leading newline.
+.Ss Scaling Widths
+Many requests and macros support scaled widths for their arguments.
+The syntax for a scaled width is
+.Sq Li [+-]?[0-9]*.[0-9]*[:unit:] ,
+where a decimal must be preceded or followed by at least one digit.
+Negative numbers, while accepted, are truncated to zero.
+.Pp
+The following scaling units are accepted:
+.Pp
+.Bl -tag -width Ds -offset indent -compact
+.It c
+centimetre
+.It i
+inch
+.It P
+pica (~1/6 inch)
+.It p
+point (~1/72 inch)
+.It f
+synonym for
+.Sq u
+.It v
+default vertical span
+.It m
+width of rendered
+.Sq m
+.Pq em
+character
+.It n
+width of rendered
+.Sq n
+.Pq en
+character
+.It u
+default horizontal span
+.It M
+mini-em (~1/100 em)
+.El
+.Pp
+Using anything other than
+.Sq m ,
+.Sq n ,
+.Sq u ,
+or
+.Sq v
+is necessarily non-portable across output media.
+See
+.Sx COMPATIBILITY .
+.Pp
+If a scaling unit is not provided, the numerical value is interpreted
+under the default rules of
+.Sq v
+for vertical spaces and
+.Sq u
+for horizontal ones.
+.Pp
+Examples:
+.Bl -tag -width ".Bl -tag -width 2i" -offset indent -compact
+.It Li \&.Bl -tag -width 2i
+two-inch tagged list indentation in
+.Xr mdoc 5
+.It Li \&.HP 2i
+two-inch tagged list indentation in
+.Xr man 5
+.It Li \&.sp 2v
+two vertical spaces
+.El
+.Ss Sentence Spacing
+Each sentence should terminate at the end of an input line.
+By doing this, a formatter will be able to apply the proper amount of
+spacing after the end of sentence (unescaped) period, exclamation mark,
+or question mark followed by zero or more non-sentence closing
+delimiters
+.Po
+.Sq \&) ,
+.Sq \&] ,
+.Sq \&' ,
+.Sq \&"
+.Pc .
+.Pp
+The proper spacing is also intelligently preserved if a sentence ends at
+the boundary of a macro line.
+.Pp
+Examples:
+.Bd -literal -offset indent -compact
+Do not end sentences mid-line like this.  Instead,
+end a sentence like this.
+A macro would end like this:
+\&.Xr mandoc 1 \&.
+.Ed
+.Sh REQUEST SYNTAX
+A request or macro line consists of:
+.Pp
+.Bl -enum -compact
+.It
+the control character
+.Sq \&.
+or
+.Sq \(aq
+at the beginning of the line,
+.It
+optionally an arbitrary amount of whitespace,
+.It
+the name of the request or the macro, which is one word of arbitrary
+length, terminated by whitespace,
+.It
+and zero or more arguments delimited by whitespace.
+.El
+.Pp
+Thus, the following request lines are all equivalent:
+.Bd -literal -offset indent
+\&.ig end
+\&.ig    end
+\&.   ig end
+.Ed
+.Sh MACRO SYNTAX
+Macros are provided by the
+.Xr mdoc 5
+and
+.Xr man 5
+languages and can be defined by the
+.Sx \&de
+request.
+When called, they follow the same syntax as requests, except that
+macro arguments may optionally be quoted by enclosing them
+in double quote characters
+.Pq Sq \(dq .
+Quoted text, even if it contains whitespace or would cause
+a macro invocation when unquoted, is always considered literal text.
+Inside quoted text, pairs of double quote characters
+.Pq Sq Qq
+resolve to single double quote characters.
+.Pp
+To be recognised as the beginning of a quoted argument, the opening
+quote character must be preceded by a space character.
+A quoted argument extends to the next double quote character that is not
+part of a pair, or to the end of the input line, whichever comes earlier.
+Leaving out the terminating double quote character at the end of the line
+is discouraged.
+For clarity, if more arguments follow on the same input line,
+it is recommended to follow the terminating double quote character
+by a space character; in case the next character after the terminating
+double quote character is anything else, it is regarded as the beginning
+of the next, unquoted argument.
+.Pp
+Both in quoted and unquoted arguments, pairs of backslashes
+.Pq Sq \e\e
+resolve to single backslashes.
+In unquoted arguments, space characters can alternatively be included
+by preceding them with a backslash
+.Pq Sq \e\~ ,
+but quoting is usually better for clarity.
+.Pp
+Examples:
+.Bl -tag -width Ds -offset indent -compact
+.It Li .Fn strlen \(dqconst char *s\(dq
+Group arguments
+.Qq const char *s
+into one function argument.
+If unspecified,
+.Qq const ,
+.Qq char ,
+and
+.Qq *s
+would be considered separate arguments.
+.It Li .Op \(dqFl a\(dq
+Consider
+.Qq \&Fl a
+as literal text instead of a flag macro.
+.El
+.Sh REQUEST REFERENCE
+The
+.Xr mandoc 1
+.Nm
+parser recognises the following requests.
+Note that the
+.Nm
+language defines many more requests not implemented in
+.Xr mandoc 1 .
+.Ss \&ad
+Set line adjustment mode.
+This line-scoped request is intended to have one argument to select
+normal, left, right, or centre adjustment for subsequent text.
+Currently, it is ignored including its arguments,
+and the number of arguments is not checked.
+.Ss \&am
+Append to a macro definition.
+The syntax of this request is the same as that of
+.Sx \&de .
+It is currently ignored by
+.Xr mandoc 1 ,
+as are its children.
+.Ss \&ami
+Append to a macro definition, specifying the macro name indirectly.
+The syntax of this request is the same as that of
+.Sx \&dei .
+It is currently ignored by
+.Xr mandoc 1 ,
+as are its children.
+.Ss \&am1
+Append to a macro definition, switching roff compatibility mode off
+during macro execution.
+The syntax of this request is the same as that of
+.Sx \&de1 .
+It is currently ignored by
+.Xr mandoc 1 ,
+as are its children.
+.Ss \&de
+Define a
+.Nm
+macro.
+Its syntax can be either
+.Bd -literal -offset indent
+.Pf . Cm \&de Ar name
+.Ar macro definition
+\&..
+.Ed
+.Pp
+or
+.Bd -literal -offset indent
+.Pf . Cm \&de Ar name Ar end
+.Ar macro definition
+.Pf . Ar end
+.Ed
+.Pp
+Both forms define or redefine the macro
+.Ar name
+to represent the
+.Ar macro definition ,
+which may consist of one or more input lines, including the newline
+characters terminating each line, optionally containing calls to
+.Nm
+requests,
+.Nm
+macros or high-level macros like
+.Xr man 5
+or
+.Xr mdoc 5
+macros, whichever applies to the document in question.
+.Pp
+Specifying a custom
+.Ar end
+macro works in the same way as for
+.Sx \&ig ;
+namely, the call to
+.Sq Pf . Ar end
+first ends the
+.Ar macro definition ,
+and after that, it is also evaluated as a
+.Nm
+request or
+.Nm
+macro, but not as a high-level macro.
+.Pp
+The macro can be invoked later using the syntax
+.Pp
+.D1 Pf . Ar name Op Ar argument Op Ar argument ...
+.Pp
+Regarding argument parsing, see
+.Sx MACRO SYNTAX
+above.
+.Pp
+The line invoking the macro will be replaced
+in the input stream by the
+.Ar macro definition ,
+replacing all occurrences of
+.No \e\e$ Ns Ar N ,
+where
+.Ar N
+is a digit, by the
+.Ar N Ns th Ar argument .
+For example,
+.Bd -literal -offset indent
+\&.de ZN
+\efI\e^\e\e$1\e^\efP\e\e$2
+\&..
+\&.ZN XtFree .
+.Ed
+.Pp
+produces
+.Pp
+.D1 \efI\e^XtFree\e^\efP.
+.Pp
+in the input stream, and thus in the output: \fI\^XtFree\^\fP.
+.Pp
+Since macros and user-defined strings share a common string table,
+defining a macro
+.Ar name
+clobbers the user-defined string
+.Ar name ,
+and the
+.Ar macro definition
+can also be printed using the
+.Sq \e*
+string interpolation syntax described below
+.Sx ds ,
+but this is rarely useful because every macro definition contains at least
+one explicit newline character.
+.Pp
+In order to prevent endless recursion, both groff and
+.Xr mandoc 1
+limit the stack depth for expanding macros and strings
+to a large, but finite number.
+Do not rely on the exact value of this limit.
+.Ss \&dei
+Define a
+.Nm
+macro, specifying the macro name indirectly.
+The syntax of this request is the same as that of
+.Sx \&de .
+It is currently ignored by
+.Xr mandoc 1 ,
+as are its children.
+.Ss \&de1
+Define a
+.Nm
+macro that will be executed with
+.Nm
+compatibility mode switched off during macro execution.
+This is a GNU extension not available in traditional
+.Nm
+implementations and not even in older versions of groff.
+Since
+.Xr mandoc 1
+does not implement
+.Nm
+compatibility mode at all, it handles this request as an alias for
+.Sx \&de .
+.Ss \&ds
+Define a user-defined string.
+Its syntax is as follows:
+.Pp
+.D1 Pf . Cm \&ds Ar name Oo \(dq Oc Ns Ar string
+.Pp
+The
+.Ar name
+and
+.Ar string
+arguments are space-separated.
+If the
+.Ar string
+begins with a double-quote character, that character will not be part
+of the string.
+All remaining characters on the input line form the
+.Ar string ,
+including whitespace and double-quote characters, even trailing ones.
+.Pp
+The
+.Ar string
+can be interpolated into subsequent text by using
+.No \e* Ns Bq Ar name
+for a
+.Ar name
+of arbitrary length, or \e*(NN or \e*N if the length of
+.Ar name
+is two or one characters, respectively.
+Interpolation can be prevented by escaping the leading backslash;
+that is, an asterisk preceded by an even number of backslashes
+does not trigger string interpolation.
+.Pp
+Since user-defined strings and macros share a common string table,
+defining a string
+.Ar name
+clobbers the macro
+.Ar name ,
+and the
+.Ar name
+used for defining a string can also be invoked as a macro,
+in which case the following input line will be appended to the
+.Ar string ,
+forming a new input line passed to the
+.Nm
+parser.
+For example,
+.Bd -literal -offset indent
+\&.ds badidea .S
+\&.badidea
+H SYNOPSIS
+.Ed
+.Pp
+invokes the
+.Cm SH
+macro when used in a
+.Xr man 5
+document.
+Such abuse is of course strongly discouraged.
+.Ss \&el
+The
+.Qq else
+half of an if/else conditional.
+Pops a result off the stack of conditional evaluations pushed by
+.Sx \&ie
+and uses it as its conditional.
+If no stack entries are present (e.g., due to no prior
+.Sx \&ie
+calls)
+then false is assumed.
+The syntax of this request is similar to
+.Sx \&if
+except that the conditional is missing.
+.Ss \&EN
+End an equation block.
+See
+.Sx \&EQ .
+.Ss \&EQ
+Begin an equation block.
+See
+.Xr eqn 5
+for a description of the equation language.
+.Ss \&hy
+Set automatic hyphenation mode.
+This line-scoped request is currently ignored.
+.Ss \&ie
+The
+.Qq if
+half of an if/else conditional.
+The result of the conditional is pushed into a stack used by subsequent
+invocations of
+.Sx \&el ,
+which may be separated by any intervening input (or not exist at all).
+Its syntax is equivalent to
+.Sx \&if .
+.Ss \&if
+Begins a conditional.
+Right now, the conditional evaluates to true
+if and only if it starts with the letter
+.Sy n ,
+indicating processing in nroff style as opposed to troff style.
+If a conditional is false, its children are not processed, but are
+syntactically interpreted to preserve the integrity of the input
+document.
+Thus,
+.Pp
+.D1 \&.if t .ig
+.Pp
+will discard the
+.Sq \&.ig ,
+which may lead to interesting results, but
+.Pp
+.D1 \&.if t .if t \e{\e
+.Pp
+will continue to syntactically interpret to the block close of the final
+conditional.
+Sub-conditionals, in this case, obviously inherit the truth value of
+the parent.
+This request has the following syntax:
+.Bd -literal -offset indent
+\&.if COND \e{\e
+BODY...
+\&.\e}
+.Ed
+.Bd -literal -offset indent
+\&.if COND \e{ BODY
+BODY... \e}
+.Ed
+.Bd -literal -offset indent
+\&.if COND \e{ BODY
+BODY...
+\&.\e}
+.Ed
+.Bd -literal -offset indent
+\&.if COND \e
+BODY
+.Ed
+.Pp
+COND is a conditional statement.
+roff allows for complicated conditionals; mandoc is much simpler.
+At this time, mandoc supports only
+.Sq n ,
+evaluating to true;
+and
+.Sq t ,
+.Sq e ,
+and
+.Sq o ,
+evaluating to false.
+All other invocations are read up to the next end of line or space and
+evaluate as false.
+.Pp
+If the BODY section is begun by an escaped brace
+.Sq \e{ ,
+scope continues until a closing-brace escape sequence
+.Sq \.\e} .
+If the BODY is not enclosed in braces, scope continues until
+the end of the line.
+If the COND is followed by a BODY on the same line, whether after a
+brace or not, then requests and macros
+.Em must
+begin with a control character.
+It is generally more intuitive, in this case, to write
+.Bd -literal -offset indent
+\&.if COND \e{\e
+\&.foo
+bar
+\&.\e}
+.Ed
+.Pp
+than having the request or macro follow as
+.Pp
+.D1 \&.if COND \e{ .foo
+.Pp
+The scope of a conditional is always parsed, but only executed if the
+conditional evaluates to true.
+.Pp
+Note that the
+.Sq \e}
+is converted into a zero-width escape sequence if not passed as a
+standalone macro
+.Sq \&.\e} .
+For example,
+.Pp
+.D1 \&.Fl a \e} b
+.Pp
+will result in
+.Sq \e}
+being considered an argument of the
+.Sq \&Fl
+macro.
+.Ss \&ig
+Ignore input.
+Its syntax can be either
+.Bd -literal -offset indent
+.Pf . Cm \&ig
+.Ar ignored text
+\&..
+.Ed
+.Pp
+or
+.Bd -literal -offset indent
+.Pf . Cm \&ig Ar end
+.Ar ignored text
+.Pf . Ar end
+.Ed
+.Pp
+In the first case, input is ignored until a
+.Sq \&..
+request is encountered on its own line.
+In the second case, input is ignored until the specified
+.Sq Pf . Ar end
+macro is encountered.
+Do not use the escape character
+.Sq \e
+anywhere in the definition of
+.Ar end ;
+it would cause very strange behaviour.
+.Pp
+When the
+.Ar end
+macro is a roff request or a roff macro, like in
+.Pp
+.D1 \&.ig if
+.Pp
+the subsequent invocation of
+.Sx \&if
+will first terminate the
+.Ar ignored text ,
+then be invoked as usual.
+Otherwise, it only terminates the
+.Ar ignored text ,
+and arguments following it or the
+.Sq \&..
+request are discarded.
+.Ss \&ne
+Declare the need for the specified minimum vertical space
+before the next trap or the bottom of the page.
+This line-scoped request is currently ignored.
+.Ss \&nh
+Turn off automatic hyphenation mode.
+This line-scoped request is currently ignored.
+.Ss \&rm
+Remove a request, macro or string.
+This request is intended to have one argument,
+the name of the request, macro or string to be undefined.
+Currently, it is ignored including its arguments,
+and the number of arguments is not checked.
+.Ss \&nr
+Define a register.
+A register is an arbitrary string value that defines some sort of state,
+which influences parsing and/or formatting.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Cm \&nr Ar name Ar value
+.Pp
+The
+.Ar value
+may, at the moment, only be an integer.
+So far, only the following register
+.Ar name
+is recognised:
+.Bl -tag -width Ds
+.It Cm nS
+If set to a positive integer value, certain
+.Xr mdoc 5
+macros will behave in the same way as in the
+.Em SYNOPSIS
+section.
+If set to 0, these macros will behave in the same way as outside the
+.Em SYNOPSIS
+section, even when called within the
+.Em SYNOPSIS
+section itself.
+Note that starting a new
+.Xr mdoc 5
+section with the
+.Cm \&Sh
+macro will reset this register.
+.El
+.Ss \&ns
+Turn on no-space mode.
+This line-scoped request is intended to take no arguments.
+Currently, it is ignored including its arguments,
+and the number of arguments is not checked.
+.Ss \&ps
+Change point size.
+This line-scoped request is intended to take one numerical argument.
+Currently, it is ignored including its arguments,
+and the number of arguments is not checked.
+.Ss \&so
+Include a source file.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Cm \&so Ar file
+.Pp
+The
+.Ar file
+will be read and its contents processed as input in place of the
+.Sq \&.so
+request line.
+To avoid inadvertent inclusion of unrelated files,
+.Xr mandoc 1
+only accepts relative paths not containing the strings
+.Qq ../
+and
+.Qq /.. .
+.Pp
+This request requires
+.Xr man 1
+to change to the right directory before calling
+.Xr mandoc 1 ,
+per convention to the root of the manual tree.
+Typical usage looks like:
+.Pp
+.Dl \&.so man3/Xcursor.3
+.Pp
+As the whole concept is rather fragile, the use of
+.Sx \&so
+is discouraged.
+Use
+.Xr ln 1
+instead.
+.Ss \&ta
+Set tab stops.
+This line-scoped request can take an arbitrary number of arguments.
+Currently, it is ignored including its arguments.
+.Ss \&tr
+Output character translation.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Cm \&tr Ar [ab]+
+.Pp
+Pairs of
+.Ar ab
+characters are replaced
+.Ar ( a
+for
+.Ar b ) .
+Replacement (or origin) characters may also be character escapes; thus,
+.Pp
+.Dl tr \e(xx\e(yy
+.Pp
+replaces all invocations of \e(xx with \e(yy.
+.Ss \&T&
+Re-start a table layout, retaining the options of the prior table
+invocation.
+See
+.Sx \&TS .
+.Ss \&TE
+End a table context.
+See
+.Sx \&TS .
+.Ss \&TS
+Begin a table, which formats input in aligned rows and columns.
+See
+.Xr tbl 5
+for a description of the tbl language.
+.Sh COMPATIBILITY
+This section documents compatibility between mandoc and other other
+.Nm
+implementations, at this time limited to GNU troff
+.Pq Qq groff .
+The term
+.Qq historic groff
+refers to groff version 1.15.
+.Pp
+.Bl -dash -compact
+.It
+In mandoc, the
+.Sx \&EQ ,
+.Sx \&TE ,
+.Sx \&TS ,
+and
+.Sx \&T& ,
+macros are considered regular macros.
+In all other
+.Nm
+implementations, these are special macros that must be specified without
+spacing between the control character (which must be a period) and the
+macro name.
+.It
+The
+.Cm nS
+register is only compatible with OpenBSD's groff-1.15.
+.It
+Historic groff did not accept white-space before a custom
+.Ar end
+macro for the
+.Sx \&ig
+request.
+.It
+The
+.Sx \&if
+and family would print funny white-spaces with historic groff when
+using the next-line syntax.
+.El
+.Sh SEE ALSO
+.Xr mandoc 1 ,
+.Xr eqn 5 ,
+.Xr man 5 ,
+.Xr mandoc_char 5 ,
+.Xr mdoc 5 ,
+.Xr tbl 5
+.Rs
+.%A Joseph F. Ossanna
+.%A Brian W. Kernighan
+.%I AT&T Bell Laboratories
+.%T Troff User's Manual
+.%R Computing Science Technical Report
+.%N 54
+.%C Murray Hill, New Jersey
+.%D 1976 and 1992
+.%U http://www.kohala.com/start/troff/cstr54.ps
+.Re
+.Rs
+.%A Joseph F. Ossanna
+.%A Brian W. Kernighan
+.%A Gunnar Ritter
+.%T Heirloom Documentation Tools Nroff/Troff User's Manual
+.%D September 17, 2007
+.%U http://heirloom.sourceforge.net/doctools/troff.pdf
+.Re
+.Sh HISTORY
+The RUNOFF typesetting system, whose input forms the basis for
+.Nm ,
+was written in MAD and FAP for the CTSS operating system by Jerome E.
+Saltzer in 1964.
+Doug McIlroy rewrote it in BCPL in 1969, renaming it
+.Nm .
+Dennis M. Ritchie rewrote McIlroy's
+.Nm
+in PDP-11 assembly for
+.At v1 ,
+Joseph F. Ossanna improved roff and renamed it nroff
+for
+.At v2 ,
+then ported nroff to C as troff, which Brian W. Kernighan released with
+.At v7 .
+In 1989, James Clarke re-implemented troff in C++, naming it groff.
+.Sh AUTHORS
+.An -nosplit
+This
+.Nm
+reference was written by
+.An Kristaps Dzonsons ,
+.Mt kristaps@bsd.lv ;
+and
+.An Ingo Schwarze ,
+.Mt schwarze@openbsd.org .
--- /dev/null	Wed Jul 16 14:05:09 2014
+++ new/usr/src/man/man5/mdoc.5	Wed Jul 16 14:05:09 2014
@@ -0,0 +1,3211 @@
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.\"
+.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+.\" Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
+.\" Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+.\" Copyright 2014 Garrett D'Amore <garrett@dmaore.org>
+.\"
+.Dd Jul 16, 2014
+.Dt MDOC 5
+.Os
+.Sh NAME
+.Nm mdoc
+.Nd semantic markup language for formatting manual pages
+.Sh DESCRIPTION
+The
+.Nm mdoc
+language supports authoring of manual pages for the
+.Xr man 1
+utility by allowing semantic annotations of words, phrases,
+page sections and complete manual pages.
+Such annotations are used by formatting tools to achieve a uniform
+presentation across all manuals written in
+.Nm ,
+and to support hyperlinking if supported by the output medium.
+.Pp
+This reference document describes the structure of manual pages
+and the syntax and usage of the
+.Nm
+language.
+The reference implementation of a parsing and formatting tool is
+.Xr mandoc 1 ;
+the
+.Sx COMPATIBILITY
+section describes compatibility with other implementations.
+.Pp
+In an
+.Nm
+document, lines beginning with the control character
+.Sq \&.
+are called
+.Dq macro lines .
+The first word is the macro name.
+It consists of two or three letters.
+Most macro names begin with a capital letter.
+For a list of available macros, see
+.Sx MACRO OVERVIEW .
+The words following the macro name are arguments to the macro, optionally
+including the names of other, callable macros; see
+.Sx MACRO SYNTAX
+for details.
+.Pp
+Lines not beginning with the control character are called
+.Dq text lines .
+They provide free-form text to be printed; the formatting of the text
+depends on the respective processing context:
+.Bd -literal -offset indent
+\&.Sh Macro lines change control state.
+Text lines are interpreted within the current state.
+.Ed
+.Pp
+Many aspects of the basic syntax of the
+.Nm
+language are based on the
+.Xr roff 5
+language; see the
+.Em LANGUAGE SYNTAX
+and
+.Em MACRO SYNTAX
+sections in the
+.Xr roff 5
+manual for details, in particular regarding
+comments, escape sequences, whitespace, and quoting.
+However, using
+.Xr roff 5
+requests in
+.Nm
+documents is discouraged;
+.Xr mandoc 1
+supports some of them merely for backward compatibility.
+.Sh MANUAL STRUCTURE
+A well-formed
+.Nm
+document consists of a document prologue followed by one or more
+sections.
+.Pp
+The prologue, which consists of the
+.Sx \&Dd ,
+.Sx \&Dt ,
+and
+.Sx \&Os
+macros in that order, is required for every document.
+.Pp
+The first section (sections are denoted by
+.Sx \&Sh )
+must be the NAME section, consisting of at least one
+.Sx \&Nm
+followed by
+.Sx \&Nd .
+.Pp
+Following that, convention dictates specifying at least the
+.Em SYNOPSIS
+and
+.Em DESCRIPTION
+sections, although this varies between manual sections.
+.Pp
+The following is a well-formed skeleton
+.Nm
+file for a utility
+.Qq progname :
+.Bd -literal -offset indent
+\&.Dd Jan 1, 1970
+\&.Dt PROGNAME section
+\&.Os
+\&.Sh NAME
+\&.Nm progname
+\&.Nd one line description
+\&.\e\(dq .Sh LIBRARY
+\&.\e\(dq For sections 2, 3, & 9 only.
+\&.Sh SYNOPSIS
+\&.Nm progname
+\&.Op Fl options
+\&.Ar
+\&.Sh DESCRIPTION
+The
+\&.Nm
+utility processes files ...
+\&.\e\(dq .Sh IMPLEMENTATION NOTES
+\&.\e\(dq .Sh RETURN VALUES
+\&.\e\(dq For sections 2, 3, & 9 only.
+\&.\e\(dq .Sh ENVIRONMENT
+\&.\e\(dq For sections 1, 1M, 5, & 6 only.
+\&.\e\(dq .Sh FILES
+\&.\e\(dq .Sh EXIT STATUS
+\&.\e\(dq For sections 1, 1M, & 6 only.
+\&.\e\(dq .Sh EXAMPLES
+\&.\e\(dq .Sh DIAGNOSTICS
+\&.\e\(dq For sections 1, 1M, 5, 6, & 7 only.
+\&.\e\(dq .Sh ERRORS
+\&.\e\(dq For sections 2, 3, & 9 only.
+\&.\e\(dq .Sh ARCHITECTURE
+\&.\e\(dq .Sh CODE SET INDEPENDENCE
+\&.\e\(dq For sections 1, 1M, & 3 only.
+\&.\e\(dq .Sh INTERFACE STABILITY
+\&.\e\(dq .Sh MT-LEVEL
+\&.\e\(dq For sections 2 & 3 only.
+\&.\e\(dq .Sh SEE ALSO
+\&.\e\(dq .Xr foobar 1
+\&.\e\(dq .Sh STANDARDS
+\&.\e\(dq .Sh HISTORY
+\&.\e\(dq .Sh AUTHORS
+\&.\e\(dq .Sh CAVEATS
+\&.\e\(dq .Sh BUGS
+\&.\e\(dq .Sh SECURITY CONSIDERATIONS
+\&.\e\(dq Not used in OpenBSD.
+.Ed
+.Pp
+The sections in an
+.Nm
+document are conventionally ordered as they appear above.
+Sections should be composed as follows:
+.Bl -ohang -offset Ds
+.It Em NAME
+The name(s) and a one line description of the documented material.
+The syntax for this as follows:
+.Bd -literal -offset indent
+\&.Nm name0 ,
+\&.Nm name1 ,
+\&.Nm name2
+\&.Nd a one line description
+.Ed
+.Pp
+Multiple
+.Sq \&Nm
+names should be separated by commas.
+.Pp
+The
+.Sx \&Nm
+macro(s) must precede the
+.Sx \&Nd
+macro.
+.Pp
+See
+.Sx \&Nm
+and
+.Sx \&Nd .
+.It Em LIBRARY
+The name of the library containing the documented material, which is
+assumed to be a function in a section 2, 3, or 9 manual.
+The syntax for this is as follows:
+.Bd -literal -offset indent
+\&.Lb libarm
+.Ed
+.Pp
+See
+.Sx \&Lb .
+.It Em SYNOPSIS
+Documents the utility invocation syntax, function call syntax, or device
+configuration.
+.Pp
+For the first, utilities (sections 1, 1M, and 6), this is
+generally structured as follows:
+.Bd -literal -offset indent
+\&.Nm bar
+\&.Op Fl v
+\&.Op Fl o Ar file
+\&.Op Ar
+\&.Nm foo
+\&.Op Fl v
+\&.Op Fl o Ar file
+\&.Op Ar
+.Ed
+.Pp
+Commands should be ordered alphabetically.
+.Pp
+For the second, function calls (sections 2, 3, 9):
+.Bd -literal -offset indent
+\&.In header.h
+\&.Vt extern const char *global;
+\&.Ft "char *"
+\&.Fn foo "const char *src"
+\&.Ft "char *"
+\&.Fn bar "const char *src"
+.Ed
+.Pp
+Ordering of
+.Sx \&In ,
+.Sx \&Vt ,
+.Sx \&Fn ,
+and
+.Sx \&Fo
+macros should follow C header-file conventions.
+.Pp
+And for the third, configurations (section 7):
+.Bd -literal -offset indent
+\&.Cd \(dqit* at isa? port 0x2e\(dq
+\&.Cd \(dqit* at isa? port 0x4e\(dq
+.Ed
+.Pp
+Manuals not in these sections generally don't need a
+.Em SYNOPSIS .
+.Pp
+Some macros are displayed differently in the
+.Em SYNOPSIS
+section, particularly
+.Sx \&Nm ,
+.Sx \&Cd ,
+.Sx \&Fd ,
+.Sx \&Fn ,
+.Sx \&Fo ,
+.Sx \&In ,
+.Sx \&Vt ,
+and
+.Sx \&Ft .
+All of these macros are output on their own line.
+If two such dissimilar macros are pairwise invoked (except for
+.Sx \&Ft
+before
+.Sx \&Fo
+or
+.Sx \&Fn ) ,
+they are separated by a vertical space, unless in the case of
+.Sx \&Fo ,
+.Sx \&Fn ,
+and
+.Sx \&Ft ,
+which are always separated by vertical space.
+.Pp
+When text and macros following an
+.Sx \&Nm
+macro starting an input line span multiple output lines,
+all output lines but the first will be indented to align
+with the text immediately following the
+.Sx \&Nm
+macro, up to the next
+.Sx \&Nm ,
+.Sx \&Sh ,
+or
+.Sx \&Ss
+macro or the end of an enclosing block, whichever comes first.
+.It Em DESCRIPTION
+This begins with an expansion of the brief, one line description in
+.Em NAME :
+.Bd -literal -offset indent
+The
+\&.Nm
+utility does this, that, and the other.
+.Ed
+.Pp
+It usually follows with a breakdown of the options (if documenting a
+command), such as:
+.Bd -literal -offset indent
+The arguments are as follows:
+\&.Bl \-tag \-width Ds
+\&.It Fl v
+Print verbose information.
+\&.El
+.Ed
+.Pp
+Manuals not documenting a command won't include the above fragment.
+.Pp
+Since the
+.Em DESCRIPTION
+section usually contains most of the text of a manual, longer manuals
+often use the
+.Sx \&Ss
+macro to form subsections.
+In very long manuals, the
+.Em DESCRIPTION
+may be split into multiple sections, each started by an
+.Sx \&Sh
+macro followed by a non-standard section name, and each having
+several subsections, like in the present
+.Nm
+manual.
+.It Em IMPLEMENTATION NOTES
+Implementation-specific notes should be kept here.
+This is useful when implementing standard functions that may have side
+effects or notable algorithmic implications.
+.It Em RETURN VALUES
+This section documents the
+return values of functions in sections 2, 3, and 9.
+.Pp
+See
+.Sx \&Rv .
+.It Em ENVIRONMENT
+Lists the environment variables used by the utility,
+and explains the syntax and semantics of their values.
+The
+.Xr environ 5
+manual provides examples of typical content and formatting.
+.Pp
+See
+.Sx \&Ev .
+.It Em FILES
+Documents files used.
+It's helpful to document both the file name and a short description of how
+the file is used (created, modified, etc.).
+.Pp
+See
+.Sx \&Pa .
+.It Em EXIT STATUS
+This section documents the
+command exit status for section 1, 6, and 8 utilities.
+Historically, this information was described in
+.Em DIAGNOSTICS ,
+a practise that is now discouraged.
+.Pp
+See
+.Sx \&Ex .
+.It Em EXAMPLES
+Example usages.
+This often contains snippets of well-formed, well-tested invocations.
+Make sure that examples work properly!
+.It Em DIAGNOSTICS
+Documents error conditions.
+This is most useful in section 4 manuals.
+Historically, this section was used in place of
+.Em EXIT STATUS
+for manuals in sections 1, 6, and 8; however, this practise is
+discouraged.
+.Pp
+See
+.Sx \&Bl
+.Fl diag .
+.It Em ERRORS
+Documents error handling in sections 2, 3, and 9.
+.Pp
+See
+.Sx \&Er .
+.It Em ARCHITECTURE
+This section is usually absent, but will be present when the
+interface is specific to one or more architectures.
+.It Em CODE SET INDEPENDENCE
+Indicates whether the interface operates correctly with various different
+code sets.  True independent code sets will support not only ASCII and
+Extended UNIX Codesets (EUC), but also other multi-byte encodings such as
+UTF-8 and GB2312.
+.Pp
+Generally there will be some limitations that are fairly standard.  See
+.Xr standards 5 for more information about some of these.  Most interfaces
+should support at least UTF-8 in addition to ASCII.
+.It Em INTERFACE STABILITY
+Indicates the level of commitment to the interface. Interfaces can be described
+with in the following ways:
+.Bl -tag
+.It Nm Standard
+Indicates that the interface is defined by one or more standards bodies.
+Generally, changes to the interface will be carefully managed to conform
+to the relevant standards.  These interfaces are generally the most suitable
+for use in portable programs.
+.It Nm Committed
+Indicates that the interface is intended to be preserved for the long-haul, and
+will rarely, if ever change, and never without notification (barring
+extraordinary and extenuating circumstances). These interfaces are 
+preferred over other interfaces with the exeception of
+.Nm Standard
+interfaces.
+.It Nm Uncommitted
+Indicates that the interface may change.  Generally, changes to these interfaces
+should be infrequent, and some effort will be made to address compatibility
+considerations when changing or removing such interfaces.  However, there is
+no firm commitment to the preservation of the interface.  Most often this
+is applied to interfaces where operational experience with the interface
+is still limited and some need to change may be anticipated.
+.Pp
+Consumers should expect to revalidate any
+.Nm Uncommitted
+interfaces when crossing release boundaries.  Products intended for
+use on many releases or intended to support compatibility with future
+releases should avoid these interfaces.
+.It Nm Volatile
+The interface can change at any time for any reason. Often this relates to
+interfaces that are part of external software components that are still evolving
+rapidly.  Consumers should not expect that the interface (either binary or
+source level) will be unchanged from one release to the next.
+.It Nm Not-an-Interface
+Describes something that is specifically not intended for programmatic
+consumption.  For example, specific human-readable output, or the layout
+of graphical items on a user interface, may be described this way.  Generally
+programmatic alternatives to these will be available, and should be used
+when programmatic consumption is needed.
+.It Nm Private
+This is an internal interface.  Generally these interfaces should only be
+used within the project, and should not be used by other programs or modules.
+The interface can and will change without notice as the project needs, at
+any time.
+.Pp
+Most often, Private interfaces will lack any documentation whatsoever, and
+generally any undocumented interface can be assumed to be Private.
+.It Nm Obsolete
+The interface is not intended for use in new projects or programs, and may
+be removed at a future date.  The
+.Nm Obsolete
+word is a modifier that can
+be applied to other commitment levels. For example an
+.Nm Obsolete Committed
+interface is unlikely to be removed or changed, but nonetheless new use
+is discouraged (perhaps a better newer alternative is present).
+.El
+.It Em MT-LEVEL
+This section describes considerations for the interface when used within
+programs that use multiple threads.  More discussion of these considerations
+is made in the MT-Level section of
+.Xr attributes 5 .
+The interface can be described in the following ways.
+.Bl -tag
+.It Nm Safe
+Indicates the interface is safe for use within multiple threads.  There
+may be additional caveats that apply, in which case those will be
+described.  Note that some interfaces have semantics which may affect
+other threads, but these should be an intrinsic part of the interface
+rather than an unexpected side effect.  For example, closing a file in
+one thread will cause that file to be closed in all threads.
+.It Nm Unsafe
+Indicates the interface is unsuitable for concurrent use within multiple
+threads.  A threaded application may still make use of the interface, but
+will be required to provide external synchronization means to ensure that
+only a single thread calls the interface at a time.
+.It Nm MT-Safe
+Indicates that the interface is not only safe for concurrent use, but is
+designed for such use.  For example, a
+.Nm Safe
+interface may make use of a global lock to provide safety, but at reduced
+internal concurrency, whereas an
+.Nm MT-Safe
+interface will be designed to be efficient even when used concurrently.
+.It Nm Async-Signal-Safe
+Indicates that the library is safe for use within a signal handler.  An
+.Nm MT-Safe
+interface can be made
+.Nm Async-Signal-Safe
+by ensuring that it blocks signals when acquiring locks.
+.It Nm Safe with Exections
+As for
+.Nm Safe
+but with specific exceptions noted.
+.It Nm MT-Safe with Exections
+As for
+.Nm MT-Safe
+but with specific exceptions noted.
+.El
+.It Em SEE ALSO
+References other manuals with related topics.
+This section should exist for most manuals.
+Cross-references should conventionally be ordered first by section, then
+alphabetically.
+.Pp
+References to other documentation concerning the topic of the manual page,
+for example authoritative books or journal articles, may also be
+provided in this section.
+.Pp
+See
+.Sx \&Rs
+and
+.Sx \&Xr .
+.It Em STANDARDS
+References any standards implemented or used.
+If not adhering to any standards, the
+.Em HISTORY
+section should be used instead.
+.Pp
+See
+.Sx \&St .
+.It Em HISTORY
+A brief history of the subject, including where it was first implemented,
+and when it was ported to or reimplemented for the operating system at hand.
+.It Em AUTHORS
+Credits to the person or persons who wrote the code and/or documentation.
+Authors should generally be noted by both name and email address.
+.Pp
+See
+.Sx \&An .
+.It Em CAVEATS
+Common misuses and misunderstandings should be explained
+in this section.
+.It Em BUGS
+Known bugs, limitations, and work-arounds should be described
+in this section.
+.It Em SECURITY CONSIDERATIONS
+Documents any security precautions that operators should consider.
+.El
+.Sh MACRO OVERVIEW
+This overview is sorted such that macros of similar purpose are listed
+together, to help find the best macro for any given purpose.
+Deprecated macros are not included in the overview, but can be found below
+in the alphabetical
+.Sx MACRO REFERENCE .
+.Ss Document preamble and NAME section macros
+.Bl -column "Brq, Bro, Brc" description
+.It Sx \&Dd Ta document date: Ar month day , year
+.It Sx \&Dt Ta document title: Ar TITLE SECTION Op Ar volume | arch
+.It Sx \&Os Ta operating system version: Op Ar system Op Ar version
+.It Sx \&Nm Ta document name (one argument)
+.It Sx \&Nd Ta document description (one line)
+.El
+.Ss Sections and cross references
+.Bl -column "Brq, Bro, Brc" description
+.It Sx \&Sh Ta section header (one line)
+.It Sx \&Ss Ta subsection header (one line)
+.It Sx \&Sx Ta internal cross reference to a section or subsection
+.It Sx \&Xr Ta cross reference to another manual page: Ar name section
+.It Sx \&Pp , \&Lp Ta start a text paragraph (no arguments)
+.El
+.Ss Displays and lists
+.Bl -column "Brq, Bro, Brc" description
+.It Sx \&Bd , \&Ed Ta display block:
+.Fl Ar type
+.Op Fl offset Ar width
+.Op Fl compact
+.It Sx \&D1 Ta indented display (one line)
+.It Sx \&Dl Ta indented literal display (one line)
+.It Sx \&Bl , \&El Ta list block:
+.Fl Ar type
+.Op Fl width Ar val
+.Op Fl offset Ar val
+.Op Fl compact
+.It Sx \&It Ta list item (syntax depends on Fl Ar type )
+.It Sx \&Ta Ta table cell separator in Sx \&Bl Fl column No lists
+.It Sx \&Rs , \&%* , \&Re Ta bibliographic block (references)
+.El
+.Ss Spacing control
+.Bl -column "Brq, Bro, Brc" description
+.It Sx \&Pf Ta prefix, no following horizontal space (one argument)
+.It Sx \&Ns Ta roman font, no preceding horizontal space (no arguments)
+.It Sx \&Ap Ta apostrophe without surrounding whitespace (no arguments)
+.It Sx \&Sm Ta switch horizontal spacing mode: Cm on | off
+.It Sx \&Bk , \&Ek Ta keep block: Fl words
+.It Sx \&br Ta force output line break in text mode (no arguments)
+.It Sx \&sp Ta force vertical space: Op Ar height
+.El
+.Ss Semantic markup for command line utilities:
+.Bl -column "Brq, Bro, Brc" description
+.It Sx \&Nm Ta start a SYNOPSIS block with the name of a utility
+.It Sx \&Fl Ta command line options (flags) (>=0 arguments)
+.It Sx \&Cm Ta command modifier (>0 arguments)
+.It Sx \&Ar Ta command arguments (>=0 arguments)
+.It Sx \&Op , \&Oo , \&Oc Ta optional syntax elements (enclosure)
+.It Sx \&Ic Ta internal or interactive command (>0 arguments)
+.It Sx \&Ev Ta environmental variable (>0 arguments)
+.It Sx \&Pa Ta file system path (>=0 arguments)
+.El
+.Ss Semantic markup for function libraries:
+.Bl -column "Brq, Bro, Brc" description
+.It Sx \&Lb Ta function library (one argument)
+.It Sx \&In Ta include file (one argument)
+.It Sx \&Ft Ta function type (>0 arguments)
+.It Sx \&Fo , \&Fc Ta function block: Ar funcname
+.It Sx \&Fn Ta function name:
+.Op Ar functype
+.Ar funcname
+.Oo
+.Op Ar argtype
+.Ar argname
+.Oc
+.It Sx \&Fa Ta function argument (>0 arguments)
+.It Sx \&Vt Ta variable type (>0 arguments)
+.It Sx \&Va Ta variable name (>0 arguments)
+.It Sx \&Dv Ta defined variable or preprocessor constant (>0 arguments)
+.It Sx \&Er Ta error constant (>0 arguments)
+.It Sx \&Ev Ta environmental variable (>0 arguments)
+.El
+.Ss Various semantic markup:
+.Bl -column "Brq, Bro, Brc" description
+.It Sx \&An Ta author name (>0 arguments)
+.It Sx \&Lk Ta hyperlink: Ar uri Op Ar name
+.It Sx \&Mt Ta Do mailto Dc hyperlink: Ar address
+.It Sx \&Cd Ta kernel configuration declaration (>0 arguments)
+.It Sx \&Ad Ta memory address (>0 arguments)
+.It Sx \&Ms Ta mathematical symbol (>0 arguments)
+.It Sx \&Tn Ta tradename (>0 arguments)
+.El
+.Ss Physical markup
+.Bl -column "Brq, Bro, Brc" description
+.It Sx \&Em Ta italic font or underline (emphasis) (>0 arguments)
+.It Sx \&Sy Ta boldface font (symbolic) (>0 arguments)
+.It Sx \&Li Ta typewriter font (literal) (>0 arguments)
+.It Sx \&No Ta return to roman font (normal) (no arguments)
+.It Sx \&Bf , \&Ef Ta font block:
+.Op Fl Ar type | Cm \&Em | \&Li | \&Sy
+.El
+.Ss Physical enclosures
+.Bl -column "Brq, Bro, Brc" description
+.It Sx \&Dq , \&Do , \&Dc Ta enclose in typographic double quotes: Dq text
+.It Sx \&Qq , \&Qo , \&Qc Ta enclose in typewriter double quotes: Qq text
+.It Sx \&Sq , \&So , \&Sc Ta enclose in single quotes: Sq text
+.It Sx \&Ql Ta single-quoted literal text: Ql text
+.It Sx \&Pq , \&Po , \&Pc Ta enclose in parentheses: Pq text
+.It Sx \&Bq , \&Bo , \&Bc Ta enclose in square brackets: Bq text
+.It Sx \&Brq , \&Bro , \&Brc Ta enclose in curly braces: Brq text
+.It Sx \&Aq , \&Ao , \&Ac Ta enclose in angle brackets: Aq text
+.It Sx \&Eo , \&Ec Ta generic enclosure
+.El
+.Ss Text production
+.Bl -column "Brq, Bro, Brc" description
+.It Sx \&Ex Fl std Ta standard command exit values: Op Ar utility ...
+.It Sx \&Rv Fl std Ta standard function return values: Op Ar function ...
+.It Sx \&St Ta reference to a standards document (one argument)
+.It Sx \&Ux Ta Ux
+.It Sx \&At Ta At
+.It Sx \&Bx Ta Bx
+.It Sx \&Bsx Ta Bsx
+.It Sx \&Nx Ta Nx
+.It Sx \&Fx Ta Fx
+.It Sx \&Ox Ta Ox
+.It Sx \&Dx Ta Dx
+.El
+.Sh MACRO REFERENCE
+This section is a canonical reference of all macros, arranged
+alphabetically.
+For the scoping of individual macros, see
+.Sx MACRO SYNTAX .
+.Ss \&%A
+Author name of an
+.Sx \&Rs
+block.
+Multiple authors should each be accorded their own
+.Sx \%%A
+line.
+Author names should be ordered with full or abbreviated forename(s)
+first, then full surname.
+.Ss \&%B
+Book title of an
+.Sx \&Rs
+block.
+This macro may also be used in a non-bibliographic context when
+referring to book titles.
+.Ss \&%C
+Publication city or location of an
+.Sx \&Rs
+block.
+.Ss \&%D
+Publication date of an
+.Sx \&Rs
+block.
+Recommended formats of arguments are
+.Ar month day , year
+or just
+.Ar year .
+.Ss \&%I
+Publisher or issuer name of an
+.Sx \&Rs
+block.
+.Ss \&%J
+Journal name of an
+.Sx \&Rs
+block.
+.Ss \&%N
+Issue number (usually for journals) of an
+.Sx \&Rs
+block.
+.Ss \&%O
+Optional information of an
+.Sx \&Rs
+block.
+.Ss \&%P
+Book or journal page number of an
+.Sx \&Rs
+block.
+.Ss \&%Q
+Institutional author (school, government, etc.) of an
+.Sx \&Rs
+block.
+Multiple institutional authors should each be accorded their own
+.Sx \&%Q
+line.
+.Ss \&%R
+Technical report name of an
+.Sx \&Rs
+block.
+.Ss \&%T
+Article title of an
+.Sx \&Rs
+block.
+This macro may also be used in a non-bibliographical context when
+referring to article titles.
+.Ss \&%U
+URI of reference document.
+.Ss \&%V
+Volume number of an
+.Sx \&Rs
+block.
+.Ss \&Ac
+Close an
+.Sx \&Ao
+block.
+Does not have any tail arguments.
+.Ss \&Ad
+Memory address.
+Do not use this for postal addresses.
+.Pp
+Examples:
+.Dl \&.Ad [0,$]
+.Dl \&.Ad 0x00000000
+.Ss \&An
+Author name.
+Can be used both for the authors of the program, function, or driver
+documented in the manual, or for the authors of the manual itself.
+Requires either the name of an author or one of the following arguments:
+.Pp
+.Bl -tag -width "-nosplitX" -offset indent -compact
+.It Fl split
+Start a new output line before each subsequent invocation of
+.Sx \&An .
+.It Fl nosplit
+The opposite of
+.Fl split .
+.El
+.Pp
+The default is
+.Fl nosplit .
+The effect of selecting either of the
+.Fl split
+modes ends at the beginning of the
+.Em AUTHORS
+section.
+In the
+.Em AUTHORS
+section, the default is
+.Fl nosplit
+for the first author listing and
+.Fl split
+for all other author listings.
+.Pp
+Examples:
+.Dl \&.An -nosplit
+.Dl \&.An Kristaps Dzonsons \&Aq kristaps@bsd.lv
+.Ss \&Ao
+Begin a block enclosed by angle brackets.
+Does not have any head arguments.
+.Pp
+Examples:
+.Dl \&.Fl -key= \&Ns \&Ao \&Ar val \&Ac
+.Pp
+See also
+.Sx \&Aq .
+.Ss \&Ap
+Inserts an apostrophe without any surrounding whitespace.
+This is generally used as a grammatical device when referring to the verb
+form of a function.
+.Pp
+Examples:
+.Dl \&.Fn execve \&Ap d
+.Ss \&Aq
+Encloses its arguments in angle brackets.
+.Pp
+Examples:
+.Dl \&.Fl -key= \&Ns \&Aq \&Ar val
+.Pp
+.Em Remarks :
+this macro is often abused for rendering URIs, which should instead use
+.Sx \&Lk
+or
+.Sx \&Mt ,
+or to note pre-processor
+.Dq Li #include
+statements, which should use
+.Sx \&In .
+.Pp
+See also
+.Sx \&Ao .
+.Ss \&Ar
+Command arguments.
+If an argument is not provided, the string
+.Dq file ...\&
+is used as a default.
+.Pp
+Examples:
+.Dl ".Fl o Ar file"
+.Dl ".Ar"
+.Dl ".Ar arg1 , arg2 ."
+.Pp
+The arguments to the
+.Sx \&Ar
+macro are names and placeholders for command arguments;
+for fixed strings to be passed verbatim as arguments, use
+.Sx \&Fl
+or
+.Sx \&Cm .
+.Ss \&At
+Formats an AT&T version.
+Accepts one optional argument:
+.Pp
+.Bl -tag -width "v[1-7] | 32vX" -offset indent -compact
+.It Cm v[1-7] | 32v
+A version of
+.At .
+.It Cm III
+.At III .
+.It Cm V[.[1-4]]?
+A version of
+.At V .
+.El
+.Pp
+Note that these arguments do not begin with a hyphen.
+.Pp
+Examples:
+.Dl \&.At
+.Dl \&.At III
+.Dl \&.At V.1
+.Pp
+See also
+.Sx \&Bsx ,
+.Sx \&Bx ,
+.Sx \&Dx ,
+.Sx \&Fx ,
+.Sx \&Nx ,
+.Sx \&Ox ,
+and
+.Sx \&Ux .
+.Ss \&Bc
+Close a
+.Sx \&Bo
+block.
+Does not have any tail arguments.
+.Ss \&Bd
+Begin a display block.
+Its syntax is as follows:
+.Bd -ragged -offset indent
+.Pf \. Sx \&Bd
+.Fl Ns Ar type
+.Op Fl offset Ar width
+.Op Fl compact
+.Ed
+.Pp
+Display blocks are used to select a different indentation and
+justification than the one used by the surrounding text.
+They may contain both macro lines and text lines.
+By default, a display block is preceded by a vertical space.
+.Pp
+The
+.Ar type
+must be one of the following:
+.Bl -tag -width 13n -offset indent
+.It Fl centered
+Produce one output line from each input line, and centre-justify each line.
+Using this display type is not recommended; many
+.Nm
+implementations render it poorly.
+.It Fl filled
+Change the positions of line breaks to fill each line, and left- and
+right-justify the resulting block.
+.It Fl literal
+Produce one output line from each input line,
+and do not justify the block at all.
+Preserve white space as it appears in the input.
+Always use a constant-width font.
+Use this for displaying source code.
+.It Fl ragged
+Change the positions of line breaks to fill each line, and left-justify
+the resulting block.
+.It Fl unfilled
+The same as
+.Fl literal ,
+but using the same font as for normal text, which is a variable width font
+if supported by the output device.
+.El
+.Pp
+The
+.Ar type
+must be provided first.
+Additional arguments may follow:
+.Bl -tag -width 13n -offset indent
+.It Fl offset Ar width
+Indent the display by the
+.Ar width ,
+which may be one of the following:
+.Bl -item
+.It
+One of the pre-defined strings
+.Cm indent ,
+the width of a standard indentation (six constant width characters);
+.Cm indent-two ,
+twice
+.Cm indent ;
+.Cm left ,
+which has no effect;
+.Cm right ,
+which justifies to the right margin; or
+.Cm center ,
+which aligns around an imagined centre axis.
+.It
+A macro invocation, which selects a predefined width
+associated with that macro.
+The most popular is the imaginary macro
+.Ar \&Ds ,
+which resolves to
+.Sy 6n .
+.It
+A width using the syntax described in
+.Sx Scaling Widths .
+.It
+An arbitrary string, which indents by the length of this string.
+.El
+.Pp
+When the argument is missing,
+.Fl offset
+is ignored.
+.It Fl compact
+Do not assert vertical space before the display.
+.El
+.Pp
+Examples:
+.Bd -literal -offset indent
+\&.Bd \-literal \-offset indent \-compact
+   Hello       world.
+\&.Ed
+.Ed
+.Pp
+See also
+.Sx \&D1
+and
+.Sx \&Dl .
+.Ss \&Bf
+Change the font mode for a scoped block of text.
+Its syntax is as follows:
+.Bd -ragged -offset indent
+.Pf \. Sx \&Bf
+.Oo
+.Fl emphasis | literal | symbolic |
+.Cm \&Em | \&Li | \&Sy
+.Oc
+.Ed
+.Pp
+The
+.Fl emphasis
+and
+.Cm \&Em
+argument are equivalent, as are
+.Fl symbolic
+and
+.Cm \&Sy ,
+and
+.Fl literal
+and
+.Cm \&Li .
+Without an argument, this macro does nothing.
+The font mode continues until broken by a new font mode in a nested
+scope or
+.Sx \&Ef
+is encountered.
+.Pp
+See also
+.Sx \&Li ,
+.Sx \&Ef ,
+.Sx \&Em ,
+and
+.Sx \&Sy .
+.Ss \&Bk
+For each macro, keep its output together on the same output line,
+until the end of the macro or the end of the input line is reached,
+whichever comes first.
+Line breaks in text lines are unaffected.
+The syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Bk Fl words
+.Pp
+The
+.Fl words
+argument is required; additional arguments are ignored.
+.Pp
+The following example will not break within each
+.Sx \&Op
+macro line:
+.Bd -literal -offset indent
+\&.Bk \-words
+\&.Op Fl f Ar flags
+\&.Op Fl o Ar output
+\&.Ek
+.Ed
+.Pp
+Be careful in using over-long lines within a keep block!
+Doing so will clobber the right margin.
+.Ss \&Bl
+Begin a list.
+Lists consist of items specified using the
+.Sx \&It
+macro, containing a head or a body or both.
+The list syntax is as follows:
+.Bd -ragged -offset indent
+.Pf \. Sx \&Bl
+.Fl Ns Ar type
+.Op Fl width Ar val
+.Op Fl offset Ar val
+.Op Fl compact
+.Op HEAD ...
+.Ed
+.Pp
+The list
+.Ar type
+is mandatory and must be specified first.
+The
+.Fl width
+and
+.Fl offset
+arguments accept
+.Sx Scaling Widths
+or use the length of the given string.
+The
+.Fl offset
+is a global indentation for the whole list, affecting both item heads
+and bodies.
+For those list types supporting it, the
+.Fl width
+argument requests an additional indentation of item bodies,
+to be added to the
+.Fl offset .
+Unless the
+.Fl compact
+argument is specified, list entries are separated by vertical space.
+.Pp
+A list must specify one of the following list types:
+.Bl -tag -width 12n -offset indent
+.It Fl bullet
+No item heads can be specified, but a bullet will be printed at the head
+of each item.
+Item bodies start on the same output line as the bullet
+and are indented according to the
+.Fl width
+argument.
+.It Fl column
+A columnated list.
+The
+.Fl width
+argument has no effect; instead, each argument specifies the width
+of one column, using either the
+.Sx Scaling Widths
+syntax or the string length of the argument.
+If the first line of the body of a
+.Fl column
+list is not an
+.Sx \&It
+macro line,
+.Sx \&It
+contexts spanning one input line each are implied until an
+.Sx \&It
+macro line is encountered, at which point items start being interpreted as
+described in the
+.Sx \&It
+documentation.
+.It Fl dash
+Like
+.Fl bullet ,
+except that dashes are used in place of bullets.
+.It Fl diag
+Like
+.Fl inset ,
+except that item heads are not parsed for macro invocations.
+Most often used in the
+.Em DIAGNOSTICS
+section with error constants in the item heads.
+.It Fl enum
+A numbered list.
+No item heads can be specified.
+Formatted like
+.Fl bullet ,
+except that cardinal numbers are used in place of bullets,
+starting at 1.
+.It Fl hang
+Like
+.Fl tag ,
+except that the first lines of item bodies are not indented, but follow
+the item heads like in
+.Fl inset
+lists.
+.It Fl hyphen
+Synonym for
+.Fl dash .
+.It Fl inset
+Item bodies follow items heads on the same line, using normal inter-word
+spacing.
+Bodies are not indented, and the
+.Fl width
+argument is ignored.
+.It Fl item
+No item heads can be specified, and none are printed.
+Bodies are not indented, and the
+.Fl width
+argument is ignored.
+.It Fl ohang
+Item bodies start on the line following item heads and are not indented.
+The
+.Fl width
+argument is ignored.
+.It Fl tag
+Item bodies are indented according to the
+.Fl width
+argument.
+When an item head fits inside the indentation, the item body follows
+this head on the same output line.
+Otherwise, the body starts on the output line following the head.
+.El
+.Pp
+Lists may be nested within lists and displays.
+Nesting of
+.Fl column
+and
+.Fl enum
+lists may not be portable.
+.Pp
+See also
+.Sx \&El
+and
+.Sx \&It .
+.Ss \&Bo
+Begin a block enclosed by square brackets.
+Does not have any head arguments.
+.Pp
+Examples:
+.Bd -literal -offset indent -compact
+\&.Bo 1 ,
+\&.Dv BUFSIZ \&Bc
+.Ed
+.Pp
+See also
+.Sx \&Bq .
+.Ss \&Bq
+Encloses its arguments in square brackets.
+.Pp
+Examples:
+.Dl \&.Bq 1 , \&Dv BUFSIZ
+.Pp
+.Em Remarks :
+this macro is sometimes abused to emulate optional arguments for
+commands; the correct macros to use for this purpose are
+.Sx \&Op ,
+.Sx \&Oo ,
+and
+.Sx \&Oc .
+.Pp
+See also
+.Sx \&Bo .
+.Ss \&Brc
+Close a
+.Sx \&Bro
+block.
+Does not have any tail arguments.
+.Ss \&Bro
+Begin a block enclosed by curly braces.
+Does not have any head arguments.
+.Pp
+Examples:
+.Bd -literal -offset indent -compact
+\&.Bro 1 , ... ,
+\&.Va n \&Brc
+.Ed
+.Pp
+See also
+.Sx \&Brq .
+.Ss \&Brq
+Encloses its arguments in curly braces.
+.Pp
+Examples:
+.Dl \&.Brq 1 , ... , \&Va n
+.Pp
+See also
+.Sx \&Bro .
+.Ss \&Bsx
+Format the BSD/OS version provided as an argument, or a default value if
+no argument is provided.
+.Pp
+Examples:
+.Dl \&.Bsx 1.0
+.Dl \&.Bsx
+.Pp
+See also
+.Sx \&At ,
+.Sx \&Bx ,
+.Sx \&Dx ,
+.Sx \&Fx ,
+.Sx \&Nx ,
+.Sx \&Ox ,
+and
+.Sx \&Ux .
+.Ss \&Bt
+Prints
+.Dq is currently in beta test.
+.Ss \&Bx
+Format the BSD version provided as an argument, or a default value if no
+argument is provided.
+.Pp
+Examples:
+.Dl \&.Bx 4.3 Tahoe
+.Dl \&.Bx 4.4
+.Dl \&.Bx
+.Pp
+See also
+.Sx \&At ,
+.Sx \&Bsx ,
+.Sx \&Dx ,
+.Sx \&Fx ,
+.Sx \&Nx ,
+.Sx \&Ox ,
+and
+.Sx \&Ux .
+.Ss \&Cd
+Kernel configuration declaration.
+This denotes strings accepted by
+.Xr config 8 .
+It is most often used in section 4 manual pages.
+.Pp
+Examples:
+.Dl \&.Cd device le0 at scode?
+.Pp
+.Em Remarks :
+this macro is commonly abused by using quoted literals to retain
+whitespace and align consecutive
+.Sx \&Cd
+declarations.
+This practise is discouraged.
+.Ss \&Cm
+Command modifiers.
+Typically used for fixed strings passed as arguments, unless
+.Sx \&Fl
+is more appropriate.
+Also useful when specifying configuration options or keys.
+.Pp
+Examples:
+.Dl ".Nm mt Fl f Ar device Cm rewind"
+.Dl ".Nm ps Fl o Cm pid , Ns Cm command"
+.Dl ".Nm dd Cm if= Ns Ar file1 Cm of= Ns Ar file2"
+.Dl ".Cm IdentityFile Pa ~/.ssh/id_rsa"
+.Dl ".Cm LogLevel Dv DEBUG"
+.Ss \&D1
+One-line indented display.
+This is formatted by the default rules and is useful for simple indented
+statements.
+It is followed by a newline.
+.Pp
+Examples:
+.Dl \&.D1 \&Fl abcdefgh
+.Pp
+See also
+.Sx \&Bd
+and
+.Sx \&Dl .
+.Ss \&Db
+Switch debugging mode.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Db Cm on | off
+.Pp
+This macro is ignored by
+.Xr mandoc 1 .
+.Ss \&Dc
+Close a
+.Sx \&Do
+block.
+Does not have any tail arguments.
+.Ss \&Dd
+Document date.
+This is the mandatory first macro of any
+.Nm
+manual.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Dd Ar month day , year
+.Pp
+The
+.Ar month
+is the full English month name, the
+.Ar day
+is an optionally zero-padded numeral, and the
+.Ar year
+is the full four-digit year.
+.Pp
+Other arguments are not portable; the
+.Xr mandoc 1
+utility handles them as follows:
+.Bl -dash -offset 3n -compact
+.It
+To have the date automatically filled in by the
+.Ox
+version of
+.Xr cvs 1 ,
+the special string
+.Dq $\&Mdocdate$
+can be given as an argument.
+.It
+A few alternative date formats are accepted as well
+and converted to the standard form.
+.It
+If a date string cannot be parsed, it is used verbatim.
+.It
+If no date string is given, the current date is used.
+.El
+.Pp
+Examples:
+.Dl \&.Dd $\&Mdocdate$
+.Dl \&.Dd $\&Mdocdate: July 21 2007$
+.Dl \&.Dd July 21, 2007
+.Pp
+See also
+.Sx \&Dt
+and
+.Sx \&Os .
+.Ss \&Dl
+One-line intended display.
+This is formatted as literal text and is useful for commands and
+invocations.
+It is followed by a newline.
+.Pp
+Examples:
+.Dl \&.Dl % mandoc mdoc.5 \e(ba less
+.Pp
+See also
+.Sx \&Bd
+and
+.Sx \&D1 .
+.Ss \&Do
+Begin a block enclosed by double quotes.
+Does not have any head arguments.
+.Pp
+Examples:
+.Bd -literal -offset indent -compact
+\&.Do
+April is the cruellest month
+\&.Dc
+\e(em T.S. Eliot
+.Ed
+.Pp
+See also
+.Sx \&Dq .
+.Ss \&Dq
+Encloses its arguments in
+.Dq typographic
+double-quotes.
+.Pp
+Examples:
+.Bd -literal -offset indent -compact
+\&.Dq April is the cruellest month
+\e(em T.S. Eliot
+.Ed
+.Pp
+See also
+.Sx \&Qq ,
+.Sx \&Sq ,
+and
+.Sx \&Do .
+.Ss \&Dt
+Document title.
+This is the mandatory second macro of any
+.Nm
+file.
+Its syntax is as follows:
+.Bd -ragged -offset indent
+.Pf \. Sx \&Dt
+.Oo
+.Ar title
+.Oo
+.Ar section
+.Op Ar volume
+.Op Ar arch
+.Oc
+.Oc
+.Ed
+.Pp
+Its arguments are as follows:
+.Bl -tag -width Ds -offset Ds
+.It Ar title
+The document's title (name), defaulting to
+.Dq UNKNOWN
+if unspecified.
+It should be capitalised.
+.It Ar section
+The manual section. It should correspond to the manual's filename suffix
+and defaults to
+.Dq 1
+if unspecified.
+.It Ar volume
+This overrides the volume inferred from
+.Ar section .
+This field is optional.
+.It Ar arch
+This specifies the machine architecture a manual page applies to,
+where relevant.
+.El
+.Ss \&Dv
+Defined variables such as preprocessor constants, constant symbols,
+enumeration values, and so on.
+.Pp
+Examples:
+.Dl \&.Dv NULL
+.Dl \&.Dv BUFSIZ
+.Dl \&.Dv STDOUT_FILENO
+.Pp
+See also
+.Sx \&Er
+and
+.Sx \&Ev
+for special-purpose constants and
+.Sx \&Va
+for variable symbols.
+.Ss \&Dx
+Format the DragonFly BSD version provided as an argument, or a default
+value if no argument is provided.
+.Pp
+Examples:
+.Dl \&.Dx 2.4.1
+.Dl \&.Dx
+.Pp
+See also
+.Sx \&At ,
+.Sx \&Bsx ,
+.Sx \&Bx ,
+.Sx \&Fx ,
+.Sx \&Nx ,
+.Sx \&Ox ,
+and
+.Sx \&Ux .
+.Ss \&Ec
+Close a scope started by
+.Sx \&Eo .
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Ec Op Ar TERM
+.Pp
+The
+.Ar TERM
+argument is used as the enclosure tail, for example, specifying \e(rq
+will emulate
+.Sx \&Dc .
+.Ss \&Ed
+End a display context started by
+.Sx \&Bd .
+.Ss \&Ef
+End a font mode context started by
+.Sx \&Bf .
+.Ss \&Ek
+End a keep context started by
+.Sx \&Bk .
+.Ss \&El
+End a list context started by
+.Sx \&Bl .
+.Pp
+See also
+.Sx \&Bl
+and
+.Sx \&It .
+.Ss \&Em
+Denotes text that should be
+.Em emphasised .
+Note that this is a presentation term and should not be used for
+stylistically decorating technical terms.
+Depending on the output device, this is usually represented
+using an italic font or underlined characters.
+.Pp
+Examples:
+.Dl \&.Em Warnings!
+.Dl \&.Em Remarks :
+.Pp
+See also
+.Sx \&Bf ,
+.Sx \&Li ,
+.Sx \&No ,
+and
+.Sx \&Sy .
+.Ss \&En
+This macro is obsolete and not implemented in
+.Xr mandoc 1 .
+.Ss \&Eo
+An arbitrary enclosure.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Eo Op Ar TERM
+.Pp
+The
+.Ar TERM
+argument is used as the enclosure head, for example, specifying \e(lq
+will emulate
+.Sx \&Do .
+.Ss \&Er
+Error constants for definitions of the
+.Va errno
+libc global variable.
+This is most often used in section 2 and 3 manual pages.
+.Pp
+Examples:
+.Dl \&.Er EPERM
+.Dl \&.Er ENOENT
+.Pp
+See also
+.Sx \&Dv
+for general constants.
+.Ss \&Es
+This macro is obsolete and not implemented.
+.Ss \&Ev
+Environmental variables such as those specified in
+.Xr environ 5 .
+.Pp
+Examples:
+.Dl \&.Ev DISPLAY
+.Dl \&.Ev PATH
+.Pp
+See also
+.Sx \&Dv
+for general constants.
+.Ss \&Ex
+Insert a standard sentence regarding command exit values of 0 on success
+and >0 on failure.
+This is most often used in section 1, 6, and 8 manual pages.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Ex Fl std Op Ar utility ...
+.Pp
+If
+.Ar utility
+is not specified, the document's name set by
+.Sx \&Nm
+is used.
+Multiple
+.Ar utility
+arguments are treated as separate utilities.
+.Pp
+See also
+.Sx \&Rv .
+.Ss \&Fa
+Function argument.
+Its syntax is as follows:
+.Bd -ragged -offset indent
+.Pf \. Sx \&Fa
+.Op Cm argtype
+.Cm argname
+.Ed
+.Pp
+This may be invoked for names with or without the corresponding type.
+It is also used to specify the field name of a structure.
+Most often, the
+.Sx \&Fa
+macro is used in the
+.Em SYNOPSIS
+within
+.Sx \&Fo
+section when documenting multi-line function prototypes.
+If invoked with multiple arguments, the arguments are separated by a
+comma.
+Furthermore, if the following macro is another
+.Sx \&Fa ,
+the last argument will also have a trailing comma.
+.Pp
+Examples:
+.Dl \&.Fa \(dqconst char *p\(dq
+.Dl \&.Fa \(dqint a\(dq \(dqint b\(dq \(dqint c\(dq
+.Dl \&.Fa foo
+.Pp
+See also
+.Sx \&Fo .
+.Ss \&Fc
+End a function context started by
+.Sx \&Fo .
+.Ss \&Fd
+Historically used to document include files.
+This usage has been deprecated in favour of
+.Sx \&In .
+Do not use this macro.
+.Pp
+See also
+.Sx MANUAL STRUCTURE
+and
+.Sx \&In .
+.Ss \&Fl
+Command-line flag or option.
+Used when listing arguments to command-line utilities.
+Prints a fixed-width hyphen
+.Sq \-
+directly followed by each argument.
+If no arguments are provided, a hyphen is printed followed by a space.
+If the argument is a macro, a hyphen is prefixed to the subsequent macro
+output.
+.Pp
+Examples:
+.Dl ".Fl R Op Fl H | L | P"
+.Dl ".Op Fl 1AaCcdFfgHhikLlmnopqRrSsTtux"
+.Dl ".Fl type Cm d Fl name Pa CVS"
+.Dl ".Fl Ar signal_number"
+.Dl ".Fl o Fl"
+.Pp
+See also
+.Sx \&Cm .
+.Ss \&Fn
+A function name.
+Its syntax is as follows:
+.Bd -ragged -offset indent
+.Pf \. Ns Sx \&Fn
+.Op Ar functype
+.Ar funcname
+.Op Oo Ar argtype Oc Ar argname
+.Ed
+.Pp
+Function arguments are surrounded in parenthesis and
+are delimited by commas.
+If no arguments are specified, blank parenthesis are output.
+In the
+.Em SYNOPSIS
+section, this macro starts a new output line,
+and a blank line is automatically inserted between function definitions.
+.Pp
+Examples:
+.Dl \&.Fn \(dqint funcname\(dq \(dqint arg0\(dq \(dqint arg1\(dq
+.Dl \&.Fn funcname \(dqint arg0\(dq
+.Dl \&.Fn funcname arg0
+.Pp
+.Bd -literal -offset indent -compact
+\&.Ft functype
+\&.Fn funcname
+.Ed
+.Pp
+When referring to a function documented in another manual page, use
+.Sx \&Xr
+instead.
+See also
+.Sx MANUAL STRUCTURE ,
+.Sx \&Fo ,
+and
+.Sx \&Ft .
+.Ss \&Fo
+Begin a function block.
+This is a multi-line version of
+.Sx \&Fn .
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Fo Ar funcname
+.Pp
+Invocations usually occur in the following context:
+.Bd -ragged -offset indent
+.Pf \. Sx \&Ft Ar functype
+.br
+.Pf \. Sx \&Fo Ar funcname
+.br
+.Pf \. Sx \&Fa Oo Ar argtype Oc Ar argname
+.br
+\&.\.\.
+.br
+.Pf \. Sx \&Fc
+.Ed
+.Pp
+A
+.Sx \&Fo
+scope is closed by
+.Sx \&Fc .
+.Pp
+See also
+.Sx MANUAL STRUCTURE ,
+.Sx \&Fa ,
+.Sx \&Fc ,
+and
+.Sx \&Ft .
+.Ss \&Fr
+This macro is obsolete and not implemented in
+.Xr mandoc 1 .
+.Pp
+It was used to show function return values.
+The syntax was:
+.Pp
+.Dl Pf . Sx \&Fr Ar value
+.Ss \&Ft
+A function type.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Ft Ar functype
+.Pp
+In the
+.Em SYNOPSIS
+section, a new output line is started after this macro.
+.Pp
+Examples:
+.Dl \&.Ft int
+.Bd -literal -offset indent -compact
+\&.Ft functype
+\&.Fn funcname
+.Ed
+.Pp
+See also
+.Sx MANUAL STRUCTURE ,
+.Sx \&Fn ,
+and
+.Sx \&Fo .
+.Ss \&Fx
+Format the
+.Fx
+version provided as an argument, or a default value
+if no argument is provided.
+.Pp
+Examples:
+.Dl \&.Fx 7.1
+.Dl \&.Fx
+.Pp
+See also
+.Sx \&At ,
+.Sx \&Bsx ,
+.Sx \&Bx ,
+.Sx \&Dx ,
+.Sx \&Nx ,
+.Sx \&Ox ,
+and
+.Sx \&Ux .
+.Ss \&Hf
+This macro is not implemented in
+.Xr mandoc 1 .
+.Pp
+It was used to include the contents of a (header) file literally.
+The syntax was:
+.Pp
+.Dl Pf . Sx \&Hf Ar filename
+.Ss \&Ic
+Designate an internal or interactive command.
+This is similar to
+.Sx \&Cm
+but used for instructions rather than values.
+.Pp
+Examples:
+.Dl \&.Ic :wq
+.Dl \&.Ic hash
+.Dl \&.Ic alias
+.Pp
+Note that using
+.Sx \&Bd Fl literal
+or
+.Sx \&D1
+is preferred for displaying code; the
+.Sx \&Ic
+macro is used when referring to specific instructions.
+.Ss \&In
+An
+.Dq include
+file.
+When invoked as the first macro on an input line in the
+.Em SYNOPSIS
+section, the argument is displayed in angle brackets
+and preceded by
+.Dq #include ,
+and a blank line is inserted in front if there is a preceding
+function declaration.
+This is most often used in section 2, 3, and 9 manual pages.
+.Pp
+Examples:
+.Dl \&.In sys/types.h
+.Pp
+See also
+.Sx MANUAL STRUCTURE .
+.Ss \&It
+A list item.
+The syntax of this macro depends on the list type.
+.Pp
+Lists
+of type
+.Fl hang ,
+.Fl ohang ,
+.Fl inset ,
+and
+.Fl diag
+have the following syntax:
+.Pp
+.D1 Pf \. Sx \&It Ar args
+.Pp
+Lists of type
+.Fl bullet ,
+.Fl dash ,
+.Fl enum ,
+.Fl hyphen
+and
+.Fl item
+have the following syntax:
+.Pp
+.D1 Pf \. Sx \&It
+.Pp
+with subsequent lines interpreted within the scope of the
+.Sx \&It
+until either a closing
+.Sx \&El
+or another
+.Sx \&It .
+.Pp
+The
+.Fl tag
+list has the following syntax:
+.Pp
+.D1 Pf \. Sx \&It Op Cm args
+.Pp
+Subsequent lines are interpreted as with
+.Fl bullet
+and family.
+The line arguments correspond to the list's left-hand side; body
+arguments correspond to the list's contents.
+.Pp
+The
+.Fl column
+list is the most complicated.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&It Ar cell Op <TAB> Ar cell ...
+.D1 Pf \. Sx \&It Ar cell Op Sx \&Ta Ar cell ...
+.Pp
+The arguments consist of one or more lines of text and macros
+representing a complete table line.
+Cells within the line are delimited by tabs or by the special
+.Sx \&Ta
+block macro.
+The tab cell delimiter may only be used within the
+.Sx \&It
+line itself; on following lines, only the
+.Sx \&Ta
+macro can be used to delimit cells, and
+.Sx \&Ta
+is only recognised as a macro when called by other macros,
+not as the first macro on a line.
+.Pp
+Note that quoted strings may span tab-delimited cells on an
+.Sx \&It
+line.
+For example,
+.Pp
+.Dl .It \(dqcol1 ; <TAB> col2 ;\(dq \&;
+.Pp
+will preserve the semicolon whitespace except for the last.
+.Pp
+See also
+.Sx \&Bl .
+.Ss \&Lb
+Specify a library.
+The syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Lb Ar library
+.Pp
+The
+.Ar library
+parameter may be a system library, such as
+.Cm libz
+or
+.Cm libpam ,
+in which case a small library description is printed next to the linker
+invocation; or a custom library, in which case the library name is
+printed in quotes.
+This is most commonly used in the
+.Em SYNOPSIS
+section as described in
+.Sx MANUAL STRUCTURE .
+.Pp
+Examples:
+.Dl \&.Lb libz
+.Dl \&.Lb mdoc
+.Ss \&Li
+Denotes text that should be in a
+.Li literal
+font mode.
+Note that this is a presentation term and should not be used for
+stylistically decorating technical terms.
+.Pp
+On terminal output devices, this is often indistinguishable from
+normal text.
+.Pp
+See also
+.Sx \&Bf ,
+.Sx \&Em ,
+.Sx \&No ,
+and
+.Sx \&Sy .
+.Ss \&Lk
+Format a hyperlink.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Lk Ar uri Op Ar name
+.Pp
+Examples:
+.Dl \&.Lk http://bsd.lv \(dqThe BSD.lv Project\(dq
+.Dl \&.Lk http://bsd.lv
+.Pp
+See also
+.Sx \&Mt .
+.Ss \&Lp
+Synonym for
+.Sx \&Pp .
+.Ss \&Ms
+Display a mathematical symbol.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Ms Ar symbol
+.Pp
+Examples:
+.Dl \&.Ms sigma
+.Dl \&.Ms aleph
+.Ss \&Mt
+Format a
+.Dq mailto:
+hyperlink.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Mt Ar address
+.Pp
+Examples:
+.Dl \&.Mt discuss@manpages.bsd.lv
+.Ss \&Nd
+A one line description of the manual's content.
+This may only be invoked in the
+.Em SYNOPSIS
+section subsequent the
+.Sx \&Nm
+macro.
+.Pp
+Examples:
+.Dl Pf . Sx \&Nd mdoc language reference
+.Dl Pf . Sx \&Nd format and display UNIX manuals
+.Pp
+The
+.Sx \&Nd
+macro technically accepts child macros and terminates with a subsequent
+.Sx \&Sh
+invocation.
+Do not assume this behaviour: some
+.Xr whatis 1
+database generators are not smart enough to parse more than the line
+arguments and will display macros verbatim.
+.Pp
+See also
+.Sx \&Nm .
+.Ss \&Nm
+The name of the manual page, or \(em in particular in section 1, 6,
+and 8 pages \(em of an additional command or feature documented in
+the manual page.
+When first invoked, the
+.Sx \&Nm
+macro expects a single argument, the name of the manual page.
+Usually, the first invocation happens in the
+.Em NAME
+section of the page.
+The specified name will be remembered and used whenever the macro is
+called again without arguments later in the page.
+The
+.Sx \&Nm
+macro uses
+.Sx Block full-implicit
+semantics when invoked as the first macro on an input line in the
+.Em SYNOPSIS
+section; otherwise, it uses ordinary
+.Sx In-line
+semantics.
+.Pp
+Examples:
+.Bd -literal -offset indent
+\&.Sh SYNOPSIS
+\&.Nm cat
+\&.Op Fl benstuv
+\&.Op Ar
+.Ed
+.Pp
+In the
+.Em SYNOPSIS
+of section 2, 3 and 9 manual pages, use the
+.Sx \&Fn
+macro rather than
+.Sx \&Nm
+to mark up the name of the manual page.
+.Ss \&No
+Normal text.
+Closes the scope of any preceding in-line macro.
+When used after physical formatting macros like
+.Sx \&Em
+or
+.Sx \&Sy ,
+switches back to the standard font face and weight.
+Can also be used to embed plain text strings in macro lines
+using semantic annotation macros.
+.Pp
+Examples:
+.Dl ".Em italic , Sy bold , No and roman"
+.Pp
+.Bd -literal -offset indent -compact
+\&.Sm off
+\&.Cm :C No / Ar pattern No / Ar replacement No /
+\&.Sm on
+.Ed
+.Pp
+See also
+.Sx \&Em ,
+.Sx \&Li ,
+and
+.Sx \&Sy .
+.Ss \&Ns
+Suppress a space between the output of the preceding macro
+and the following text or macro.
+Following invocation, input is interpreted as normal text
+just like after an
+.Sx \&No
+macro.
+.Pp
+This has no effect when invoked at the start of a macro line.
+.Pp
+Examples:
+.Dl ".Ar name Ns = Ns Ar value"
+.Dl ".Cm :M Ns Ar pattern"
+.Dl ".Fl o Ns Ar output"
+.Pp
+See also
+.Sx \&No
+and
+.Sx \&Sm .
+.Ss \&Nx
+Format the
+.Nx
+version provided as an argument, or a default value if
+no argument is provided.
+.Pp
+Examples:
+.Dl \&.Nx 5.01
+.Dl \&.Nx
+.Pp
+See also
+.Sx \&At ,
+.Sx \&Bsx ,
+.Sx \&Bx ,
+.Sx \&Dx ,
+.Sx \&Fx ,
+.Sx \&Ox ,
+and
+.Sx \&Ux .
+.Ss \&Oc
+Close multi-line
+.Sx \&Oo
+context.
+.Ss \&Oo
+Multi-line version of
+.Sx \&Op .
+.Pp
+Examples:
+.Bd -literal -offset indent -compact
+\&.Oo
+\&.Op Fl flag Ns Ar value
+\&.Oc
+.Ed
+.Ss \&Op
+Optional part of a command line.
+Prints the argument(s) in brackets.
+This is most often used in the
+.Em SYNOPSIS
+section of section 1 and 8 manual pages.
+.Pp
+Examples:
+.Dl \&.Op \&Fl a \&Ar b
+.Dl \&.Op \&Ar a | b
+.Pp
+See also
+.Sx \&Oo .
+.Ss \&Os
+Document operating system version.
+This is the mandatory third macro of
+any
+.Nm
+file.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Os Op Ar system Op Ar version
+.Pp
+The optional
+.Ar system
+parameter specifies the relevant operating system or environment.
+Left unspecified, it defaults to the local operating system version.
+This is the suggested form.
+.Pp
+Examples:
+.Dl \&.Os
+.Dl \&.Os KTH/CSC/TCS
+.Dl \&.Os BSD 4.3
+.Pp
+See also
+.Sx \&Dd
+and
+.Sx \&Dt .
+.Ss \&Ot
+This macro is obsolete and not implemented in
+.Xr mandoc 1 .
+.Pp
+Historical
+.Xr mdoc 5
+packages described it as
+.Dq "old function type (FORTRAN)" .
+.Ss \&Ox
+Format the
+.Ox
+version provided as an argument, or a default value
+if no argument is provided.
+.Pp
+Examples:
+.Dl \&.Ox 4.5
+.Dl \&.Ox
+.Pp
+See also
+.Sx \&At ,
+.Sx \&Bsx ,
+.Sx \&Bx ,
+.Sx \&Dx ,
+.Sx \&Fx ,
+.Sx \&Nx ,
+and
+.Sx \&Ux .
+.Ss \&Pa
+An absolute or relative file system path, or a file or directory name.
+If an argument is not provided, the character
+.Sq \(ti
+is used as a default.
+.Pp
+Examples:
+.Dl \&.Pa /usr/bin/mandoc
+.Dl \&.Pa /usr/share/man/man5/mdoc.5
+.Pp
+See also
+.Sx \&Lk .
+.Ss \&Pc
+Close parenthesised context opened by
+.Sx \&Po .
+.Ss \&Pf
+Removes the space between its argument
+.Pq Dq prefix
+and the following macro.
+Its syntax is as follows:
+.Pp
+.D1 .Pf Ar prefix macro arguments ...
+.Pp
+This is equivalent to:
+.Pp
+.D1 .No Ar prefix No \&Ns Ar macro arguments ...
+.Pp
+Examples:
+.Dl ".Pf $ Ar variable_name"
+.Dl ".Pf 0x Ar hex_digits"
+.Pp
+See also
+.Sx \&Ns
+and
+.Sx \&Sm .
+.Ss \&Po
+Multi-line version of
+.Sx \&Pq .
+.Ss \&Pp
+Break a paragraph.
+This will assert vertical space between prior and subsequent macros
+and/or text.
+.Pp
+Paragraph breaks are not needed before or after
+.Sx \&Sh
+or
+.Sx \&Ss
+macros or before displays
+.Pq Sx \&Bd
+or lists
+.Pq Sx \&Bl
+unless the
+.Fl compact
+flag is given.
+.Ss \&Pq
+Parenthesised enclosure.
+.Pp
+See also
+.Sx \&Po .
+.Ss \&Qc
+Close quoted context opened by
+.Sx \&Qo .
+.Ss \&Ql
+Format a single-quoted literal.
+See also
+.Sx \&Qq
+and
+.Sx \&Sq .
+.Ss \&Qo
+Multi-line version of
+.Sx \&Qq .
+.Ss \&Qq
+Encloses its arguments in
+.Qq typewriter
+double-quotes.
+Consider using
+.Sx \&Dq .
+.Pp
+See also
+.Sx \&Dq ,
+.Sx \&Sq ,
+and
+.Sx \&Qo .
+.Ss \&Re
+Close an
+.Sx \&Rs
+block.
+Does not have any tail arguments.
+.Ss \&Rs
+Begin a bibliographic
+.Pq Dq reference
+block.
+Does not have any head arguments.
+The block macro may only contain
+.Sx \&%A ,
+.Sx \&%B ,
+.Sx \&%C ,
+.Sx \&%D ,
+.Sx \&%I ,
+.Sx \&%J ,
+.Sx \&%N ,
+.Sx \&%O ,
+.Sx \&%P ,
+.Sx \&%Q ,
+.Sx \&%R ,
+.Sx \&%T ,
+.Sx \&%U ,
+and
+.Sx \&%V
+child macros (at least one must be specified).
+.Pp
+Examples:
+.Bd -literal -offset indent -compact
+\&.Rs
+\&.%A J. E. Hopcroft
+\&.%A J. D. Ullman
+\&.%B Introduction to Automata Theory, Languages, and Computation
+\&.%I Addison-Wesley
+\&.%C Reading, Massachusettes
+\&.%D 1979
+\&.Re
+.Ed
+.Pp
+If an
+.Sx \&Rs
+block is used within a SEE ALSO section, a vertical space is asserted
+before the rendered output, else the block continues on the current
+line.
+.Ss \&Rv
+Insert a standard sentence regarding a function call's return value of 0
+on success and \-1 on error, with the
+.Va errno
+libc global variable set on error.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Rv Fl std Op Ar function ...
+.Pp
+If
+.Ar function
+is not specified, the document's name set by
+.Sx \&Nm
+is used.
+Multiple
+.Ar function
+arguments are treated as separate functions.
+.Pp
+See also
+.Sx \&Ex .
+.Ss \&Sc
+Close single-quoted context opened by
+.Sx \&So .
+.Ss \&Sh
+Begin a new section.
+For a list of conventional manual sections, see
+.Sx MANUAL STRUCTURE .
+These sections should be used unless it's absolutely necessary that
+custom sections be used.
+.Pp
+Section names should be unique so that they may be keyed by
+.Sx \&Sx .
+Although this macro is parsed, it should not consist of child node or it
+may not be linked with
+.Sx \&Sx .
+.Pp
+See also
+.Sx \&Pp ,
+.Sx \&Ss ,
+and
+.Sx \&Sx .
+.Ss \&Sm
+Switches the spacing mode for output generated from macros.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Sm Cm on | off
+.Pp
+By default, spacing is
+.Cm on .
+When switched
+.Cm off ,
+no white space is inserted between macro arguments and between the
+output generated from adjacent macros, but text lines
+still get normal spacing between words and sentences.
+.Ss \&So
+Multi-line version of
+.Sx \&Sq .
+.Ss \&Sq
+Encloses its arguments in
+.Sq typewriter
+single-quotes.
+.Pp
+See also
+.Sx \&Dq ,
+.Sx \&Qq ,
+and
+.Sx \&So .
+.Ss \&Ss
+Begin a new subsection.
+Unlike with
+.Sx \&Sh ,
+there is no convention for the naming of subsections.
+Except
+.Em DESCRIPTION ,
+the conventional sections described in
+.Sx MANUAL STRUCTURE
+rarely have subsections.
+.Pp
+Sub-section names should be unique so that they may be keyed by
+.Sx \&Sx .
+Although this macro is parsed, it should not consist of child node or it
+may not be linked with
+.Sx \&Sx .
+.Pp
+See also
+.Sx \&Pp ,
+.Sx \&Sh ,
+and
+.Sx \&Sx .
+.Ss \&St
+Replace an abbreviation for a standard with the full form.
+The following standards are recognised:
+.Pp
+.Bl -tag -width "-p1003.1g-2000X" -compact
+.It \-p1003.1-88
+.St -p1003.1-88
+.It \-p1003.1-90
+.St -p1003.1-90
+.It \-p1003.1-96
+.St -p1003.1-96
+.It \-p1003.1-2001
+.St -p1003.1-2001
+.It \-p1003.1-2004
+.St -p1003.1-2004
+.It \-p1003.1-2008
+.St -p1003.1-2008
+.It \-p1003.1
+.St -p1003.1
+.It \-p1003.1b
+.St -p1003.1b
+.It \-p1003.1b-93
+.St -p1003.1b-93
+.It \-p1003.1c-95
+.St -p1003.1c-95
+.It \-p1003.1g-2000
+.St -p1003.1g-2000
+.It \-p1003.1i-95
+.St -p1003.1i-95
+.It \-p1003.2-92
+.St -p1003.2-92
+.It \-p1003.2a-92
+.St -p1003.2a-92
+.It \-p1387.2-95
+.St -p1387.2-95
+.It \-p1003.2
+.St -p1003.2
+.It \-p1387.2
+.St -p1387.2
+.It \-isoC
+.St -isoC
+.It \-isoC-90
+.St -isoC-90
+.It \-isoC-amd1
+.St -isoC-amd1
+.It \-isoC-tcor1
+.St -isoC-tcor1
+.It \-isoC-tcor2
+.St -isoC-tcor2
+.It \-isoC-99
+.St -isoC-99
+.It \-isoC-2011
+.St -isoC-2011
+.It \-iso9945-1-90
+.St -iso9945-1-90
+.It \-iso9945-1-96
+.St -iso9945-1-96
+.It \-iso9945-2-93
+.St -iso9945-2-93
+.It \-ansiC
+.St -ansiC
+.It \-ansiC-89
+.St -ansiC-89
+.It \-ansiC-99
+.St -ansiC-99
+.It \-ieee754
+.St -ieee754
+.It \-iso8802-3
+.St -iso8802-3
+.It \-iso8601
+.St -iso8601
+.It \-ieee1275-94
+.St -ieee1275-94
+.It \-xpg3
+.St -xpg3
+.It \-xpg4
+.St -xpg4
+.It \-xpg4.2
+.St -xpg4.2
+.It \-xpg4.3
+.St -xpg4.3
+.It \-xbd5
+.St -xbd5
+.It \-xcu5
+.St -xcu5
+.It \-xsh5
+.St -xsh5
+.It \-xns5
+.St -xns5
+.It \-xns5.2
+.St -xns5.2
+.It \-xns5.2d2.0
+.St -xns5.2d2.0
+.It \-xcurses4.2
+.St -xcurses4.2
+.It \-susv2
+.St -susv2
+.It \-susv3
+.St -susv3
+.It \-svid4
+.St -svid4
+.El
+.Ss \&Sx
+Reference a section or subsection in the same manual page.
+The referenced section or subsection name must be identical to the
+enclosed argument, including whitespace.
+.Pp
+Examples:
+.Dl \&.Sx MANUAL STRUCTURE
+.Pp
+See also
+.Sx \&Sh
+and
+.Sx \&Ss .
+.Ss \&Sy
+Format enclosed arguments in symbolic
+.Pq Dq boldface .
+Note that this is a presentation term and should not be used for
+stylistically decorating technical terms.
+.Pp
+See also
+.Sx \&Bf ,
+.Sx \&Em ,
+.Sx \&Li ,
+and
+.Sx \&No .
+.Ss \&Ta
+Table cell separator in
+.Sx \&Bl Fl column
+lists; can only be used below
+.Sx \&It .
+.Ss \&Tn
+Format a tradename.
+.Pp
+Since this macro is often implemented to use a small caps font,
+it has historically been used for acronyms (like ASCII) as well.
+Such usage is not recommended because it would use the same macro
+sometimes for semantical annotation, sometimes for physical formatting.
+.Pp
+Examples:
+.Dl \&.Tn IBM
+.Ss \&Ud
+Prints out
+.Dq currently under development.
+.Ss \&Ux
+Format the UNIX name.
+Accepts no argument.
+.Pp
+Examples:
+.Dl \&.Ux
+.Pp
+See also
+.Sx \&At ,
+.Sx \&Bsx ,
+.Sx \&Bx ,
+.Sx \&Dx ,
+.Sx \&Fx ,
+.Sx \&Nx ,
+and
+.Sx \&Ox .
+.Ss \&Va
+A variable name.
+.Pp
+Examples:
+.Dl \&.Va foo
+.Dl \&.Va const char *bar ;
+.Ss \&Vt
+A variable type.
+This is also used for indicating global variables in the
+.Em SYNOPSIS
+section, in which case a variable name is also specified.
+Note that it accepts
+.Sx Block partial-implicit
+syntax when invoked as the first macro on an input line in the
+.Em SYNOPSIS
+section, else it accepts ordinary
+.Sx In-line
+syntax.
+In the former case, this macro starts a new output line,
+and a blank line is inserted in front if there is a preceding
+function definition or include directive.
+.Pp
+Note that this should not be confused with
+.Sx \&Ft ,
+which is used for function return types.
+.Pp
+Examples:
+.Dl \&.Vt unsigned char
+.Dl \&.Vt extern const char * const sys_signame[] \&;
+.Pp
+See also
+.Sx MANUAL STRUCTURE
+and
+.Sx \&Va .
+.Ss \&Xc
+Close a scope opened by
+.Sx \&Xo .
+.Ss \&Xo
+Extend the header of an
+.Sx \&It
+macro or the body of a partial-implicit block macro
+beyond the end of the input line.
+This macro originally existed to work around the 9-argument limit
+of historic
+.Xr roff 5 .
+.Ss \&Xr
+Link to another manual
+.Pq Qq cross-reference .
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Xr Ar name section
+.Pp
+The
+.Ar name
+and
+.Ar section
+are the name and section of the linked manual.
+If
+.Ar section
+is followed by non-punctuation, an
+.Sx \&Ns
+is inserted into the token stream.
+This behaviour is for compatibility with
+GNU troff.
+.Pp
+Examples:
+.Dl \&.Xr mandoc 1
+.Dl \&.Xr mandoc 1 \&;
+.Dl \&.Xr mandoc 1 \&Ns s behaviour
+.Ss \&br
+Emits a line-break.
+This macro should not be used; it is implemented for compatibility with
+historical manuals.
+.Pp
+Consider using
+.Sx \&Pp
+in the event of natural paragraph breaks.
+.Ss \&sp
+Emits vertical space.
+This macro should not be used; it is implemented for compatibility with
+historical manuals.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&sp Op Ar height
+.Pp
+The
+.Ar height
+argument must be formatted as described in
+.Sx Scaling Widths .
+If unspecified,
+.Sx \&sp
+asserts a single vertical space.
+.Sh MACRO SYNTAX
+The syntax of a macro depends on its classification.
+In this section,
+.Sq \-arg
+refers to macro arguments, which may be followed by zero or more
+.Sq parm
+parameters;
+.Sq \&Yo
+opens the scope of a macro; and if specified,
+.Sq \&Yc
+closes it out.
+.Pp
+The
+.Em Callable
+column indicates that the macro may also be called by passing its name
+as an argument to another macro.
+For example,
+.Sq \&.Op \&Fl O \&Ar file
+produces
+.Sq Op Fl O Ar file .
+To prevent a macro call and render the macro name literally,
+escape it by prepending a zero-width space,
+.Sq \e& .
+For example,
+.Sq \&Op \e&Fl O
+produces
+.Sq Op \&Fl O .
+If a macro is not callable but its name appears as an argument
+to another macro, it is interpreted as opaque text.
+For example,
+.Sq \&.Fl \&Sh
+produces
+.Sq Fl \&Sh .
+.Pp
+The
+.Em Parsed
+column indicates whether the macro may call other macros by receiving
+their names as arguments.
+If a macro is not parsed but the name of another macro appears
+as an argument, it is interpreted as opaque text.
+.Pp
+The
+.Em Scope
+column, if applicable, describes closure rules.
+.Ss Block full-explicit
+Multi-line scope closed by an explicit closing macro.
+All macros contains bodies; only
+.Sx \&Bf
+and
+.Pq optionally
+.Sx \&Bl
+contain a head.
+.Bd -literal -offset indent
+\&.Yo \(lB\-arg \(lBparm...\(rB\(rB \(lBhead...\(rB
+\(lBbody...\(rB
+\&.Yc
+.Ed
+.Bl -column "MacroX" "CallableX" "ParsedX" "closed by XXX" -offset indent
+.It Em Macro Ta Em Callable Ta Em Parsed Ta Em Scope
+.It Sx \&Bd  Ta    \&No     Ta    \&No     Ta    closed by Sx \&Ed
+.It Sx \&Bf  Ta    \&No     Ta    \&No     Ta    closed by Sx \&Ef
+.It Sx \&Bk  Ta    \&No     Ta    \&No     Ta    closed by Sx \&Ek
+.It Sx \&Bl  Ta    \&No     Ta    \&No     Ta    closed by Sx \&El
+.It Sx \&Ed  Ta    \&No     Ta    \&No     Ta    opened by Sx \&Bd
+.It Sx \&Ef  Ta    \&No     Ta    \&No     Ta    opened by Sx \&Bf
+.It Sx \&Ek  Ta    \&No     Ta    \&No     Ta    opened by Sx \&Bk
+.It Sx \&El  Ta    \&No     Ta    \&No     Ta    opened by Sx \&Bl
+.El
+.Ss Block full-implicit
+Multi-line scope closed by end-of-file or implicitly by another macro.
+All macros have bodies; some
+.Po
+.Sx \&It Fl bullet ,
+.Fl hyphen ,
+.Fl dash ,
+.Fl enum ,
+.Fl item
+.Pc
+don't have heads; only one
+.Po
+.Sx \&It
+in
+.Sx \&Bl Fl column
+.Pc
+has multiple heads.
+.Bd -literal -offset indent
+\&.Yo \(lB\-arg \(lBparm...\(rB\(rB \(lBhead... \(lBTa head...\(rB\(rB
+\(lBbody...\(rB
+.Ed
+.Bl -column "MacroX" "CallableX" "ParsedX" "closed by XXXXXXXXXXX" -offset indent
+.It Em Macro Ta Em Callable Ta Em Parsed Ta Em Scope
+.It Sx \&It Ta \&No Ta Yes  Ta closed by Sx \&It , Sx \&El
+.It Sx \&Nd Ta \&No Ta \&No Ta closed by Sx \&Sh
+.It Sx \&Nm Ta \&No Ta Yes  Ta closed by Sx \&Nm , Sx \&Sh , Sx \&Ss
+.It Sx \&Sh Ta \&No Ta Yes  Ta closed by Sx \&Sh
+.It Sx \&Ss Ta \&No Ta Yes  Ta closed by Sx \&Sh , Sx \&Ss
+.El
+.Pp
+Note that the
+.Sx \&Nm
+macro is a
+.Sx Block full-implicit
+macro only when invoked as the first macro
+in a
+.Em SYNOPSIS
+section line, else it is
+.Sx In-line .
+.Ss Block partial-explicit
+Like block full-explicit, but also with single-line scope.
+Each has at least a body and, in limited circumstances, a head
+.Po
+.Sx \&Fo ,
+.Sx \&Eo
+.Pc
+and/or tail
+.Pq Sx \&Ec .
+.Bd -literal -offset indent
+\&.Yo \(lB\-arg \(lBparm...\(rB\(rB \(lBhead...\(rB
+\(lBbody...\(rB
+\&.Yc \(lBtail...\(rB
+
+\&.Yo \(lB\-arg \(lBparm...\(rB\(rB \(lBhead...\(rB \
+\(lBbody...\(rB \&Yc \(lBtail...\(rB
+.Ed
+.Bl -column "MacroX" "CallableX" "ParsedX" "closed by XXXX" -offset indent
+.It Em Macro Ta Em Callable Ta Em Parsed Ta Em Scope
+.It Sx \&Ac  Ta    Yes      Ta    Yes      Ta    opened by Sx \&Ao
+.It Sx \&Ao  Ta    Yes      Ta    Yes      Ta    closed by Sx \&Ac
+.It Sx \&Bc  Ta    Yes      Ta    Yes      Ta    closed by Sx \&Bo
+.It Sx \&Bo  Ta    Yes      Ta    Yes      Ta    opened by Sx \&Bc
+.It Sx \&Brc Ta    Yes      Ta    Yes      Ta    opened by Sx \&Bro
+.It Sx \&Bro Ta    Yes      Ta    Yes      Ta    closed by Sx \&Brc
+.It Sx \&Dc  Ta    Yes      Ta    Yes      Ta    opened by Sx \&Do
+.It Sx \&Do  Ta    Yes      Ta    Yes      Ta    closed by Sx \&Dc
+.It Sx \&Ec  Ta    Yes      Ta    Yes      Ta    opened by Sx \&Eo
+.It Sx \&Eo  Ta    Yes      Ta    Yes      Ta    closed by Sx \&Ec
+.It Sx \&Fc  Ta    Yes      Ta    Yes      Ta    opened by Sx \&Fo
+.It Sx \&Fo  Ta    \&No     Ta    \&No     Ta    closed by Sx \&Fc
+.It Sx \&Oc  Ta    Yes      Ta    Yes      Ta    closed by Sx \&Oo
+.It Sx \&Oo  Ta    Yes      Ta    Yes      Ta    opened by Sx \&Oc
+.It Sx \&Pc  Ta    Yes      Ta    Yes      Ta    closed by Sx \&Po
+.It Sx \&Po  Ta    Yes      Ta    Yes      Ta    opened by Sx \&Pc
+.It Sx \&Qc  Ta    Yes      Ta    Yes      Ta    opened by Sx \&Oo
+.It Sx \&Qo  Ta    Yes      Ta    Yes      Ta    closed by Sx \&Oc
+.It Sx \&Re  Ta    \&No     Ta    \&No     Ta    opened by Sx \&Rs
+.It Sx \&Rs  Ta    \&No     Ta    \&No     Ta    closed by Sx \&Re
+.It Sx \&Sc  Ta    Yes      Ta    Yes      Ta    opened by Sx \&So
+.It Sx \&So  Ta    Yes      Ta    Yes      Ta    closed by Sx \&Sc
+.It Sx \&Xc  Ta    Yes      Ta    Yes      Ta    opened by Sx \&Xo
+.It Sx \&Xo  Ta    Yes      Ta    Yes      Ta    closed by Sx \&Xc
+.El
+.Ss Block partial-implicit
+Like block full-implicit, but with single-line scope closed by the
+end of the line.
+.Bd -literal -offset indent
+\&.Yo \(lB\-arg \(lBval...\(rB\(rB \(lBbody...\(rB \(lBres...\(rB
+.Ed
+.Bl -column "MacroX" "CallableX" "ParsedX" -offset indent
+.It Em Macro Ta Em Callable Ta Em Parsed
+.It Sx \&Aq  Ta    Yes      Ta    Yes
+.It Sx \&Bq  Ta    Yes      Ta    Yes
+.It Sx \&Brq Ta    Yes      Ta    Yes
+.It Sx \&D1  Ta    \&No     Ta    \&Yes
+.It Sx \&Dl  Ta    \&No     Ta    Yes
+.It Sx \&Dq  Ta    Yes      Ta    Yes
+.It Sx \&Op  Ta    Yes      Ta    Yes
+.It Sx \&Pq  Ta    Yes      Ta    Yes
+.It Sx \&Ql  Ta    Yes      Ta    Yes
+.It Sx \&Qq  Ta    Yes      Ta    Yes
+.It Sx \&Sq  Ta    Yes      Ta    Yes
+.It Sx \&Vt  Ta    Yes      Ta    Yes
+.El
+.Pp
+Note that the
+.Sx \&Vt
+macro is a
+.Sx Block partial-implicit
+only when invoked as the first macro
+in a
+.Em SYNOPSIS
+section line, else it is
+.Sx In-line .
+.Ss Special block macro
+The
+.Sx \&Ta
+macro can only be used below
+.Sx \&It
+in
+.Sx \&Bl Fl column
+lists.
+It delimits blocks representing table cells;
+these blocks have bodies, but no heads.
+.Bl -column "MacroX" "CallableX" "ParsedX" "closed by XXXX" -offset indent
+.It Em Macro Ta Em Callable Ta Em Parsed Ta Em Scope
+.It Sx \&Ta  Ta    Yes      Ta    Yes    Ta closed by Sx \&Ta , Sx \&It
+.El
+.Ss In-line
+Closed by the end of the line, fixed argument lengths,
+and/or subsequent macros.
+In-line macros have only text children.
+If a number (or inequality) of arguments is
+.Pq n ,
+then the macro accepts an arbitrary number of arguments.
+.Bd -literal -offset indent
+\&.Yo \(lB\-arg \(lBval...\(rB\(rB \(lBargs...\(rB \(lBres...\(rB
+
+\&.Yo \(lB\-arg \(lBval...\(rB\(rB \(lBargs...\(rB Yc...
+
+\&.Yo \(lB\-arg \(lBval...\(rB\(rB arg0 arg1 argN
+.Ed
+.Bl -column "MacroX" "CallableX" "ParsedX" "Arguments" -offset indent
+.It Em Macro Ta Em Callable Ta Em Parsed Ta Em Arguments
+.It Sx \&%A  Ta    \&No     Ta    \&No     Ta    >0
+.It Sx \&%B  Ta    \&No     Ta    \&No     Ta    >0
+.It Sx \&%C  Ta    \&No     Ta    \&No     Ta    >0
+.It Sx \&%D  Ta    \&No     Ta    \&No     Ta    >0
+.It Sx \&%I  Ta    \&No     Ta    \&No     Ta    >0
+.It Sx \&%J  Ta    \&No     Ta    \&No     Ta    >0
+.It Sx \&%N  Ta    \&No     Ta    \&No     Ta    >0
+.It Sx \&%O  Ta    \&No     Ta    \&No     Ta    >0
+.It Sx \&%P  Ta    \&No     Ta    \&No     Ta    >0
+.It Sx \&%Q  Ta    \&No     Ta    \&No     Ta    >0
+.It Sx \&%R  Ta    \&No     Ta    \&No     Ta    >0
+.It Sx \&%T  Ta    \&No     Ta    \&No     Ta    >0
+.It Sx \&%U  Ta    \&No     Ta    \&No     Ta    >0
+.It Sx \&%V  Ta    \&No     Ta    \&No     Ta    >0
+.It Sx \&Ad  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&An  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Ap  Ta    Yes      Ta    Yes      Ta    0
+.It Sx \&Ar  Ta    Yes      Ta    Yes      Ta    n
+.It Sx \&At  Ta    Yes      Ta    Yes      Ta    1
+.It Sx \&Bsx Ta    Yes      Ta    Yes      Ta    n
+.It Sx \&Bt  Ta    \&No     Ta    \&No     Ta    0
+.It Sx \&Bx  Ta    Yes      Ta    Yes      Ta    n
+.It Sx \&Cd  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Cm  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Db  Ta    \&No     Ta    \&No     Ta    1
+.It Sx \&Dd  Ta    \&No     Ta    \&No     Ta    n
+.It Sx \&Dt  Ta    \&No     Ta    \&No     Ta    n
+.It Sx \&Dv  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Dx  Ta    Yes      Ta    Yes      Ta    n
+.It Sx \&Em  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&En  Ta    \&No     Ta    \&No     Ta    0
+.It Sx \&Er  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Es  Ta    \&No     Ta    \&No     Ta    0
+.It Sx \&Ev  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Ex  Ta    \&No     Ta    \&No     Ta    n
+.It Sx \&Fa  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Fd  Ta    \&No     Ta    \&No     Ta    >0
+.It Sx \&Fl  Ta    Yes      Ta    Yes      Ta    n
+.It Sx \&Fn  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Fr  Ta    \&No     Ta    \&No     Ta    n
+.It Sx \&Ft  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Fx  Ta    Yes      Ta    Yes      Ta    n
+.It Sx \&Hf  Ta    \&No     Ta    \&No     Ta    n
+.It Sx \&Ic  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&In  Ta    \&No     Ta    \&No     Ta    1
+.It Sx \&Lb  Ta    \&No     Ta    \&No     Ta    1
+.It Sx \&Li  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Lk  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Lp  Ta    \&No     Ta    \&No     Ta    0
+.It Sx \&Ms  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Mt  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Nm  Ta    Yes      Ta    Yes      Ta    n
+.It Sx \&No  Ta    Yes      Ta    Yes      Ta    0
+.It Sx \&Ns  Ta    Yes      Ta    Yes      Ta    0
+.It Sx \&Nx  Ta    Yes      Ta    Yes      Ta    n
+.It Sx \&Os  Ta    \&No     Ta    \&No     Ta    n
+.It Sx \&Ot  Ta    \&No     Ta    \&No     Ta    n
+.It Sx \&Ox  Ta    Yes      Ta    Yes      Ta    n
+.It Sx \&Pa  Ta    Yes      Ta    Yes      Ta    n
+.It Sx \&Pf  Ta    Yes      Ta    Yes      Ta    1
+.It Sx \&Pp  Ta    \&No     Ta    \&No     Ta    0
+.It Sx \&Rv  Ta    \&No     Ta    \&No     Ta    n
+.It Sx \&Sm  Ta    \&No     Ta    \&No     Ta    1
+.It Sx \&St  Ta    \&No     Ta    Yes      Ta    1
+.It Sx \&Sx  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Sy  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Tn  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Ud  Ta    \&No     Ta    \&No     Ta    0
+.It Sx \&Ux  Ta    Yes      Ta    Yes      Ta    n
+.It Sx \&Va  Ta    Yes      Ta    Yes      Ta    n
+.It Sx \&Vt  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&Xr  Ta    Yes      Ta    Yes      Ta    >0
+.It Sx \&br  Ta    \&No     Ta    \&No     Ta    0
+.It Sx \&sp  Ta    \&No     Ta    \&No     Ta    1
+.El
+.Ss Delimiters
+When a macro argument consists of one single input character
+considered as a delimiter, the argument gets special handling.
+This does not apply when delimiters appear in arguments containing
+more than one character.
+Consequently, to prevent special handling and just handle it
+like any other argument, a delimiter can be escaped by prepending
+a zero-width space
+.Pq Sq \e& .
+In text lines, delimiters never need escaping, but may be used
+as normal punctuation.
+.Pp
+For many macros, when the leading arguments are opening delimiters,
+these delimiters are put before the macro scope,
+and when the trailing arguments are closing delimiters,
+these delimiters are put after the macro scope.
+For example,
+.Pp
+.D1 Pf \. \&Aq "( [ word ] ) ."
+.Pp
+renders as:
+.Pp
+.D1 Aq ( [ word ] ) .
+.Pp
+Opening delimiters are:
+.Pp
+.Bl -tag -width Ds -offset indent -compact
+.It \&(
+left parenthesis
+.It \&[
+left bracket
+.El
+.Pp
+Closing delimiters are:
+.Pp
+.Bl -tag -width Ds -offset indent -compact
+.It \&.
+period
+.It \&,
+comma
+.It \&:
+colon
+.It \&;
+semicolon
+.It \&)
+right parenthesis
+.It \&]
+right bracket
+.It \&?
+question mark
+.It \&!
+exclamation mark
+.El
+.Pp
+Note that even a period preceded by a backslash
+.Pq Sq \e.\&
+gets this special handling; use
+.Sq \e&.
+to prevent that.
+.Pp
+Many in-line macros interrupt their scope when they encounter
+delimiters, and resume their scope when more arguments follow that
+are not delimiters.
+For example,
+.Pp
+.D1 Pf \. \&Fl "a ( b | c \e*(Ba d ) e"
+.Pp
+renders as:
+.Pp
+.D1 Fl a ( b | c \*(Ba d ) e
+.Pp
+This applies to both opening and closing delimiters,
+and also to the middle delimiter:
+.Pp
+.Bl -tag -width Ds -offset indent -compact
+.It \&|
+vertical bar
+.El
+.Pp
+As a special case, the predefined string \e*(Ba is handled and rendered
+in the same way as a plain
+.Sq \&|
+character.
+Using this predefined string is not recommended in new manuals.
+.Ss Font handling
+In
+.Nm
+documents, usage of semantic markup is recommended in order to have
+proper fonts automatically selected; only when no fitting semantic markup
+is available, consider falling back to
+.Sx Physical markup
+macros.
+Whenever any
+.Nm
+macro switches the
+.Xr roff 5
+font mode, it will automatically restore the previous font when exiting
+its scope.
+Manually switching the font using the
+.Xr roff 5
+.Ql \ef
+font escape sequences is never required.
+.Sh COMPATIBILITY
+This section documents compatibility between mandoc and other other
+troff implementations, at this time limited to GNU troff
+.Pq Qq groff .
+The term
+.Qq historic groff
+refers to groff versions before 1.17,
+which featured a significant update of the
+.Pa doc.tmac
+file.
+.Pp
+Heirloom troff, the other significant troff implementation accepting
+\-mdoc, is similar to historic groff.
+.Pp
+The following problematic behaviour is found in groff:
+.ds hist (Historic groff only.)
+.Pp
+.Bl -dash -compact
+.It
+Display macros
+.Po
+.Sx \&Bd ,
+.Sx \&Dl ,
+and
+.Sx \&D1
+.Pc
+may not be nested.
+\*[hist]
+.It
+.Sx \&At
+with unknown arguments produces no output at all.
+\*[hist]
+Newer groff and mandoc print
+.Qq AT&T UNIX
+and the arguments.
+.It
+.Sx \&Bl Fl column
+does not recognise trailing punctuation characters when they immediately
+precede tabulator characters, but treats them as normal text and
+outputs a space before them.
+.It
+.Sx \&Bd Fl ragged compact
+does not start a new line.
+\*[hist]
+.It
+.Sx \&Dd
+with non-standard arguments behaves very strangely.
+When there are three arguments, they are printed verbatim.
+Any other number of arguments is replaced by the current date,
+but without any arguments the string
+.Dq Epoch
+is printed.
+.It
+.Sx \&Fl
+does not print a dash for an empty argument.
+\*[hist]
+.It
+.Sx \&Fn
+does not start a new line unless invoked as the line macro in the
+.Em SYNOPSIS
+section.
+\*[hist]
+.It
+.Sx \&Fo
+with
+.Pf non- Sx \&Fa
+children causes inconsistent spacing between arguments.
+In mandoc, a single space is always inserted between arguments.
+.It
+.Sx \&Ft
+in the
+.Em SYNOPSIS
+causes inconsistent vertical spacing, depending on whether a prior
+.Sx \&Fn
+has been invoked.
+See
+.Sx \&Ft
+and
+.Sx \&Fn
+for the normalised behaviour in mandoc.
+.It
+.Sx \&In
+ignores additional arguments and is not treated specially in the
+.Em SYNOPSIS .
+\*[hist]
+.It
+.Sx \&It
+sometimes requires a
+.Fl nested
+flag.
+\*[hist]
+In new groff and mandoc, any list may be nested by default and
+.Fl enum
+lists will restart the sequence only for the sub-list.
+.It
+.Sx \&Li
+followed by a delimiter is incorrectly used in some manuals
+instead of properly quoting that character, which sometimes works with
+historic groff.
+.It
+.Sx \&Lk
+only accepts a single link-name argument; the remainder is misformatted.
+.It
+.Sx \&Pa
+does not format its arguments when used in the FILES section under
+certain list types.
+.It
+.Sx \&Ta
+can only be called by other macros, but not at the beginning of a line.
+.It
+.Sx \&%C
+is not implemented.
+.It
+Historic groff only allows up to eight or nine arguments per macro input
+line, depending on the exact situation.
+Providing more arguments causes garbled output.
+The number of arguments on one input line is not limited with mandoc.
+.It
+Historic groff has many un-callable macros.
+Most of these (excluding some block-level macros) are callable
+in new groff and mandoc.
+.It
+.Sq \(ba
+(vertical bar) is not fully supported as a delimiter.
+\*[hist]
+.It
+.Sq \ef
+.Pq font face
+and
+.Sq \ef
+.Pq font family face
+.Sx Text Decoration
+escapes behave irregularly when specified within line-macro scopes.
+.It
+Negative scaling units return to prior lines.
+Instead, mandoc truncates them to zero.
+.El
+.Pp
+The following features are unimplemented in mandoc:
+.Pp
+.Bl -dash -compact
+.It
+.Sx \&Bd
+.Fl file Ar file .
+.It
+.Sx \&Bd
+.Fl offset Ar center
+and
+.Fl offset Ar right .
+Groff does not implement centred and flush-right rendering either,
+but produces large indentations.
+.It
+The
+.Sq \eh
+.Pq horizontal position ,
+.Sq \ev
+.Pq vertical position ,
+.Sq \em
+.Pq text colour ,
+.Sq \eM
+.Pq text filling colour ,
+.Sq \ez
+.Pq zero-length character ,
+.Sq \ew
+.Pq string length ,
+.Sq \ek
+.Pq horizontal position marker ,
+.Sq \eo
+.Pq text overstrike ,
+and
+.Sq \es
+.Pq text size
+escape sequences are all discarded in mandoc.
+.It
+The
+.Sq \ef
+scaling unit is accepted by mandoc, but rendered as the default unit.
+.It
+In quoted literals, groff allows pairwise double-quotes to produce a
+standalone double-quote in formatted output.
+This is not supported by mandoc.
+.El
+.Sh SEE ALSO
+.Xr man 1 ,
+.Xr mandoc 1 ,
+.Xr eqn 5 ,
+.Xr man 5 ,
+.Xr mandoc_char 5 ,
+.Xr roff 5 ,
+.Xr tbl 5
+.Sh HISTORY
+The
+.Nm
+language first appeared as a troff macro package in
+.Bx 4.4 .
+It was later significantly updated by Werner Lemberg and Ruslan Ermilov
+in groff-1.17.
+The standalone implementation that is part of the
+.Xr mandoc 1
+utility written by Kristaps Dzonsons appeared in
+.Ox 4.6 .
+in July, 2014.
+.Sh AUTHORS
+The
+.Nm
+reference was written by
+.An Kristaps Dzonsons ,
+.Mt kristaps@bsd.lv .
--- /dev/null	Wed Jul 16 14:05:09 2014
+++ new/usr/src/man/man5/tbl.5	Wed Jul 16 14:05:09 2014
@@ -0,0 +1,349 @@
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.\"
+.\" Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+.\" Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+.\"
+.Dd Sep 3, 2011
+.Dt TBL 5
+.Os
+.Sh NAME
+.Nm tbl
+.Nd tbl language reference for mandoc
+.Sh DESCRIPTION
+The
+.Nm tbl
+language is a table-formatting language.
+It is used within
+.Xr mdoc 5
+and
+.Xr man 5
+.Ux
+manual pages.
+This manual describes the subset of the
+.Nm
+language accepted by the
+.Xr mandoc 1
+utility.
+.Pp
+Tables within
+.Xr mdoc 5
+or
+.Xr man 5
+are enclosed by the
+.Sq TS
+and
+.Sq TE
+macro tags, whose precise syntax is documented in
+.Xr roff 5 .
+Tables consist of a series of options on a single line, followed by the
+table layout, followed by data.
+.Pp
+For example, the following creates a boxed table with digits centred in
+the cells.
+.Bd -literal -offset indent
+\&.TS
+tab(:) box;
+c5 c5 c5.
+1:2:3
+4:5:6
+\&.TE
+.Ed
+.Pp
+When formatted, the following output is produced:
+.Bd -filled -offset indent -compact
+.TS
+tab(:) box;
+c5 c5 c5.
+1:2:3
+4:5:6
+.TE
+.Ed
+.Pp
+The
+.Nm
+implementation in
+.Xr mandoc 1
+is
+.Ud
+.Sh TABLE STRUCTURE
+Tables are enclosed by the
+.Sq TS
+and
+.Sq TE
+.Xr roff 5
+macros.
+A table consists of an optional single line of table
+.Sx Options
+terminated by a semicolon, followed by one or more lines of
+.Sx Layout
+specifications terminated by a period, then
+.Sx Data .
+All input must be 7-bit ASCII.
+Example:
+.Bd -literal -offset indent
+\&.TS
+box tab(:);
+c | c
+| c | c.
+1:2
+3:4
+\&.TE
+.Ed
+.Pp
+Table data is
+.Em pre-processed ,
+that is, data rows are parsed then inserted into the underlying stream
+of input data.
+This allows data rows to be interspersed by arbitrary
+.Xr roff 5 ,
+.Xr mdoc 5 ,
+and
+.Xr man 5
+macros such as
+.Bd -literal -offset indent
+\&.TS
+tab(:);
+c c c.
+1:2:3
+\&.Ao
+3:2:1
+\&.Ac
+\&.TE
+.Ed
+.Pp
+in the case of
+.Xr mdoc 5
+or
+.Bd -literal -offset indent
+\&.TS
+tab(:);
+c c c.
+\&.ds ab 2
+1:\e*(ab:3
+\&.I
+3:2:1
+\&.TE
+.Ed
+.Pp
+in the case of
+.Xr man 5 .
+.Ss Options
+The first line of a table consists of space-separated option keys and
+modifiers terminated by a semicolon.
+If the first line does not have a terminating semicolon, it is assumed
+that no options are specified and instead a
+.Sx Layout
+is processed.
+Some options accept arguments enclosed by parenthesis.
+The following case-insensitive options are available:
+.Bl -tag -width Ds
+.It Cm center
+This option is not supported by
+.Xr mandoc 1 .
+This may also be invoked with
+.Cm centre .
+.It Cm delim
+Accepts a two-character argument.
+This option is not supported by
+.Xr mandoc 1 .
+.It Cm expand
+This option is not supported by
+.Xr mandoc 1 .
+.It Cm box
+Draw a single-line box around the table.
+This may also be invoked with
+.Cm frame .
+.It Cm doublebox
+Draw a double-line box around the table.
+This may also be invoked with
+.Cm doubleframe .
+.It Cm allbox
+This option is not supported by
+.Xr mandoc 1 .
+.It Cm tab
+Accepts a single-character argument.
+This character is used as a delimiter between data cells, which otherwise
+defaults to the tab character.
+.It Cm linesize
+Accepts a natural number (all digits).
+This option is not supported by
+.Xr mandoc 1 .
+.It Cm nokeep
+This option is not supported by
+.Xr mandoc 1 .
+.It Cm decimalpoint
+Accepts a single-character argument.
+This character will be used as the decimal point with the
+.Cm n
+layout key.
+.It Cm nospaces
+This option is not supported by
+.Xr mandoc 1 .
+.El
+.Ss Layout
+The table layout follows
+.Sx Options
+or a
+.Sq \&T&
+macro invocation.
+Layout specifies how data rows are displayed on output.
+Each layout line corresponds to a line of data; the last layout line
+applies to all remaining data lines.
+Layout lines may also be separated by a comma.
+Each layout cell consists of one of the following case-insensitive keys:
+.Bl -tag -width Ds
+.It Cm c
+Centre a literal string within its column.
+.It Cm r
+Right-justify a literal string within its column.
+.It Cm l
+Left-justify a literal string within its column.
+.It Cm n
+Justify a number around its last decimal point.
+If the decimal point is not found on the number, it's assumed to trail
+the number.
+.It Cm s
+Horizontally span columns from the last
+.No non- Ns Cm s
+data cell.
+It is an error if spanning columns follow a
+.Cm \-
+or
+.Cm \(ba
+cell, or come first.
+This option is not supported by
+.Xr mandoc 1 .
+.It Cm a
+Left-justify a literal string and pad with one space.
+.It Cm ^
+Vertically span rows from the last
+.No non- Ns Cm ^
+data cell.
+It is an error to invoke a vertical span on the first layout row.
+Unlike a horizontal spanner, you must specify an empty cell (if it not
+empty, the data is discarded) in the corresponding data cell.
+.It Cm \-
+Replace the data cell (its contents will be lost) with a single
+horizontal line.
+This may also be invoked with
+.Cm _ .
+.It Cm =
+Replace the data cell (its contents will be lost) with a double
+horizontal line.
+.It Cm \(ba
+Emit a vertical bar instead of data.
+.It Cm \(ba\(ba
+Emit a double-vertical bar instead of data.
+.El
+.Pp
+Keys may be followed by a set of modifiers.
+A modifier is either a modifier key or a natural number for specifying
+the minimum width of a column.
+The following case-insensitive modifier keys are available:
+.Cm z ,
+.Cm u ,
+.Cm e ,
+.Cm t ,
+.Cm d ,
+.Cm b ,
+.Cm i ,
+.Cm r ,
+and
+.Cm f
+.Po
+followed by
+.Cm b ,
+.Cm i ,
+.Cm r ,
+.Cm 3 ,
+.Cm 2 ,
+or
+.Cm 1
+.Pc .
+All of these are ignored by
+.Xr mandoc 1 .
+.Pp
+For example, the following layout specifies a centre-justified column of
+minimum width 10, followed by vertical bar, followed by a left-justified
+column of minimum width 10, another vertical bar, then a column
+justified about the decimal point in numbers:
+.Pp
+.Dl c10 | l10 | n
+.Ss Data
+The data section follows the last layout row.
+By default, cells in a data section are delimited by a tab.
+This behaviour may be changed with the
+.Cm tab
+option.
+If
+.Cm _
+or
+.Cm =
+is specified, a single or double line, respectively, is drawn across the
+data field.
+If
+.Cm \e-
+or
+.Cm \e=
+is specified, a line is drawn within the data field (i.e. terminating
+within the cell and not draw to the border).
+If the last cell of a line is
+.Cm T{ ,
+all subsequent lines are included as part of the cell until
+.Cm T}
+is specified as its own data cell.
+It may then be followed by a tab
+.Pq or as designated by Cm tab
+or an end-of-line to terminate the row.
+.Sh COMPATIBILITY
+This section documents compatibility between mandoc and other
+.Nm
+implementations, at this time limited to GNU tbl.
+.Pp
+.Bl -dash -compact
+.It
+In GNU tbl, comments and macros are disallowed prior to the data block
+of a table.
+The
+.Xr mandoc 1
+implementation allows them.
+.El
+.Sh SEE ALSO
+.Xr mandoc 1 ,
+.Xr man 5 ,
+.Xr mandoc_char 5 ,
+.Xr mdoc 5 ,
+.Xr roff 5
+.Rs
+.%A M. E. Lesk
+.%T Tbl\(emA Program to Format Tables
+.%D June 11, 1976
+.Re
+.Sh HISTORY
+The tbl utility, a preprocessor for troff, was originally written by M.
+E. Lesk at Bell Labs in 1975.
+The GNU reimplementation of tbl, part of the groff package, was released
+in 1990 by James Clark.
+A standalone tbl implementation was written by Kristaps Dzonsons in
+2010.
+This formed the basis of the implementation that is part of the
+.Xr mandoc 1
+utility.
+.Sh AUTHORS
+This
+.Nm
+reference was written by
+.An Kristaps Dzonsons ,
+.Mt kristaps@bsd.lv .
--- /dev/null	Wed Jul 16 14:05:09 2014
+++ new/usr/src/pkg/manifests/system-man.mf	Wed Jul 16 14:05:09 2014
@@ -0,0 +1,64 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+#
+
+set name=pkg.fmri value=pkg:/system/man@$(PKGVERS)
+set name=pkg.description \
+    value="utilities for display and formatting of reference manual pages"
+set name=pkg.summary value="Reference Manual Pages Tools"
+set name=info.classification \
+    value="org.opensolaris.category.2008:System/Text Tools"
+set name=variant.arch value=$(ARCH)
+dir path=usr/bin
+dir path=usr/lib
+dir path=usr/share
+dir path=usr/share/man
+dir path=usr/share/man/man1
+dir path=usr/share/man/man1m
+dir path=usr/share/man/man5
+file path=usr/bin/man mode=0555
+file path=usr/bin/mandoc mode=0555
+file path=usr/lib/mandoc_preconv mode=0555
+file path=usr/share/man/man1/apropos.1
+file path=usr/share/man/man1/man.1
+file path=usr/share/man/man1/mandoc.1
+file path=usr/share/man/man1m/catman.1m
+file path=usr/share/man/man5/eqn.5
+file path=usr/share/man/man5/man.5
+file path=usr/share/man/man5/mandoc_char.5
+file path=usr/share/man/man5/mandoc_roff.5
+file path=usr/share/man/man5/mdoc.5
+file path=usr/share/man/man5/tbl.5
+hardlink path=usr/bin/apropos target=../../usr/bin/man
+hardlink path=usr/bin/catman target=../../usr/bin/man
+hardlink path=usr/bin/whatis target=../../usr/bin/man
+hardlink path=usr/lib/makewhatis target=../../usr/bin/man
+license lic_CDDL license=lic_CDDL
+license usr/src/cmd/man/THIRDPARTYLICENSE \
+    license=usr/src/cmd/man/THIRDPARTYLICENSE
+license usr/src/cmd/mandoc/THIRDPARTYLICENSE \
+    license=usr/src/cmd/mandoc/THIRDPARTYLICENSE
+link path=usr/man target=./share/man
+link path=usr/share/man/man1/whatis.1 target=apropos.1
+# arguably we also need lp, for man -t support, but really we don't
+# want to make this mandatory, so we don't express teh dependency here.
+# gzcat/bzcat are used for displaying compressed manpages.  However,
+# as we don't format such pages this way by default, lets leave the
+# dependency out.
+#depend fmri=compress/bzip2 type=require
+#depend fmri=compress/gzip type=require
+# less is the default (per user environment) pager.  We really should just
+# import this into illumos-gate.
+depend fmri=text/less type=require
--- old/usr/src/pkg/manifests/text-doctools.mf	Wed Jul 16 14:05:09 2014
+++ new/usr/src/pkg/manifests/text-doctools.mf	Wed Jul 16 14:05:09 2014
@@ -22,8 +22,10 @@
 #
 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
 #
 
+# man moved to system/man
 set name=pkg.fmri value=pkg:/text/doctools@$(PKGVERS)
 set name=pkg.description \
     value="utilities and fonts for development, display, and production of documentation such as manual pages (nroff/troff)"
@@ -50,7 +52,6 @@
 dir path=usr/share/man/man1m
 dir path=usr/share/man/man5
 file path=usr/bin/addbib mode=0555
-file path=usr/bin/apropos mode=0555
 file path=usr/bin/checkeq mode=0555
 file path=usr/bin/checknr mode=0555
 file path=usr/bin/deroff mode=0555
@@ -228,8 +229,6 @@
 file path=usr/lib/font/devpost/charlib/~ group=lp mode=0444
 file path=usr/lib/font/devpost/fontmaps/post group=lp mode=0444
 file path=usr/lib/font/makedev group=lp mode=0555
-file path=usr/lib/getNAME mode=0555
-file path=usr/lib/makewhatis mode=0555
 file path=usr/lib/refer/hunt mode=0555
 file path=usr/lib/refer/inv mode=0555
 file path=usr/lib/refer/mkey mode=0555
@@ -294,7 +293,6 @@
 file path=usr/share/lib/tmac/v
 file path=usr/share/lib/tmac/vgrind
 file path=usr/share/man/man1/addbib.1
-file path=usr/share/man/man1/apropos.1
 file path=usr/share/man/man1/checknr.1
 file path=usr/share/man/man1/deroff.1
 file path=usr/share/man/man1/diffmk.1
@@ -301,7 +299,6 @@
 file path=usr/share/man/man1/eqn.1
 file path=usr/share/man/man1/indxbib.1
 file path=usr/share/man/man1/lookbib.1
-file path=usr/share/man/man1/man.1
 file path=usr/share/man/man1/nroff.1
 file path=usr/share/man/man1/refer.1
 file path=usr/share/man/man1/roffbib.1
@@ -311,18 +308,11 @@
 file path=usr/share/man/man1/troff.1
 file path=usr/share/man/man1/ul.1
 file path=usr/share/man/man1/vgrind.1
-file path=usr/share/man/man1/whatis.1
-file path=usr/share/man/man1m/catman.1m
 file path=usr/share/man/man5/eqnchar.5
-file path=usr/share/man/man5/man.5
-file path=usr/share/man/man5/mansun.5
 file path=usr/share/man/man5/me.5
 file path=usr/share/man/man5/mm.5
 file path=usr/share/man/man5/ms.5
 file path=usr/share/man/man5/vgrindefs.5
-hardlink path=usr/bin/catman target=../../usr/bin/apropos
-hardlink path=usr/bin/man target=../../usr/bin/apropos
-hardlink path=usr/bin/whatis target=../../usr/bin/apropos
 hardlink path=usr/lib/font/devpost/charlib/~= target=./~
 hardlink path=usr/share/lib/nterm/tab.300s \
     target=../../../../usr/share/lib/nterm/tab.300S
@@ -340,8 +330,6 @@
     license=usr/src/cmd/checknr/THIRDPARTYLICENSE
 license usr/src/cmd/eqn/THIRDPARTYLICENSE \
     license=usr/src/cmd/eqn/THIRDPARTYLICENSE
-license usr/src/cmd/man/src/THIRDPARTYLICENSE \
-    license=usr/src/cmd/man/src/THIRDPARTYLICENSE
 license usr/src/cmd/refer/THIRDPARTYLICENSE \
     license=usr/src/cmd/refer/THIRDPARTYLICENSE
 license usr/src/cmd/soelim/THIRDPARTYLICENSE \
@@ -353,14 +341,6 @@
 license usr/src/cmd/vgrind/THIRDPARTYLICENSE \
     license=usr/src/cmd/vgrind/THIRDPARTYLICENSE
 link path=usr/lib/tmac target=../share/lib/tmac
-link path=usr/man target=./share/man
 link path=usr/share/man/man1/checkeq.1 target=eqn.1
 link path=usr/share/man/man1/neqn.1 target=eqn.1
-# lp is used by man -t and -r
-depend fmri=print/lp/print-client-commands type=require
-# awk is used by catman (via makewhatis)
-depend fmri=system/extended-system-utilities type=require
-# gpic is used as a preprocessor by the apropos command
-depend fmri=text/groff type=require
-# less is the default (per user environment) pager
-depend fmri=text/less type=require
+depend fmri=system/man type=require
