=================================================================== RCS file: /cvs/mandoc/roff.c,v retrieving revision 1.195 retrieving revision 1.197 diff -u -p -r1.195 -r1.197 --- mandoc/roff.c 2014/03/07 02:22:05 1.195 +++ mandoc/roff.c 2014/03/07 18:37:37 1.197 @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.195 2014/03/07 02:22:05 schwarze Exp $ */ +/* $Id: roff.c,v 1.197 2014/03/07 18:37:37 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -1070,26 +1070,23 @@ roff_cond_sub(ROFF_ARGS) ln, ppos, pos, offs)); } - /* Always check for the closing delimiter `\}'. */ + /* + * If `\}' occurs on a macro line without a preceding macro, + * drop the line completely. + */ - ep = &(*bufp)[pos]; - while (NULL != (ep = strchr(ep, '\\'))) { - if ('}' != *(++ep)) - continue; + ep = *bufp + pos; + if ('\\' == ep[0] && '}' == ep[1]) + rr = ROFFRULE_DENY; - /* - * If we're at the end of line, then just chop - * off the \} and resize the buffer. - * If we aren't, then convert it to spaces. - */ + /* Always check for the closing delimiter `\}'. */ - if ('\0' == *(ep + 1)) { - *--ep = '\0'; - *szp -= 2; - } else - *(ep - 1) = *ep = ' '; - - roff_ccond(r, ln, pos); + while (NULL != (ep = strchr(ep, '\\'))) { + if ('}' == *(++ep)) { + *ep = '&'; + roff_ccond(r, ln, ep - *bufp - 1); + } + ++ep; } return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT); } @@ -1104,13 +1101,13 @@ roff_cond_text(ROFF_ARGS) rr = r->last->rule; roffnode_cleanscope(r); - ep = &(*bufp)[pos]; - for ( ; NULL != (ep = strchr(ep, '\\')); ep++) { - ep++; - if ('}' != *ep) - continue; - *ep = '&'; - roff_ccond(r, ln, pos); + ep = *bufp + pos; + while (NULL != (ep = strchr(ep, '\\'))) { + if ('}' == *(++ep)) { + *ep = '&'; + roff_ccond(r, ln, ep - *bufp - 1); + } + ++ep; } return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT); }