aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_argv.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-11-29 03:37:44 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-11-29 03:37:44 +0000
commit51e313e588be7d0035542c2c7b1fb7fbbe768e34 (patch)
tree5893269576d9c6b09b0002a68c141f44de14b641 /mdoc_argv.c
parentaaa501aed947d338340f598a6c435126af70b9a4 (diff)
downloadmandoc-51e313e588be7d0035542c2c7b1fb7fbbe768e34.tar.gz
mandoc-51e313e588be7d0035542c2c7b1fb7fbbe768e34.tar.zst
mandoc-51e313e588be7d0035542c2c7b1fb7fbbe768e34.zip
Provide a helper function macro_or_word() and use it to prune the
same chunk of argument parsing code out of five of the eight callback functions. The other three have too much special handling to participate. As a bonus, let lookup() and mdoc_args() deal with line macros and retire the lookup_raw() helper and the mdoc_zargs() internal interface function. No functional change, minus 40 lines of code.
Diffstat (limited to 'mdoc_argv.c')
-rw-r--r--mdoc_argv.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/mdoc_argv.c b/mdoc_argv.c
index aebbac3a..3e7fabd2 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -412,22 +412,17 @@ argn_free(struct mdoc_arg *p, int iarg)
}
enum margserr
-mdoc_zargs(struct mdoc *mdoc, int line, int *pos, char *buf, char **v)
-{
-
- return(args(mdoc, line, pos, buf, ARGSFL_NONE, v));
-}
-
-enum margserr
mdoc_args(struct mdoc *mdoc, int line, int *pos,
char *buf, enum mdoct tok, char **v)
{
- enum argsflag fl;
struct mdoc_node *n;
+ char *v_local;
+ enum argsflag fl;
- fl = mdocargs[tok].flags;
-
- if (MDOC_It != tok)
+ if (v == NULL)
+ v = &v_local;
+ fl = tok == MDOC_MAX ? ARGSFL_NONE : mdocargs[tok].flags;
+ if (tok != MDOC_It)
return(args(mdoc, line, pos, buf, fl, v));
/*