=================================================================== RCS file: /cvs/mandoc/roff.c,v retrieving revision 1.341 retrieving revision 1.345 diff -u -p -r1.341 -r1.345 --- mandoc/roff.c 2018/08/25 16:53:39 1.341 +++ mandoc/roff.c 2018/12/12 21:54:35 1.345 @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.341 2018/08/25 16:53:39 schwarze Exp $ */ +/* $Id: roff.c,v 1.345 2018/12/12 21:54:35 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons * Copyright (c) 2010-2015, 2017, 2018 Ingo Schwarze @@ -28,10 +28,11 @@ #include #include -#include "mandoc.h" #include "mandoc_aux.h" #include "mandoc_ohash.h" +#include "mandoc.h" #include "roff.h" +#include "tbl.h" #include "libmandoc.h" #include "roff_int.h" #include "libroff.h" @@ -1067,6 +1068,14 @@ roff_node_unlink(struct roff_man *man, struct roff_nod } void +roff_node_relink(struct roff_man *man, struct roff_node *n) +{ + roff_node_unlink(man, n); + n->prev = n->next = NULL; + roff_node_append(man, n); +} + +void roff_node_free(struct roff_node *n) { @@ -2107,7 +2116,10 @@ roff_cond_sub(ROFF_ARGS) if (ep[0] == '\\' && ep[1] == '}') rr = 0; - /* Always check for the closing delimiter `\}'. */ + /* + * The closing delimiter `\}' rewinds the conditional scope + * but is otherwise ignored when interpreting the line. + */ while ((ep = strchr(ep, '\\')) != NULL) { switch (ep[1]) { @@ -2150,15 +2162,34 @@ roff_cond_text(ROFF_ARGS) 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) { - if (*(++ep) == '}') { - *ep = '&'; - if (roff_ccond(r, ln, ep - buf->buf - 1)) + switch (ep[1]) { + case '}': + memmove(ep, ep + 2, strlen(ep + 2) + 1); + if (roff_ccond(r, ln, ep - buf->buf)) irc |= endloop; - } - if (*ep != '\0') + break; + case '\0': ++ep; + break; + default: + ep += 2; + break; + } } if (rr) irc |= ROFF_CONT; @@ -3361,6 +3392,7 @@ roff_char(ROFF_ARGS) case ESCAPE_FONTITALIC: case ESCAPE_FONTBOLD: case ESCAPE_FONTBI: + case ESCAPE_FONTCW: case ESCAPE_FONTPREV: font++; break;