summaryrefslogtreecommitdiffstats
path: root/eqn.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-12-13 03:40:13 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-12-13 03:40:13 +0000
commitb705aa5d322006a519c498654b59f3b1ba185233 (patch)
tree0bbe8ba3b79256717611153301186967246c92da /eqn.c
parentae67a8ca5712135cc0c82b55de5e8d387d42b8ef (diff)
downloadmandoc-b705aa5d322006a519c498654b59f3b1ba185233.tar.gz
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.
Diffstat (limited to 'eqn.c')
-rw-r--r--eqn.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/eqn.c b/eqn.c
index 48ce9d36..1e47aadd 100644
--- a/eqn.c
+++ b/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_mode mode)
void
eqn_box_free(struct eqn_box *bp)
{
+ if (bp == NULL)
+ return;
if (bp->first)
eqn_box_free(bp->first);
@@ -1093,6 +1101,9 @@ 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);
free(p->defs[i].val);