summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-05-08 20:33:41 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-05-08 20:33:41 +0000
commitf1b5aca91094613ffed617cc1e1643ddb36cb81f (patch)
treeba4bf14278fada9372fbe4d9d7ab992e6a7d6122 /usr.bin
parent1d7e974d90ad6036a86b784ba57132df9a6c90f7 (diff)
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.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/man.c13
-rw-r--r--usr.bin/mandoc/roff.c10
2 files changed, 14 insertions, 9 deletions
diff --git a/usr.bin/mandoc/man.c b/usr.bin/mandoc/man.c
index 2d9eb25c215..c89fe0789ee 100644
--- a/usr.bin/mandoc/man.c
+++ b/usr.bin/mandoc/man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man.c,v 1.120 2017/05/05 15:16:25 schwarze Exp $ */
+/* $OpenBSD: man.c,v 1.121 2017/05/08 20:33:40 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -92,6 +92,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) {
@@ -256,7 +257,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);
@@ -265,8 +266,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;
@@ -292,7 +292,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)
@@ -307,8 +307,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/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index f2395296b30..9893599c0eb 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.173 2017/05/08 15:33:43 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.174 2017/05/08 20:33:40 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -1007,7 +1007,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);
@@ -2776,6 +2776,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;
@@ -2824,6 +2828,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,