diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-03-07 18:37:33 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-03-07 18:37:33 +0000 |
commit | ae7dfe87886f2abbc46f5b44b71e097b7e18d8b9 (patch) | |
tree | e863ef8afcffe3cd67152c51d96ec6b8b9151907 /usr.bin | |
parent | a9076407bf3f70c7a0211207dcd61829200fe3fd (diff) |
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 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/roff.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index 2b695e4b917..b335ea866ad 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.69 2014/03/07 17:57:28 schwarze Exp $ */ +/* $Id: roff.c,v 1.70 2014/03/07 18:37:32 schwarze Exp $ */ /* * Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org> @@ -1078,10 +1078,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); } @@ -1096,13 +1097,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); } |