aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-02-06 03:44:58 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-02-06 03:44:58 +0000
commitfc520e3cedbcdd86eb2b80e94cce78f98af717cf (patch)
treed8925b29052be33ff201b5a1d09de0aeba121ed7 /mdoc_validate.c
parent70f435794e7d1b7082fbf988409e27476dace0bc (diff)
downloadmandoc-fc520e3cedbcdd86eb2b80e94cce78f98af717cf.tar.gz
mandoc-fc520e3cedbcdd86eb2b80e94cce78f98af717cf.tar.zst
mandoc-fc520e3cedbcdd86eb2b80e94cce78f98af717cf.zip
The .Nm macro does not only use the default name when it has no
argument, but also when the first argument is a child macro. Arcane issue found in the FreeBSD cxgbetool(8) manual that Baptiste Daroussin <bapt at FreeBSD> sent me long ago for a different reason. While solving this, switch to the new technique of doing text production in the validator, reducing code duplication in the formatters, which also makes -Ttree output clearer.
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 043145ae..e58e7a47 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.317 2017/01/11 17:39:53 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.318 2017/02/06 03:44:58 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -1013,6 +1013,16 @@ post_nm(POST_ARGS)
(mdoc->lastsec == SEC_NAME && n->child == NULL))
mandoc_msg(MANDOCERR_NM_NONAME, mdoc->parse,
n->line, n->pos, "Nm");
+
+ if ((n->type != ROFFT_ELEM && n->type != ROFFT_HEAD) ||
+ (n->child != NULL && n->child->type == ROFFT_TEXT) ||
+ mdoc->meta.name == NULL)
+ return;
+
+ mdoc->next = ROFF_NEXT_CHILD;
+ roff_word_alloc(mdoc, n->line, n->pos, mdoc->meta.name);
+ mdoc->last->flags |= NODE_NOSRC;
+ mdoc->last = n;
}
static void