summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mdoc.h11
-rw-r--r--mdoc_term.c17
-rw-r--r--mdoc_validate.c33
3 files changed, 32 insertions, 29 deletions
diff --git a/mdoc.h b/mdoc.h
index 50f6647e..50864bcd 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -279,6 +279,12 @@ enum mdoc_disp {
DISP_literal
};
+enum mdoc_auth {
+ AUTH__NONE = 0,
+ AUTH_split,
+ AUTH_nosplit
+};
+
enum mdoc_font {
FONT__NONE = 0,
FONT_Em,
@@ -303,6 +309,10 @@ struct mdoc_bf {
enum mdoc_font font; /* font */
};
+struct mdoc_an {
+ enum mdoc_auth auth; /* -split, etc. */
+};
+
/* Node in AST. */
struct mdoc_node {
struct mdoc_node *parent; /* parent AST node */
@@ -332,6 +342,7 @@ struct mdoc_node {
enum mdoc_endbody end; /* BODY */
union {
+ struct mdoc_an An;
struct mdoc_bd *Bd;
struct mdoc_bf *Bf;
struct mdoc_bl *Bl;
diff --git a/mdoc_term.c b/mdoc_term.c
index 6ab8bb9c..eae580af 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -57,7 +57,6 @@ static size_t a2width(const struct termp *, const char *);
static size_t a2height(const struct termp *, const char *);
static size_t a2offs(const struct termp *, const char *);
-static int arg_hasattr(int, const struct mdoc_node *);
static int arg_getattr(int, const struct mdoc_node *);
static void print_bvspace(struct termp *,
const struct mdoc_node *,
@@ -528,18 +527,6 @@ a2offs(const struct termp *p, const char *v)
/*
- * Return 1 if an argument has a particular argument value or 0 if it
- * does not. See arg_getattr().
- */
-static int
-arg_hasattr(int arg, const struct mdoc_node *n)
-{
-
- return(-1 != arg_getattr(arg, n));
-}
-
-
-/*
* Get the index of an argument in a node's argument list or -1 if it
* does not exist.
*/
@@ -1141,10 +1128,10 @@ termp_an_post(DECL_ARGS)
return;
}
- if (arg_hasattr(MDOC_Split, n)) {
+ if (AUTH_split == n->data.An.auth) {
p->flags &= ~TERMP_NOSPLIT;
p->flags |= TERMP_SPLIT;
- } else {
+ } else if (AUTH_nosplit == n->data.An.auth) {
p->flags &= ~TERMP_SPLIT;
p->flags |= TERMP_NOSPLIT;
}
diff --git a/mdoc_validate.c b/mdoc_validate.c
index dd70ed96..3e8e1066 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -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));
}