From 755753869db767ba371ee733bb746571813258a3 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Tue, 4 Jul 2017 22:52:00 +0000 Subject: Fix handling of \} on roff request lines. Cures bogus error messages in pages generated with pod2man(1). --- roff.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'roff.c') diff --git a/roff.c b/roff.c index 5a0fcd85..d1d2490c 100644 --- a/roff.c +++ b/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.317 2017/06/25 11:42:02 schwarze Exp $ */ +/* $Id: roff.c,v 1.318 2017/07/04 22:52:00 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015, 2017 Ingo Schwarze @@ -1926,15 +1926,6 @@ roff_cond_sub(ROFF_ARGS) rr = r->last->rule; roffnode_cleanscope(r); - t = roff_parse(r, buf->buf, &pos, ln, ppos); - - /* - * Fully handle known macros when they are structurally - * required or when the conditional evaluated to true. - */ - - if (t != TOKEN_NONE && (rr || roffs[t].flags & ROFFMAC_STRUCT)) - return (*roffs[t].proc)(r, t, buf, ln, ppos, pos, offs); /* * If `\}' occurs on a macro line without a preceding macro, @@ -1948,14 +1939,29 @@ roff_cond_sub(ROFF_ARGS) /* Always check for the closing delimiter `\}'. */ while ((ep = strchr(ep, '\\')) != NULL) { - if (*(++ep) == '}') { - *ep = '&'; - roff_ccond(r, ln, ep - buf->buf - 1); - } - if (*ep != '\0') + switch (ep[1]) { + case '}': + memmove(ep, ep + 2, strlen(ep + 2) + 1); + roff_ccond(r, ln, ep - buf->buf); + break; + case '\0': ++ep; + break; + default: + ep += 2; + break; + } } - return rr ? ROFF_CONT : ROFF_IGN; + + /* + * Fully handle known macros when they are structurally + * required or when the conditional evaluated to true. + */ + + t = roff_parse(r, buf->buf, &pos, ln, ppos); + return t != TOKEN_NONE && (rr || roffs[t].flags & ROFFMAC_STRUCT) + ? (*roffs[t].proc)(r, t, buf, ln, ppos, pos, offs) : rr + ? ROFF_CONT : ROFF_IGN; } static enum rofferr -- cgit v1.2.3