summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-03-07 18:37:37 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-03-07 18:37:37 +0000
commitd3bc35e0fd4d9bed56d9663c0b330ceac96e4a9f (patch)
treed1edaf97b92b57abad354da877c857b294e9191e
parent54aa3e7af1c3beec35737d65971e1ab156590b65 (diff)
downloadmandoc-d3bc35e0fd4d9bed56d9663c0b330ceac96e4a9f.tar.gz
In roff_cond_sub(), make sure that the incorrect input sequence `\\}',
when found on a macro line, does not close a conditional block. The companion function roff_cond_text() already did this correctly, but make the code more readable without functional change. While here, report the correct column number in related error messages.
-rw-r--r--roff.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/roff.c b/roff.c
index e23fae1e..1e2047a0 100644
--- a/roff.c
+++ b/roff.c
@@ -1082,10 +1082,11 @@ roff_cond_sub(ROFF_ARGS)
/* Always check for the closing delimiter `\}'. */
while (NULL != (ep = strchr(ep, '\\'))) {
- if ('}' != *(++ep))
- continue;
- *ep = '&';
- roff_ccond(r, ln, pos);
+ if ('}' == *(++ep)) {
+ *ep = '&';
+ roff_ccond(r, ln, ep - *bufp - 1);
+ }
+ ++ep;
}
return(ROFFRULE_DENY == rr ? ROFF_IGN : ROFF_CONT);
}
@@ -1100,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);
}