summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2020-08-27 12:58:01 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2020-08-27 12:58:01 +0000
commitdea2960a85988b0ee221d9aef8d96994c9849187 (patch)
treeba6583c092eb9af65e34321628c6d03a1aa27809 /usr.bin
parentf4b9ae1cbbbb5bbb8ea8c20be040f5ec92caeeb9 (diff)
Avoid artifacts in the most common case of closing conditional blocks
when no arguments follow the closing brace, \}. For example, the line "'br\}" contained in the pod2man(1) preamble would throw a bogus "escaped character not allowed in a name" error. This issue was originally reported by Chris Bennett on ports@, and afresh1@ noticed it came from the pod2man(1) preamble.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/roff.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 11a77cf7842..00db7b800fc 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.247 2020/08/03 10:52:38 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.248 2020/08/27 12:58:00 schwarze Exp $ */
/*
* Copyright (c) 2010-2015, 2017-2020 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -2360,7 +2360,9 @@ roff_cond_checkend(ROFF_ARGS)
while ((ep = strchr(ep, '\\')) != NULL) {
switch (ep[1]) {
case '}':
- if (rr)
+ if (ep[2] == '\0')
+ ep[0] = '\0';
+ else if (rr)
ep[1] = '&';
else
memmove(ep, ep + 2, strlen(ep + 2) + 1);