summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-05-08 20:33:53 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-05-08 20:33:53 +0000
commit73dc5e8b721bdd4c7e867dc7dd39d4f8dec3e3a9 (patch)
treeb24d5c6f8df8f4b598ba7e51d302c78191c54fc4
parent743d8976911a7ef031de0fe12ef9ba67c3e7e5d4 (diff)
downloadmandoc-73dc5e8b721bdd4c7e867dc7dd39d4f8dec3e3a9.tar.gz
Line-breaking roff(7) requests also break man(7) next-line scope.
Considering that real roff implements next-line scope using input line traps, that isn't all that surprising. Issue found in the games/xbattle port.
-rw-r--r--man.c11
-rw-r--r--roff.c8
2 files changed, 12 insertions, 7 deletions
diff --git a/man.c b/man.c
index 98e259e5..68d1fee1 100644
--- a/man.c
+++ b/man.c
@@ -94,6 +94,7 @@ man_ptext(struct roff_man *man, int line, char *buf, int offs)
*/
if (buf[i] == '\0') {
+ man_breakscope(man, ROFF_sp);
/* Allocate a blank entry. */
if (man->last->tok != MAN_SH &&
man->last->tok != MAN_SS) {
@@ -258,7 +259,7 @@ man_breakscope(struct roff_man *man, int tok)
* Delete the element that is being broken.
*/
- if (man->flags & MAN_ELINE && (tok == TOKEN_NONE ||
+ if (man->flags & MAN_ELINE && (tok < MAN_TH ||
! (man_macros[tok].flags & MAN_NSCOPED))) {
n = man->last;
assert(n->type != ROFFT_TEXT);
@@ -267,8 +268,7 @@ man_breakscope(struct roff_man *man, int tok)
mandoc_vmsg(MANDOCERR_BLK_LINE, man->parse,
n->line, n->pos, "%s breaks %s",
- tok == TOKEN_NONE ? "TS" : roff_name[tok],
- roff_name[n->tok]);
+ roff_name[tok], roff_name[n->tok]);
roff_node_delete(man, n);
man->flags &= ~MAN_ELINE;
@@ -294,7 +294,7 @@ man_breakscope(struct roff_man *man, int tok)
* Delete the block that is being broken.
*/
- if (man->flags & MAN_BLINE && (tok == TOKEN_NONE ||
+ if (man->flags & MAN_BLINE && (tok < MAN_TH ||
man_macros[tok].flags & MAN_BSCOPE)) {
n = man->last;
if (n->type == ROFFT_TEXT)
@@ -309,8 +309,7 @@ man_breakscope(struct roff_man *man, int tok)
mandoc_vmsg(MANDOCERR_BLK_LINE, man->parse,
n->line, n->pos, "%s breaks %s",
- tok == TOKEN_NONE ? "TS" : roff_name[tok],
- roff_name[n->tok]);
+ roff_name[tok], roff_name[n->tok]);
roff_node_delete(man, n);
man->flags &= ~MAN_BLINE;
diff --git a/roff.c b/roff.c
index 763d78a7..ff6d9806 100644
--- a/roff.c
+++ b/roff.c
@@ -1009,7 +1009,7 @@ roff_addtbl(struct roff_man *man, const struct tbl_span *tbl)
struct roff_node *n;
if (man->macroset == MACROSET_MAN)
- man_breakscope(man, TOKEN_NONE);
+ man_breakscope(man, ROFF_TS);
n = roff_node_alloc(man, tbl->line, 0, ROFFT_TBL, TOKEN_NONE);
n->span = tbl;
roff_node_append(man, n);
@@ -2778,6 +2778,10 @@ roff_onearg(ROFF_ARGS)
struct roff_node *n;
char *cp;
+ if (r->man->flags & (MAN_BLINE | MAN_ELINE) &&
+ (tok == ROFF_sp || tok == ROFF_ti))
+ man_breakscope(r->man, tok);
+
roff_elem_alloc(r->man, ln, ppos, tok);
n = r->man->last;
@@ -2826,6 +2830,8 @@ roff_manyarg(ROFF_ARGS)
static enum rofferr
roff_br(ROFF_ARGS)
{
+ if (r->man->flags & (MAN_BLINE | MAN_ELINE))
+ man_breakscope(r->man, ROFF_br);
roff_elem_alloc(r->man, ln, ppos, ROFF_br);
if (buf->buf[pos] != '\0')
mandoc_vmsg(MANDOCERR_ARG_SKIP, r->parse, ln, pos,