aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--mdoc.h13
-rw-r--r--mdoc_term.c19
-rw-r--r--mdoc_validate.c35
3 files changed, 35 insertions, 32 deletions
diff --git a/mdoc.h b/mdoc.h
index 224ad1ba..569864d2 100644
--- a/mdoc.h
+++ b/mdoc.h
@@ -1,4 +1,4 @@
-/* $Id: mdoc.h,v 1.98 2010/07/02 12:54:33 kristaps Exp $ */
+/* $Id: mdoc.h,v 1.99 2010/07/02 15:03:14 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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 62414099..dc4df036 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.167 2010/07/02 12:54:33 kristaps Exp $ */
+/* $Id: mdoc_term.c,v 1.168 2010/07/02 15:03:14 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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 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));
}