diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-11-28 03:14:18 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-11-28 03:14:18 +0000 |
commit | cd2da2e154b1769e7e7c7149764398901662008e (patch) | |
tree | 17a476f451f3d44a4cd206a895f6a46e171ae3f1 /mdoc_argv.c | |
parent | 5bd116b7cf73aba2041700609c3b7745aae1cb3b (diff) | |
download | mandoc-cd2da2e154b1769e7e7c7149764398901662008e.tar.gz |
Simplify the code by making various mdoc parser helper functions void.
No functional change, minus 130 lines of code.
Diffstat (limited to 'mdoc_argv.c')
-rw-r--r-- | mdoc_argv.c | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/mdoc_argv.c b/mdoc_argv.c index 37af880f..20dac8af 100644 --- a/mdoc_argv.c +++ b/mdoc_argv.c @@ -1,4 +1,4 @@ -/* $Id$ */ +/* $OpenBSD$ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2012 Ingo Schwarze <schwarze@openbsd.org> @@ -54,9 +54,9 @@ static void argn_free(struct mdoc_arg *, int); static enum margserr args(struct mdoc *, int, int *, char *, enum argsflag, char **); static int args_checkpunct(const char *, int); -static int argv_multi(struct mdoc *, int, +static void argv_multi(struct mdoc *, int, struct mdoc_argv *, int *, char *); -static int argv_single(struct mdoc *, int, +static void argv_single(struct mdoc *, int, struct mdoc_argv *, int *, char *); static const enum argvflag argvflags[MDOC_ARG_MAX] = { @@ -342,12 +342,10 @@ mdoc_argv(struct mdoc *mdoc, int line, enum mdoct tok, switch (argvflags[tmp.arg]) { case ARGV_SINGLE: - if ( ! argv_single(mdoc, line, &tmp, pos, buf)) - return(ARGV_ERROR); + argv_single(mdoc, line, &tmp, pos, buf); break; case ARGV_MULTI: - if ( ! argv_multi(mdoc, line, &tmp, pos, buf)) - return(ARGV_ERROR); + argv_multi(mdoc, line, &tmp, pos, buf); break; case ARGV_NONE: break; @@ -652,7 +650,7 @@ args_checkpunct(const char *buf, int i) return('\0' == buf[i]); } -static int +static void argv_multi(struct mdoc *mdoc, int line, struct mdoc_argv *v, int *pos, char *buf) { @@ -660,25 +658,21 @@ argv_multi(struct mdoc *mdoc, int line, char *p; for (v->sz = 0; ; v->sz++) { - if ('-' == buf[*pos]) + if (buf[*pos] == '-') break; ac = args(mdoc, line, pos, buf, ARGSFL_NONE, &p); - if (ARGS_ERROR == ac) - return(0); - else if (ARGS_EOLN == ac) + if (ac == ARGS_EOLN) break; - if (0 == v->sz % MULTI_STEP) + if (v->sz % MULTI_STEP == 0) v->value = mandoc_reallocarray(v->value, v->sz + MULTI_STEP, sizeof(char *)); v->value[(int)v->sz] = mandoc_strdup(p); } - - return(1); } -static int +static void argv_single(struct mdoc *mdoc, int line, struct mdoc_argv *v, int *pos, char *buf) { @@ -686,14 +680,10 @@ argv_single(struct mdoc *mdoc, int line, char *p; ac = args(mdoc, line, pos, buf, ARGSFL_NONE, &p); - if (ARGS_ERROR == ac) - return(0); - if (ARGS_EOLN == ac) - return(1); + if (ac == ARGS_EOLN) + return; v->sz = 1; v->value = mandoc_malloc(sizeof(char *)); v->value[0] = mandoc_strdup(p); - - return(1); } |