diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-05-24 15:22:14 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2011-05-24 15:22:14 +0000 |
commit | d5beaabedad767345a35912f5bd7cb796c6160f5 (patch) | |
tree | a9269625b7c9a96f28a979d7b124facf166abe65 /roff.c | |
parent | fe48fc74f1ca4c34565410df711ceebd198fd253 (diff) | |
download | mandoc-d5beaabedad767345a35912f5bd7cb796c6160f5.tar.gz |
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.
Diffstat (limited to 'roff.c')
-rw-r--r-- | roff.c | 36 |
1 files changed, 11 insertions, 25 deletions
@@ -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) { |