Module Name:    src
Committed By:   joerg
Date:           Mon Jan 30 17:03:01 UTC 2012

Modified Files:
        src/external/bsd/mdocml/dist: arch.in compat_fgetln.c lib.in man_term.c
            mdoc_term.c mdoc_validate.c msec.in read.c roff.c tbl_data.c

Log Message:
Merge for mdocml 1.20.1pre import


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/mdocml/dist/arch.in \
    src/external/bsd/mdocml/dist/msec.in \
    src/external/bsd/mdocml/dist/tbl_data.c
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/mdocml/dist/compat_fgetln.c
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/mdocml/dist/lib.in
cvs rdiff -u -r1.8 -r1.9 src/external/bsd/mdocml/dist/man_term.c \
    src/external/bsd/mdocml/dist/mdoc_term.c
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/mdocml/dist/mdoc_validate.c \
    src/external/bsd/mdocml/dist/read.c
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/mdocml/dist/roff.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/mdocml/dist/arch.in
diff -u src/external/bsd/mdocml/dist/arch.in:1.2 src/external/bsd/mdocml/dist/arch.in:1.3
--- src/external/bsd/mdocml/dist/arch.in:1.2	Sun Dec 18 13:40:08 2011
+++ src/external/bsd/mdocml/dist/arch.in	Mon Jan 30 17:03:01 2012
@@ -1,4 +1,4 @@
-/*	$Vendor-Id: arch.in,v 1.10 2010/09/27 06:56:44 kristaps Exp $ */
+/*	$Vendor-Id: arch.in,v 1.12 2012/01/28 14:02:17 joerg Exp $ */
 /*
  * Copyright (c) 2009 Kristaps Dzonsons <[email protected]>
  *
@@ -26,54 +26,86 @@
  * REMEMBER TO ADD NEW ARCHITECTURES TO MDOC.7!
  */
 
-LINE("acorn26",		"acorn26")
-LINE("acorn32",		"acorn32")
-LINE("alpha",		"alpha")
-LINE("amd64",		"amd64")
-LINE("amiga",		"amiga")
-LINE("arc",		"arc")
-LINE("arm",		"arm")
-LINE("armish",		"armish")
-LINE("atari",		"atari")
-LINE("aviion",		"aviion")
-LINE("cobalt",		"cobalt")
-LINE("dreamcast",	"dreamcast")
-LINE("emips",		"emips")
-LINE("evbarm",		"evbarm")
-LINE("evbmips",		"evbmips")
-LINE("evbppc",		"evbppc")
-LINE("hp300",		"hp300")
-LINE("hp700",		"hp700")
-LINE("hpcarm",		"hpcarm")
-LINE("hpcmips",		"hpcmips")
-LINE("hpcsh",		"hpcsh")
-LINE("hppa",		"hppa")
-LINE("hppa64",		"hppa64")
+LINE("acorn26",		"Acorn26")
+LINE("acorn32",		"Acorn32")
+LINE("algor",		"Algor")
+LINE("alpha",		"Alpha")
+LINE("amd64",		"AMD64")
+LINE("amiga",		"Amiga")
+LINE("amigappc",	"AmigaPPC")
+LINE("arc",		"ARC")
+LINE("arm",		"ARM")
+LINE("arm26",		"ARM26")
+LINE("arm32",		"ARM32")
+LINE("armish",		"ARMISH")
+LINE("aviion",		"AViiON")
+LINE("atari",		"ATARI")
+LINE("beagle",		"Beagle")
+LINE("bebox",		"BeBox")
+LINE("cats",		"cats")
+LINE("cesfic",		"CESFIC")
+LINE("cobalt",		"Cobalt")
+LINE("dreamcast",	"Dreamcast")
+LINE("emips",		"EMIPS")
+LINE("evbarm",		"evbARM")
+LINE("evbmips",		"evbMIPS")
+LINE("evbppc",		"evbPPC")
+LINE("evbsh3",		"evbSH3")
+LINE("ews4800mips",	"EWS4800MIPS")
+LINE("hp300",		"HP300")
+LINE("hp700",		"HP700")
+LINE("hpcarm",		"HPCARM")
+LINE("hpcmips",		"HPCMIPS")
+LINE("hpcsh",		"HPCSH")
+LINE("hppa",		"HPPA")
+LINE("hppa64",		"HPPA64")
+LINE("ia64",		"ia64")
 LINE("i386",		"i386")
-LINE("landisk",		"landisk")
-LINE("loongson",	"loongson")
-LINE("luna88k",		"luna88k")
-LINE("mac68k",		"mac68k")
+LINE("ibmnws",		"IBMNWS")
+LINE("iyonix",		"Iyonix")
+LINE("landisk",		"LANDISK")
+LINE("loongson",	"Loongson")
+LINE("luna68k",		"Luna68k")
+LINE("luna88k",		"Luna88k")
 LINE("m68k",		"m68k")
