From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]) by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id f405fc57 for ; Fri, 14 Dec 2018 01:33:44 -0500 (EST) Date: Fri, 14 Dec 2018 01:33:44 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: Cleanup, no functional change: Now that message handling is X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: <05f5e3d7ef3e9a63@fantadrom.bsd.lv> Log Message: ----------- 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. Modified Files: -------------- mandoc: eqn.c eqn_parse.h libmandoc.h man_macro.c mandoc.c mandoc_headers.3 mdoc_argv.c read.c roff.c roff.h tbl.3 tbl.c tbl_int.h tbl_parse.h Revision Data ------------- Index: roff.h =================================================================== RCS file: /home/cvs/mandoc/mandoc/roff.h,v retrieving revision 1.64 retrieving revision 1.65 diff -Lroff.h -Lroff.h -u -p -r1.64 -r1.65 --- roff.h +++ roff.h @@ -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. */ Index: mdoc_argv.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/mdoc_argv.c,v retrieving revision 1.117 retrieving revision 1.118 diff -Lmdoc_argv.c -Lmdoc_argv.c -u -p -r1.117 -r1.118 --- mdoc_argv.c +++ mdoc_argv.c @@ -572,7 +572,7 @@ args(struct roff_man *mdoc, int line, in } 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, Index: tbl.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/tbl.c,v retrieving revision 1.45 retrieving revision 1.46 diff -Ltbl.c -Ltbl.c -u -p -r1.45 -r1.46 --- tbl.c +++ tbl.c @@ -88,7 +88,7 @@ tbl_read(struct tbl_node *tbl, int ln, c } 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 mpar 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 = '.'; Index: mandoc_headers.3 =================================================================== RCS file: /home/cvs/mandoc/mandoc/mandoc_headers.3,v retrieving revision 1.27 retrieving revision 1.28 diff -Lmandoc_headers.3 -Lmandoc_headers.3 -u -p -r1.27 -r1.28 --- mandoc_headers.3 +++ 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 @@ -496,12 +478,6 @@ and the functions .Fn tbl_cdata , 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. Index: tbl_parse.h =================================================================== RCS file: /home/cvs/mandoc/mandoc/tbl_parse.h,v retrieving revision 1.1 retrieving revision 1.2 diff -Ltbl_parse.h -Ltbl_parse.h -u -p -r1.1 -r1.2 --- tbl_parse.h +++ tbl_parse.h @@ -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); Index: eqn.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/eqn.c,v retrieving revision 1.82 retrieving revision 1.83 diff -Leqn.c -Leqn.c -u -p -r1.82 -r1.83 --- eqn.c +++ eqn.c @@ -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; } Index: mandoc.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/mandoc.c,v retrieving revision 1.109 retrieving revision 1.110 diff -Lmandoc.c -Lmandoc.c -u -p -r1.109 -r1.110 --- mandoc.c +++ mandoc.c @@ -401,7 +401,7 @@ mandoc_escape(const char **end, const ch * 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; Index: tbl_int.h =================================================================== RCS file: /home/cvs/mandoc/mandoc/tbl_int.h,v retrieving revision 1.1 retrieving revision 1.2 diff -Ltbl_int.h -Ltbl_int.h -u -p -r1.1 -r1.2 --- tbl_int.h +++ tbl_int.h @@ -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. */ Index: man_macro.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/man_macro.c,v retrieving revision 1.135 retrieving revision 1.136 diff -Lman_macro.c -Lman_macro.c -u -p -r1.135 -r1.136 --- man_macro.c +++ man_macro.c @@ -456,6 +456,6 @@ man_args(struct roff_man *man, int line, if ('\0' == *start) return 0; - *v = mandoc_getarg(man->parse, v, line, pos); + *v = mandoc_getarg(v, line, pos); return 1; } Index: libmandoc.h =================================================================== RCS file: /home/cvs/mandoc/mandoc/libmandoc.h,v retrieving revision 1.75 retrieving revision 1.76 diff -Llibmandoc.h -Llibmandoc.h -u -p -r1.75 -r1.76 --- libmandoc.h +++ libmandoc.h @@ -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 *, 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 *); Index: eqn_parse.h =================================================================== RCS file: /home/cvs/mandoc/mandoc/eqn_parse.h,v retrieving revision 1.2 retrieving revision 1.3 diff -Leqn_parse.h -Leqn_parse.h -u -p -r1.2 -r1.3 --- eqn_parse.h +++ eqn_parse.h @@ -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 *); Index: read.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/read.c,v retrieving revision 1.206 retrieving revision 1.207 diff -Lread.c -Lread.c -u -p -r1.206 -r1.207 --- read.c +++ read.c @@ -647,8 +647,8 @@ mparse_alloc(int options, enum mandoc_os 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; Index: tbl.3 =================================================================== RCS file: /home/cvs/mandoc/mandoc/tbl.3,v retrieving revision 1.5 retrieving revision 1.6 diff -Ltbl.3 -Ltbl.3 -u -p -r1.5 -r1.6 --- tbl.3 +++ tbl.3 @@ -33,7 +33,6 @@ .Fo tbl_alloc .Fa "int pos" .Fa "int line" -.Fa "struct mparse *parse" .Fc .Ft void .Fo tbl_read @@ -103,12 +102,6 @@ members may be 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. Index: roff.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/roff.c,v retrieving revision 1.350 retrieving revision 1.351 diff -Lroff.c -Lroff.c -u -p -r1.350 -r1.351 --- roff.c +++ roff.c @@ -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; -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv