diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2015-02-06 01:07:22 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2015-02-06 01:07:22 +0000 |
commit | c99b323342e53370e16b09aca5d39e301af04142 (patch) | |
tree | 407fe105f5432bb2ed36ce1b6351ec93de2229c9 | |
parent | 902f6a979cb9238ddee3e60feebb858f2c773e7f (diff) | |
download | mandoc-c99b323342e53370e16b09aca5d39e301af04142.tar.gz |
better handle .In .Sh .Ss .St .Xr without arguments
-rw-r--r-- | mdoc_macro.c | 11 | ||||
-rw-r--r-- | mdoc_validate.c | 12 |
2 files changed, 13 insertions, 10 deletions
diff --git a/mdoc_macro.c b/mdoc_macro.c index 78a8e5e6..dc710030 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -904,6 +904,12 @@ blk_full(MACRO_PROT_ARGS) nl = MDOC_NEWLINE & mdoc->flags; + if (buf[*pos] == '\0' && (tok == MDOC_Sh || tok == MDOC_Ss)) { + mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, + line, ppos, mdoc_macronames[tok]); + return; + } + if ( ! (mdoc_macros[tok].flags & MDOC_EXPLICIT)) { /* Here, tok is one of Sh Ss Nm Nd It. */ @@ -1367,6 +1373,11 @@ in_line_argn(MACRO_PROT_ARGS) } if (j == 0) { + if (tok == MDOC_In || tok == MDOC_St || tok == MDOC_Xr) { + mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, + line, ppos, mdoc_macronames[tok]); + return; + } mdoc_elem_alloc(mdoc, line, ppos, tok, arg); if (ac == ARGS_PUNCT && tok == MDOC_Pf) append_delims(mdoc, line, pos, buf); diff --git a/mdoc_validate.c b/mdoc_validate.c index 5b77ca73..65ac1b7b 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -156,7 +156,7 @@ static const struct valids mdoc_valids[MDOC_MAX] = { { NULL, post_fn }, /* Fn */ { NULL, NULL }, /* Ft */ { NULL, NULL }, /* Ic */ - { NULL, ewarn_eq1 }, /* In */ + { NULL, NULL }, /* In */ { NULL, post_defaults }, /* Li */ { NULL, post_nd }, /* Nd */ { NULL, post_nm }, /* Nm */ @@ -167,7 +167,7 @@ static const struct valids mdoc_valids[MDOC_MAX] = { { NULL, post_st }, /* St */ { NULL, NULL }, /* Va */ { NULL, post_vt }, /* Vt */ - { NULL, ewarn_ge1 }, /* Xr */ + { NULL, NULL }, /* Xr */ { NULL, ewarn_ge1 }, /* %A */ { NULL, post_hyphtext }, /* %B */ /* FIXME: can be used outside Rs/Re. */ { NULL, ewarn_ge1 }, /* %D */ @@ -1640,13 +1640,6 @@ post_st(POST_ARGS) n = mdoc->last; nch = n->child; - if (NULL == nch) { - mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, - n->line, n->pos, mdoc_macronames[n->tok]); - mdoc_node_delete(mdoc, n); - return; - } - assert(MDOC_TEXT == nch->type); if (NULL == (p = mdoc_a2st(nch->string))) { @@ -2076,7 +2069,6 @@ post_ignpar(POST_ARGS) { struct mdoc_node *np; - check_count(mdoc, MDOC_HEAD, CHECK_GT, 0); post_hyph(mdoc); if (MDOC_BODY != mdoc->last->type) |