aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roff.c
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
commitd806944940b787e24fae0b8cd31a3b81855822b7 (patch)
treecf86056ddfa0566b322937ac0fb08ba0f9bfd85d /roff.c
parent3bfe2f390a614764a145e5cb543f22f7c4864417 (diff)
downloadmandoc-d806944940b787e24fae0b8cd31a3b81855822b7.tar.gz
mandoc-d806944940b787e24fae0b8cd31a3b81855822b7.tar.zst
mandoc-d806944940b787e24fae0b8cd31a3b81855822b7.zip
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.
Diffstat (limited to 'roff.c')
-rw-r--r--roff.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/roff.c b/roff.c
index 9cf39dbf..a3482135 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.196 2014/03/07 18:30:11 schwarze Exp $ */
+/* $Id: roff.c,v 1.197 2014/03/07 18:37:37 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -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);
}