summaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-07-02 15:03:14 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-07-02 15:03:14 +0000
commitbd7b99562ebb68adda0d9219a79d4eebc159b835 (patch)
tree1fb42c5f1e3c5fcf5f5ceb34a558161f62cb326b /mdoc_validate.c
parent810f75ce83e5d6362d138c5e9ccfe24c23ae8509 (diff)
downloadmandoc-bd7b99562ebb68adda0d9219a79d4eebc159b835.tar.gz
mandoc-bd7b99562ebb68adda0d9219a79d4eebc159b835.tar.zst
mandoc-bd7b99562ebb68adda0d9219a79d4eebc159b835.zip
Cached `An' arguments in struct mdoc_an. Note that this isn't a
pointer like the other data members, as there's no need to copy it around.
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index f16ed8d3..89801d52 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.106 2010/07/02 13:12:47 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.107 2010/07/02 15:03:14 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -849,13 +849,20 @@ static int
pre_an(PRE_ARGS)
{
- if (NULL == n->args || 1 == n->args->argc)
+ if (NULL == n->args)
return(1);
- mdoc_vmsg(mdoc, MANDOCERR_SYNTARGCOUNT,
- n->line, n->pos,
- "line arguments == 1 (have %d)",
- n->args->argc);
- return(0);
+ if (n->args->argc > 1)
+ if ( ! mdoc_nmsg(mdoc, n, MANDOCERR_ARGCOUNT))
+ return(0);
+
+ if (MDOC_Split == n->args->argv[0].arg)
+ n->data.An.auth = AUTH_split;
+ else if (MDOC_Nosplit == n->args->argv[0].arg)
+ n->data.An.auth = AUTH_nosplit;
+ else
+ abort();
+
+ return(1);
}
@@ -1076,16 +1083,14 @@ post_at(POST_ARGS)
static int
post_an(POST_ARGS)
{
+ struct mdoc_node *np;
- if (mdoc->last->args) {
- if (NULL == mdoc->last->child)
- return(1);
- return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_ARGCOUNT));
- }
-
- if (mdoc->last->child)
+ np = mdoc->last;
+ if (AUTH__NONE != np->data.An.auth && np->child)
+ return(mdoc_nmsg(mdoc, np, MANDOCERR_ARGCOUNT));
+ if (AUTH__NONE != np->data.An.auth || np->child)
return(1);
- return(mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS));
+ return(mdoc_nmsg(mdoc, np, MANDOCERR_NOARGS));
}