aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roff.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-05-24 15:22:14 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-05-24 15:22:14 +0000
commita0590dbedd34ee38d8cf6a83bc5846668e0c29fd (patch)
tree3bdda48fe324d5088b4e5aba01c1b06565e082dd /roff.c
parent99de3aa8f6c69f02b989060a0aa3ce3559333dd1 (diff)
downloadmandoc-a0590dbedd34ee38d8cf6a83bc5846668e0c29fd.tar.gz
mandoc-a0590dbedd34ee38d8cf6a83bc5846668e0c29fd.tar.zst
mandoc-a0590dbedd34ee38d8cf6a83bc5846668e0c29fd.zip
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.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/roff.c b/roff.c
index 35e0f883..4960d947 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.139 2011/05/24 14:00:39 kristaps Exp $ */
+/* $Id: roff.c,v 1.140 2011/05/24 15:22:14 kristaps Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -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)
{