From d5beaabedad767345a35912f5bd7cb796c6160f5 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Tue, 24 May 2011 15:22:14 +0000 Subject: Have conditional closure for both text and macro lines call through to ccond(). Fix the text handler to behave like the macro handler regarding escaped \}. Make \} actually become a zero-width space, too, and clean up the documentation in this regard. --- roff.c | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) (limited to 'roff.c') diff --git a/roff.c b/roff.c index d813c211..d822966b 100644 --- a/roff.c +++ b/roff.c @@ -853,17 +853,12 @@ roff_cond_sub(ROFF_ARGS) */ if (ROFF_MAX == (t = roff_parse(r, *bufp, &pos))) { - /* - * Jump through hoops to detect a \}, because it could - * be (say) \\}, which is something completely - * different. - */ ep = &(*bufp)[pos]; for ( ; NULL != (ep = strchr(ep, '\\')); ep++) { ep++; if ('}' != *ep) continue; - *--ep = '\0'; + *ep = '&'; roff_ccond(r, ROFF_ccond, bufp, szp, ln, pos, pos + 2, offs); break; @@ -887,37 +882,28 @@ roff_cond_sub(ROFF_ARGS) ln, ppos, pos, offs)); } - /* ARGSUSED */ static enum rofferr roff_cond_text(ROFF_ARGS) { - char *ep, *st; + char *ep; enum roffrule rr; rr = r->last->rule; + roffnode_cleanscope(r); - /* - * We display the value of the text if out current evaluation - * scope permits us to do so. - */ - - /* FIXME: use roff_ccond? */ - - st = &(*bufp)[pos]; - if (NULL == (ep = strstr(st, "\\}"))) { - roffnode_cleanscope(r); - return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT); + ep = &(*bufp)[pos]; + for ( ; NULL != (ep = strchr(ep, '\\')); ep++) { + ep++; + if ('}' != *ep) + continue; + *ep = '&'; + roff_ccond(r, ROFF_ccond, bufp, szp, + ln, pos, pos + 2, offs); } - - if (ep == st || (ep > st && '\\' != *(ep - 1))) - roffnode_pop(r); - - roffnode_cleanscope(r); return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT); } - static enum roffrule roff_evalcond(const char *v, int *pos) { -- cgit