diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2018-12-14 06:33:14 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2018-12-14 06:33:14 +0000 |
commit | 4c2762423e7dcaf40f505c9000f23b6f18a484e5 (patch) | |
tree | 506be8e4f33431f64d95bfecad57d08f20be9dba | |
parent | 7a6eb8920bdea2ecc151b308352b2a98699b2350 (diff) | |
download | mandoc-4c2762423e7dcaf40f505c9000f23b6f18a484e5.tar.gz mandoc-4c2762423e7dcaf40f505c9000f23b6f18a484e5.tar.zst mandoc-4c2762423e7dcaf40f505c9000f23b6f18a484e5.zip |
Cleanup, no functional change:
Now that message handling is properly encapsulated,
remove struct mparse pointers from four structs (roff, roff_man,
tbl_node, eqn_node) and from the argument lists of five functions
(roff_alloc, roff_man_alloc, mandoc_getarg, tbl_alloc, eqn_alloc).
Except for being passed to the main program as an opaque object,
it now only occurs in read.c, as it should, and not across 15 files
like in the past.
-rw-r--r-- | eqn.c | 5 | ||||
-rw-r--r-- | eqn_parse.h | 6 | ||||
-rw-r--r-- | libmandoc.h | 10 | ||||
-rw-r--r-- | man_macro.c | 4 | ||||
-rw-r--r-- | mandoc.c | 4 | ||||
-rw-r--r-- | mandoc_headers.3 | 28 | ||||
-rw-r--r-- | mdoc_argv.c | 4 | ||||
-rw-r--r-- | read.c | 6 | ||||
-rw-r--r-- | roff.c | 16 | ||||
-rw-r--r-- | roff.h | 3 | ||||
-rw-r--r-- | tbl.3 | 11 | ||||
-rw-r--r-- | tbl.c | 5 | ||||
-rw-r--r-- | tbl_int.h | 3 | ||||
-rw-r--r-- | tbl_parse.h | 5 |
14 files changed, 33 insertions, 77 deletions
@@ -1,4 +1,4 @@ -/* $Id: eqn.c,v 1.82 2018/12/14 05:18:02 schwarze Exp $ */ +/* $Id: eqn.c,v 1.83 2018/12/14 06:33:14 schwarze Exp $ */ /* * Copyright (c) 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -303,12 +303,11 @@ static void eqn_undef(struct eqn_node *); struct eqn_node * -eqn_alloc(struct mparse *parse) +eqn_alloc(void) { struct eqn_node *ep; ep = mandoc_calloc(1, sizeof(*ep)); - ep->parse = parse; ep->gsize = EQN_DEFSIZE; return ep; } diff --git a/eqn_parse.h b/eqn_parse.h index c0090119..a2a4e6fd 100644 --- a/eqn_parse.h +++ b/eqn_parse.h @@ -1,4 +1,4 @@ -/* $Id: eqn_parse.h,v 1.2 2018/12/13 05:23:38 schwarze Exp $ */ +/* $Id: eqn_parse.h,v 1.3 2018/12/14 06:33:14 schwarze Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -19,13 +19,11 @@ * For use in the roff(7) and eqn(7) parsers only. */ -struct mparse; struct roff_node; struct eqn_box; struct eqn_def; struct eqn_node { - struct mparse *parse; /* Main parser, for error reporting. */ struct roff_node *node; /* Syntax tree of this equation. */ struct eqn_def *defs; /* Array of definitions. */ char *data; /* Source code of this equation. */ @@ -41,7 +39,7 @@ struct eqn_node { }; -struct eqn_node *eqn_alloc(struct mparse *); +struct eqn_node *eqn_alloc(void); struct eqn_box *eqn_box_new(void); void eqn_box_free(struct eqn_box *); void eqn_free(struct eqn_node *); diff --git a/libmandoc.h b/libmandoc.h index e2452f3e..d56ca1b6 100644 --- a/libmandoc.h +++ b/libmandoc.h @@ -1,4 +1,4 @@ -/* $Id: libmandoc.h,v 1.75 2018/12/14 01:18:25 schwarze Exp $ */ +/* $Id: libmandoc.h,v 1.76 2018/12/14 06:33:14 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org> @@ -45,11 +45,10 @@ struct buf { }; -struct mparse; struct roff; struct roff_man; -char *mandoc_getarg(struct mparse *, char **, int, int *); +char *mandoc_getarg(char **, int, int *); char *mandoc_normdate(struct roff_man *, char *, int, int); int mandoc_eos(const char *, size_t); int mandoc_strntoi(const char *, size_t, int); @@ -66,11 +65,10 @@ int preconv_encode(const struct buf *, size_t *, struct buf *, size_t *, int *); void roff_free(struct roff *); -struct roff *roff_alloc(struct mparse *, int); +struct roff *roff_alloc(int); void roff_reset(struct roff *); void roff_man_free(struct roff_man *); -struct roff_man *roff_man_alloc(struct roff *, struct mparse *, - const char *, int); +struct roff_man *roff_man_alloc(struct roff *, const char *, int); void roff_man_reset(struct roff_man *); int roff_parseln(struct roff *, int, struct buf *, int *); void roff_userret(struct roff *); diff --git a/man_macro.c b/man_macro.c index 7f0cccd7..faa37bf9 100644 --- a/man_macro.c +++ b/man_macro.c @@ -1,4 +1,4 @@ -/* $Id: man_macro.c,v 1.135 2018/12/14 05:18:02 schwarze Exp $ */ +/* $Id: man_macro.c,v 1.136 2018/12/14 06:33:14 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2012-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -456,6 +456,6 @@ man_args(struct roff_man *man, int line, int *pos, char *buf, char **v) if ('\0' == *start) return 0; - *v = mandoc_getarg(man->parse, v, line, pos); + *v = mandoc_getarg(v, line, pos); return 1; } @@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.109 2018/12/14 05:18:02 schwarze Exp $ */ +/* $Id: mandoc.c,v 1.110 2018/12/14 06:33:14 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -401,7 +401,7 @@ mandoc_escape(const char **end, const char **start, int *sz) * or to the NUL byte terminating the argument line. */ char * -mandoc_getarg(struct mparse *parse, char **cpp, int ln, int *pos) +mandoc_getarg(char **cpp, int ln, int *pos) { char *start, *cp; int quoted, pairs, white; diff --git a/mandoc_headers.3 b/mandoc_headers.3 index 66107e0d..e98f4174 100644 --- a/mandoc_headers.3 +++ b/mandoc_headers.3 @@ -192,7 +192,7 @@ and for .Vt enum mandoc_os . .Pp -Uses to opaque type +Uses the opaque type .Vt struct mparse from .Pa read.c @@ -260,11 +260,6 @@ Provides the functions described in .Xr mandoc 3 . .Pp -Uses the opaque type -.Vt struct mparse -from -.Pa read.c -for function prototypes. Uses the type .Vt struct roff_man from @@ -296,11 +291,7 @@ Provides utility functions needed by multiple parsers, and the top-level functions to call the parsers. .Pp -Uses the opaque types -.Vt struct mparse -from -.Pa read.c -and +Uses the opaque type .Vt struct roff from .Pa roff.c @@ -424,11 +415,6 @@ and the functions and .Fn eqn_reset . .Pp -Uses the opaque type -.Vt struct mparse -from -.Pa read.c -for function prototypes. Uses the type .Vt struct eqn_box from @@ -458,10 +444,6 @@ parsers only. Provides the functions documented in .Xr tbl 3 . .Pp -Uses the opaque type -.Vt struct mparse -from -.Pa read.c . Uses the types .Vt struct tbl_span from @@ -497,12 +479,6 @@ and the functions and .Fn tbl_reset . .Pp -Uses a pointer to the opaque type -.Vt struct mparse -from -.Pa read.c -as an opaque struct member. -.Pp When this header is included, the same file should not include interfaces of different parsers. .El diff --git a/mdoc_argv.c b/mdoc_argv.c index 1e52699a..fc1bc699 100644 --- a/mdoc_argv.c +++ b/mdoc_argv.c @@ -1,4 +1,4 @@ -/* $Id: mdoc_argv.c,v 1.117 2018/12/14 05:18:02 schwarze Exp $ */ +/* $Id: mdoc_argv.c,v 1.118 2018/12/14 06:33:14 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2012, 2014-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -572,7 +572,7 @@ args(struct roff_man *mdoc, int line, int *pos, } p = &buf[*pos]; - *v = mandoc_getarg(mdoc->parse, &p, line, pos); + *v = mandoc_getarg(&p, line, pos); /* * After parsing the last word in this phrase, @@ -1,4 +1,4 @@ -/* $Id: read.c,v 1.206 2018/12/14 05:18:03 schwarze Exp $ */ +/* $Id: read.c,v 1.207 2018/12/14 06:33:14 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -647,8 +647,8 @@ mparse_alloc(int options, enum mandoc_os os_e, const char *os_s) curp->options = options; curp->os_s = os_s; - curp->roff = roff_alloc(curp, options); - curp->man = roff_man_alloc(curp->roff, curp, curp->os_s, + curp->roff = roff_alloc(options); + curp->man = roff_man_alloc(curp->roff, curp->os_s, curp->options & MPARSE_QUICK ? 1 : 0); if (curp->options & MPARSE_MDOC) { curp->man->macroset = MACROSET_MDOC; @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.350 2018/12/14 05:18:03 schwarze Exp $ */ +/* $Id: roff.c,v 1.351 2018/12/14 06:33:14 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -98,7 +98,6 @@ struct mctx { }; struct roff { - struct mparse *parse; /* parse point */ struct roff_man *man; /* mdoc or man parser */ struct roffnode *last; /* leaf of stack */ struct mctx *mstack; /* stack of macro contexts */ @@ -780,12 +779,11 @@ roff_free(struct roff *r) } struct roff * -roff_alloc(struct mparse *parse, int options) +roff_alloc(int options) { struct roff *r; r = mandoc_calloc(1, sizeof(struct roff)); - r->parse = parse; r->reqtab = roffhash_alloc(0, ROFF_RENAMED); r->options = options; r->format = options & (MPARSE_MDOC | MPARSE_MAN); @@ -844,13 +842,11 @@ roff_man_free(struct roff_man *man) } struct roff_man * -roff_man_alloc(struct roff *roff, struct mparse *parse, - const char *os_s, int quick) +roff_man_alloc(struct roff *roff, const char *os_s, int quick) { struct roff_man *man; man = mandoc_calloc(1, sizeof(*man)); - man->parse = parse; man->roff = roff; man->os_s = os_s; man->quick = quick; @@ -3148,7 +3144,7 @@ roff_EQ(ROFF_ARGS) assert(r->eqn == NULL); if (r->last_eqn == NULL) - r->last_eqn = eqn_alloc(r->parse); + r->last_eqn = eqn_alloc(); else eqn_reset(r->last_eqn); r->eqn = r->last_eqn; @@ -3182,7 +3178,7 @@ roff_TS(ROFF_ARGS) mandoc_msg(MANDOCERR_BLK_BROKEN, ln, ppos, "TS breaks TS"); tbl_end(r->tbl, 0); } - r->tbl = tbl_alloc(ppos, ln, r->parse, r->last_tbl); + r->tbl = tbl_alloc(ppos, ln, r->last_tbl); if (r->last_tbl == NULL) r->first_tbl = r->tbl; r->last_tbl = r->tbl; @@ -3659,7 +3655,7 @@ roff_userdef(ROFF_ARGS) ctx->argv = mandoc_reallocarray(ctx->argv, ctx->argsz, sizeof(*ctx->argv)); } - arg = mandoc_getarg(r->parse, &src, ln, &pos); + arg = mandoc_getarg(&src, ln, &pos); sz = 1; /* For the terminating NUL. */ for (ap = arg; *ap != '\0'; ap++) sz += *ap == '"' ? 4 : 1; @@ -1,4 +1,4 @@ -/* $Id: roff.h,v 1.64 2018/12/13 11:55:47 schwarze Exp $ */ +/* $Id: roff.h,v 1.65 2018/12/14 06:33:14 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org> @@ -548,7 +548,6 @@ struct roff_meta { struct roff_man { struct roff_meta meta; /* Document meta-data. */ - struct mparse *parse; /* Parse pointer. */ struct roff *roff; /* Roff parser state data. */ struct ohash *mdocmac; /* Mdoc macro lookup table. */ struct ohash *manmac; /* Man macro lookup table. */ @@ -1,4 +1,4 @@ -.\" $Id: tbl.3,v 1.5 2018/12/13 02:06:07 schwarze Exp $ +.\" $Id: tbl.3,v 1.6 2018/12/14 06:33:14 schwarze Exp $ .\" .\" Copyright (c) 2013, 2015, 2018 Ingo Schwarze <schwarze@openbsd.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 13 2018 $ +.Dd $Mdocdate: December 14 2018 $ .Dt TBL 3 .Os .Sh NAME @@ -33,7 +33,6 @@ .Fo tbl_alloc .Fa "int pos" .Fa "int line" -.Fa "struct mparse *parse" .Fc .Ft void .Fo tbl_read @@ -104,12 +103,6 @@ but if there is a span, the function .Fn tbl_layout guarantees that these pointers are not .Dv NULL . -The function -.Fn tbl_alloc -guarantees that the -.Fa parse -member is not -.Dv NULL . .It Vt struct tbl_opts This structure describes the options of one table. It is used as a substructure of @@ -1,4 +1,4 @@ -/* $Id: tbl.c,v 1.45 2018/12/14 05:18:03 schwarze Exp $ */ +/* $Id: tbl.c,v 1.46 2018/12/14 06:33:14 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -88,7 +88,7 @@ tbl_read(struct tbl_node *tbl, int ln, const char *p, int pos) } struct tbl_node * -tbl_alloc(int pos, int line, struct mparse *parse, struct tbl_node *last_tbl) +tbl_alloc(int pos, int line, struct tbl_node *last_tbl) { struct tbl_node *tbl; @@ -97,7 +97,6 @@ tbl_alloc(int pos, int line, struct mparse *parse, struct tbl_node *last_tbl) last_tbl->next = tbl; tbl->line = line; tbl->pos = pos; - tbl->parse = parse; tbl->part = TBL_PART_OPTS; tbl->opts.tab = '\t'; tbl->opts.decimal = '.'; @@ -1,4 +1,4 @@ -/* $Id: tbl_int.h,v 1.1 2018/12/13 02:06:07 schwarze Exp $ */ +/* $Id: tbl_int.h,v 1.2 2018/12/14 06:33:14 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011,2013,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org> @@ -28,7 +28,6 @@ enum tbl_part { struct tbl_node { struct tbl_opts opts; /* Options for the whole table. */ - struct mparse *parse; /* For error reporting. */ struct tbl_node *next; /* Next table. */ struct tbl_row *first_row; /* First layout row. */ struct tbl_row *last_row; /* Last layout row. */ diff --git a/tbl_parse.h b/tbl_parse.h index b2fc8523..bb65536f 100644 --- a/tbl_parse.h +++ b/tbl_parse.h @@ -1,4 +1,4 @@ -/* $Id: tbl_parse.h,v 1.1 2018/12/13 02:06:07 schwarze Exp $ */ +/* $Id: tbl_parse.h,v 1.2 2018/12/14 06:33:14 schwarze Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -19,11 +19,10 @@ * For use in the roff(7) and tbl(7) parsers only. */ -struct mparse; struct tbl_node; struct tbl_span; -struct tbl_node *tbl_alloc(int, int, struct mparse *, struct tbl_node *); +struct tbl_node *tbl_alloc(int, int, struct tbl_node *); int tbl_end(struct tbl_node *, int); void tbl_free(struct tbl_node *); void tbl_read(struct tbl_node *, int, const char *, int); |