From aa85d82aeaa92eb4f5ebff80f69420180ae71322 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Mon, 29 Mar 2010 10:10:35 +0000 Subject: Final (?) fix to issue pointed out by Sascha Wildner: roff instructions clobbering prior scope rules and line modes. --- index.sgml | 14 ++++++++++++-- libman.h | 3 ++- man.c | 23 ++++++++++++++--------- man_macro.c | 30 ++++++++++-------------------- man_validate.c | 4 ++-- mandoc.1 | 7 ++++--- 6 files changed, 44 insertions(+), 37 deletions(-) diff --git a/index.sgml b/index.sgml index 12e95c67..280f401d 100644 --- a/index.sgml +++ b/index.sgml @@ -4,7 +4,7 @@ - mdocml.bsd.lv + mdocml | mdoc macro compiler @@ -218,6 +218,16 @@
+ + + + diff --git a/libman.h b/libman.h index 8faa7a04..eb6969f6 100644 --- a/libman.h +++ b/libman.h @@ -1,4 +1,4 @@ -/* $Id: libman.h,v 1.29 2010/03/29 04:52:14 kristaps Exp $ */ +/* $Id: libman.h,v 1.30 2010/03/29 10:10:35 kristaps Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons * @@ -37,6 +37,7 @@ struct man { #define MAN_LITERAL (1 << 4) /* Literal input. */ #define MAN_BPLINE (1 << 5) enum man_next next; + enum man_next svnext; struct man_node *last; struct man_node *first; struct man_meta meta; diff --git a/man.c b/man.c index 1d258836..b1853d1a 100644 --- a/man.c +++ b/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.58 2010/03/29 04:52:14 kristaps Exp $ */ +/* $Id: man.c,v 1.59 2010/03/29 10:10:35 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -485,9 +485,6 @@ man_pmacro(struct man *m, int ln, char *buf) /* Comments and empties are quickly ignored. */ - if (MAN_BLINE & m->flags) - m->flags |= MAN_BPLINE; - if ('\0' == buf[1]) return(1); @@ -555,6 +552,9 @@ man_pmacro(struct man *m, int ln, char *buf) * Remove prior ELINE macro, as it's being clobbering by a new * macro. Note that NSCOPED macros do not close out ELINE * macros---they don't print text---so we let those slip by. + * NOTE: we don't allow roff blocks (NOCLOSE) to be embedded + * here because that would stipulate blocks as children of + * elements! */ if ( ! (MAN_NSCOPED & man_macros[tok].flags) && @@ -586,10 +586,18 @@ man_pmacro(struct man *m, int ln, char *buf) m->flags &= ~MAN_ELINE; } - /* Begin recursive parse sequence. */ + /* + * Save the fact that we're in the next-line for a block. In + * this way, embedded roff instructions can "remember" state + * when they exit. + */ + + if (MAN_BLINE & m->flags) + m->flags |= MAN_BPLINE; - assert(man_macros[tok].fp); + /* Call to handler... */ + assert(man_macros[tok].fp); if ( ! (*man_macros[tok].fp)(m, tok, ln, ppos, &i, buf)) goto err; @@ -597,9 +605,6 @@ out: /* * We weren't in a block-line scope when entering the * above-parsed macro, so return. - * - * FIXME: this prohibits the nesting of blocks (e.g., `de' and - * family) within BLINE or ELINE systems. This is annoying. */ if ( ! (MAN_BPLINE & m->flags)) { diff --git a/man_macro.c b/man_macro.c index 81dd6057..37534e09 100644 --- a/man_macro.c +++ b/man_macro.c @@ -1,4 +1,4 @@ -/* $Id: man_macro.c,v 1.41 2010/03/29 04:52:14 kristaps Exp $ */ +/* $Id: man_macro.c,v 1.42 2010/03/29 10:10:35 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -314,28 +314,14 @@ blk_dotted(MACRO_PROT_ARGS) if ( ! rew_scope(MAN_BLOCK, m, ntok)) return(0); - /* - * XXX: manually adjust our next-line status. roff macros are, - * for the moment, ignored, so we don't want to close out bodies - * and so on. - */ - - switch (m->last->type) { - case (MAN_BODY): - m->next = MAN_NEXT_CHILD; - break; - default: - break; - } - /* * Restore flags set when we got here and also stipulate that we * don't post-process the line when exiting the macro op - * function in man_pmacro(). + * function in man_pmacro(). See blk_exp(). */ - m->flags = m->svflags; - m->flags |= MAN_ILINE; + m->flags = m->svflags | MAN_ILINE; + m->next = m->svnext; return(1); } @@ -395,10 +381,14 @@ blk_exp(MACRO_PROT_ARGS) return(0); } else { /* - * Save our state; we restore it when exiting from the - * roff instruction block. + * Save our state and next-scope indicator; we restore + * it when exiting from the roff instruction block. See + * blk_dotted(). */ m->svflags = m->flags; + m->svnext = m->next; + + /* Make sure we drop any line modes. */ m->flags = 0; } diff --git a/man_validate.c b/man_validate.c index ad40b4a4..0b69d58c 100644 --- a/man_validate.c +++ b/man_validate.c @@ -1,4 +1,4 @@ -/* $Id: man_validate.c,v 1.32 2010/03/27 10:04:56 kristaps Exp $ */ +/* $Id: man_validate.c,v 1.33 2010/03/29 10:10:35 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -59,7 +59,7 @@ static v_check posts_part[] = { check_part, NULL }; static v_check posts_sec[] = { check_sec, NULL }; static v_check posts_le1[] = { check_le1, NULL }; static v_check pres_bline[] = { check_bline, NULL }; -static v_check pres_roff[] = { check_bline, check_roff, NULL }; +static v_check pres_roff[] = { check_roff, NULL }; static const struct man_valid man_valids[MAN_MAX] = { { NULL, posts_eq0 }, /* br */ diff --git a/mandoc.1 b/mandoc.1 index 85912ad5..ffbc18c2 100644 --- a/mandoc.1 +++ b/mandoc.1 @@ -1,4 +1,4 @@ -.\" $Id: mandoc.1,v 1.55 2010/03/27 14:44:19 kristaps Exp $ +.\" $Id: mandoc.1,v 1.56 2010/03/29 10:10:35 kristaps Exp $ .\" .\" Copyright (c) 2009 Kristaps Dzonsons .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 27 2010 $ +.Dd $Mdocdate: March 29 2010 $ .Dt MANDOC 1 .Os . @@ -220,7 +220,8 @@ and .Fl f Ns Ar no-ign-chars . . .It Fl f Ns Ar ign-errors -Don't halt when encountering parse errors. Useful with +When parsing multiple files, don't halt when one errors out. Useful +with .Fl T Ns Ar lint over a large set of manuals passed on the command line. .El -- cgit v1.2.3-56-ge451
29-03-2010 + Version 1.9.20: more efforts to get roff instructions + in -man documents under control. This seems to be working for all manuals I can + find. Please let me know if you find ill-formatted -man manuals. Note that + roff instructions embedded in line-scoped, next-line macros (e.g. B) are + not supported. +
27-03-2010 @@ -265,7 +275,7 @@
- Copyright © 2008–2010 Kristaps Dzonsons, $Date: 2010/03/27 10:04:56 $ + Copyright © 2008–2010 Kristaps Dzonsons, $Date: 2010/03/29 10:10:35 $