From 17fb05b577517a04553bc0c0a3301f3113889621 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Mon, 29 Mar 2010 04:52:14 +0000 Subject: Initial step in fixing badness reported by Sascha Wildner (wip). --- libman.h | 10 ++++++---- man.c | 10 ++++++---- man_macro.c | 17 ++++++++++++++++- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/libman.h b/libman.h index 06769354..8faa7a04 100644 --- a/libman.h +++ b/libman.h @@ -1,4 +1,4 @@ -/* $Id: libman.h,v 1.28 2010/03/27 10:04:56 kristaps Exp $ */ +/* $Id: libman.h,v 1.29 2010/03/29 04:52:14 kristaps Exp $ */ /* * Copyright (c) 2009 Kristaps Dzonsons * @@ -27,13 +27,15 @@ enum man_next { struct man { void *data; struct man_cb cb; - int pflags; - int flags; -#define MAN_HALT (1 << 0) + int pflags; /* parse flags (see man.h) */ + int svflags; /* flags saved during roff blocks */ + int flags; /* parse flags */ +#define MAN_HALT (1 << 0) /* badness happened: die */ #define MAN_ELINE (1 << 1) /* Next-line element scope. */ #define MAN_BLINE (1 << 2) /* Next-line block scope. */ #define MAN_ILINE (1 << 3) /* Ignored in next-line scope. */ #define MAN_LITERAL (1 << 4) /* Literal input. */ +#define MAN_BPLINE (1 << 5) enum man_next next; struct man_node *last; struct man_node *first; diff --git a/man.c b/man.c index 6d735169..1d258836 100644 --- a/man.c +++ b/man.c @@ -1,4 +1,4 @@ -/* $Id: man.c,v 1.57 2010/03/27 10:26:39 kristaps Exp $ */ +/* $Id: man.c,v 1.58 2010/03/29 04:52:14 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -478,14 +478,15 @@ macrowarn(struct man *m, int ln, const char *buf) int man_pmacro(struct man *m, int ln, char *buf) { - int i, j, ppos, fl; + int i, j, ppos; enum mant tok; char mac[5]; struct man_node *n; /* Comments and empties are quickly ignored. */ - fl = m->flags; + if (MAN_BLINE & m->flags) + m->flags |= MAN_BPLINE; if ('\0' == buf[1]) return(1); @@ -601,10 +602,11 @@ out: * family) within BLINE or ELINE systems. This is annoying. */ - if ( ! (MAN_BLINE & fl)) { + if ( ! (MAN_BPLINE & m->flags)) { m->flags &= ~MAN_ILINE; return(1); } + m->flags &= ~MAN_BPLINE; /* * If we're in a block scope, then allow this macro to slip by diff --git a/man_macro.c b/man_macro.c index cc6d116c..81dd6057 100644 --- a/man_macro.c +++ b/man_macro.c @@ -1,4 +1,4 @@ -/* $Id: man_macro.c,v 1.40 2010/03/27 10:14:32 kristaps Exp $ */ +/* $Id: man_macro.c,v 1.41 2010/03/29 04:52:14 kristaps Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * @@ -328,6 +328,14 @@ blk_dotted(MACRO_PROT_ARGS) 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(). + */ + m->flags = m->svflags; + m->flags |= MAN_ILINE; + return(1); } @@ -385,6 +393,13 @@ blk_exp(MACRO_PROT_ARGS) return(0); if ( ! rew_scope(MAN_BLOCK, m, tok)) return(0); + } else { + /* + * Save our state; we restore it when exiting from the + * roff instruction block. + */ + m->svflags = m->flags; + m->flags = 0; } if ( ! man_block_alloc(m, line, ppos, tok)) -- cgit v1.2.3-56-ge451