=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/roff.c,v retrieving revision 1.214 retrieving revision 1.215 diff -c -r1.214 -r1.215 *** src/usr.bin/mandoc/roff.c 2018/10/25 01:21:30 1.214 --- src/usr.bin/mandoc/roff.c 2018/11/26 17:44:29 1.215 *************** *** 1,4 **** ! /* $OpenBSD: roff.c,v 1.214 2018/10/25 01:21:30 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze --- 1,4 ---- ! /* $OpenBSD: roff.c,v 1.215 2018/11/26 17:44:29 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze *************** *** 2105,2111 **** if (ep[0] == '\\' && ep[1] == '}') rr = 0; ! /* Always check for the closing delimiter `\}'. */ while ((ep = strchr(ep, '\\')) != NULL) { switch (ep[1]) { --- 2105,2114 ---- if (ep[0] == '\\' && ep[1] == '}') rr = 0; ! /* ! * The closing delimiter `\}' rewinds the conditional scope ! * but is otherwise ignored when interpreting the line. ! */ while ((ep = strchr(ep, '\\')) != NULL) { switch (ep[1]) { *************** *** 2148,2162 **** if (roffnode_cleanscope(r)) irc |= endloop; ep = buf->buf + pos; while ((ep = strchr(ep, '\\')) != NULL) { ! if (*(++ep) == '}') { ! *ep = '&'; ! if (roff_ccond(r, ln, ep - buf->buf - 1)) irc |= endloop; ! } ! if (*ep != '\0') ++ep; } if (rr) irc |= ROFF_CONT; --- 2151,2184 ---- if (roffnode_cleanscope(r)) irc |= endloop; + /* + * If `\}' occurs on a text line with neither preceding + * nor following characters, drop the line completely. + */ + ep = buf->buf + pos; + if (strcmp(ep, "\\}") == 0) + rr = 0; + + /* + * The closing delimiter `\}' rewinds the conditional scope + * but is otherwise ignored when interpreting the line. + */ + while ((ep = strchr(ep, '\\')) != NULL) { ! switch (ep[1]) { ! case '}': ! memmove(ep, ep + 2, strlen(ep + 2) + 1); ! if (roff_ccond(r, ln, ep - buf->buf)) irc |= endloop; ! break; ! case '\0': ++ep; + break; + default: + ep += 2; + break; + } } if (rr) irc |= ROFF_CONT;