diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2018-12-14 06:33:04 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2018-12-14 06:33:04 +0000 |
commit | 517029c35a0748509844aaff82467e644ba37a22 (patch) | |
tree | 9e6887342895cc77dcf0e9e12b8f54f39dbdfa60 /usr.bin/mandoc | |
parent | 0dad72fbe7b543626df4b8f7375e7a5dcd75dbab (diff) |
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.
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r-- | usr.bin/mandoc/eqn.c | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/eqn_parse.h | 6 | ||||
-rw-r--r-- | usr.bin/mandoc/libmandoc.h | 10 | ||||
-rw-r--r-- | usr.bin/mandoc/man_macro.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/mandoc.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/mdoc_argv.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/read.c | 6 | ||||
-rw-r--r-- | usr.bin/mandoc/roff.c | 16 | ||||
-rw-r--r-- | usr.bin/mandoc/roff.h | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl.c | 5 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl_int.h | 3 | ||||
-rw-r--r-- | usr.bin/mandoc/tbl_parse.h | 5 |
12 files changed, 29 insertions, 42 deletions
diff --git a/usr.bin/mandoc/eqn.c b/usr.bin/mandoc/eqn.c index 46d1ab3ae92..667781fd748 100644 --- a/usr.bin/mandoc/eqn.c +++ b/usr.bin/mandoc/eqn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eqn.c,v 1.45 2018/12/14 05:17:45 schwarze Exp $ */ +/* $OpenBSD: eqn.c,v 1.46 2018/12/14 06:33:03 schwarze Exp $ */ /* * Copyright (c) 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2014, 2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -301,12 +301,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/usr.bin/mandoc/eqn_parse.h b/usr.bin/mandoc/eqn_parse.h index b935bc53645..0a8e61953b9 100644 --- a/usr.bin/mandoc/eqn_parse.h +++ b/usr.bin/mandoc/eqn_parse.h @@ -1,4 +1,4 @@ -/* $OpenBSD: eqn_parse.h,v 1.2 2018/12/13 05:13:15 schwarze Exp $ */ +/* $OpenBSD: eqn_parse.h,v 1.3 2018/12/14 06:33:03 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/usr.bin/mandoc/libmandoc.h b/usr.bin/mandoc/libmandoc.h index 26384fc38bc..1ec94ba4608 100644 --- a/usr.bin/mandoc/libmandoc.h +++ b/usr.bin/mandoc/libmandoc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libmandoc.h,v 1.60 2018/12/14 01:17:46 schwarze Exp $ */ +/* $OpenBSD: libmandoc.h,v 1.61 2018/12/14 06:33:03 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/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c index b01b695d556..c99eb3d9592 100644 --- a/usr.bin/mandoc/man_macro.c +++ b/usr.bin/mandoc/man_macro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man_macro.c,v 1.97 2018/12/14 05:17:45 schwarze Exp $ */ +/* $OpenBSD: man_macro.c,v 1.98 2018/12/14 06:33:03 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2012-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -454,6 +454,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; } diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c index d4f97235388..ac84e93497c 100644 --- a/usr.bin/mandoc/mandoc.c +++ b/usr.bin/mandoc/mandoc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mandoc.c,v 1.77 2018/12/14 05:17:45 schwarze Exp $ */ +/* $OpenBSD: mandoc.c,v 1.78 2018/12/14 06:33:03 schwarze Exp $ */ /* * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -399,7 +399,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/usr.bin/mandoc/mdoc_argv.c b/usr.bin/mandoc/mdoc_argv.c index 653633e958b..be2775f8f6e 100644 --- a/usr.bin/mandoc/mdoc_argv.c +++ b/usr.bin/mandoc/mdoc_argv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_argv.c,v 1.73 2018/12/14 05:17:45 schwarze Exp $ */ +/* $OpenBSD: mdoc_argv.c,v 1.74 2018/12/14 06:33:03 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2012, 2014-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -570,7 +570,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, diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c index 0ab390f6254..2cb4b29a478 100644 --- a/usr.bin/mandoc/read.c +++ b/usr.bin/mandoc/read.c @@ -1,4 +1,4 @@ -/* $OpenBSD: read.c,v 1.177 2018/12/14 05:17:45 schwarze Exp $ */ +/* $OpenBSD: read.c,v 1.178 2018/12/14 06:33:03 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -645,8 +645,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; diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index 5642e728572..439ef112e16 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.c,v 1.222 2018/12/14 05:17:45 schwarze Exp $ */ +/* $OpenBSD: roff.c,v 1.223 2018/12/14 06:33:03 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org> @@ -96,7 +96,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 */ @@ -778,12 +777,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); @@ -842,13 +840,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; @@ -3146,7 +3142,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; @@ -3180,7 +3176,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; @@ -3657,7 +3653,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; diff --git a/usr.bin/mandoc/roff.h b/usr.bin/mandoc/roff.h index b5709cd29e7..2d562908bc3 100644 --- a/usr.bin/mandoc/roff.h +++ b/usr.bin/mandoc/roff.h @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.h,v 1.46 2018/12/13 11:55:14 schwarze Exp $ */ +/* $OpenBSD: roff.h,v 1.47 2018/12/14 06:33:03 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. */ diff --git a/usr.bin/mandoc/tbl.c b/usr.bin/mandoc/tbl.c index c1f2d319df9..a3da958bd03 100644 --- a/usr.bin/mandoc/tbl.c +++ b/usr.bin/mandoc/tbl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl.c,v 1.26 2018/12/14 05:17:45 schwarze Exp $ */ +/* $OpenBSD: tbl.c,v 1.27 2018/12/14 06:33:03 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2015 Ingo Schwarze <schwarze@openbsd.org> @@ -86,7 +86,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; @@ -95,7 +95,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 = '.'; diff --git a/usr.bin/mandoc/tbl_int.h b/usr.bin/mandoc/tbl_int.h index f4e3b8a5d7b..299ceaaf792 100644 --- a/usr.bin/mandoc/tbl_int.h +++ b/usr.bin/mandoc/tbl_int.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl_int.h,v 1.1 2018/12/13 02:05:57 schwarze Exp $ */ +/* $OpenBSD: tbl_int.h,v 1.2 2018/12/14 06:33:03 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/usr.bin/mandoc/tbl_parse.h b/usr.bin/mandoc/tbl_parse.h index d1bb5bb66b7..b564490998a 100644 --- a/usr.bin/mandoc/tbl_parse.h +++ b/usr.bin/mandoc/tbl_parse.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tbl_parse.h,v 1.1 2018/12/13 02:05:57 schwarze Exp $ */ +/* $OpenBSD: tbl_parse.h,v 1.2 2018/12/14 06:33:03 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); |