summaryrefslogtreecommitdiffstats
path: root/roff.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-12-31 14:52:41 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-12-31 14:52:41 +0000
commit9c243a1c877e4c624333ef5f2c736974a3c52251 (patch)
tree70064f0421edf9486c451cf4cfd48ad687227fae /roff.c
parentbb503db26691fd10d98793fe9960376cd9835add (diff)
downloadmandoc-9c243a1c877e4c624333ef5f2c736974a3c52251.tar.gz
Put parsed tables into a queue that's cleared at the end of parsing.
This completes the parsing phase of the new tbl implementation.
Diffstat (limited to 'roff.c')
-rw-r--r--roff.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/roff.c b/roff.c
index a481619e..9536bac3 100644
--- a/roff.c
+++ b/roff.c
@@ -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);
}