-LINE("macppc",		"macppc")
-LINE("mips64",		"mips64")
-LINE("mvme68k",		"mvme68k")
-LINE("mvme88k",		"mvme88k")
-LINE("mvmeppc",		"mvmeppc")
-LINE("next68k",		"next68k")
-LINE("pmax",		"pmax")
-LINE("prep",		"prep")
-LINE("sandpoint",	"sandpoint")
-LINE("sgi",		"sgi")
-LINE("sgimips",		"sgimips")
-LINE("socppc",		"socppc")
-LINE("sparc",		"sparc")
-LINE("sparc64",		"sparc64")
-LINE("sun2",		"sun2")
-LINE("sun3",		"sun3")
-LINE("vax",		"vax")
-LINE("x68k",		"x68k")
+LINE("mac68k",		"Mac68k")
+LINE("macppc",		"MacPPC")
+LINE("mips",		"MIPS")
+LINE("mips64",		"MIPS64")
+LINE("mipsco",		"MIPSCo")
+LINE("mmeye",		"mmEye")
+LINE("mvme68k",		"MVME68k")
+LINE("mvme88k",		"MVME88k")
+LINE("mvmeppc",		"MVMEPPC")
+LINE("netwinder",	"NetWinder")
+LINE("news68k",		"NeWS68k")
+LINE("newsmips",	"NeWSMIPS")
+LINE("next68k",		"NeXT68k")
+LINE("ofppc",		"OFPPC")
+LINE("palm",		"Palm")
+LINE("pc532",		"PC532")
+LINE("playstation2",	"PlayStation2")
+LINE("pmax",		"PMAX")
+LINE("pmppc",		"pmPPC")
+LINE("powerpc",		"PowerPC")
+LINE("prep",		"PReP")
+LINE("rs6000",		"RS6000")
+LINE("sandpoint",	"Sandpoint")
+LINE("sbmips",		"SBMIPS")
+LINE("sgi",		"SGI")
+LINE("sgimips",		"SGIMIPS")
+LINE("sh3",		"SH3")
+LINE("shark",		"Shark")
+LINE("socppc",		"SOCPPC")
+LINE("solbourne",	"Solbourne")
+LINE("sparc",		"SPARC")
+LINE("sparc64",		"SPARC64")
+LINE("sun2",		"Sun2")
+LINE("sun3",		"Sun3")
+LINE("tahoe",		"Tahoe")
+LINE("vax",		"VAX")
+LINE("x68k",		"X68k")
 LINE("x86",		"x86")
 LINE("x86_64",		"x86_64")
-LINE("xen",		"xen")
-LINE("zaurus",		"zaurus")
+LINE("xen",		"Xen")
+LINE("zaurus",		"Zaurus")
Index: src/external/bsd/mdocml/dist/msec.in
diff -u src/external/bsd/mdocml/dist/msec.in:1.2 src/external/bsd/mdocml/dist/msec.in:1.3
--- src/external/bsd/mdocml/dist/msec.in:1.2	Sun Jan  2 22:03:24 2011
+++ src/external/bsd/mdocml/dist/msec.in	Mon Jan 30 17:03:01 2012
@@ -22,16 +22,16 @@
  * Be sure to escape strings.
  */
 
-LINE("1",		"NetBSD General Commands Manual")
-LINE("2",		"NetBSD System Calls Manual")
-LINE("3",		"NetBSD Library Functions Manual")
+LINE("1",		"General Commands Manual")
+LINE("2",		"System Calls Manual")
+LINE("3",		"Library Functions Manual")
 LINE("3p",		"Perl Library Functions Manual")
-LINE("4",		"NetBSD Kernel Interfaces Manual")
-LINE("5",		"NetBSD File Formats Manual")
-LINE("6",		"NetBSD Games Manual")
-LINE("7",		"NetBSD Miscellaneous Information Manual")
-LINE("8",		"NetBSD System Manager\'s Manual")
-LINE("9",		"NetBSD Kernel Developer\'s Manual")
+LINE("4",		"Kernel Interfaces Manual")
+LINE("5",		"File Formats Manual")
+LINE("6",		"Games Manual")
+LINE("7",		"Miscellaneous Information Manual")
+LINE("8",		"System Manager\'s Manual")
+LINE("9",		"Kernel Developer\'s Manual")
 LINE("X11",		"X11 Developer\'s Manual")
 LINE("X11R6",		"X11 Developer\'s Manual")
 LINE("unass",		"Unassociated")
Index: src/external/bsd/mdocml/dist/tbl_data.c
diff -u src/external/bsd/mdocml/dist/tbl_data.c:1.2 src/external/bsd/mdocml/dist/tbl_data.c:1.3
--- src/external/bsd/mdocml/dist/tbl_data.c:1.2	Fri Oct 28 14:00:20 2011
+++ src/external/bsd/mdocml/dist/tbl_data.c	Mon Jan 30 17:03:01 2012
@@ -29,13 +29,13 @@
 #include "libmandoc.h"
 #include "libroff.h"
 
