summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/mdoc.c
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2014-11-28 04:46:30 +0000
committerschwarze <schwarze@openbsd.org>2014-11-28 04:46:30 +0000
commit07f8b160d06743df934a293285b048338a89addd (patch)
tree3f49bd7df3d4743addf0e16369008f36501062e7 /usr.bin/mandoc/mdoc.c
parentSimplify the code by making various mdoc parser helper functions void. (diff)
downloadwireguard-openbsd-07f8b160d06743df934a293285b048338a89addd.tar.xz
wireguard-openbsd-07f8b160d06743df934a293285b048338a89addd.zip
Simplify by making the mdoc parser callbacks void, and some cleanup;
no functional change, minus 50 lines of code.
Diffstat (limited to 'usr.bin/mandoc/mdoc.c')
-rw-r--r--usr.bin/mandoc/mdoc.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c
index e24a9ef1a02..c0cd05b3c80 100644
--- a/usr.bin/mandoc/mdoc.c
+++ b/usr.bin/mandoc/mdoc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc.c,v 1.120 2014/11/28 03:13:58 schwarze Exp $ */
+/* $OpenBSD: mdoc.c,v 1.121 2014/11/28 04:46:30 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -192,7 +192,8 @@ int
mdoc_endparse(struct mdoc *mdoc)
{
- return(mdoc_macroend(mdoc));
+ mdoc_macroend(mdoc);
+ return(1);
}
int
@@ -248,7 +249,7 @@ mdoc_parseln(struct mdoc *mdoc, int ln, char *buf, int offs)
mdoc_ptext(mdoc, ln, buf, offs));
}
-int
+void
mdoc_macro(MACRO_PROT_ARGS)
{
assert(tok < MDOC_MAX);
@@ -258,7 +259,7 @@ mdoc_macro(MACRO_PROT_ARGS)
mandoc_vmsg(MANDOCERR_DT_LATE,
mdoc->parse, line, ppos,
"Dt %s", buf + *pos);
- return(1);
+ return;
}
} else if ( ! (mdoc_macros[tok].flags & MDOC_PROLOGUE)) {
if (mdoc->meta.title == NULL) {
@@ -271,8 +272,7 @@ mdoc_macro(MACRO_PROT_ARGS)
mdoc->meta.vol = mandoc_strdup("LOCAL");
mdoc->flags |= MDOC_PBODY;
}
-
- return((*mdoc_macros[tok].fp)(mdoc, tok, line, ppos, pos, buf));
+ (*mdoc_macros[tok].fp)(mdoc, tok, line, ppos, pos, buf);
}
@@ -604,7 +604,8 @@ mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs)
LIST_column == n->norm->Bl.type) {
/* `Bl' is open without any children. */
mdoc->flags |= MDOC_FREECOL;
- return(mdoc_macro(mdoc, MDOC_It, line, offs, &offs, buf));
+ mdoc_macro(mdoc, MDOC_It, line, offs, &offs, buf);
+ return(1);
}
if (MDOC_It == n->tok && MDOC_BLOCK == n->type &&
@@ -613,7 +614,8 @@ mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs)
LIST_column == n->parent->norm->Bl.type) {
/* `Bl' has block-level `It' children. */
mdoc->flags |= MDOC_FREECOL;
- return(mdoc_macro(mdoc, MDOC_It, line, offs, &offs, buf));
+ mdoc_macro(mdoc, MDOC_It, line, offs, &offs, buf);
+ return(1);
}
/*
@@ -691,7 +693,6 @@ mdoc_ptext(struct mdoc *mdoc, int line, char *buf, int offs)
if (mandoc_eos(buf+offs, (size_t)(end-buf-offs)))
mdoc->last->flags |= MDOC_EOS;
-
return(1);
}
@@ -763,8 +764,10 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs)
* into macro processing.
*/
- if (NULL == mdoc->last || MDOC_It == tok || MDOC_El == tok)
- return(mdoc_macro(mdoc, tok, ln, sv, &offs, buf));
+ if (NULL == mdoc->last || MDOC_It == tok || MDOC_El == tok) {
+ mdoc_macro(mdoc, tok, ln, sv, &offs, buf);
+ return(1);
+ }
n = mdoc->last;
assert(mdoc->last);
@@ -777,7 +780,8 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs)
if (MDOC_Bl == n->tok && MDOC_BODY == n->type &&
LIST_column == n->norm->Bl.type) {
mdoc->flags |= MDOC_FREECOL;
- return(mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf));
+ mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf);
+ return(1);
}
/*
@@ -791,13 +795,13 @@ mdoc_pmacro(struct mdoc *mdoc, int ln, char *buf, int offs)
MDOC_Bl == n->parent->tok &&
LIST_column == n->parent->norm->Bl.type) {
mdoc->flags |= MDOC_FREECOL;
- return(mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf));
+ mdoc_macro(mdoc, MDOC_It, ln, sv, &sv, buf);
+ return(1);
}
/* Normal processing of a macro. */
- if ( ! mdoc_macro(mdoc, tok, ln, sv, &offs, buf))
- return(0);
+ mdoc_macro(mdoc, tok, ln, sv, &offs, buf);
/* In quick mode (for mandocdb), abort after the NAME section. */