summaryrefslogtreecommitdiffstats
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
commitd7a5b4c3c2f2f5da253943d18545b97fafd28a49 (patch)
treebe80dcc927f48bf2ab10656d1e0e10d0e32919c8
parent4e045795c0b9e4b7f54bcb4057d3980e4dd9dfdf (diff)
downloadmandoc-d7a5b4c3c2f2f5da253943d18545b97fafd28a49.tar.gz
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.
-rw-r--r--mdoc_html.c2
-rw-r--r--mdoc_man.c6
-rw-r--r--mdoc_term.c4
-rw-r--r--mdoc_validate.c10
4 files changed, 13 insertions, 9 deletions
diff --git a/mdoc_html.c b/mdoc_html.c
index 26b20ed1..a3c3cced 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -582,8 +582,6 @@ mdoc_nm_pre(MDOC_ARGS)
/* FALLTHROUGH */
case ROFFT_ELEM:
print_otag(h, TAG_B, "c", "Nm");
- if (n->child == NULL && meta->name != NULL)
- print_text(h, meta->name);
return 1;
case ROFFT_BODY:
print_otag(h, TAG_TD, "");
diff --git a/mdoc_man.c b/mdoc_man.c
index adb76b34..1d1f0f13 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1518,7 +1518,7 @@ pre_nm(DECL_ARGS)
}
if (n->type != ROFFT_ELEM && n->type != ROFFT_HEAD)
return 1;
- name = n->child ? n->child->string : meta->name;
+ name = n->child == NULL ? NULL : n->child->string;
if (NULL == name)
return 0;
if (n->type == ROFFT_HEAD) {
@@ -1529,8 +1529,6 @@ pre_nm(DECL_ARGS)
outflags |= MMAN_nl;
}
font_push('B');
- if (NULL == n->child)
- print_word(meta->name);
return 1;
}
@@ -1544,7 +1542,7 @@ post_nm(DECL_ARGS)
break;
case ROFFT_HEAD:
case ROFFT_ELEM:
- if (n->child != NULL || meta->name != NULL)
+ if (n->child != NULL && n->child->string != NULL)
font_pop();
break;
default:
diff --git a/mdoc_term.c b/mdoc_term.c
index 1feddb55..b35f951d 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -996,7 +996,7 @@ termp_nm_pre(DECL_ARGS)
return 1;
}
- if (NULL == n->child && NULL == meta->name)
+ if (n->child == NULL)
return 0;
if (n->type == ROFFT_HEAD)
@@ -1020,8 +1020,6 @@ termp_nm_pre(DECL_ARGS)
}
term_fontpush(p, TERMFONT_BOLD);
- if (NULL == n->child)
- term_word(p, meta->name);
return 1;
}
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 885d6281..48d4fd31 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -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