-static	int		 parse_data(struct tbl_node *, struct tbl_span *, 
+static	int		 data(struct tbl_node *, struct tbl_span *, 
 				int, const char *, int *);
 static	struct tbl_span	*newspan(struct tbl_node *, int, 
 				struct tbl_row *);
 
 static int
-parse_data(struct tbl_node *tbl, struct tbl_span *dp, 
+data(struct tbl_node *tbl, struct tbl_span *dp, 
 		int ln, const char *p, int *pos)
 {
 	struct tbl_dat	*dat;
@@ -154,7 +154,7 @@ tbl_cdata(struct tbl_node *tbl, int ln, 
 		if (p[pos] == tbl->opts.tab) {
 			tbl->part = TBL_PART_DATA;
 			pos++;
-			return(parse_data(tbl, tbl->last_span, ln, p, &pos));
+			return(data(tbl, tbl->last_span, ln, p, &pos));
 		} else if ('\0' == p[pos]) {
 			tbl->part = TBL_PART_DATA;
 			return(1);
@@ -269,7 +269,7 @@ tbl_data(struct tbl_node *tbl, int ln, c
 	/* This returns 0 when TBL_PART_CDATA is entered. */
 
 	while ('\0' != p[pos])
-		if ( ! parse_data(tbl, dp, ln, p, &pos))
+		if ( ! data(tbl, dp, ln, p, &pos))
 			return(0);
 
 	return(1);

Index: src/external/bsd/mdocml/dist/compat_fgetln.c
diff -u src/external/bsd/mdocml/dist/compat_fgetln.c:1.1.1.1 src/external/bsd/mdocml/dist/compat_fgetln.c:1.2
--- src/external/bsd/mdocml/dist/compat_fgetln.c:1.1.1.1	Mon Jan 30 16:44:03 2012
+++ src/external/bsd/mdocml/dist/compat_fgetln.c	Mon Jan 30 17:03:01 2012
@@ -8,7 +8,7 @@ int dummy;
 
 #else
 
-/*	$NetBSD: compat_fgetln.c,v 1.1.1.1 2012/01/30 16:44:03 joerg Exp $	*/
+/*	$NetBSD: compat_fgetln.c,v 1.2 2012/01/30 17:03:01 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.

Index: src/external/bsd/mdocml/dist/lib.in
diff -u src/external/bsd/mdocml/dist/lib.in:1.6 src/external/bsd/mdocml/dist/lib.in:1.7
--- src/external/bsd/mdocml/dist/lib.in:1.6	Wed Jan 25 22:23:46 2012
+++ src/external/bsd/mdocml/dist/lib.in	Mon Jan 30 17:03:01 2012
@@ -1,4 +1,4 @@
-/*	$Vendor-Id: lib.in,v 1.10 2011/09/20 23:36:24 schwarze Exp $ */
+/*	$Vendor-Id: lib.in,v 1.13 2012/01/28 23:46:28 joerg Exp $ */
 /*
  * Copyright (c) 2009 Kristaps Dzonsons <[email protected]>
  *
@@ -81,10 +81,11 @@ LINE("librefuse",	"File System in Usersp
 LINE("libresolv",	"DNS Resolver Library (libresolv, \\-lresolv)")
 LINE("librpcsec_gss",	"RPC GSS-API Authentication Library (librpcsec_gss, \\-lrpcsec_gss)")
 LINE("librpcsvc",	"RPC Service Library (librpcsvc, \\-lrpcsvc)")
-LINE("librt",		"POSIX Real\\-time Library (librt, -lrt)")
+LINE("librt",		"POSIX Real\\-time Library (librt, \\-lrt)")
 LINE("libsaslc",	"Simple Authentication and Security Layer client library (libsaslc, \\-lsaslc)")
 LINE("libsdp",		"Bluetooth Service Discovery Protocol User Library (libsdp, \\-lsdp)")
 LINE("libssp",		"Buffer Overflow Protection Library (libssp, \\-lssp)")
+LINE("libSystem",	"System Library (libSystem, \\-lSystem)")
 LINE("libtermcap",	"Termcap Access Library (libtermcap, \\-ltermcap)")
 LINE("libterminfo",	"Terminal Information Library (libterminfo, \\-lterminfo)")
 LINE("libthr",		"1:1 Threading Library (libthr, \\-lthr)")

Index: src/external/bsd/mdocml/dist/man_term.c
diff -u src/external/bsd/mdocml/dist/man_term.c:1.8 src/external/bsd/mdocml/dist/man_term.c:1.9
--- src/external/bsd/mdocml/dist/man_term.c:1.8	Tue Oct 11 19:12:13 2011
+++ src/external/bsd/mdocml/dist/man_term.c	Mon Jan 30 17:03:01 2012
@@ -1,4 +1,4 @@
-/*	$Vendor-Id: man_term.c,v 1.121 2011/09/21 09:57:13 schwarze Exp $ */
+/*	$Vendor-Id: man_term.c,v 1.127 2012/01/03 15:16:24 kristaps Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <[email protected]>
  * Copyright (c) 2010, 2011 Ingo Schwarze <[email protected]>
@@ -33,8 +33,6 @@
 #include "term.h"
 #include "main.h"
 
-#define	INDENT		  7 /* fixed-width char full-indent */
-#define	HALFINDENT	  3 /* fixed-width char half-indent */
 #define	MAXMARGINS	  64 /* maximum number of indented scopes */
 
 /* FIXME: have PD set the default vspace width. */
@@ -70,21 +68,22 @@ static	void		  print_man_foot(struct ter
 static	void		  print_bvspace(struct termp *, 
 				const struct man_node *);
 
-static	int		  pre_alternate(DECL_ARGS);
 static	int		  pre_B(DECL_ARGS);
 static	int		  pre_HP(DECL_ARGS);
 static	int		  pre_I(DECL_ARGS);
 static	int		  pre_IP(DECL_ARGS);
+static	int		  pre_OP(DECL_ARGS);
 static	int		  pre_PP(DECL_ARGS);
 static	int		  pre_RS(DECL_ARGS);
 static	int		  pre_SH(DECL_ARGS);
 static	int		  pre_SS(DECL_ARGS);
 static	int		  pre_TP(DECL_ARGS);
+static	int		  pre_alternate(DECL_ARGS);
+static	int		  pre_ft(DECL_ARGS);
 static	int		  pre_ign(DECL_ARGS);
 static	int		  pre_in(DECL_ARGS);
 static	int		  pre_literal(DECL_ARGS);
 static	int		  pre_sp(DECL_ARGS);
-static	int		  pre_ft(DECL_ARGS);
 
 static	void		  post_IP(DECL_ARGS);
 static	void		  post_HP(DECL_ARGS);
@@ -127,6 +126,7 @@ static	const struct termact termacts[MAN
 	{ pre_ign, NULL, 0 }, /* AT */
 	{ pre_in, NULL, MAN_NOTEXT }, /* in */
 	{ pre_ft, NULL, MAN_NOTEXT }, /* ft */
+	{ pre_OP, NULL, 0 }, /* OP */
 };
 
 
@@ -141,6 +141,9 @@ terminal_man(void *arg, const struct man
 
 	p = (struct termp *)arg;
 
+	if (0 == p->defindent)
+		p->defindent = 7;
+
 	p->overstep = 0;
 	p->maxrmargin = p->defrmargin;
 	p->tabwidth = term_len(p, 5);
@@ -156,8 +159,8 @@ terminal_man(void *arg, const struct man
 
 	memset(&mt, 0, sizeof(struct mtermp));
 
-	mt.lmargin[mt.lmargincur] = term_len(p, INDENT);
-	mt.offset = term_len(p, INDENT);
+	mt.lmargin[mt.lmargincur] = term_len(p, p->defindent);
+	mt.offset = term_len(p, p->defindent);
 
 	if (n->child)
 		print_man_nodelist(p, &mt, n->child, m);
@@ -323,6 +326,29 @@ pre_B(DECL_ARGS)
 
 /* ARGSUSED */
 static int
+pre_OP(DECL_ARGS)
+{
+
+	term_word(p, "[");
+	p->flags |= TERMP_NOSPACE;
+
+	if (NULL != (n = n->child)) {
+		term_fontrepl(p, TERMFONT_BOLD);
+		term_word(p, n->string);
+	}
+	if (NULL != n && NULL != n->next) {
+		term_fontrepl(p, TERMFONT_UNDER);
+		term_word(p, n->next->string);
+	}
+
+	term_fontrepl(p, TERMFONT_NONE);
+	p->flags |= TERMP_NOSPACE;
+	term_word(p, "]");
+	return(0);
+}
+
+/* ARGSUSED */
+static int
 pre_ft(DECL_ARGS)
 {
 	const char	*cp;
@@ -511,7 +537,7 @@ pre_PP(DECL_ARGS)
 
 	switch (n->type) {
 	case (MAN_BLOCK):
-		mt->lmargin[mt->lmargincur] = term_len(p, INDENT);
+		mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
 		print_bvspace(p, n);
 		break;
 	default:
@@ -706,8 +732,8 @@ pre_SS(DECL_ARGS)
 	switch (n->type) {
 	case (MAN_BLOCK):
 		mt->fl &= ~MANT_LITERAL;
-		mt->lmargin[mt->lmargincur] = term_len(p, INDENT);
-		mt->offset = term_len(p, INDENT);
+		mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
+		mt->offset = term_len(p, p->defindent);
 		/* If following a prior empty `SS', no vspace. */
 		if (n->prev && MAN_SS == n->prev->tok)
 			if (NULL == n->prev->body->child)
@@ -718,7 +744,7 @@ pre_SS(DECL_ARGS)
 		break;
 	case (MAN_HEAD):
 		term_fontrepl(p, TERMFONT_BOLD);
-		p->offset = term_len(p, HALFINDENT);
+		p->offset = term_len(p, p->defindent/2);
 		break;
 	case (MAN_BODY):
 		p->offset = mt->offset;
@@ -757,8 +783,8 @@ pre_SH(DECL_ARGS)
 	switch (n->type) {
 	case (MAN_BLOCK):
 		mt->fl &= ~MANT_LITERAL;
-		mt->lmargin[mt->lmargincur] = term_len(p, INDENT);
-		mt->offset = term_len(p, INDENT);
+		mt->lmargin[mt->lmargincur] = term_len(p, p->defindent);
+		mt->offset = term_len(p, p->defindent);
 		/* If following a prior empty `SH', no vspace. */
 		if (n->prev && MAN_SH == n->prev->tok)
 			if (NULL == n->prev->body->child)
@@ -817,7 +843,7 @@ pre_RS(DECL_ARGS)
 		break;
 	}
 
-	sz = term_len(p, INDENT);
+	sz = term_len(p, p->defindent);
 
 	if (NULL != (n = n->parent->head->child))
 		if ((ival = a2width(p, n->string)) >= 0) 
@@ -851,7 +877,7 @@ post_RS(DECL_ARGS)
 		break;
 	}
 
-	sz = term_len(p, INDENT);
+	sz = term_len(p, p->defindent);
 
 	if (NULL != (n = n->parent->head->child)) 
 		if ((ival = a2width(p, n->string)) >= 0) 
@@ -957,37 +983,66 @@ print_man_nodelist(DECL_ARGS)
 static void
 print_man_foot(struct termp *p, const void *arg)
 {
+	char		title[BUFSIZ];
+	size_t		datelen;
 	const struct man_meta *meta;
 
 	meta = (const struct man_meta *)arg;
+	assert(meta->title);
+	assert(meta->msec);
+	assert(meta->date);
 
 	term_fontrepl(p, TERMFONT_NONE);
 
 	term_vspace(p);
-	term_vspace(p);
-	term_vspace(p);
+
+	/*
+	 * Temporary, undocumented option to imitate mdoc(7) output.
+	 * In the bottom right corner, use the source instead of
+	 * the title.
+	 */
+
+	if ( ! p->mdocstyle) {
+		term_vspace(p);
+		term_vspace(p);
+		snprintf(title, BUFSIZ, "%s(%s)", meta->title, meta->msec);
+	} else if (meta->source) {
+		strlcpy(title, meta->source, BUFSIZ);
+	} else {
+		title[0] = '\0';
+	}
+	datelen = term_strlen(p, meta->date);
+
+	/* Bottom left corner: manual source. */
 
 	p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
-	p->rmargin = p->maxrmargin - term_strlen(p, meta->date);
 	p->offset = 0;
-
-	/* term_strlen() can return zero. */
-	if (p->rmargin == p->maxrmargin)
-		p->rmargin--;
+	p->rmargin = (p->maxrmargin - datelen + term_len(p, 1)) / 2;
 
 	if (meta->source)
 		term_word(p, meta->source);
-	if (meta->source)
-		term_word(p, "");
 	term_flushln(p);
 
+	/* At the bottom in the middle: manual date. */
+
 	p->flags |= TERMP_NOSPACE;
 	p->offset = p->rmargin;
-	p->rmargin = p->maxrmargin;
-	p->flags &= ~TERMP_NOBREAK;
+	p->rmargin = p->maxrmargin - term_strlen(p, title);
+	if (p->offset + datelen >= p->rmargin)
+		p->rmargin = p->offset + datelen;
 
 	term_word(p, meta->date);
 	term_flushln(p);
+
+	/* Bottom right corner: manual title and section. */
+
+	p->flags &= ~TERMP_NOBREAK;
+	p->flags |= TERMP_NOSPACE;
+	p->offset = p->rmargin;
+	p->rmargin = p->maxrmargin;
+
+	term_word(p, title);
+	term_flushln(p);
 }
 
 
@@ -999,22 +1054,17 @@ print_man_head(struct termp *p, const vo
 	const struct man_meta *m;
 
 	m = (const struct man_meta *)arg;
-
-	/*
-	 * Note that old groff would spit out some spaces before the
-	 * header.  We discontinue this strange behaviour, but at one
-	 * point we did so here.
-	 */
-
-	p->offset = 0;
-	p->rmargin = p->maxrmargin;
-
-	buf[0] = title[0] = '\0';
+	assert(m->title);
+	assert(m->msec);
 
 	if (m->vol)
 		strlcpy(buf, m->vol, BUFSIZ);
+	else
+		buf[0] = '\0';
 	buflen = term_strlen(p, buf);
 
+	/* Top left corner: manual title and section. */
+
 	snprintf(title, BUFSIZ, "%s(%s)", m->title, m->msec);
 	titlen = term_strlen(p, title);
 
@@ -1028,6 +1078,8 @@ print_man_head(struct termp *p, const vo
 	term_word(p, title);
 	term_flushln(p);
 
+	/* At the top in the middle: manual volume. */
+
 	p->flags |= TERMP_NOSPACE;
 	p->offset = p->rmargin;
 	p->rmargin = p->offset + buflen + titlen < p->maxrmargin ?
@@ -1036,6 +1088,8 @@ print_man_head(struct termp *p, const vo
 	term_word(p, buf);
 	term_flushln(p);
 
+	/* Top right corner: title and section, again. */
+
 	p->flags &= ~TERMP_NOBREAK;
 	if (p->rmargin + titlen <= p->maxrmargin) {
 		p->flags |= TERMP_NOSPACE;
@@ -1050,11 +1104,14 @@ print_man_head(struct termp *p, const vo
 	p->rmargin = p->maxrmargin;
 
 	/* 
-	 * Groff likes to have some leading spaces before content.  Well
-	 * that's fine by me.
+	 * Groff prints three blank lines before the content.
+	 * Do the same, except in the temporary, undocumented
+	 * mode imitating mdoc(7) output.
 	 */
 
 	term_vspace(p);
-	term_vspace(p);
-	term_vspace(p);
+	if ( ! p->mdocstyle) {
+		term_vspace(p);
+		term_vspace(p);
+	}
 }
Index: src/external/bsd/mdocml/dist/mdoc_term.c
diff -u src/external/bsd/mdocml/dist/mdoc_term.c:1.8 src/external/bsd/mdocml/dist/mdoc_term.c:1.9
--- src/external/bsd/mdocml/dist/mdoc_term.c:1.8	Tue Oct 11 19:12:13 2011
+++ src/external/bsd/mdocml/dist/mdoc_term.c	Mon Jan 30 17:03:01 2012
@@ -1,4 +1,4 @@
-/*	$Vendor-Id: mdoc_term.c,v 1.235 2011/09/20 09:02:23 schwarze Exp $ */
+/*	$Vendor-Id: mdoc_term.c,v 1.238 2011/11/13 13:15:14 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <[email protected]>
  * Copyright (c) 2010 Ingo Schwarze <[email protected]>
@@ -34,9 +34,6 @@
 #include "mdoc.h"
 #include "main.h"
 
-#define	INDENT		  5
-#define	HALFINDENT	  3
-
 struct	termpair {
 	struct termpair	 *ppair;
 	int		  count;
@@ -194,7 +191,7 @@ static	const struct termact termacts[MDO
 	{ NULL, NULL }, /* Ec */ /* FIXME: no space */
 	{ NULL, NULL }, /* Ef */
 	{ termp_under_pre, NULL }, /* Em */ 
-	{ NULL, NULL }, /* Eo */
+	{ termp_quote_pre, termp_quote_post }, /* Eo */
 	{ termp_xx_pre, NULL }, /* Fx */
 	{ termp_bold_pre, NULL }, /* Ms */
 	{ termp_igndelim_pre, NULL }, /* No */
@@ -259,6 +256,9 @@ terminal_mdoc(void *arg, const struct md
 
 	p = (struct termp *)arg;
 
+	if (0 == p->defindent)
+		p->defindent = 5;
+
 	p->overstep = 0;
 	p->maxrmargin = p->defrmargin;
 	p->tabwidth = term_len(p, 5);
@@ -562,9 +562,9 @@ a2offs(const struct termp *p, const char
 	else if (0 == strcmp(v, "left"))
 		return(0);
 	else if (0 == strcmp(v, "indent"))
-		return(term_len(p, INDENT + 1));
+		return(term_len(p, p->defindent + 1));
 	else if (0 == strcmp(v, "indent-two"))
-		return(term_len(p, (INDENT + 1) * 2));
+		return(term_len(p, (p->defindent + 1) * 2));
 	else if ( ! a2roffsu(v, &su, SCALE_MAX))
 		SCALE_HS_INIT(&su, term_strlen(p, v));
 
@@ -584,6 +584,8 @@ print_bvspace(struct termp *p, 
 {
 	const struct mdoc_node	*nn;
 
+	assert(n);
+
 	term_newln(p);
 
 	if (MDOC_Bd == bl->tok && bl->norm->Bd.comp)
@@ -1422,7 +1424,7 @@ termp_sh_pre(DECL_ARGS)
 		term_fontpush(p, TERMFONT_BOLD);
 		break;
 	case (MDOC_BODY):
-		p->offset = term_len(p, INDENT);
+		p->offset = term_len(p, p->defindent);
 		break;
 	default:
 		break;
@@ -1490,7 +1492,7 @@ termp_d1_pre(DECL_ARGS)
 	if (MDOC_BLOCK != n->type)
 		return(1);
 	term_newln(p);
-	p->offset += term_len(p, (INDENT + 1));
+	p->offset += term_len(p, p->defindent + 1);
 	return(1);
 }
 
@@ -1795,7 +1797,7 @@ termp_ss_pre(DECL_ARGS)
 		break;
 	case (MDOC_HEAD):
 		term_fontpush(p, TERMFONT_BOLD);
-		p->offset = term_len(p, HALFINDENT);
+		p->offset = term_len(p, (p->defindent+1)/2);
 		break;
 	default:
 		break;
@@ -1923,6 +1925,8 @@ termp_quote_pre(DECL_ARGS)
 	case (MDOC_Dq):
 		term_word(p, "``");
 		break;
+	case (MDOC_Eo):
+		break;
 	case (MDOC_Po):
 		/* FALLTHROUGH */
 	case (MDOC_Pq):
@@ -1987,6 +1991,8 @@ termp_quote_post(DECL_ARGS)
 	case (MDOC_Dq):
 		term_word(p, "''");
 		break;
+	case (MDOC_Eo):
+		break;
 	case (MDOC_Po):
 		/* FALLTHROUGH */
 	case (MDOC_Pq):

Index: src/external/bsd/mdocml/dist/mdoc_validate.c
diff -u src/external/bsd/mdocml/dist/mdoc_validate.c:1.3 src/external/bsd/mdocml/dist/mdoc_validate.c:1.4
--- src/external/bsd/mdocml/dist/mdoc_validate.c:1.3	Tue Oct 11 19:12:13 2011
+++ src/external/bsd/mdocml/dist/mdoc_validate.c	Mon Jan 30 17:03:01 2012
@@ -1,4 +1,4 @@
-/*	$Vendor-Id: mdoc_validate.c,v 1.176 2011/09/02 19:40:18 kristaps Exp $ */
+/*	$Vendor-Id: mdoc_validate.c,v 1.181 2011/12/03 16:58:54 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <[email protected]>
  * Copyright (c) 2010, 2011 Ingo Schwarze <[email protected]>
@@ -545,12 +545,11 @@ check_text(struct mdoc *m, int ln, int p
 {
 	char		*cp;
 
-	cp = p;
-	for (cp = p; NULL != (p = strchr(p, '\t')); p++) {
-		if (MDOC_LITERAL & m->flags)
-			continue;
+	if (MDOC_LITERAL & m->flags)
+		return;
+
+	for (cp = p; NULL != (p = strchr(p, '\t')); p++)
 		mdoc_pmsg(m, ln, pos + (int)(p - cp), MANDOCERR_BADTAB);
-	}
 }
 
 static int
@@ -1695,6 +1694,14 @@ post_rs(POST_ARGS)
 	}
 
 	/*
+	 * Nothing to sort if only invalid nodes were found
+	 * inside the `Rs' body.
+	 */
+
+	if (NULL == mdoc->last->child)
+		return(1);
+
+	/*
 	 * The full `Rs' block needs special handling to order the
 	 * sub-elements according to `rsord'.  Pick through each element
 	 * and correctly order it.  This is a insertion sort.
@@ -1819,6 +1826,7 @@ static int
 post_sh_head(POST_ARGS)
 {
 	char		 buf[BUFSIZ];
+	struct mdoc_node *n;
 	enum mdoc_sec	 sec;
 	int		 c;
 
@@ -1853,6 +1861,20 @@ post_sh_head(POST_ARGS)
 
 	mdoc->lastsec = sec;
 
+	/*
+	 * Set the section attribute for the current HEAD, for its
+	 * parent BLOCK, and for the HEAD children; the latter can
+	 * only be TEXT nodes, so no recursion is needed.
+	 * For other blocks and elements, including .Sh BODY, this is
+	 * done when allocating the node data structures, but for .Sh
+	 * BLOCK and HEAD, the section is still unknown at that time.
+	 */
+
+	mdoc->last->parent->sec = sec;
+	mdoc->last->sec = sec;
+	for (n = mdoc->last->child; n; n = n->next)
+		n->sec = sec;
+
 	/* We don't care about custom sections after this. */
 
 	if (SEC_CUSTOM == sec)
@@ -2077,7 +2099,7 @@ post_dt(POST_ARGS)
 	 *       arch = NULL
 	 */
 
-	cp = mdoc_a2msec(nn->string);
+	cp = mandoc_a2msec(nn->string);
 	if (cp) {
 		mdoc->meta.vol = mandoc_strdup(cp);
 		mdoc->meta.msec = mandoc_strdup(nn->string);
Index: src/external/bsd/mdocml/dist/read.c
diff -u src/external/bsd/mdocml/dist/read.c:1.3 src/external/bsd/mdocml/dist/read.c:1.4
--- src/external/bsd/mdocml/dist/read.c:1.3	Tue Oct 11 19:12:13 2011
+++ src/external/bsd/mdocml/dist/read.c	Mon Jan 30 17:03:01 2012
@@ -1,4 +1,4 @@
-/*	$Vendor-Id: read.c,v 1.25 2011/10/08 15:42:29 kristaps Exp $ */
+/*	$Vendor-Id: read.c,v 1.26 2011/11/07 01:24:40 schwarze Exp $ */
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <[email protected]>
  * Copyright (c) 2010, 2011 Ingo Schwarze <[email protected]>
@@ -192,7 +192,6 @@ static	const char * const	mandocerrs[MAN
 	"not a manual",
 	"column syntax is inconsistent",
 	"NOT IMPLEMENTED: .Bd -file",
-	"line scope broken, syntax violated",
 	"argument count wrong, violates syntax",
 	"child violates parent syntax",
 	"argument count wrong, violates syntax",

Index: src/external/bsd/mdocml/dist/roff.c
diff -u src/external/bsd/mdocml/dist/roff.c:1.5 src/external/bsd/mdocml/dist/roff.c:1.6
--- src/external/bsd/mdocml/dist/roff.c:1.5	Wed Oct 12 14:11:25 2011
+++ src/external/bsd/mdocml/dist/roff.c	Mon Jan 30 17:03:01 2012
@@ -1,4 +1,4 @@
-/*	$Vendor-Id: roff.c,v 1.171 2011/09/19 08:34:45 schwarze Exp $ */
+/*	$Vendor-Id: roff.c,v 1.172 2011/10/24 21:41:45 schwarze Exp $ */
 /*
  * Copyright (c) 2010, 2011 Kristaps Dzonsons <[email protected]>
  * Copyright (c) 2010, 2011 Ingo Schwarze <[email protected]>
@@ -21,11 +21,9 @@
 
 #include <assert.h>
 #include <ctype.h>
-#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "main.h"
 #include "mandoc.h"
 #include "libroff.h"
 #include "libmandoc.h"
@@ -188,7 +186,7 @@ static	void		 roff_openeqn(struct roff *
 				int, int, const char *);
 static	enum rofft	 roff_parse(struct roff *, const char *, int *);
 static	enum rofferr	 roff_parsetext(char *);
-static	void		 roff_res(struct roff *, 
+static	enum rofferr	 roff_res(struct roff *, 
 				char **, size_t *, int, int);
 static	enum rofferr	 roff_rm(ROFF_ARGS);
 static	void		 roff_setstr(struct roff *,
@@ -434,7 +432,7 @@ roff_alloc(struct mparse *parse)
  * is processed. 
  * This also checks the syntax of regular escapes.
  */
-static void
+static enum rofferr
 roff_res(struct roff *r, char **bufp, size_t *szp, int ln, int pos)
 {
 	enum mandoc_esc	 esc;
@@ -460,7 +458,7 @@ again:
 		 */
 
 		if ('\0' == *cp)
-			return;
+			return(ROFF_CONT);
 
 		if ('*' != *cp) {
 			res = cp;
@@ -471,7 +469,7 @@ again:
 			mandoc_msg
 				(MANDOCERR_BADESCAPE, r->parse, 
 				 ln, (int)(stesc - *bufp), NULL);
-			return;
+			return(ROFF_CONT);
 		}
 
 		cp++;
@@ -484,7 +482,7 @@ again:
 
 		switch (*cp) {
 		case ('\0'):
-			return;
+			return(ROFF_CONT);
 		case ('('):
 			cp++;
 			maxl = 2;
@@ -507,7 +505,7 @@ again:
 					(MANDOCERR_BADESCAPE, 
 					 r->parse, ln, 
 					 (int)(stesc - *bufp), NULL);
-				return;
+				return(ROFF_CONT);
 			}
 			if (0 == maxl && ']' == *cp)
 				break;
@@ -548,8 +546,9 @@ again:
 
 		/* Just leave the string unexpanded. */
 		mandoc_msg(MANDOCERR_ROFFLOOP, r->parse, ln, pos, NULL);
-		return;
+		return(ROFF_IGN);
 	}
+	return(ROFF_CONT);
 }
 
 /*
@@ -561,7 +560,6 @@ roff_parsetext(char *p)
 	size_t		 sz;
 	const char	*start;
 	enum mandoc_esc	 esc;
-	const char	*const_p;
 
 	start = p;
 
@@ -575,9 +573,8 @@ roff_parsetext(char *p)
 		if ('\\' == *p) {
 			/* Skip over escapes. */
 			p++;
-			const_p = p;
-			esc = mandoc_escape(&const_p, NULL, NULL);
-			p = UNCONST(const_p);
+			esc = mandoc_escape
+				((const char **)&p, NULL, NULL);
 			if (ESCAPE_ERROR == esc)
 				break;
 			continue;
@@ -608,7 +605,10 @@ roff_parseln(struct roff *r, int ln, cha
 	 * words to fill in.
 	 */
 
-	roff_res(r, bufp, szp, ln, pos);
+	e = roff_res(r, bufp, szp, ln, pos);
+	if (ROFF_IGN == e)
+		return(e);
+	assert(ROFF_CONT == e);
 
 	ppos = pos;
 	ctl = mandoc_getcontrol(*bufp, &pos);

Reply via email to