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 d51fbbce for ; Wed, 12 Dec 2018 22:40:43 -0500 (EST) Date: Wed, 12 Dec 2018 22:40:43 -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: In libroff.h, nothing was left X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: <05f5ce6101929675@fantadrom.bsd.lv> Log Message: ----------- Cleanup, no functional change: In libroff.h, nothing was left except the eqn(7) parser interface, which isn't really part of the roff(7) parser, so rename it to eqn_parse.h. While here, move struct eqn_def to eqn.c because that's the only file using it, and let eqn_box_free() and eqn_free() handle NULL. Modified Files: -------------- mandoc: Makefile Makefile.depend eqn.c mandoc_headers.3 roff.c Added Files: ----------- mandoc: eqn_parse.h Removed Files: ------------- mandoc: libroff.h Revision Data ------------- Index: Makefile =================================================================== RCS file: /home/cvs/mandoc/mandoc/Makefile,v retrieving revision 1.522 retrieving revision 1.523 diff -LMakefile -LMakefile -u -p -r1.522 -r1.523 --- Makefile +++ Makefile @@ -155,13 +155,13 @@ DISTFILES = INSTALL \ dbm_map.h \ demandoc.1 \ eqn.7 \ + eqn_parse.h \ gmdiff \ html.h \ lib.in \ libman.h \ libmandoc.h \ libmdoc.h \ - libroff.h \ main.h \ makewhatis.8 \ man.1 \ --- libroff.h +++ /dev/null @@ -1,48 +0,0 @@ -/* $Id: libroff.h,v 1.43 2018/12/13 02:06:07 schwarze Exp $ */ -/* - * Copyright (c) 2011 Kristaps Dzonsons - * Copyright (c) 2014, 2017 Ingo Schwarze - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -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 */ - char *start; /* first byte of the current token */ - char *end; /* first byte of the next token */ - size_t defsz; /* number of definitions */ - size_t sz; /* length of the source code */ - size_t toksz; /* length of the current token */ - int gsize; /* default point size */ - int delim; /* in-line delimiters enabled */ - char odelim; /* in-line opening delimiter */ - char cdelim; /* in-line closing delimiter */ -}; - -struct eqn_def { - char *key; - size_t keysz; - char *val; - size_t valsz; -}; - - -struct eqn_node *eqn_alloc(struct mparse *); -void eqn_box_free(struct eqn_box *); -void eqn_free(struct eqn_node *); -void eqn_parse(struct eqn_node *); -void eqn_read(struct eqn_node *, const char *); -void eqn_reset(struct eqn_node *); Index: Makefile.depend =================================================================== RCS file: /home/cvs/mandoc/mandoc/Makefile.depend,v retrieving revision 1.34 retrieving revision 1.35 diff -LMakefile.depend -LMakefile.depend -u -p -r1.34 -r1.35 --- Makefile.depend +++ Makefile.depend @@ -27,7 +27,7 @@ dba_write.o: dba_write.c config.h dba_wr dbm.o: dbm.c config.h mansearch.h dbm_map.h dbm.h dbm_map.o: dbm_map.c config.h mansearch.h dbm_map.h dbm.h demandoc.o: demandoc.c config.h mandoc.h roff.h man.h mdoc.h -eqn.o: eqn.c config.h mandoc_aux.h mandoc.h roff.h libmandoc.h libroff.h +eqn.o: eqn.c config.h mandoc_aux.h mandoc.h roff.h libmandoc.h eqn_parse.h eqn_html.o: eqn_html.c config.h mandoc.h out.h html.h eqn_term.o: eqn_term.c config.h mandoc.h out.h term.h html.o: html.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h out.h html.h manconf.h main.h @@ -56,24 +56,24 @@ mdoc_state.o: mdoc_state.c mandoc.h roff mdoc_term.o: mdoc_term.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h out.h term.h tag.h main.h mdoc_validate.o: mdoc_validate.c config.h mandoc_aux.h mandoc.h mandoc_xr.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h msec.o: msec.c config.h mandoc.h libmandoc.h msec.in -out.o: out.c config.h mandoc_aux.h mandoc.h out.h +out.o: out.c config.h mandoc_aux.h mandoc.h tbl.h out.h preconv.o: preconv.c config.h mandoc.h libmandoc.h read.o: read.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h libmandoc.h -roff.o: roff.c config.h mandoc.h mandoc_aux.h mandoc_ohash.h compat_ohash.h roff.h libmandoc.h roff_int.h libroff.h predefs.in +roff.o: roff.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h libmandoc.h roff_int.h tbl_parse.h eqn_parse.h predefs.in roff_html.o: roff_html.c mandoc.h roff.h out.h html.h roff_term.o: roff_term.c mandoc.h roff.h out.h term.h roff_validate.o: roff_validate.c mandoc.h roff.h libmandoc.h roff_int.h soelim.o: soelim.c config.h compat_stringlist.h st.o: st.c config.h mandoc.h roff.h mdoc.h libmdoc.h st.in tag.o: tag.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h tag.h -tbl.o: tbl.c config.h mandoc.h mandoc_aux.h libmandoc.h libroff.h -tbl_data.o: tbl_data.c config.h mandoc.h mandoc_aux.h libmandoc.h libroff.h -tbl_html.o: tbl_html.c config.h mandoc.h out.h html.h -tbl_layout.o: tbl_layout.c config.h mandoc.h mandoc_aux.h libmandoc.h libroff.h -tbl_opts.o: tbl_opts.c config.h mandoc.h libmandoc.h libroff.h -tbl_term.o: tbl_term.c config.h mandoc.h out.h term.h +tbl.o: tbl.c config.h mandoc_aux.h mandoc.h tbl.h libmandoc.h tbl_parse.h tbl_int.h +tbl_data.o: tbl_data.c config.h mandoc_aux.h mandoc.h tbl.h libmandoc.h tbl_int.h +tbl_html.o: tbl_html.c config.h tbl.h out.h html.h +tbl_layout.o: tbl_layout.c config.h mandoc_aux.h mandoc.h tbl.h libmandoc.h tbl_int.h +tbl_opts.o: tbl_opts.c config.h mandoc.h tbl.h libmandoc.h tbl_int.h +tbl_term.o: tbl_term.c config.h mandoc.h tbl.h out.h term.h term.o: term.c config.h mandoc.h mandoc_aux.h out.h term.h main.h term_ascii.o: term_ascii.c config.h mandoc.h mandoc_aux.h out.h term.h manconf.h main.h term_ps.o: term_ps.c config.h mandoc_aux.h out.h term.h manconf.h main.h term_tab.o: term_tab.c mandoc_aux.h out.h term.h -tree.o: tree.c config.h mandoc.h roff.h mdoc.h man.h main.h +tree.o: tree.c config.h mandoc.h roff.h mdoc.h man.h tbl.h main.h Index: eqn.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/eqn.c,v retrieving revision 1.79 retrieving revision 1.80 diff -Leqn.c -Leqn.c -u -p -r1.79 -r1.80 --- eqn.c +++ eqn.c @@ -30,9 +30,8 @@ #include "mandoc_aux.h" #include "mandoc.h" #include "roff.h" -#include "tbl.h" #include "libmandoc.h" -#include "libroff.h" +#include "eqn_parse.h" #define EQN_NEST_MAX 128 /* maximum nesting of defines */ #define STRNEQ(p1, sz1, p2, sz2) \ @@ -285,6 +284,13 @@ enum parse_mode { MODE_TOK }; +struct eqn_def { + char *key; + size_t keysz; + char *val; + size_t valsz; +}; + static struct eqn_box *eqn_box_alloc(struct eqn_node *, struct eqn_box *); static struct eqn_box *eqn_box_makebinary(struct eqn_node *, struct eqn_box *); @@ -469,6 +475,8 @@ eqn_next(struct eqn_node *ep, enum parse void eqn_box_free(struct eqn_box *bp) { + if (bp == NULL) + return; if (bp->first) eqn_box_free(bp->first); @@ -1092,6 +1100,9 @@ void eqn_free(struct eqn_node *p) { int i; + + if (p == NULL) + return; for (i = 0; i < (int)p->defsz; i++) { free(p->defs[i].key); Index: roff.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/roff.c,v retrieving revision 1.346 retrieving revision 1.347 diff -Lroff.c -Lroff.c -u -p -r1.346 -r1.347 --- roff.c +++ roff.c @@ -34,8 +34,8 @@ #include "roff.h" #include "libmandoc.h" #include "roff_int.h" -#include "libroff.h" #include "tbl_parse.h" +#include "eqn_parse.h" /* Maximum number of string expansions per line, to break infinite loops. */ #define EXPAND_LIMIT 1000 @@ -723,8 +723,7 @@ roff_free1(struct roff *r) tbl_free(r->first_tbl); r->first_tbl = r->last_tbl = r->tbl = NULL; - if (r->last_eqn != NULL) - eqn_free(r->last_eqn); + eqn_free(r->last_eqn); r->last_eqn = r->eqn = NULL; while (r->mstackpos >= 0) @@ -1079,8 +1078,7 @@ roff_node_free(struct roff_node *n) mdoc_argv_free(n->args); if (n->type == ROFFT_BLOCK || n->type == ROFFT_ELEM) free(n->norm); - if (n->eqn != NULL) - eqn_box_free(n->eqn); + eqn_box_free(n->eqn); free(n->string); free(n); } --- /dev/null +++ eqn_parse.h @@ -0,0 +1,49 @@ +/* $Id: eqn_parse.h,v 1.1 2018/12/13 03:40:13 schwarze Exp $ */ +/* + * Copyright (c) 2011 Kristaps Dzonsons + * Copyright (c) 2014, 2017 Ingo Schwarze + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * External interface of the eqn(7) parser. + * 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. */ + char *start; /* First byte of the current token. */ + char *end; /* First byte of the next token. */ + size_t defsz; /* Number of definitions. */ + size_t sz; /* Length of the source code. */ + size_t toksz; /* Length of the current token. */ + int gsize; /* Default point size. */ + int delim; /* In-line delimiters enabled. */ + char odelim; /* In-line opening delimiter. */ + char cdelim; /* In-line closing delimiter. */ +}; + + +struct eqn_node *eqn_alloc(struct mparse *); +void eqn_box_free(struct eqn_box *); +void eqn_free(struct eqn_node *); +void eqn_parse(struct eqn_node *); +void eqn_read(struct eqn_node *, const char *); +void eqn_reset(struct eqn_node *); Index: mandoc_headers.3 =================================================================== RCS file: /home/cvs/mandoc/mandoc/mandoc_headers.3,v retrieving revision 1.21 retrieving revision 1.22 diff -Lmandoc_headers.3 -Lmandoc_headers.3 -u -p -r1.21 -r1.22 --- mandoc_headers.3 +++ mandoc_headers.3 @@ -231,9 +231,7 @@ from as an opaque type for function prototypes. .Pp When this header is included, the same file should not include -.Pa libman.h -or -.Pa libroff.h . +internals of different parsers. .It Qq Pa man.h Provides the functions .Fn man_* @@ -252,9 +250,7 @@ from as an opaque type for function prototypes. .Pp When this header is included, the same file should not include -.Pa libmdoc.h -or -.Pa libroff.h . +internals of different parsers. .El .Ss Parser internals Most of the following headers require inclusion of a parser interface header @@ -351,10 +347,7 @@ from as opaque types for function prototypes. .Pp When this header is included, the same file should not include -.Pa man.h , -.Pa libman.h , -or -.Pa libroff.h . +interfaces of different parsers. .It Qq Pa libman.h Requires .Qq Pa roff.h @@ -376,38 +369,54 @@ from as opaque types for function prototypes. .Pp When this header is included, the same file should not include -.Pa mdoc.h , -.Pa libmdoc.h , -or -.Pa libroff.h . -.It Qq Pa libroff.h +interfaces of different parsers. +.It Qq Pa eqn_parse.h +External interface of the +.Xr eqn 7 +parser, for use in the +.Xr roff 7 +and +.Xr eqn 7 +parsers only. +.Pp Requires .In sys/types.h for -.Vt size_t -and -.Qq Pa mandoc.h -for -.Vt struct eqn_box . +.Vt size_t . .Pp Provides -.Vt struct eqn_def , -.Vt struct eqn_node , -and many functions internal to the -.Xr eqn 7 -parser. +.Vt struct eqn_node +and the functions +.Fn eqn_alloc , +.Fn eqn_box_free , +.Fn eqn_free , +.Fn eqn_parse , +.Fn eqn_read , +and +.Fn eqn_reset . .Pp Uses the opaque type .Vt struct mparse from -.Pa read.c . +.Pa read.c +for function prototypes. +Uses the type +.Vt struct eqn_box +from +.Pa mandoc.h +as an opaque type for function prototypes. +Uses the types +.Vt struct roff_node +from +.Pa roff.h +and +.Vt struct eqn_def +from +.Pa eqn.c +as opaque struct members. .Pp When this header is included, the same file should not include -.Pa man.h , -.Pa mdoc.h , -.Pa libman.h , -or -.Pa libmdoc.h . +internals of different parsers. .It Qq Pa tbl_parse.h External interface of the .Xr tbl 7 @@ -435,7 +444,7 @@ from as opaque types for function prototypes. .Pp When this header is included, the same file should not include -internals of a different parser. +internals of different parsers. .It Qq Pa tbl_int.h Internal interfaces of the .Xr tbl 7 -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv