diff options
author | 2018-12-13 02:05:57 +0000 | |
---|---|---|
committer | 2018-12-13 02:05:57 +0000 | |
commit | fb382a019a53c397434fb3f70980852770813a0c (patch) | |
tree | 0dcc008cfce13eccc79b35d2358d8fc9ee4fe79c /usr.bin/mandoc/roff.c | |
parent | add commented-out "val-log-level: 2" next to the uncommentable line to (diff) | |
download | wireguard-openbsd-fb382a019a53c397434fb3f70980852770813a0c.tar.xz wireguard-openbsd-fb382a019a53c397434fb3f70980852770813a0c.zip |
Cleanup, no functional change:
Move tbl(7)-specific parser internals out of libroff.h.
Move some tbl(7)-internal processing from roff.c to tbl.c.
Diffstat (limited to 'usr.bin/mandoc/roff.c')
-rw-r--r-- | usr.bin/mandoc/roff.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index a3ef67721e1..1b0bf0b9687 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.c,v 1.217 2018/12/12 21:54:30 schwarze Exp $ */ +/* $OpenBSD: roff.c,v 1.218 2018/12/13 02:05:57 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -30,10 +30,10 @@ #include "mandoc_ohash.h" #include "mandoc.h" #include "roff.h" -#include "tbl.h" #include "libmandoc.h" #include "roff_int.h" #include "libroff.h" +#include "tbl_parse.h" /* Maximum number of string expansions per line, to break infinite loops. */ #define EXPAND_LIMIT 1000 @@ -166,7 +166,7 @@ static int roffnode_cleanscope(struct roff *); static int roffnode_pop(struct roff *); static void roffnode_push(struct roff *, enum roff_tok, const char *, int, int); -static void roff_addtbl(struct roff_man *, struct tbl_node *); +static void roff_addtbl(struct roff_man *, int, struct tbl_node *); static int roff_als(ROFF_ARGS); static int roff_block(ROFF_ARGS); static int roff_block_text(ROFF_ARGS); @@ -716,13 +716,9 @@ roffnode_push(struct roff *r, enum roff_tok tok, const char *name, static void roff_free1(struct roff *r) { - struct tbl_node *tbl; int i; - while (NULL != (tbl = r->first_tbl)) { - r->first_tbl = tbl->next; - tbl_free(tbl); - } + tbl_free(r->first_tbl); r->first_tbl = r->last_tbl = r->tbl = NULL; if (r->last_eqn != NULL) @@ -1012,15 +1008,15 @@ roff_body_alloc(struct roff_man *man, int line, int pos, int tok) } static void -roff_addtbl(struct roff_man *man, struct tbl_node *tbl) +roff_addtbl(struct roff_man *man, int line, struct tbl_node *tbl) { struct roff_node *n; - const struct tbl_span *span; + struct tbl_span *span; if (man->macroset == MACROSET_MAN) man_breakscope(man, ROFF_TS); while ((span = tbl_span(tbl)) != NULL) { - n = roff_node_alloc(man, tbl->line, 0, ROFFT_TBL, TOKEN_NONE); + n = roff_node_alloc(man, line, 0, ROFFT_TBL, TOKEN_NONE); n->span = span; roff_node_append(man, n); n->flags |= NODE_VALID | NODE_ENDED; @@ -1658,7 +1654,7 @@ roff_parseln(struct roff *r, int ln, struct buf *buf, int *offs) } if (r->tbl != NULL && (ctl == 0 || buf->buf[pos] == '\0')) { tbl_read(r->tbl, ln, buf->buf, ppos); - roff_addtbl(r->man, r->tbl); + roff_addtbl(r->man, ln, r->tbl); return e; } if ( ! ctl) @@ -1702,7 +1698,7 @@ roff_parseln(struct roff *r, int ln, struct buf *buf, int *offs) while (buf->buf[pos] == ' ') pos++; tbl_read(r->tbl, ln, buf->buf, pos); - roff_addtbl(r->man, r->tbl); + roff_addtbl(r->man, ln, r->tbl); return ROFF_IGN; } @@ -1765,9 +1761,7 @@ roff_endparse(struct roff *r) } if (r->tbl != NULL) { - mandoc_msg(MANDOCERR_BLK_NOEND, r->parse, - r->tbl->line, r->tbl->pos, "TS"); - tbl_end(r->tbl); + tbl_end(r->tbl, 1); r->tbl = NULL; } } @@ -3058,7 +3052,7 @@ roff_TE(ROFF_ARGS) ln, ppos, "TE"); return ROFF_IGN; } - if (tbl_end(r->tbl) == 0) { + if (tbl_end(r->tbl, 0) == 0) { r->tbl = NULL; free(buf->buf); buf->buf = mandoc_strdup(".sp"); @@ -3199,12 +3193,10 @@ roff_TS(ROFF_ARGS) if (r->tbl != NULL) { mandoc_msg(MANDOCERR_BLK_BROKEN, r->parse, ln, ppos, "TS breaks TS"); - tbl_end(r->tbl); + tbl_end(r->tbl, 0); } - r->tbl = tbl_alloc(ppos, ln, r->parse); - if (r->last_tbl) - r->last_tbl->next = r->tbl; - else + r->tbl = tbl_alloc(ppos, ln, r->parse, r->last_tbl); + if (r->last_tbl == NULL) r->first_tbl = r->tbl; r->last_tbl = r->tbl; return ROFF_IGN; |