X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/aff7055e2d69b65767cc1314a7898f31abe2c74a..25662a4940503ffb064a92f60db8cd83050b1878:/mdoc_macro.c?ds=sidebyside diff --git a/mdoc_macro.c b/mdoc_macro.c index c6b0f352..f04acb96 100644 --- a/mdoc_macro.c +++ b/mdoc_macro.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.174 2015/02/04 22:30:10 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.180 2015/02/07 16:42:33 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2012-2015 Ingo Schwarze @@ -262,9 +262,6 @@ rew_last(struct mdoc *mdoc, const struct mdoc_node *to) assert(to); mdoc->next = MDOC_NEXT_SIBLING; while (mdoc->last != to) { - if ( ! (mdoc->last->flags & MDOC_VALID)) - mdoc->last->lastline = to->lastline - - (mdoc->flags & MDOC_NEWLINE ? 1 : 0); /* * Save the parent here, because we may delete the * mdoc->last node in the post-validation phase and reset @@ -578,10 +575,8 @@ blk_exp_close(MACRO_PROT_ARGS) /* Remember the start of our own body. */ if (n->type == MDOC_BODY && atok == n->tok) { - if (n->end == ENDBODY_NOT) { + if (n->end == ENDBODY_NOT) body = n; - n->lastline = line; - } continue; } @@ -594,7 +589,6 @@ blk_exp_close(MACRO_PROT_ARGS) } if (atok == n->tok) { - n->lastline = line; assert(body); /* @@ -778,7 +772,7 @@ in_line(MACRO_PROT_ARGS) */ if (ac == ARGS_PUNCT) { - if (cnt == 0 && nc == 0) + if (cnt == 0 && (nc == 0 || tok == MDOC_An)) mdoc->flags |= MDOC_NODELIMC; break; } @@ -910,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. */ @@ -941,6 +941,7 @@ blk_full(MACRO_PROT_ARGS) mdoc_macronames[tok], mdoc_macronames[n->tok]); rew_pending(mdoc, n); + n = mdoc->last; continue; case MDOC_It: /* Delay in case it's astray. */ @@ -1373,6 +1374,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); @@ -1398,6 +1404,13 @@ in_line_eoln(MACRO_PROT_ARGS) rew_last(mdoc, mdoc->last->parent); } + if (buf[*pos] == '\0' && + (tok == MDOC_Fd || mdoc_macronames[tok][0] == '%')) { + mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse, + line, ppos, mdoc_macronames[tok]); + return; + } + mdoc_argv(mdoc, line, tok, &arg, pos, buf); mdoc_elem_alloc(mdoc, line, ppos, tok, arg); if (parse_rest(mdoc, tok, line, pos, buf))