diff options
author | 2017-07-04 22:49:59 +0000 | |
---|---|---|
committer | 2017-07-04 22:49:59 +0000 | |
commit | a6f1c49ac0bbb063bd1da9093fa0b575d2e60b3f (patch) | |
tree | 6e2c773b30cdfed6e35bb531b096e629de90bbfd /usr.bin/mandoc/roff.c | |
parent | Ignore entries with specific PCI subvendor/subdevice such that we don't (diff) | |
download | wireguard-openbsd-a6f1c49ac0bbb063bd1da9093fa0b575d2e60b3f.tar.xz wireguard-openbsd-a6f1c49ac0bbb063bd1da9093fa0b575d2e60b3f.zip |
Fix handling of \} on roff request lines.
Cures bogus error messages in pages generated with pod2man(1).
Diffstat (limited to 'usr.bin/mandoc/roff.c')
-rw-r--r-- | usr.bin/mandoc/roff.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index 1311d4897bf..6d085c53b32 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.c,v 1.189 2017/06/25 07:23:53 bentley Exp $ */ +/* $OpenBSD: roff.c,v 1.190 2017/07/04 22:49:59 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -1924,15 +1924,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, @@ -1946,14 +1937,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 |