summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/man/man7/roff.76
-rw-r--r--usr.bin/mandoc/man_term.c19
-rw-r--r--usr.bin/mandoc/mdoc_man.c3
-rw-r--r--usr.bin/mandoc/mdoc_term.c32
-rw-r--r--usr.bin/mandoc/roff.c10
-rw-r--r--usr.bin/mandoc/roff.h4
-rw-r--r--usr.bin/mandoc/roff_html.c3
-rw-r--r--usr.bin/mandoc/roff_term.c21
-rw-r--r--usr.bin/mandoc/roff_validate.c3
-rw-r--r--usr.bin/mandoc/tbl_term.c27
-rw-r--r--usr.bin/mandoc/term.c101
-rw-r--r--usr.bin/mandoc/term.h9
12 files changed, 128 insertions, 110 deletions
diff --git a/share/man/man7/roff.7 b/share/man/man7/roff.7
index 39b81055ab5..3ad9ee4f96a 100644
--- a/share/man/man7/roff.7
+++ b/share/man/man7/roff.7
@@ -1,4 +1,4 @@
-.\" $OpenBSD: roff.7,v 1.63 2017/06/04 00:08:56 schwarze Exp $
+.\" $OpenBSD: roff.7,v 1.64 2017/06/04 22:43:50 schwarze Exp $
.\"
.\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010,2011,2013-2015,2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -1294,7 +1294,9 @@ Set title line length.
Currently ignored.
.It Ic \&mc Ar glyph Op Ar dist
Print margin character in the right margin.
-Currently ignored.
+The
+.Ar dist
+is currently ignored; instead, 1n is used.
.It Ic \&mediasize Ar media
Set the device media size.
This is a Heirloom extension and currently ignored.
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index fa7d5159bd0..39cee3a82ec 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man_term.c,v 1.154 2017/06/04 18:48:09 schwarze Exp $ */
+/* $OpenBSD: man_term.c,v 1.155 2017/06/04 22:43:50 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -860,7 +860,6 @@ post_UR(DECL_ARGS)
static void
print_man_node(DECL_ARGS)
{
- size_t rm, rmax;
int c;
switch (n->type) {
@@ -928,20 +927,16 @@ out:
if (mt->fl & MANT_LITERAL &&
! (p->flags & (TERMP_NOBREAK | TERMP_NONEWLINE)) &&
(n->next == NULL || n->next->flags & NODE_LINE)) {
- rm = p->rmargin;
- rmax = p->maxrmargin;
- p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
- p->flags |= TERMP_NOSPACE;
+ p->flags |= TERMP_BRNEVER | TERMP_NOSPACE;
if (n->string != NULL && *n->string != '\0')
term_flushln(p);
else
term_newln(p);
- if (rm < rmax && n->parent->tok == MAN_HP) {
- p->offset = rm;
- p->rmargin = rmax;
- } else
- p->rmargin = rm;
- p->maxrmargin = rmax;
+ p->flags &= ~TERMP_BRNEVER;
+ if (p->rmargin < p->maxrmargin && n->parent->tok == MAN_HP) {
+ p->offset = p->rmargin;
+ p->rmargin = p->maxrmargin;
+ }
}
if (NODE_EOS & n->flags)
p->flags |= TERMP_SENTENCE;
diff --git a/usr.bin/mandoc/mdoc_man.c b/usr.bin/mandoc/mdoc_man.c
index 0267d88a2f2..5c4a41a47ce 100644
--- a/usr.bin/mandoc/mdoc_man.c
+++ b/usr.bin/mandoc/mdoc_man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_man.c,v 1.114 2017/05/30 16:31:25 schwarze Exp $ */
+/* $OpenBSD: mdoc_man.c,v 1.115 2017/06/04 22:43:50 schwarze Exp $ */
/*
* Copyright (c) 2011-2017 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -126,6 +126,7 @@ static const void_fp roff_manacts[ROFF_MAX] = {
pre_br,
pre_ft,
pre_onearg,
+ pre_onearg,
pre_sp,
pre_ta,
pre_onearg,
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index 38b2a59f2e4..d3b643e9b9a 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_term.c,v 1.259 2017/06/04 18:48:09 schwarze Exp $ */
+/* $OpenBSD: mdoc_term.c,v 1.260 2017/06/04 22:43:50 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -1411,7 +1411,7 @@ termp_fa_pre(DECL_ARGS)
static int
termp_bd_pre(DECL_ARGS)
{
- size_t lm, len, rm, rmax;
+ size_t lm, len;
struct roff_node *nn;
int offset;
@@ -1458,17 +1458,14 @@ termp_bd_pre(DECL_ARGS)
}
lm = p->offset;
- rm = p->rmargin;
- rmax = p->maxrmargin;
- p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
-
+ p->flags |= TERMP_BRNEVER;
for (nn = n->child; nn; nn = nn->next) {
if (DISP_centered == n->norm->Bd.type) {
if (nn->type == ROFFT_TEXT) {
len = term_strlen(p, nn->string);
- p->offset = len >= rm ? 0 :
- lm + len >= rm ? rm - len :
- (lm + rm - len) / 2;
+ p->offset = len >= p->rmargin ? 0 :
+ lm + len >= p->rmargin ? p->rmargin - len :
+ (lm + p->rmargin - len) / 2;
} else
p->offset = lm;
}
@@ -1498,32 +1495,21 @@ termp_bd_pre(DECL_ARGS)
term_flushln(p);
p->flags |= TERMP_NOSPACE;
}
-
- p->rmargin = rm;
- p->maxrmargin = rmax;
+ p->flags &= ~TERMP_BRNEVER;
return 0;
}
static void
termp_bd_post(DECL_ARGS)
{
- size_t rm, rmax;
-
if (n->type != ROFFT_BODY)
return;
-
- rm = p->rmargin;
- rmax = p->maxrmargin;
-
if (DISP_literal == n->norm->Bd.type ||
DISP_unfilled == n->norm->Bd.type)
- p->rmargin = p->maxrmargin = TERM_MAXMARGIN;
-
+ p->flags |= TERMP_BRNEVER;
p->flags |= TERMP_NOSPACE;
term_newln(p);
-
- p->rmargin = rm;
- p->maxrmargin = rmax;
+ p->flags &= ~TERMP_BRNEVER;
}
static int
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c
index 07a2d227350..a6c19dd3a23 100644
--- a/usr.bin/mandoc/roff.c
+++ b/usr.bin/mandoc/roff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.c,v 1.175 2017/06/04 00:08:56 schwarze Exp $ */
+/* $OpenBSD: roff.c,v 1.176 2017/06/04 22:43:50 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -213,8 +213,8 @@ static enum rofferr roff_userdef(ROFF_ARGS);
#define ROFFNUM_WHITE (1 << 1) /* Skip whitespace in roff_evalnum(). */
const char *__roff_name[MAN_MAX + 1] = {
- "br", "ft", "ll", "sp",
- "ta", "ti", NULL,
+ "br", "ft", "ll", "mc",
+ "sp", "ta", "ti", NULL,
"ab", "ad", "af", "aln",
"als", "am", "am1", "ami",
"ami1", "as", "as1", "asciify",
@@ -247,7 +247,7 @@ const char *__roff_name[MAN_MAX + 1] = {
"lc", "lc_ctype", "lds", "length",
"letadj", "lf", "lg", "lhang",
"linetabs", "lnr", "lnrf", "lpfx",
- "ls", "lsm", "lt", "mc",
+ "ls", "lsm", "lt",
"mediasize", "minss", "mk", "mso",
"na", "ne", "nh", "nhychar",
"nm", "nn", "nop", "nr",
@@ -323,6 +323,7 @@ static struct roffmac roffs[TOKEN_NONE] = {
{ roff_br, NULL, NULL, 0 }, /* br */
{ roff_onearg, NULL, NULL, 0 }, /* ft */
{ roff_onearg, NULL, NULL, 0 }, /* ll */
+ { roff_onearg, NULL, NULL, 0 }, /* mc */
{ roff_onearg, NULL, NULL, 0 }, /* sp */
{ roff_manyarg, NULL, NULL, 0 }, /* ta */
{ roff_onearg, NULL, NULL, 0 }, /* ti */
@@ -458,7 +459,6 @@ static struct roffmac roffs[TOKEN_NONE] = {
{ roff_line_ignore, NULL, NULL, 0 }, /* ls */
{ roff_unsupp, NULL, NULL, 0 }, /* lsm */
{ roff_line_ignore, NULL, NULL, 0 }, /* lt */
- { roff_line_ignore, NULL, NULL, 0 }, /* mc */
{ roff_line_ignore, NULL, NULL, 0 }, /* mediasize */
{ roff_line_ignore, NULL, NULL, 0 }, /* minss */
{ roff_line_ignore, NULL, NULL, 0 }, /* mk */
diff --git a/usr.bin/mandoc/roff.h b/usr.bin/mandoc/roff.h
index 59384b5caf6..0f4c3e3eba8 100644
--- a/usr.bin/mandoc/roff.h
+++ b/usr.bin/mandoc/roff.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff.h,v 1.30 2017/05/08 15:33:43 schwarze Exp $ */
+/* $OpenBSD: roff.h,v 1.31 2017/06/04 22:43:50 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -69,6 +69,7 @@ enum roff_tok {
ROFF_br = 0,
ROFF_ft,
ROFF_ll,
+ ROFF_mc,
ROFF_sp,
ROFF_ta,
ROFF_ti,
@@ -206,7 +207,6 @@ enum roff_tok {
ROFF_ls,
ROFF_lsm,
ROFF_lt,
- ROFF_mc,
ROFF_mediasize,
ROFF_minss,
ROFF_mk,
diff --git a/usr.bin/mandoc/roff_html.c b/usr.bin/mandoc/roff_html.c
index a031d98aeac..49745576933 100644
--- a/usr.bin/mandoc/roff_html.c
+++ b/usr.bin/mandoc/roff_html.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff_html.c,v 1.5 2017/05/08 15:33:43 schwarze Exp $ */
+/* $OpenBSD: roff_html.c,v 1.6 2017/06/04 22:43:50 schwarze Exp $ */
/*
* Copyright (c) 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -35,6 +35,7 @@ static const roff_html_pre_fp roff_html_pre_acts[ROFF_MAX] = {
roff_html_pre_br, /* br */
NULL, /* ft */
NULL, /* ll */
+ NULL, /* mc */
roff_html_pre_sp, /* sp */
NULL, /* ta */
NULL, /* ti */
diff --git a/usr.bin/mandoc/roff_term.c b/usr.bin/mandoc/roff_term.c
index 4d5b50ff47b..7f15f3cfa80 100644
--- a/usr.bin/mandoc/roff_term.c
+++ b/usr.bin/mandoc/roff_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff_term.c,v 1.6 2017/05/08 15:33:43 schwarze Exp $ */
+/* $OpenBSD: roff_term.c,v 1.7 2017/06/04 22:43:50 schwarze Exp $ */
/*
* Copyright (c) 2010, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -30,6 +30,7 @@ typedef void (*roff_term_pre_fp)(ROFF_TERM_ARGS);
static void roff_term_pre_br(ROFF_TERM_ARGS);
static void roff_term_pre_ft(ROFF_TERM_ARGS);
static void roff_term_pre_ll(ROFF_TERM_ARGS);
+static void roff_term_pre_mc(ROFF_TERM_ARGS);
static void roff_term_pre_sp(ROFF_TERM_ARGS);
static void roff_term_pre_ta(ROFF_TERM_ARGS);
static void roff_term_pre_ti(ROFF_TERM_ARGS);
@@ -37,7 +38,8 @@ static void roff_term_pre_ti(ROFF_TERM_ARGS);
static const roff_term_pre_fp roff_term_pre_acts[ROFF_MAX] = {
roff_term_pre_br, /* br */
roff_term_pre_ft, /* ft */
- roff_term_pre_ll, /* ft */
+ roff_term_pre_ll, /* ll */
+ roff_term_pre_mc, /* mc */
roff_term_pre_sp, /* sp */
roff_term_pre_ta, /* ta */
roff_term_pre_ti, /* ti */
@@ -95,6 +97,21 @@ roff_term_pre_ll(ROFF_TERM_ARGS)
}
static void
+roff_term_pre_mc(ROFF_TERM_ARGS)
+{
+ if (p->col) {
+ p->flags |= TERMP_NOBREAK;
+ term_flushln(p);
+ p->flags &= ~(TERMP_NOBREAK | TERMP_NOSPACE);
+ }
+ if (n->child != NULL) {
+ p->mc = n->child->string;
+ p->flags |= TERMP_NEWMC;
+ } else
+ p->flags |= TERMP_ENDMC;
+}
+
+static void
roff_term_pre_sp(ROFF_TERM_ARGS)
{
struct roffsu su;
diff --git a/usr.bin/mandoc/roff_validate.c b/usr.bin/mandoc/roff_validate.c
index 558255ddb44..c1974d2fc6b 100644
--- a/usr.bin/mandoc/roff_validate.c
+++ b/usr.bin/mandoc/roff_validate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: roff_validate.c,v 1.5 2017/05/08 15:33:43 schwarze Exp $ */
+/* $OpenBSD: roff_validate.c,v 1.6 2017/06/04 22:43:50 schwarze Exp $ */
/*
* Copyright (c) 2010, 2017 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -34,6 +34,7 @@ static const roff_valid_fp roff_valids[ROFF_MAX] = {
NULL, /* br */
roff_valid_ft, /* ft */
NULL, /* ll */
+ NULL, /* mc */
NULL, /* sp */
NULL, /* ta */
NULL, /* ti */
diff --git a/usr.bin/mandoc/tbl_term.c b/usr.bin/mandoc/tbl_term.c
index 531b59c122e..1c911f9b12a 100644
--- a/usr.bin/mandoc/tbl_term.c
+++ b/usr.bin/mandoc/tbl_term.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: tbl_term.c,v 1.31 2015/10/12 00:07:27 schwarze Exp $ */
+/* $OpenBSD: tbl_term.c,v 1.32 2017/06/04 22:43:50 schwarze Exp $ */
/*
* Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011, 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011,2012,2014,2015,2017 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -61,18 +61,12 @@ term_tbl(struct termp *tp, const struct tbl_span *sp)
const struct tbl_cell *cp;
const struct tbl_dat *dp;
static size_t offset;
- size_t rmargin, maxrmargin, tsz;
+ size_t tsz;
int ic, horiz, spans, vert;
- rmargin = tp->rmargin;
- maxrmargin = tp->maxrmargin;
-
- tp->rmargin = tp->maxrmargin = TERM_MAXMARGIN;
-
/* Inhibit printing of spaces: we do padding ourselves. */
- tp->flags |= TERMP_NONOSPACE;
- tp->flags |= TERMP_NOSPACE;
+ tp->flags |= TERMP_NOSPACE | TERMP_NONOSPACE | TERMP_BRNEVER;
/*
* The first time we're invoked for a given table block,
@@ -84,7 +78,7 @@ term_tbl(struct termp *tp, const struct tbl_span *sp)
tp->tbl.slen = term_tbl_strlen;
tp->tbl.arg = tp;
- tblcalc(&tp->tbl, sp, rmargin - tp->offset);
+ tblcalc(&tp->tbl, sp, tp->rmargin - tp->offset);
/* Center the table as a whole. */
@@ -95,10 +89,10 @@ term_tbl(struct termp *tp, const struct tbl_span *sp)
for (ic = 0; ic < sp->opts->cols; ic++)
tsz += tp->tbl.cols[ic].width + 3;
tsz -= 3;
- if (offset + tsz > rmargin)
+ if (offset + tsz > tp->rmargin)
tsz -= 1;
- tp->offset = (offset + rmargin > tsz) ?
- (offset + rmargin - tsz) / 2 : 0;
+ tp->offset = (offset + tp->rmargin > tsz) ?
+ (offset + tp->rmargin - tsz) / 2 : 0;
}
/* Horizontal frame at the start of boxed tables. */
@@ -199,10 +193,7 @@ term_tbl(struct termp *tp, const struct tbl_span *sp)
tp->tbl.cols = NULL;
tp->offset = offset;
}
-
- tp->flags &= ~TERMP_NONOSPACE;
- tp->rmargin = rmargin;
- tp->maxrmargin = maxrmargin;
+ tp->flags &= ~(TERMP_NONOSPACE | TERMP_BRNEVER);
}
/*
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index 0e17f6b1fa8..b6ca1459fd1 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: term.c,v 1.123 2017/06/04 18:48:09 schwarze Exp $ */
+/* $OpenBSD: term.c,v 1.124 2017/06/04 22:43:50 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -34,6 +34,7 @@ static void adjbuf(struct termp *p, size_t);
static void bufferc(struct termp *, char);
static void encode(struct termp *, const char *, size_t);
static void encode1(struct termp *, int);
+static void endline(struct termp *);
void
@@ -167,10 +168,10 @@ term_flushln(struct termp *p)
* Find out whether we would exceed the right margin.
* If so, break to the next line.
*/
- if (vend > bp && 0 == jhy && vis > 0) {
+ if (vend > bp && 0 == jhy && vis > 0 &&
+ (p->flags & TERMP_BRNEVER) == 0) {
vend -= vis;
- (*p->endline)(p);
- p->viscol = 0;
+ endline(p);
/* Use pending tabs on the new line. */
@@ -241,31 +242,37 @@ term_flushln(struct termp *p)
vis = 0;
p->col = 0;
+ p->minbl = p->trailspace;
p->flags &= ~(TERMP_BACKAFTER | TERMP_BACKBEFORE | TERMP_NOPAD);
- if ( ! (TERMP_NOBREAK & p->flags)) {
- p->viscol = 0;
- p->minbl = 0;
- (*p->endline)(p);
- return;
- }
-
- if (TERMP_HANG & p->flags) {
- p->minbl = p->trailspace;
- return;
- }
-
/* Trailing whitespace is significant in some columns. */
if (vis && vbl && (TERMP_BRTRSP & p->flags))
vis += vbl;
/* If the column was overrun, break the line. */
- if (maxvis < vis + p->trailspace * (*p->width)(p, ' ')) {
- (*p->endline)(p);
- p->viscol = 0;
- p->minbl = 0;
- } else
- p->minbl = p->trailspace;
+ if ((p->flags & TERMP_NOBREAK) == 0 ||
+ ((p->flags & TERMP_HANG) == 0 &&
+ vis + p->trailspace * (*p->width)(p, ' ') > maxvis))
+ endline(p);
+}
+
+static void
+endline(struct termp *p)
+{
+ if ((p->flags & (TERMP_NEWMC | TERMP_ENDMC)) == TERMP_ENDMC) {
+ p->mc = NULL;
+ p->flags &= ~TERMP_ENDMC;
+ }
+ if (p->mc != NULL) {
+ if (p->viscol && p->maxrmargin >= p->viscol)
+ (*p->advance)(p, p->maxrmargin - p->viscol + 1);
+ p->flags |= TERMP_NOBUF | TERMP_NOSPACE;
+ term_word(p, p->mc);
+ p->flags &= ~(TERMP_NOBUF | TERMP_NEWMC);
+ }
+ p->viscol = 0;
+ p->minbl = 0;
+ (*p->endline)(p);
}
/*
@@ -294,6 +301,7 @@ term_vspace(struct termp *p)
term_newln(p);
p->viscol = 0;
+ p->minbl = 0;
if (0 < p->skipvsp)
p->skipvsp--;
else
@@ -368,24 +376,24 @@ term_word(struct termp *p, const char *word)
size_t csz, lsz, ssz;
enum mandoc_esc esc;
- if ( ! (TERMP_NOSPACE & p->flags)) {
- if ( ! (TERMP_KEEP & p->flags)) {
- bufferc(p, ' ');
- if (TERMP_SENTENCE & p->flags)
+ if ((p->flags & TERMP_NOBUF) == 0) {
+ if ((p->flags & TERMP_NOSPACE) == 0) {
+ if ((p->flags & TERMP_KEEP) == 0) {
bufferc(p, ' ');
- } else
- bufferc(p, ASCII_NBRSP);
+ if (p->flags & TERMP_SENTENCE)
+ bufferc(p, ' ');
+ } else
+ bufferc(p, ASCII_NBRSP);
+ }
+ if (p->flags & TERMP_PREKEEP)
+ p->flags |= TERMP_KEEP;
+ if (p->flags & TERMP_NONOSPACE)
+ p->flags |= TERMP_NOSPACE;
+ else
+ p->flags &= ~TERMP_NOSPACE;
+ p->flags &= ~(TERMP_SENTENCE | TERMP_NONEWLINE);
+ p->skipvsp = 0;
}
- if (TERMP_PREKEEP & p->flags)
- p->flags |= TERMP_KEEP;
-
- if ( ! (p->flags & TERMP_NONOSPACE))
- p->flags &= ~TERMP_NOSPACE;
- else
- p->flags |= TERMP_NOSPACE;
-
- p->flags &= ~(TERMP_SENTENCE | TERMP_NONEWLINE);
- p->skipvsp = 0;
while ('\0' != *word) {
if ('\\' != *word) {
@@ -588,10 +596,12 @@ adjbuf(struct termp *p, size_t sz)
static void
bufferc(struct termp *p, char c)
{
-
+ if (p->flags & TERMP_NOBUF) {
+ (*p->letter)(p, c);
+ return;
+ }
if (p->col + 1 >= p->maxcols)
adjbuf(p, p->col + 1);
-
p->buf[p->col++] = c;
}
@@ -605,6 +615,11 @@ encode1(struct termp *p, int c)
{
enum termfont f;
+ if (p->flags & TERMP_NOBUF) {
+ (*p->letter)(p, c);
+ return;
+ }
+
if (p->col + 7 >= p->maxcols)
adjbuf(p, p->col + 7);
@@ -641,6 +656,12 @@ encode(struct termp *p, const char *word, size_t sz)
{
size_t i;
+ if (p->flags & TERMP_NOBUF) {
+ for (i = 0; i < sz; i++)
+ (*p->letter)(p, word[i]);
+ return;
+ }
+
if (p->col + 2 + (sz * 5) >= p->maxcols)
adjbuf(p, p->col + 2 + (sz * 5));
diff --git a/usr.bin/mandoc/term.h b/usr.bin/mandoc/term.h
index 23135b930f5..b625a231eef 100644
--- a/usr.bin/mandoc/term.h
+++ b/usr.bin/mandoc/term.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: term.h,v 1.66 2017/06/04 18:48:09 schwarze Exp $ */
+/* $OpenBSD: term.h,v 1.67 2017/06/04 22:43:50 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -36,8 +36,6 @@ enum termfont {
TERMFONT__MAX
};
-#define TERM_MAXMARGIN 100000 /* FIXME */
-
struct eqn;
struct roff_meta;
struct roff_node;
@@ -87,6 +85,10 @@ struct termp {
#define TERMP_NOSPLIT (1 << 13) /* Do not break line before .An. */
#define TERMP_SPLIT (1 << 14) /* Break line before .An. */
#define TERMP_NONEWLINE (1 << 15) /* No line break in nofill mode. */
+#define TERMP_BRNEVER (1 << 16) /* Don't even break at maxrmargin. */
+#define TERMP_NOBUF (1 << 17) /* Bypass output buffer. */
+#define TERMP_NEWMC (1 << 18) /* No .mc printed yet. */
+#define TERMP_ENDMC (1 << 19) /* Next break ends .mc mode. */
int *buf; /* Output buffer. */
enum termenc enc; /* Type of encoding. */
enum termfont fontl; /* Last font set. */
@@ -105,6 +107,7 @@ struct termp {
int (*hspan)(const struct termp *,
const struct roffsu *);
const void *argf; /* arg for headf/footf */
+ const char *mc; /* Margin character. */
struct termp_ps *ps;
};