]> git.cameronkatri.com Git - mandoc.git/blobdiff - mdoc_validate.c
Note discarding of \m, \M, and \s in COMPATIBILITY sections.
[mandoc.git] / mdoc_validate.c
index f16ed8d38bf7cc4166dbfb8a25a90ef8ddfa76f2..256f0fe8e7eb07020349aac3384fad6ba9e568d0 100644 (file)
@@ -1,6 +1,6 @@
-/*     $Id: mdoc_validate.c,v 1.106 2010/07/02 13:12:47 kristaps Exp $ */
+/*     $Id: mdoc_validate.c,v 1.110 2010/07/13 23:53:20 schwarze Exp $ */
 /*
- * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -647,8 +647,16 @@ pre_bl(PRE_ARGS)
 
                /* Assign list type. */
 
-               if (LIST__NONE != lt && n->data.Bl->type == LIST__NONE)
+               if (LIST__NONE != lt && n->data.Bl->type == LIST__NONE) {
                        n->data.Bl->type = lt;
+                       /* Set column information, too. */
+                       if (LIST_column == lt) {
+                               n->data.Bl->ncols = 
+                                       n->args->argv[i].sz;
+                               n->data.Bl->cols = (const char **)
+                                       n->args->argv[i].value;
+                       }
+               }
 
                /* The list type should come first. */
 
@@ -849,13 +857,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 +1091,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));
 }
 
 
@@ -1127,9 +1140,6 @@ post_it(POST_ARGS)
                if (NULL == mdoc->last->head->child)
                        if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS))
                                return(0);
-               if (NULL == mdoc->last->body->child)
-                       if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY))
-                               return(0);
                break;
        case (LIST_bullet):
                /* FALLTHROUGH */
@@ -1138,24 +1148,18 @@ post_it(POST_ARGS)
        case (LIST_enum):
                /* FALLTHROUGH */
        case (LIST_hyphen):
+               if (NULL == mdoc->last->body->child)
+                       if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY))
+                               return(0);
                /* FALLTHROUGH */
        case (LIST_item):
                if (mdoc->last->head->child)
                        if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_ARGSLOST))
                                return(0);
-               if (NULL == mdoc->last->body->child)
-                       if ( ! mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY))
-                               return(0);
                break;
        case (LIST_column):
-               cols = -1;
-               for (i = 0; i < (int)n->args->argc; i++)
-                       if (MDOC_Column == n->args->argv[i].arg) {
-                               cols = (int)n->args->argv[i].sz;
-                               break;
-                       }
+               cols = (int)n->data.Bl->ncols;
 
-               assert(-1 != cols);
                assert(NULL == mdoc->last->head->child);
 
                if (NULL == mdoc->last->body->child)
@@ -1195,12 +1199,7 @@ post_bl_head(POST_ARGS)
        n = mdoc->last->parent;
 
        if (LIST_column == n->data.Bl->type) {
-               for (i = 0; i < (int)n->args->argc; i++)
-                       if (MDOC_Column == n->args->argv[i].arg)
-                               break;
-               assert(i < (int)n->args->argc);
-
-               if (n->args->argv[i].sz && mdoc->last->nchild) {
+               if (n->data.Bl->ncols && mdoc->last->nchild) {
                        mdoc_nmsg(mdoc, n, MANDOCERR_COLUMNS);
                        return(0);
                }