=================================================================== RCS file: /cvs/mandoc/mdoc.c,v retrieving revision 1.145 retrieving revision 1.150 diff -u -p -r1.145 -r1.150 --- mandoc/mdoc.c 2010/05/31 21:32:57 1.145 +++ mandoc/mdoc.c 2010/06/27 16:18:13 1.150 @@ -1,4 +1,4 @@ -/* $Id: mdoc.c,v 1.145 2010/05/31 21:32:57 kristaps Exp $ */ +/* $Id: mdoc.c,v 1.150 2010/06/27 16:18:13 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -29,6 +29,7 @@ #include #include "mandoc.h" +#include "regs.h" #include "libmdoc.h" #include "libmandoc.h" @@ -191,7 +192,8 @@ mdoc_free(struct mdoc *mdoc) * Allocate volatile and non-volatile parse resources. */ struct mdoc * -mdoc_alloc(void *data, int pflags, mandocmsg msg) +mdoc_alloc(struct regset *regs, void *data, + int pflags, mandocmsg msg) { struct mdoc *p; @@ -200,6 +202,7 @@ mdoc_alloc(void *data, int pflags, mandocmsg msg) p->msg = msg; p->data = data; p->pflags = pflags; + p->regs = regs; mdoc_hash_init(); mdoc_alloc1(p); @@ -258,8 +261,7 @@ mdoc_vmsg(struct mdoc *mdoc, enum mandocerr t, int -mdoc_macro(struct mdoc *m, enum mdoct tok, - int ln, int pp, int *pos, char *buf) +mdoc_macro(MACRO_PROT_ARGS) { assert(tok < MDOC_MAX); @@ -267,13 +269,13 @@ mdoc_macro(struct mdoc *m, enum mdoct tok, if (MDOC_PROLOGUE & mdoc_macros[tok].flags && MDOC_PBODY & m->flags) - return(mdoc_pmsg(m, ln, pp, MANDOCERR_BADBODY)); + return(mdoc_pmsg(m, line, ppos, MANDOCERR_BADBODY)); /* If we're in the prologue, deny "body" macros. */ if ( ! (MDOC_PROLOGUE & mdoc_macros[tok].flags) && ! (MDOC_PBODY & m->flags)) { - if ( ! mdoc_pmsg(m, ln, pp, MANDOCERR_BADPROLOG)) + if ( ! mdoc_pmsg(m, line, ppos, MANDOCERR_BADPROLOG)) return(0); if (NULL == m->meta.title) m->meta.title = mandoc_strdup("UNKNOWN"); @@ -286,7 +288,7 @@ mdoc_macro(struct mdoc *m, enum mdoct tok, m->flags |= MDOC_PBODY; } - return((*mdoc_macros[tok].fp)(m, tok, ln, pp, pos, buf)); + return((*mdoc_macros[tok].fp)(m, tok, line, ppos, pos, buf)); } @@ -366,9 +368,18 @@ node_alloc(struct mdoc *m, int line, int pos, p->pos = pos; p->tok = tok; p->type = type; + + /* Flag analysis. */ + if (MDOC_NEWLINE & m->flags) p->flags |= MDOC_LINE; m->flags &= ~MDOC_NEWLINE; + + /* Section analysis. */ + + if (SEC_SYNOPSIS == p->sec) + p->flags |= MDOC_SYNPRETTY; + return(p); } @@ -568,7 +579,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int of */ if (MDOC_Bl == n->tok && MDOC_BODY == n->type && - LIST_column == n->data.list) { + LIST_column == n->data.Bl.type) { /* `Bl' is open without any children. */ m->flags |= MDOC_FREECOL; return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf)); @@ -577,7 +588,7 @@ mdoc_ptext(struct mdoc *m, int line, char *buf, int of if (MDOC_It == n->tok && MDOC_BLOCK == n->type && NULL != n->parent && MDOC_Bl == n->parent->tok && - LIST_column == n->parent->data.list) { + LIST_column == n->parent->data.Bl.type) { /* `Bl' has block-level `It' children. */ m->flags |= MDOC_FREECOL; return(mdoc_macro(m, MDOC_It, line, offs, &offs, buf)); @@ -783,9 +794,9 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off */ if (MDOC_Bl == n->tok && MDOC_BODY == n->type && - LIST_column == n->data.list) { + LIST_column == n->data.Bl.type) { m->flags |= MDOC_FREECOL; - if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf)) + if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf)) goto err; return(1); } @@ -799,7 +810,7 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off if (MDOC_It == n->tok && MDOC_BLOCK == n->type && NULL != n->parent && MDOC_Bl == n->parent->tok && - LIST_column == n->parent->data.list) { + LIST_column == n->parent->data.Bl.type) { m->flags |= MDOC_FREECOL; if ( ! mdoc_macro(m, MDOC_It, ln, sv, &sv, buf)) goto err;