summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/roff.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2018-12-31 04:55:43 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2018-12-31 04:55:43 +0000
commit9dc0cbc9432027eab2d3c04c14013690b258818c (patch)
tree4c751989e920d43325566c37f6a4292d7ecd0f26 /usr.bin/mandoc/roff.c
parent9eca19b985d2c8f9ff720551709ddebb3287cfba (diff)
Cleanup, minus 15 LOC, no functional change:
Simplify the way the man(7) and mdoc(7) validators are called. Reset the parser state with a common function before calling them. There is no need to again reset the parser state afterwards, the parsers are no longer used after validation. This allows getting rid of man_node_validate() and mdoc_node_validate() as separate functions.
Diffstat (limited to 'usr.bin/mandoc/roff.c')
-rw-r--r--usr.bin/mandoc/roff.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 419fd3db0d6..ab9de5dd6d5 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.228 2018/12/30 00:48:48 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.229 2018/12/31 04:55:42 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze <schwarze@openbsd.org>
@@ -817,18 +817,25 @@ roff_man_free1(struct roff_man *man)
free(man->meta.sodest);
}
+void
+roff_state_reset(struct roff_man *man)
+{
+ man->last = man->meta.first;
+ man->last_es = NULL;
+ man->flags = 0;
+ man->lastsec = man->lastnamed = SEC_NONE;
+ man->next = ROFF_NEXT_CHILD;
+ roff_setreg(man->roff, "nS", 0, '=');
+}
+
static void
roff_man_alloc1(struct roff_man *man)
{
memset(&man->meta, 0, sizeof(man->meta));
man->meta.first = mandoc_calloc(1, sizeof(*man->meta.first));
man->meta.first->type = ROFFT_ROOT;
- man->last = man->meta.first;
- man->last_es = NULL;
- man->flags = 0;
man->meta.macroset = MACROSET_NONE;
- man->lastsec = man->lastnamed = SEC_NONE;
- man->next = ROFF_NEXT_CHILD;
+ roff_state_reset(man);
}
void