diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2011-01-16 19:27:26 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2011-01-16 19:27:26 +0000 |
commit | b82ba953905f806ce4e5553c1536579080b7352e (patch) | |
tree | 3c36e823156523bc9abbcf91e0ef94a54893e075 /usr.bin/mandoc/man_macro.c | |
parent | 4cb54dc5d7dbc06a06da71e20b14c15d883a8949 (diff) |
Some improvements to error handling from kristaps@:
* Make out-of-context .fi invocations not cause an error, but just a warning.
* Downgrade -man message about ignored empty paragraph to MANDOC_IGNPAR.
* Avoid syntax tree corruption when removing empty block macros.
Triggered by some reports from brad@.
Diffstat (limited to 'usr.bin/mandoc/man_macro.c')
-rw-r--r-- | usr.bin/mandoc/man_macro.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/usr.bin/mandoc/man_macro.c b/usr.bin/mandoc/man_macro.c index a30b585b91a..413cbbd56ee 100644 --- a/usr.bin/mandoc/man_macro.c +++ b/usr.bin/mandoc/man_macro.c @@ -1,4 +1,4 @@ -/* $Id: man_macro.c,v 1.26 2011/01/04 22:28:17 schwarze Exp $ */ +/* $Id: man_macro.c,v 1.27 2011/01/16 19:27:25 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -103,19 +103,27 @@ rew_warn(struct man *m, struct man_node *n, enum mandocerr er) * will be used if an explicit block scope is being closed out. */ int -man_unscope(struct man *m, const struct man_node *n, +man_unscope(struct man *m, const struct man_node *to, enum mandocerr er) { + struct man_node *n; - assert(n); + assert(to); /* LINTED */ - while (m->last != n) { + while (m->last != to) { + /* + * Save the parent here, because we may delete the + * m->last node in the post-validation phase and reset + * it to m->last->parent, causing a step in the closing + * out to be lost. + */ + n = m->last->parent; if ( ! rew_warn(m, m->last, er)) return(0); if ( ! man_valid_post(m)) return(0); - m->last = m->last->parent; + m->last = n; assert(m->last); } |