version 1.17, 2009/01/07 15:53:00 |
version 1.19, 2009/01/08 15:05:50 |
|
|
#include "private.h" |
#include "private.h" |
|
|
|
|
typedef int (*v_pre)(struct mdoc *, int, int, |
typedef int (*v_pre)(struct mdoc *, struct mdoc_node *); |
int, const struct mdoc_arg *); |
typedef int (*v_post)(struct mdoc *); |
typedef int (*v_post)(struct mdoc *, int, int); |
|
|
|
|
|
struct valids { |
struct valids { |
|
|
}; |
}; |
|
|
|
|
static int pre_sh(struct mdoc *, int, int, |
static int pre_sh(struct mdoc *, struct mdoc_node *); |
int, const struct mdoc_arg *); |
static int post_headchild_err_ge1(struct mdoc *); |
static int post_headchild_err_ge1(struct mdoc *, int, int); |
static int post_headchild_err_le8(struct mdoc *); |
static int post_headchild_err_le8(struct mdoc *, int, int); |
static int post_bodychild_warn_ge1(struct mdoc *); |
static int post_bodychild_warn_ge1(struct mdoc *, int, int); |
|
|
|
static v_post posts_sh[] = { post_headchild_err_ge1, |
static v_post posts_sh[] = { post_headchild_err_ge1, |
post_bodychild_warn_ge1, |
post_bodychild_warn_ge1, |
Line 46 static v_post posts_sh[] = { post_headchild_err_ge1, |
|
Line 44 static v_post posts_sh[] = { post_headchild_err_ge1, |
|
|
|
const struct valids mdoc_valids[MDOC_MAX] = { |
const struct valids mdoc_valids[MDOC_MAX] = { |
{ NULL, NULL }, /* \" */ |
{ NULL, NULL }, /* \" */ |
{ NULL, NULL }, /* Dd */ /* TODO */ |
{ NULL, NULL }, /* Dd */ /* TODO: pre: ordering, repetition */ |
{ NULL, NULL }, /* Dt */ /* TODO */ |
{ NULL, NULL }, /* Dt */ /* TODO ... */ |
{ NULL, NULL }, /* Os */ /* TODO */ |
{ NULL, NULL }, /* Os */ /* TODO ... */ |
{ pre_sh, posts_sh }, /* Sh */ /* FIXME: preceding Pp. */ |
{ pre_sh, posts_sh }, /* Sh */ /* FIXME: preceding Pp. */ |
{ NULL, NULL }, /* Ss */ /* FIXME: preceding Pp. */ |
{ NULL, NULL }, /* Ss */ /* FIXME: preceding Pp. */ |
{ NULL, NULL }, /* Pp */ |
{ NULL, NULL }, /* Pp */ |
Line 155 const struct valids mdoc_valids[MDOC_MAX] = { |
|
Line 153 const struct valids mdoc_valids[MDOC_MAX] = { |
|
|
|
|
|
static int |
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) |
if (MDOC_BODY != mdoc->last->type) |
Line 163 post_bodychild_warn_ge1(struct mdoc *mdoc, int tok, in |
|
Line 161 post_bodychild_warn_ge1(struct mdoc *mdoc, int tok, in |
|
if (mdoc->last->child) |
if (mdoc->last->child) |
return(1); |
return(1); |
|
|
return(mdoc_warn(mdoc, tok, pos, WARN_ARGS_GE1)); |
return(mdoc_warn(mdoc, WARN_ARGS_GE1)); |
} |
} |
|
|
|
|
static int |
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) |
if (MDOC_HEAD != mdoc->last->type) |
return(1); |
return(1); |
if (mdoc->last->child) |
if (mdoc->last->child) |
return(1); |
return(1); |
return(mdoc_err(mdoc, tok, pos, ERR_ARGS_GE1)); |
return(mdoc_err(mdoc, ERR_ARGS_GE1)); |
} |
} |
|
|
|
|
static int |
static int |
post_headchild_err_le8(struct mdoc *mdoc, int tok, int pos) |
post_headchild_err_le8(struct mdoc *mdoc) |
{ |
{ |
int i; |
int i; |
struct mdoc_node *n; |
struct mdoc_node *n; |
Line 191 post_headchild_err_le8(struct mdoc *mdoc, int tok, int |
|
Line 189 post_headchild_err_le8(struct mdoc *mdoc, int tok, int |
|
/* Do nothing. */ ; |
/* Do nothing. */ ; |
if (i <= 8) |
if (i <= 8) |
return(1); |
return(1); |
return(mdoc_err(mdoc, tok, pos, ERR_ARGS_LE8)); |
return(mdoc_err(mdoc, ERR_ARGS_LE8)); |
} |
} |
|
|
|
|
static int |
static int |
pre_sh(struct mdoc *mdoc, int tok, int pos, |
pre_sh(struct mdoc *mdoc, struct mdoc_node *node) |
int argc, const struct mdoc_arg *argv) |
|
{ |
{ |
|
|
return(1); |
return(1); |
Line 205 pre_sh(struct mdoc *mdoc, int tok, int pos, |
|
Line 202 pre_sh(struct mdoc *mdoc, int tok, int pos, |
|
|
|
|
|
int |
int |
mdoc_valid_pre(struct mdoc *mdoc, int tok, int pos, |
mdoc_valid_pre(struct mdoc *mdoc, struct mdoc_node *node) |
int argc, const struct mdoc_arg *argv) |
|
{ |
{ |
|
int t; |
|
|
if (NULL == mdoc_valids[tok].pre) |
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); |
return(1); |
return((*mdoc_valids[tok].pre)(mdoc, tok, pos, argc, argv)); |
} |
|
|
|
if (NULL == mdoc_valids[t].pre) |
|
return(1); |
|
return((*mdoc_valids[t].pre)(mdoc, node)); |
} |
} |
|
|
|
|
int |
int |
mdoc_valid_post(struct mdoc *mdoc, int pos) |
mdoc_valid_post(struct mdoc *mdoc) |
{ |
{ |
v_post *p; |
v_post *p; |
int t; |
int t; |
Line 242 mdoc_valid_post(struct mdoc *mdoc, int pos) |
|
Line 256 mdoc_valid_post(struct mdoc *mdoc, int pos) |
|
return(1); |
return(1); |
|
|
for (p = mdoc_valids[t].post; *p; p++) |
for (p = mdoc_valids[t].post; *p; p++) |
if ( ! (*p)(mdoc, t, pos)) |
if ( ! (*p)(mdoc)) |
return(0); |
return(0); |
|
|
return(1); |
return(1); |