summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-01-12 17:26:42 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-01-12 17:26:42 +0000
commit29a6a3e523dc0b1673d87a68f8801d248cc7926d (patch)
treee9e37b64db68050e4d1e16819aa722abbd7a583b
parent1ffa508fd07870fb2094e48de2c5207abd02fc6c (diff)
downloadmandoc-29a6a3e523dc0b1673d87a68f8801d248cc7926d.tar.gz
*** empty log message ***
-rw-r--r--macro.c28
-rw-r--r--validate.c52
2 files changed, 52 insertions, 28 deletions
diff --git a/macro.c b/macro.c
index 37769a85..673325d4 100644
--- a/macro.c
+++ b/macro.c
@@ -68,6 +68,8 @@ rewind_last(struct mdoc *mdoc, struct mdoc_node *to)
return(0);
if ( ! mdoc_action_post(mdoc))
return(0);
+ mdoc_msg(mdoc, "rewound to %s",
+ mdoc_macronames[mdoc->last->tok]);
return(1);
}
@@ -78,6 +80,8 @@ rewind_last(struct mdoc *mdoc, struct mdoc_node *to)
return(0);
if ( ! mdoc_action_post(mdoc))
return(0);
+ mdoc_msg(mdoc, "rewound to %s",
+ mdoc_macronames[mdoc->last->tok]);
} while (mdoc->last != to);
return(1);
@@ -109,11 +113,10 @@ rewind_body(struct mdoc *mdoc, int tok)
/* LINTED */
for (n = mdoc->last; n; n = n->parent) {
- if (MDOC_BODY != n->type)
- continue;
- if (tok == (t = n->tok))
+ t = n->tok;
+ if (MDOC_BODY == n->type && tok == t)
break;
- if ( ! (MDOC_EXPLICIT & mdoc_macros[t].flags))
+ if (MDOC_NESTED & mdoc_macros[t].flags)
continue;
return(mdoc_verr(mdoc, n, ERR_SCOPE_BREAK));
}
@@ -133,11 +136,10 @@ rewind_head(struct mdoc *mdoc, int tok)
/* LINTED */
for (n = mdoc->last; n; n = n->parent) {
- if (MDOC_HEAD != n->type)
- continue;
- if (tok == (t = n->tok))
+ t = n->tok;
+ if (MDOC_HEAD == n->type && tok == t)
break;
- if ( ! (MDOC_EXPLICIT & mdoc_macros[t].flags))
+ if (MDOC_NESTED & mdoc_macros[t].flags)
continue;
return(mdoc_verr(mdoc, n, ERR_SCOPE_BREAK));
}
@@ -157,9 +159,8 @@ rewind_expblock(struct mdoc *mdoc, int tok)
/* LINTED */
for ( ; n; n = n->parent) {
- if (MDOC_BLOCK != n->type)
- continue;
- if (tok == (t = n->tok))
+ t = n->tok;
+ if (MDOC_BLOCK == n->type && tok == t)
break;
if (MDOC_NESTED & mdoc_macros[t].flags)
continue;
@@ -181,9 +182,8 @@ rewind_impblock(struct mdoc *mdoc, int tok)
/* LINTED */
for ( ; n; n = n->parent) {
- if (MDOC_BLOCK != n->type)
- continue;
- if (tok == (t = n->tok))
+ t = n->tok;
+ if (MDOC_BLOCK == n->type && tok == t)
break;
if ( ! (MDOC_EXPLICIT & mdoc_macros[t].flags))
continue;
diff --git a/validate.c b/validate.c
index 19702916..4a24aeff 100644
--- a/validate.c
+++ b/validate.c
@@ -41,11 +41,13 @@ static int pre_prologue(struct mdoc *, struct mdoc_node *);
static int pre_prologue(struct mdoc *, struct mdoc_node *);
static int headchild_err_ge1(struct mdoc *);
+static int headchild_warn_ge1(struct mdoc *);
static int headchild_err_eq0(struct mdoc *);
static int elemchild_err_eq0(struct mdoc *);
static int elemchild_err_ge1(struct mdoc *);
static int elemchild_warn_eq0(struct mdoc *);
static int bodychild_warn_ge1(struct mdoc *);
+static int bodychild_err_eq0(struct mdoc *);
static int elemchild_warn_ge1(struct mdoc *);
static int post_sh(struct mdoc *);
static int post_bl(struct mdoc *);
@@ -56,16 +58,14 @@ static v_pre pres_d1[] = { pre_display, NULL };
static v_pre pres_bd[] = { pre_display, pre_bd, NULL };
static v_pre pres_bl[] = { pre_bl, NULL };
static v_pre pres_it[] = { pre_it, NULL };
-static v_post posts_bd[] = { headchild_err_eq0,
- bodychild_warn_ge1, NULL };
+static v_post posts_bd[] = { headchild_err_eq0, bodychild_warn_ge1, NULL };
static v_post posts_text[] = { elemchild_err_ge1, NULL };
static v_post posts_wtext[] = { elemchild_warn_ge1, NULL };
static v_post posts_notext[] = { elemchild_err_eq0, NULL };
-static v_post posts_sh[] = { headchild_err_ge1,
- bodychild_warn_ge1, post_sh, NULL };
-static v_post posts_bl[] = { headchild_err_eq0,
- bodychild_warn_ge1, post_bl, NULL };
+static v_post posts_wline[] = { headchild_warn_ge1, bodychild_err_eq0, NULL };
+static v_post posts_sh[] = { headchild_err_ge1, bodychild_warn_ge1, post_sh, NULL };
+static v_post posts_bl[] = { headchild_err_eq0, bodychild_warn_ge1, post_bl, NULL };
static v_post posts_it[] = { post_it, NULL };
static v_post posts_ss[] = { headchild_err_ge1, NULL };
static v_post posts_pp[] = { elemchild_warn_eq0, NULL };
@@ -114,7 +114,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, posts_text }, /* Li */
{ NULL, posts_wtext }, /* Nd */
{ NULL, NULL }, /* Nm */ /* FIXME: If name not set? */
- { NULL, posts_wtext }, /* Op */
+ { NULL, posts_wline }, /* Op */
{ NULL, NULL }, /* Ot */
{ NULL, NULL }, /* Pa */
{ NULL, posts_notext }, /* Rv */ /* -std required */
@@ -135,18 +135,18 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, posts_text }, /* %V */
{ NULL, NULL }, /* Ac */
{ NULL, NULL }, /* Ao */
- { NULL, posts_wtext }, /* Aq */
+ { NULL, posts_wline }, /* Aq */
{ NULL, NULL }, /* At */ /* FIXME */
{ NULL, NULL }, /* Bc */
{ NULL, NULL }, /* Bf */
{ NULL, NULL }, /* Bo */
- { NULL, posts_wtext }, /* Bq */
+ { NULL, posts_wline }, /* Bq */
{ NULL, NULL }, /* Bsx */
{ NULL, NULL }, /* Bx */
{ NULL, NULL }, /* Db */ /* FIXME: boolean */
{ NULL, NULL }, /* Dc */
{ NULL, NULL }, /* Do */
- { NULL, posts_wtext }, /* Dq */
+ { NULL, posts_wline }, /* Dq */
{ NULL, NULL }, /* Ec */
{ NULL, NULL }, /* Ef */ /* -symbolic, etc. */
{ NULL, posts_text }, /* Em */
@@ -160,16 +160,16 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ NULL, NULL }, /* Pc */
{ NULL, NULL }, /* Pf */ /* FIXME: 2 or more arguments */
{ NULL, NULL }, /* Po */
- { NULL, posts_wtext }, /* Pq */ /* FIXME: ignore following Sh/Ss */
+ { NULL, posts_wline }, /* Pq */ /* FIXME: ignore following Sh/Ss */
{ NULL, NULL }, /* Qc */
- { NULL, posts_wtext }, /* Ql */
+ { NULL, posts_wline }, /* Ql */
{ NULL, NULL }, /* Qo */
- { NULL, posts_wtext }, /* Qq */
+ { NULL, posts_wline }, /* Qq */
{ NULL, NULL }, /* Re */
{ NULL, NULL }, /* Rs */
{ NULL, NULL }, /* Sc */
{ NULL, NULL }, /* So */
- { NULL, posts_wtext }, /* Sq */
+ { NULL, posts_wline }, /* Sq */
{ NULL, NULL }, /* Sm */ /* FIXME: boolean */
{ NULL, posts_text }, /* Sx */
{ NULL, posts_text }, /* Sy */
@@ -191,6 +191,18 @@ const struct valids mdoc_valids[MDOC_MAX] = {
static int
+bodychild_err_eq0(struct mdoc *mdoc)
+{
+
+ if (MDOC_BODY != mdoc->last->type)
+ return(1);
+ if (NULL == mdoc->last->child)
+ return(1);
+ return(mdoc_warn(mdoc, WARN_ARGS_EQ0));
+}
+
+
+static int
bodychild_warn_ge1(struct mdoc *mdoc)
{
@@ -261,6 +273,18 @@ headchild_err_eq0(struct mdoc *mdoc)
static int
+headchild_warn_ge1(struct mdoc *mdoc)
+{
+
+ if (MDOC_HEAD != mdoc->last->type)
+ return(1);
+ if (mdoc->last->child)
+ return(1);
+ return(mdoc_warn(mdoc, WARN_ARGS_GE1));
+}
+
+
+static int
headchild_err_ge1(struct mdoc *mdoc)
{