diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-11-28 06:27:05 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-11-28 06:27:05 +0000 |
commit | b7ed451bab9b712963df52a4f4ea0783fa4941d7 (patch) | |
tree | 5fb21a5e9b0f03fbe26d8bec4debbf45ca34578a | |
parent | cfd12f597e8f3e9e5acc3bfbeeef43065481d942 (diff) | |
download | mandoc-b7ed451bab9b712963df52a4f4ea0783fa4941d7.tar.gz |
Simplify by making the eqn and tbl steering functions void;
no functional change, minus 15 lines of code.
-rw-r--r-- | libmandoc.h | 8 | ||||
-rw-r--r-- | man.c | 6 | ||||
-rw-r--r-- | mdoc.c | 6 | ||||
-rw-r--r-- | read.c | 45 |
4 files changed, 24 insertions, 41 deletions
diff --git a/libmandoc.h b/libmandoc.h index 76309b7b..65613d8c 100644 --- a/libmandoc.h +++ b/libmandoc.h @@ -60,16 +60,16 @@ struct mdoc *mdoc_alloc(struct roff *, struct mparse *, void mdoc_reset(struct mdoc *); int mdoc_parseln(struct mdoc *, int, char *, int); int mdoc_endparse(struct mdoc *); -int mdoc_addspan(struct mdoc *, const struct tbl_span *); -int mdoc_addeqn(struct mdoc *, const struct eqn *); +void mdoc_addspan(struct mdoc *, const struct tbl_span *); +void mdoc_addeqn(struct mdoc *, const struct eqn *); void man_free(struct man *); struct man *man_alloc(struct roff *, struct mparse *, int); void man_reset(struct man *); int man_parseln(struct man *, int, char *, int); int man_endparse(struct man *); -int man_addspan(struct man *, const struct tbl_span *); -int man_addeqn(struct man *, const struct eqn *); +void man_addspan(struct man *, const struct tbl_span *); +void man_addeqn(struct man *, const struct eqn *); int preconv_cue(const struct buf *, size_t); int preconv_encode(struct buf *, size_t *, @@ -317,7 +317,7 @@ man_node_delete(struct man *man, struct man_node *p) man_node_free(p); } -int +void man_addeqn(struct man *man, const struct eqn *ep) { struct man_node *n; @@ -329,10 +329,9 @@ man_addeqn(struct man *man, const struct eqn *ep) man_node_append(man, n); man->next = MAN_NEXT_SIBLING; man_descope(man, ep->ln, ep->pos); - return(1); } -int +void man_addspan(struct man *man, const struct tbl_span *sp) { struct man_node *n; @@ -342,7 +341,6 @@ man_addspan(struct man *man, const struct tbl_span *sp) man_node_append(man, n); man->next = MAN_NEXT_SIBLING; man_descope(man, sp->line, 0); - return(1); } static void @@ -198,7 +198,7 @@ mdoc_endparse(struct mdoc *mdoc) return(1); } -int +void mdoc_addeqn(struct mdoc *mdoc, const struct eqn *ep) { struct mdoc_node *n; @@ -209,10 +209,9 @@ mdoc_addeqn(struct mdoc *mdoc, const struct eqn *ep) n->flags |= MDOC_LINE; node_append(mdoc, n); mdoc->next = MDOC_NEXT_SIBLING; - return(1); } -int +void mdoc_addspan(struct mdoc *mdoc, const struct tbl_span *sp) { struct mdoc_node *n; @@ -221,7 +220,6 @@ mdoc_addspan(struct mdoc *mdoc, const struct tbl_span *sp) n->span = sp; node_append(mdoc, n); mdoc->next = MDOC_NEXT_SIBLING; - return(1); } /* @@ -317,7 +317,7 @@ mparse_buf_r(struct mparse *curp, struct buf blk, size_t i, int start) struct buf ln; size_t pos; /* byte number in the ln buffer */ enum rofferr rr; - int of, rc; + int of; int lnn; /* line number in the real file */ unsigned char c; @@ -570,34 +570,21 @@ rerun: * Do the same for ROFF_EQN. */ - rc = -1; - - if (ROFF_TBL == rr) - while (NULL != (span = roff_span(curp->roff))) { - rc = curp->man ? - man_addspan(curp->man, span) : - mdoc_addspan(curp->mdoc, span); - if (0 == rc) - break; - } - else if (ROFF_EQN == rr) - rc = curp->mdoc ? - mdoc_addeqn(curp->mdoc, - roff_eqn(curp->roff)) : - man_addeqn(curp->man, - roff_eqn(curp->roff)); - else if (curp->man || curp->mdoc) - rc = curp->man ? - man_parseln(curp->man, - curp->line, ln.buf, of) : - mdoc_parseln(curp->mdoc, - curp->line, ln.buf, of); - - if (0 == rc) { - assert(MANDOCLEVEL_FATAL <= curp->file_status); - break; - } else if (2 == rc) - break; + if (rr == ROFF_TBL) { + while ((span = roff_span(curp->roff)) != NULL) + if (curp->man == NULL) + mdoc_addspan(curp->mdoc, span); + else + man_addspan(curp->man, span); + } else if (rr == ROFF_EQN) { + if (curp->man == NULL) + mdoc_addeqn(curp->mdoc, roff_eqn(curp->roff)); + else + man_addeqn(curp->man, roff_eqn(curp->roff)); + } else if ((curp->man == NULL ? + mdoc_parseln(curp->mdoc, curp->line, ln.buf, of) : + man_parseln(curp->man, curp->line, ln.buf, of)) == 2) + break; /* Temporary buffers typically are not full. */ |