=================================================================== RCS file: /cvs/mandoc/roff.c,v retrieving revision 1.114 retrieving revision 1.118 diff -u -p -r1.114 -r1.118 --- mandoc/roff.c 2010/12/31 18:19:43 1.114 +++ mandoc/roff.c 2011/01/02 10:10:57 1.118 @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.114 2010/12/31 18:19:43 kristaps Exp $ */ +/* $Id: roff.c,v 1.118 2011/01/02 10:10:57 kristaps Exp $ */ /* * Copyright (c) 2010 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -86,9 +86,9 @@ struct roff { struct regset *regs; /* read/writable registers */ struct roffstr *first_string; /* user-defined strings & macros */ const char *current_string; /* value of last called user macro */ - struct tbl *first_tbl; /* first table parsed */ - struct tbl *last_tbl; /* last table parsed */ - struct tbl *tbl; /* current table being parsed */ + struct tbl_node *first_tbl; /* first table parsed */ + struct tbl_node *last_tbl; /* last table parsed */ + struct tbl_node *tbl; /* current table being parsed */ }; struct roffnode { @@ -301,7 +301,7 @@ roffnode_push(struct roff *r, enum rofft tok, const ch static void roff_free1(struct roff *r) { - struct tbl *t; + struct tbl_node *t; while (r->first_tbl) { t = r->first_tbl; @@ -515,15 +515,20 @@ roff_parseln(struct roff *r, int ln, char **bufp, } -int +void roff_endparse(struct roff *r) { - /* FIXME: if r->tbl */ if (r->last) (*r->msg)(MANDOCERR_SCOPEEXIT, r->data, r->last->line, r->last->col, NULL); - return(1); + + if (r->tbl) { + (*r->msg)(MANDOCERR_SCOPEEXIT, r->data, + r->tbl->line, r->tbl->pos, NULL); + tbl_end(r->tbl); + r->tbl = NULL; + } } @@ -1123,6 +1128,8 @@ roff_TE(ROFF_ARGS) if (NULL == r->tbl) (*r->msg)(MANDOCERR_NOSCOPE, r->data, ln, ppos, NULL); + else + tbl_end(r->tbl); r->tbl = NULL; return(ROFF_IGN); @@ -1136,7 +1143,7 @@ roff_T_(ROFF_ARGS) if (NULL == r->tbl) (*r->msg)(MANDOCERR_NOSCOPE, r->data, ln, ppos, NULL); else - tbl_restart(r->tbl); + tbl_restart(ppos, ln, r->tbl); return(ROFF_IGN); } @@ -1145,12 +1152,14 @@ roff_T_(ROFF_ARGS) static enum rofferr roff_TS(ROFF_ARGS) { - struct tbl *t; + struct tbl_node *t; - if (r->tbl) + if (r->tbl) { (*r->msg)(MANDOCERR_SCOPEBROKEN, r->data, ln, ppos, NULL); + tbl_end(r->tbl); + } - t = tbl_alloc(r->data, r->msg); + t = tbl_alloc(ppos, ln, r->data, r->msg); if (r->last_tbl) r->last_tbl->next = t;