From 8e25f248df0dc1385f91b1da975e220bd25e4c34 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Wed, 29 Dec 2010 14:53:31 +0000 Subject: Add handling for `T&', which restarts a table except for its options. --- libroff.h | 1 + roff.c | 16 ++++++++++++++++ tbl.c | 8 ++++++++ 3 files changed, 25 insertions(+) diff --git a/libroff.h b/libroff.h index 1ab4cd49..05889954 100644 --- a/libroff.h +++ b/libroff.h @@ -84,6 +84,7 @@ struct tbl { (*(tblp)->msg)((type), (tblp)->data, (line), (col), NULL) struct tbl *tbl_alloc(void *, mandocmsg); +void tbl_restart(struct tbl *); void tbl_free(struct tbl *); void tbl_reset(struct tbl *); enum rofferr tbl_read(struct tbl *, int, const char *, int); diff --git a/roff.c b/roff.c index bf1dbf0c..a481619e 100644 --- a/roff.c +++ b/roff.c @@ -59,6 +59,7 @@ enum rofft { ROFF_tr, ROFF_TS, ROFF_TE, + ROFF_T_, ROFF_cblock, ROFF_ccond, /* FIXME: remove this. */ ROFF_USERDEF, @@ -143,6 +144,7 @@ static void roff_setstr(struct roff *, static enum rofferr roff_so(ROFF_ARGS); static enum rofferr roff_TE(ROFF_ARGS); static enum rofferr roff_TS(ROFF_ARGS); +static enum rofferr roff_T_(ROFF_ARGS); static enum rofferr roff_userdef(ROFF_ARGS); /* See roff_hash_find() */ @@ -175,6 +177,7 @@ static struct roffmac roffs[ROFF_MAX] = { { "tr", roff_line_ignore, NULL, NULL, 0, NULL }, { "TS", roff_TS, NULL, NULL, 0, NULL }, { "TE", roff_TE, NULL, NULL, 0, NULL }, + { "T&", roff_T_, NULL, NULL, 0, NULL }, { ".", roff_cblock, NULL, NULL, 0, NULL }, { "\\}", roff_ccond, NULL, NULL, 0, NULL }, { NULL, roff_userdef, NULL, NULL, 0, NULL }, @@ -1121,6 +1124,19 @@ roff_TE(ROFF_ARGS) return(ROFF_IGN); } +/* ARGSUSED */ +static enum rofferr +roff_T_(ROFF_ARGS) +{ + + if (NULL == r->tbl) + (*r->msg)(MANDOCERR_NOSCOPE, r->data, ln, ppos, NULL); + else + tbl_restart(r->tbl); + + return(ROFF_IGN); +} + /* ARGSUSED */ static enum rofferr roff_TS(ROFF_ARGS) diff --git a/tbl.c b/tbl.c index 537c7182..db468617 100644 --- a/tbl.c +++ b/tbl.c @@ -120,3 +120,11 @@ tbl_reset(struct tbl *tbl) tbl_init(tbl); } +void +tbl_restart(struct tbl *tbl) +{ + + tbl_clear(tbl); + tbl->part = TBL_PART_LAYOUT; +} + -- cgit