=================================================================== RCS file: /cvs/mandoc/mdoc.c,v retrieving revision 1.231 retrieving revision 1.238 diff -u -p -r1.231 -r1.238 --- mandoc/mdoc.c 2014/11/28 03:14:18 1.231 +++ mandoc/mdoc.c 2015/02/12 13:00:52 1.238 @@ -1,7 +1,7 @@ -/* $Id: mdoc.c,v 1.231 2014/11/28 03:14:18 schwarze Exp $ */ +/* $Id: mdoc.c,v 1.238 2015/02/12 13:00:52 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons - * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze + * Copyright (c) 2010, 2012-2015 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -190,14 +190,14 @@ mdoc_alloc(struct roff *roff, struct mparse *parse, return(p); } -int +void mdoc_endparse(struct mdoc *mdoc) { - return(mdoc_macroend(mdoc)); + mdoc_macroend(mdoc); } -int +void mdoc_addeqn(struct mdoc *mdoc, const struct eqn *ep) { struct mdoc_node *n; @@ -208,10 +208,9 @@ mdoc_addeqn(struct mdoc *mdoc, const struct eqn *ep) n->flags |= MDOC_LINE; node_append(mdoc, n); mdoc->next = MDOC_NEXT_SIBLING; - return(1); } -int +void mdoc_addspan(struct mdoc *mdoc, const struct tbl_span *sp) { struct mdoc_node *n; @@ -220,7 +219,6 @@ mdoc_addspan(struct mdoc *mdoc, const struct tbl_span n->span = sp; node_append(mdoc, n); mdoc->next = MDOC_NEXT_SIBLING; - return(1); } /* @@ -250,7 +248,7 @@ mdoc_parseln(struct mdoc *mdoc, int ln, char *buf, int mdoc_ptext(mdoc, ln, buf, offs)); } -int +void mdoc_macro(MACRO_PROT_ARGS) { assert(tok < MDOC_MAX); @@ -260,7 +258,7 @@ mdoc_macro(MACRO_PROT_ARGS) mandoc_vmsg(MANDOCERR_DT_LATE, mdoc->parse, line, ppos, "Dt %s", buf + *pos); - return(1); + return; } } else if ( ! (mdoc_macros[tok].flags & MDOC_PROLOGUE)) { if (mdoc->meta.title == NULL) { @@ -273,8 +271,7 @@ mdoc_macro(MACRO_PROT_ARGS) mdoc->meta.vol = mandoc_strdup("LOCAL"); mdoc->flags |= MDOC_PBODY; } - - return((*mdoc_macros[tok].fp)(mdoc, tok, line, ppos, pos, buf)); + (*mdoc_macros[tok].fp)(mdoc, tok, line, ppos, pos, buf); } @@ -366,7 +363,6 @@ node_alloc(struct mdoc *mdoc, int line, int pos, p->sec = mdoc->lastsec; p->line = line; p->pos = pos; - p->lastline = line; p->tok = tok; p->type = type; @@ -417,18 +413,21 @@ mdoc_body_alloc(struct mdoc *mdoc, int line, int pos, return(p); } -void +struct mdoc_node * mdoc_endbody_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok, struct mdoc_node *body, enum mdoc_endbody end) { struct mdoc_node *p; + body->flags |= MDOC_ENDED; + body->parent->flags |= MDOC_ENDED; p = node_alloc(mdoc, line, pos, tok, MDOC_BODY); - p->pending = body; + p->body = body; p->norm = body->norm; p->end = end; node_append(mdoc, p); mdoc->next = MDOC_NEXT_SIBLING; + return(p); } struct mdoc_node * @@ -602,11 +601,12 @@ mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int * process within its context in the normal way). */ - if (MDOC_Bl == n->tok && MDOC_BODY == n->type && - LIST_column == n->norm->Bl.type) { + if (n->tok == MDOC_Bl && n->type == MDOC_BODY && + n->end == ENDBODY_NOT && n->norm->Bl.type == LIST_column) { /* `Bl' is open without any children. */ mdoc->flags |= MDOC_FREECOL; - return(mdoc_macro(mdoc, MDOC_It, line, offs, &offs, buf)); + mdoc_macro(mdoc, MDOC_It, line, offs, &offs, buf); + return(1); } if (MDOC_It == n->tok && MDOC_BLOCK == n->type && @@ -615,7 +615,8 @@ mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int LIST_column == n->parent->norm->Bl.type) { /* `Bl' has block-level `It' children. */ mdoc->flags |= MDOC_FREECOL; - return(mdoc_macro(mdoc, MDOC_It, line, offs, &offs, buf)); + mdoc_macro(mdoc, MDOC_It, line, offs, &offs, buf); + return(1); } /* @@ -693,7 +694,6 @@ mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int if (mandoc_eos(buf+offs, (size_t)(end-buf-offs))) mdoc->last->flags |= MDOC_EOS; - return(1); } @@ -765,8 +765,10 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int * into macro processing. */ - if (NULL == mdoc->last || MDOC_It == tok || MDOC_El == tok) - return(mdoc_macro(mdoc, tok, ln, sv, &offs, buf)); + if (NULL == mdoc->last || MDOC_It == tok || MDOC_El == tok) { + mdoc_macro(mdoc, tok, ln, sv, &offs, buf); + return(1); + } n = mdoc->last; assert(mdoc->last); @@ -776,10 +778,11 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int * context around the parsed macro. */ - if (MDOC_Bl == n->tok && MDOC_BODY == n->type && - LIST_column == n->norm->Bl.type) { + if (n->tok == MDOC_Bl && n->type == MDOC_BODY && + n->end == ENDBODY_NOT && n->norm->Bl.type == LIST_column) { mdoc->flags |= MDOC_FREECOL; - return(mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf)); + mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf); + return(1); } /* @@ -793,13 +796,13 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int MDOC_Bl == n->parent->tok && LIST_column == n->parent->norm->Bl.type) { mdoc->flags |= MDOC_FREECOL; - return(mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf)); + mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf); + return(1); } /* Normal processing of a macro. */ - if ( ! mdoc_macro(mdoc, tok, ln, sv, &offs, buf)) - return(0); + mdoc_macro(mdoc, tok, ln, sv, &offs, buf); /* In quick mode (for mandocdb), abort after the NAME section. */