summaryrefslogtreecommitdiffstatshomepage
path: root/validate.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-01-08 14:55:59 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-01-08 14:55:59 +0000
commit41c017fd617974d1e7c44afa5e64143ad4f41e1e (patch)
treeef0a241e0ccef57897830fc705bc06f5e4b6bcdf /validate.c
parenta3f75e2959afffc9f3aaca2083e538f159a81bd5 (diff)
downloadmandoc-41c017fd617974d1e7c44afa5e64143ad4f41e1e.tar.gz
mandoc-41c017fd617974d1e7c44afa5e64143ad4f41e1e.tar.zst
mandoc-41c017fd617974d1e7c44afa5e64143ad4f41e1e.zip
*** empty log message ***
Diffstat (limited to 'validate.c')
-rw-r--r--validate.c60
1 files changed, 37 insertions, 23 deletions
diff --git a/validate.c b/validate.c
index ddf3c70d..a5cc6024 100644
--- a/validate.c
+++ b/validate.c
@@ -1,4 +1,4 @@
-/* $Id: validate.c,v 1.17 2009/01/07 15:53:00 kristaps Exp $ */
+/* $Id: validate.c,v 1.18 2009/01/08 14:55:59 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -22,9 +22,8 @@
#include "private.h"
-typedef int (*v_pre)(struct mdoc *, int, int,
- int, const struct mdoc_arg *);
-typedef int (*v_post)(struct mdoc *, int, int);
+typedef int (*v_pre)(struct mdoc *, struct mdoc_node *);
+typedef int (*v_post)(struct mdoc *);
struct valids {
@@ -33,11 +32,10 @@ struct valids {
};
-static int pre_sh(struct mdoc *, int, int,
- int, const struct mdoc_arg *);
-static int post_headchild_err_ge1(struct mdoc *, int, int);
-static int post_headchild_err_le8(struct mdoc *, int, int);
-static int post_bodychild_warn_ge1(struct mdoc *, int, int);
+static int pre_sh(struct mdoc *, struct mdoc_node *);
+static int post_headchild_err_ge1(struct mdoc *);
+static int post_headchild_err_le8(struct mdoc *);
+static int post_bodychild_warn_ge1(struct mdoc *);
static v_post posts_sh[] = { post_headchild_err_ge1,
post_bodychild_warn_ge1,
@@ -155,7 +153,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
static int
-post_bodychild_warn_ge1(struct mdoc *mdoc, int tok, int pos)
+post_bodychild_warn_ge1(struct mdoc *mdoc)
{
if (MDOC_BODY != mdoc->last->type)
@@ -163,24 +161,24 @@ post_bodychild_warn_ge1(struct mdoc *mdoc, int tok, int pos)
if (mdoc->last->child)
return(1);
- return(mdoc_warn(mdoc, tok, pos, WARN_ARGS_GE1));
+ return(mdoc_warn(mdoc, WARN_ARGS_GE1));
}
static int
-post_headchild_err_ge1(struct mdoc *mdoc, int tok, int pos)
+post_headchild_err_ge1(struct mdoc *mdoc)
{
if (MDOC_HEAD != mdoc->last->type)
return(1);
if (mdoc->last->child)
return(1);
- return(mdoc_err(mdoc, tok, pos, ERR_ARGS_GE1));
+ return(mdoc_err(mdoc, ERR_ARGS_GE1));
}
static int
-post_headchild_err_le8(struct mdoc *mdoc, int tok, int pos)
+post_headchild_err_le8(struct mdoc *mdoc)
{
int i;
struct mdoc_node *n;
@@ -191,13 +189,12 @@ post_headchild_err_le8(struct mdoc *mdoc, int tok, int pos)
/* Do nothing. */ ;
if (i <= 8)
return(1);
- return(mdoc_err(mdoc, tok, pos, ERR_ARGS_LE8));
+ return(mdoc_err(mdoc, ERR_ARGS_LE8));
}
static int
-pre_sh(struct mdoc *mdoc, int tok, int pos,
- int argc, const struct mdoc_arg *argv)
+pre_sh(struct mdoc *mdoc, struct mdoc_node *node)
{
return(1);
@@ -205,18 +202,35 @@ pre_sh(struct mdoc *mdoc, int tok, int pos,
int
-mdoc_valid_pre(struct mdoc *mdoc, int tok, int pos,
- int argc, const struct mdoc_arg *argv)
+mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *node)
{
+ int t;
+
+ switch (node->type) {
+ case (MDOC_BODY):
+ t = mdoc->last->data.body.tok;
+ break;
+ case (MDOC_ELEM):
+ t = mdoc->last->data.elem.tok;
+ break;
+ case (MDOC_BLOCK):
+ t = mdoc->last->data.block.tok;
+ break;
+ case (MDOC_HEAD):
+ t = mdoc->last->data.head.tok;
+ break;
+ default:
+ return(1);
+ }
- if (NULL == mdoc_valids[tok].pre)
+ if (NULL == mdoc_valids[t].pre)
return(1);
- return((*mdoc_valids[tok].pre)(mdoc, tok, pos, argc, argv));
+ return((*mdoc_valids[t].pre)(mdoc, node));
}
int
-mdoc_valid_post(struct mdoc *mdoc, int pos)
+mdoc_valid_post(struct mdoc *mdoc)
{
v_post *p;
int t;
@@ -242,7 +256,7 @@ mdoc_valid_post(struct mdoc *mdoc, int pos)
return(1);
for (p = mdoc_valids[t].post; *p; p++)
- if ( ! (*p)(mdoc, t, pos))
+ if ( ! (*p)(mdoc))
return(0);
return(1);