From 6120130ed0e80f6397c99e688829ad06c4415cd6 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Fri, 31 Dec 2010 14:52:41 +0000 Subject: Put parsed tables into a queue that's cleared at the end of parsing. This completes the parsing phase of the new tbl implementation. --- roff.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'roff.c') diff --git a/roff.c b/roff.c index d62ebcc3..439784a9 100644 --- a/roff.c +++ b/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.112 2010/12/29 14:53:31 kristaps Exp $ */ +/* $Id: roff.c,v 1.113 2010/12/31 14:52:41 kristaps Exp $ */ /* * Copyright (c) 2010 Kristaps Dzonsons * Copyright (c) 2010 Ingo Schwarze @@ -86,7 +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 *tbl; + struct tbl *first_tbl; /* first table parsed */ + struct tbl *last_tbl; /* last table parsed */ + struct tbl *tbl; /* current table being parsed */ }; struct roffnode { @@ -299,12 +301,16 @@ roffnode_push(struct roff *r, enum rofft tok, const char *name, static void roff_free1(struct roff *r) { + struct tbl *t; - if (r->tbl) { - tbl_free(r->tbl); - r->tbl = NULL; + while (r->first_tbl) { + t = r->first_tbl; + r->first_tbl = t->next; + tbl_free(t); } + r->first_tbl = r->last_tbl = r->tbl = NULL; + while (r->last) roffnode_pop(r); @@ -1117,8 +1123,6 @@ roff_TE(ROFF_ARGS) if (NULL == r->tbl) (*r->msg)(MANDOCERR_NOSCOPE, r->data, ln, ppos, NULL); - else - tbl_free(r->tbl); r->tbl = NULL; return(ROFF_IGN); @@ -1141,13 +1145,19 @@ roff_T_(ROFF_ARGS) static enum rofferr roff_TS(ROFF_ARGS) { + struct tbl *t; - if (r->tbl) { + if (r->tbl) (*r->msg)(MANDOCERR_SCOPEBROKEN, r->data, ln, ppos, NULL); - tbl_reset(r->tbl); - } else - r->tbl = tbl_alloc(r->data, r->msg); + t = tbl_alloc(r->data, r->msg); + + if (r->last_tbl) + r->last_tbl->next = t; + else + r->first_tbl = r->last_tbl = t; + + r->tbl = r->last_tbl = t; return(ROFF_IGN); } -- cgit v1.2.3-56-ge451