X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/bbf2e5b44d2836d001e4dc02087421dbc5cb0c04..fa99e371284a414ce8b13892006df003d31a0e37:/man.c?ds=inline diff --git a/man.c b/man.c index f231f9b6..aea3872e 100644 --- a/man.c +++ b/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.164 2015/09/04 21:25:00 schwarze Exp $ */ +/* $Id: man.c,v 1.168 2017/03/03 13:55:31 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2013, 2014, 2015 Ingo Schwarze @@ -62,9 +62,9 @@ man_parseln(struct roff_man *man, int ln, char *buf, int offs) if (man->last->type != ROFFT_EQN || ln > man->last->line) man->flags |= MAN_NEWLINE; - return (roff_getcontrol(man->roff, buf, &offs) ? + return roff_getcontrol(man->roff, buf, &offs) ? man_pmacro(man, ln, buf, offs) : - man_ptext(man, ln, buf, offs)); + man_ptext(man, ln, buf, offs); } static void @@ -97,7 +97,7 @@ man_ptext(struct roff_man *man, int line, char *buf, int offs) if (man->flags & MAN_LITERAL) { roff_word_alloc(man, line, offs, buf + offs); man_descope(man, line, offs); - return(1); + return 1; } for (i = offs; buf[i] == ' '; i++) @@ -115,7 +115,7 @@ man_ptext(struct roff_man *man, int line, char *buf, int offs) roff_elem_alloc(man, line, offs, MAN_sp); man->next = ROFF_NEXT_SIBLING; } - return(1); + return 1; } /* @@ -149,10 +149,10 @@ man_ptext(struct roff_man *man, int line, char *buf, int offs) assert(i); if (mandoc_eos(buf, (size_t)i)) - man->last->flags |= MAN_EOS; + man->last->flags |= NODE_EOS; man_descope(man, line, offs); - return(1); + return 1; } static int @@ -183,7 +183,7 @@ man_pmacro(struct roff_man *man, int ln, char *buf, int offs) if (tok == TOKEN_NONE) { mandoc_msg(MANDOCERR_MACRO, man->parse, ln, ppos, buf + ppos - 1); - return(1); + return 1; } /* Skip a leading escape sequence or tab. */ @@ -203,7 +203,7 @@ man_pmacro(struct roff_man *man, int ln, char *buf, int offs) /* Jump to the next non-whitespace word. */ - while (buf[offs] && buf[offs] == ' ') + while (buf[offs] == ' ') offs++; /* @@ -234,7 +234,7 @@ man_pmacro(struct roff_man *man, int ln, char *buf, int offs) n = man->last; if (n->type == ROFFT_BODY && strcmp(n->prev->child->string, "NAME")) - return(2); + return 2; } /* @@ -245,14 +245,14 @@ man_pmacro(struct roff_man *man, int ln, char *buf, int offs) if ( ! bline || man->flags & MAN_ELINE || man_macros[tok].flags & MAN_NSCOPED) - return(1); + return 1; assert(man->flags & MAN_BLINE); man->flags &= ~MAN_BLINE; man_unscope(man, man->last->parent); roff_body_alloc(man, ln, ppos, man->last->tok); - return(1); + return 1; } void @@ -330,5 +330,40 @@ man_mparse(const struct roff_man *man) { assert(man && man->parse); - return(man->parse); + return man->parse; +} + +void +man_state(struct roff_man *man, struct roff_node *n) +{ + + switch(n->tok) { + case MAN_nf: + case MAN_EX: + if (man->flags & MAN_LITERAL && ! (n->flags & NODE_VALID)) + mandoc_msg(MANDOCERR_NF_SKIP, man->parse, + n->line, n->pos, "nf"); + man->flags |= MAN_LITERAL; + break; + case MAN_fi: + case MAN_EE: + if ( ! (man->flags & MAN_LITERAL) && + ! (n->flags & NODE_VALID)) + mandoc_msg(MANDOCERR_FI_SKIP, man->parse, + n->line, n->pos, "fi"); + man->flags &= ~MAN_LITERAL; + break; + default: + break; + } + man->last->flags |= NODE_VALID; +} + +void +man_validate(struct roff_man *man) +{ + + man->last = man->first; + man_node_validate(man); + man->flags &= ~MAN_LITERAL; }