From d5b18a2eadce9a79cc1dc6c39b74d5bb41bfb6b5 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Mon, 12 Jan 2009 17:26:42 +0000 Subject: *** empty log message *** --- macro.c | 30 +++++++++++++++--------------- validate.c | 54 +++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 54 insertions(+), 30 deletions(-) diff --git a/macro.c b/macro.c index 0ed6f173..55c6f89d 100644 --- a/macro.c +++ b/macro.c @@ -1,4 +1,4 @@ -/* $Id: macro.c,v 1.33 2009/01/12 16:39:57 kristaps Exp $ */ +/* $Id: macro.c,v 1.34 2009/01/12 17:26:42 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -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 2ca0b376..87f686ac 100644 --- a/validate.c +++ b/validate.c @@ -1,4 +1,4 @@ -/* $Id: validate.c,v 1.26 2009/01/12 16:39:57 kristaps Exp $ */ +/* $Id: validate.c,v 1.27 2009/01/12 17:26:42 kristaps Exp $ */ /* * Copyright (c) 2008 Kristaps Dzonsons * @@ -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 */ @@ -190,6 +190,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) { @@ -260,6 +272,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) { -- cgit v1.2.3-56-ge451