-/* $OpenBSD: libman.h,v 1.52 2015/04/23 15:35:39 schwarze Exp $ */
+/* $OpenBSD: libman.h,v 1.53 2015/10/22 21:53:49 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
__BEGIN_DECLS
int man_hash_find(const char *);
-void man_valid_post(struct roff_man *);
+void man_node_validate(struct roff_man *);
+void man_state(struct roff_man *, struct roff_node *);
void man_unscope(struct roff_man *, const struct roff_node *);
__END_DECLS
-/* $OpenBSD: main.c,v 1.160 2015/10/22 21:02:55 schwarze Exp $ */
+/* $OpenBSD: main.c,v 1.161 2015/10/22 21:53:49 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
}
}
if (man->macroset == MACROSET_MAN) {
+ man_validate(man);
switch (curp->outtype) {
case OUTT_HTML:
html_man(curp->outdata, man);
-/* $OpenBSD: man.c,v 1.113 2015/10/06 18:30:43 schwarze Exp $ */
+/* $OpenBSD: man.c,v 1.114 2015/10/22 21:53:49 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
assert(man && man->parse);
return man->parse;
}
+
+void
+man_state(struct roff_man *man, struct roff_node *n)
+{
+
+ switch(n->tok) {
+ case MAN_nf:
+ case MAN_EX:
+ if (man->flags & MAN_LITERAL && ! (n->flags & MAN_VALID))
+ mandoc_msg(MANDOCERR_NF_SKIP, man->parse,
+ n->line, n->pos, "nf");
+ man->flags |= MAN_LITERAL;
+ break;
+ case MAN_fi:
+ case MAN_EE:
+ if ( ! (man->flags & MAN_LITERAL) &&
+ ! (n->flags & MAN_VALID))
+ mandoc_msg(MANDOCERR_FI_SKIP, man->parse,
+ n->line, n->pos, "fi");
+ man->flags &= ~MAN_LITERAL;
+ break;
+ default:
+ break;
+ }
+ man->last->flags |= MAN_VALID;
+}
+
+void
+man_validate(struct roff_man *man)
+{
+
+ man->last = man->first;
+ man_node_validate(man);
+ man->flags &= ~MAN_LITERAL;
+}
-/* $OpenBSD: man.h,v 1.55 2015/04/23 16:17:04 schwarze Exp $ */
+/* $OpenBSD: man.h,v 1.56 2015/10/22 21:53:49 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
struct roff_man;
-const struct mparse *man_mparse(const struct roff_man *);
+const struct mparse *man_mparse(const struct roff_man *);
+void man_validate(struct roff_man *);
__END_DECLS
-/* $OpenBSD: man_macro.c,v 1.74 2015/10/06 18:30:43 schwarze Exp $ */
+/* $OpenBSD: man_macro.c,v 1.75 2015/10/22 21:53:49 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2012, 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
man->last = n;
n = n->parent;
- man_valid_post(man);
+ man->last->flags |= MAN_VALID;
}
/*
assert(man->last->type != ROFFT_ROOT);
man->next = ROFF_NEXT_SIBLING;
- /*
- * Rewind our element scope. Note that when TH is pruned, we'll
- * be back at the root, so make sure that we don't clobber as
- * its sibling.
- */
+ /* Rewind our element scope. */
for ( ; man->last; man->last = man->last->parent) {
+ man_state(man, man->last);
if (man->last == n)
break;
- if (man->last->type == ROFFT_ROOT)
- break;
- man_valid_post(man);
}
-
- assert(man->last);
-
- /*
- * Same here regarding whether we're back at the root.
- */
-
- if (man->last->type != ROFFT_ROOT)
- man_valid_post(man);
}
void
{
man_unscope(man, man->first);
+ man->flags &= ~MAN_LITERAL;
}
static int
-/* $OpenBSD: man_validate.c,v 1.91 2015/10/12 00:07:27 schwarze Exp $ */
+/* $OpenBSD: man_validate.c,v 1.92 2015/10/22 21:53:49 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
static void post_AT(CHKARGS);
static void post_IP(CHKARGS);
static void post_vs(CHKARGS);
-static void post_fi(CHKARGS);
static void post_ft(CHKARGS);
-static void post_nf(CHKARGS);
static void post_OP(CHKARGS);
static void post_TH(CHKARGS);
static void post_UC(CHKARGS);
NULL, /* IR */
NULL, /* RI */
post_vs, /* sp */
- post_nf, /* nf */
- post_fi, /* fi */
+ NULL, /* nf */
+ NULL, /* fi */
NULL, /* RE */
check_part, /* RS */
NULL, /* DT */
NULL, /* in */
post_ft, /* ft */
post_OP, /* OP */
- post_nf, /* EX */
- post_fi, /* EE */
+ NULL, /* EX */
+ NULL, /* EE */
post_UR, /* UR */
NULL, /* UE */
NULL, /* ll */
void
-man_valid_post(struct roff_man *man)
+man_node_validate(struct roff_man *man)
{
struct roff_node *n;
v_check *cp;
n = man->last;
- if (n->flags & MAN_VALID)
- return;
- n->flags |= MAN_VALID;
+ man->last = man->last->child;
+ while (man->last != NULL) {
+ man_node_validate(man);
+ if (man->last == n)
+ man->last = man->last->child;
+ else
+ man->last = man->last->next;
+ }
+ man->last = n;
+ man->next = ROFF_NEXT_SIBLING;
switch (n->type) {
case ROFFT_TEXT:
check_text(man, n);
cp = man_valids + n->tok;
if (*cp)
(*cp)(man, n);
+ if (man->last == n)
+ man_state(man, n);
break;
}
}
roff_node_delete(man, man->last);
}
-static void
-post_nf(CHKARGS)
-{
-
- if (man->flags & MAN_LITERAL)
- mandoc_msg(MANDOCERR_NF_SKIP, man->parse,
- n->line, n->pos, "nf");
-
- man->flags |= MAN_LITERAL;
-}
-
-static void
-post_fi(CHKARGS)
-{
-
- if ( ! (MAN_LITERAL & man->flags))
- mandoc_msg(MANDOCERR_FI_SKIP, man->parse,
- n->line, n->pos, "fi");
-
- man->flags &= ~MAN_LITERAL;
-}
-
static void
post_UC(CHKARGS)
{
-/* $OpenBSD: roff.c,v 1.154 2015/10/21 23:49:05 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.155 2015/10/22 21:53:49 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
if (man->macroset == MACROSET_MDOC)
n->flags |= MDOC_VALID | MDOC_ENDED;
else
- man_valid_post(man);
+ n->flags |= MAN_VALID;
man->next = ROFF_NEXT_SIBLING;
}
if (man->macroset == MACROSET_MDOC)
n->flags |= MDOC_VALID | MDOC_ENDED;
else
- man_valid_post(man);
+ n->flags |= MAN_VALID;
man->next = ROFF_NEXT_SIBLING;
}
-/* $OpenBSD: roff_int.h,v 1.5 2015/10/21 23:49:05 schwarze Exp $ */
+/* $OpenBSD: roff_int.h,v 1.6 2015/10/22 21:53:49 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
*/
void man_breakscope(struct roff_man *, int);
-void man_valid_post(struct roff_man *);
void mdoc_argv_free(struct mdoc_arg *);
__END_DECLS