aboutsummaryrefslogtreecommitdiffstatshomepage
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
commit6120130ed0e80f6397c99e688829ad06c4415cd6 (patch)
tree93e4d40958b76fae1b57ec09aa87b9902337f803 /roff.c
parentf4ef2b56c63e66af623a65be9e0bc802888eacb5 (diff)
downloadmandoc-6120130ed0e80f6397c99e688829ad06c4415cd6.tar.gz
mandoc-6120130ed0e80f6397c99e688829ad06c4415cd6.tar.zst
mandoc-6120130ed0e80f6397c99e688829ad06c4415cd6.zip
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.c32
1 files changed, 21 insertions, 11 deletions
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 <kristaps@bsd.lv>
* Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);
}