summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/usr.bin/mandoc/man/IP/Makefile4
-rw-r--r--regress/usr.bin/mandoc/man/IP/longhead.in10
-rw-r--r--regress/usr.bin/mandoc/man/IP/longhead.out_ascii19
-rw-r--r--regress/usr.bin/mandoc/man/TP/Makefile5
-rw-r--r--regress/usr.bin/mandoc/man/TP/longhead.in11
-rw-r--r--regress/usr.bin/mandoc/man/TP/longhead.out_ascii19
-rw-r--r--usr.bin/mandoc/man_term.c8
-rw-r--r--usr.bin/mandoc/mdoc_term.c27
-rw-r--r--usr.bin/mandoc/term.c49
-rw-r--r--usr.bin/mandoc/term.h13
10 files changed, 110 insertions, 55 deletions
diff --git a/regress/usr.bin/mandoc/man/IP/Makefile b/regress/usr.bin/mandoc/man/IP/Makefile
index 13541b0eaec..a493fc0630c 100644
--- a/regress/usr.bin/mandoc/man/IP/Makefile
+++ b/regress/usr.bin/mandoc/man/IP/Makefile
@@ -1,5 +1,5 @@
-# $OpenBSD: Makefile,v 1.6 2012/07/18 16:51:50 schwarze Exp $
+# $OpenBSD: Makefile,v 1.7 2014/04/08 07:13:01 schwarze Exp $
-REGRESS_TARGETS = literal spacing width manyargs empty
+REGRESS_TARGETS = empty literal longhead manyargs spacing width
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/man/IP/longhead.in b/regress/usr.bin/mandoc/man/IP/longhead.in
new file mode 100644
index 00000000000..f24922c0aa1
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/IP/longhead.in
@@ -0,0 +1,10 @@
+.TH IP-LONGHEAD 1 "April 8, 2014" OpenBSD
+.SH NAME
+IP-longhead \- indented paragraph with a long head
+.SH DESCRIPTION
+normal text
+.IP "This indented paragraph has ridiculously long text \
+in its head, such that it doesn't even fit on the line" 6n
+paragraph body
+.PP
+normal text
diff --git a/regress/usr.bin/mandoc/man/IP/longhead.out_ascii b/regress/usr.bin/mandoc/man/IP/longhead.out_ascii
new file mode 100644
index 00000000000..edbd820ff01
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/IP/longhead.out_ascii
@@ -0,0 +1,19 @@
+IP-LONGHEAD(1) OpenBSD Reference Manual IP-LONGHEAD(1)
+
+
+
+NNAAMMEE
+ IP-longhead - indented paragraph with a long head
+
+DDEESSCCRRIIPPTTIIOONN
+ normal text
+
+ This indented paragraph has ridiculously long text in its head, such
+ that it doesn't even fit on the line
+ paragraph body
+
+ normal text
+
+
+
+OpenBSD April 8, 2014 IP-LONGHEAD(1)
diff --git a/regress/usr.bin/mandoc/man/TP/Makefile b/regress/usr.bin/mandoc/man/TP/Makefile
index fd42111dbf7..d5b74f160d1 100644
--- a/regress/usr.bin/mandoc/man/TP/Makefile
+++ b/regress/usr.bin/mandoc/man/TP/Makefile
@@ -1,5 +1,6 @@
-# $OpenBSD: Makefile,v 1.6 2014/03/08 15:50:21 schwarze Exp $
+# $OpenBSD: Makefile,v 1.7 2014/04/08 07:13:01 schwarze Exp $
-REGRESS_TARGETS = literal width manyargs badarg macrotag double sameline
+REGRESS_TARGETS = badarg double literal longhead macrotag manyargs
+REGRESS_TARGETS += sameline width
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/man/TP/longhead.in b/regress/usr.bin/mandoc/man/TP/longhead.in
new file mode 100644
index 00000000000..2fab0df4933
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/TP/longhead.in
@@ -0,0 +1,11 @@
+.TH TP-LONGHEAD 1 "April 8, 2014" OpenBSD
+.SH NAME
+TP-longhead \- tagged paragraph with a long head
+.SH DESCRIPTION
+normal text
+.TP 6n
+.B "This tagged paragraph has ridiculously long text \
+in its head, such that it doesn't even fit on the line"
+paragraph body
+.PP
+normal text
diff --git a/regress/usr.bin/mandoc/man/TP/longhead.out_ascii b/regress/usr.bin/mandoc/man/TP/longhead.out_ascii
new file mode 100644
index 00000000000..5a519103125
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/TP/longhead.out_ascii
@@ -0,0 +1,19 @@
+TP-LONGHEAD(1) OpenBSD Reference Manual TP-LONGHEAD(1)
+
+
+
+NNAAMMEE
+ TP-longhead - tagged paragraph with a long head
+
+DDEESSCCRRIIPPTTIIOONN
+ normal text
+
+ TThhiiss ttaaggggeedd ppaarraaggrraapphh hhaass rriiddiiccuulloouussllyy lloonngg tteexxtt iinn iittss hheeaadd,, ssuucchh tthhaatt
+ iitt ddooeessnn''tt eevveenn ffiitt oonn tthhee lliinnee
+ paragraph body
+
+ normal text
+
+
+
+OpenBSD April 8, 2014 TP-LONGHEAD(1)
diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c
index 1028eabd5c7..4d39aa4469f 100644
--- a/usr.bin/mandoc/man_term.c
+++ b/usr.bin/mandoc/man_term.c
@@ -1,4 +1,4 @@
-/* $Id: man_term.c,v 1.98 2014/03/30 21:27:59 schwarze Exp $ */
+/* $Id: man_term.c,v 1.99 2014/04/08 07:13:01 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -274,7 +274,7 @@ pre_literal(DECL_ARGS)
p->offset = p->rmargin;
p->rmargin = p->maxrmargin;
p->trailspace = 0;
- p->flags &= ~TERMP_NOBREAK;
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
p->flags |= TERMP_NOSPACE;
}
@@ -543,7 +543,7 @@ pre_HP(DECL_ARGS)
}
if ( ! (MANT_LITERAL & mt->fl)) {
- p->flags |= TERMP_NOBREAK;
+ p->flags |= TERMP_NOBREAK | TERMP_BRIND;
p->trailspace = 2;
}
@@ -578,7 +578,7 @@ post_HP(DECL_ARGS)
switch (n->type) {
case (MAN_BODY):
term_newln(p);
- p->flags &= ~TERMP_NOBREAK;
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND);
p->trailspace = 0;
p->offset = mt->offset;
p->rmargin = p->maxrmargin;
diff --git a/usr.bin/mandoc/mdoc_term.c b/usr.bin/mandoc/mdoc_term.c
index ff4a59b6d82..804e4c86de3 100644
--- a/usr.bin/mandoc/mdoc_term.c
+++ b/usr.bin/mandoc/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.164 2014/04/08 04:40:29 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.165 2014/04/08 07:13:01 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -815,14 +815,14 @@ termp_it_pre(DECL_ARGS)
MDOC_Bd == n->next->child->tok))
break;
- p->flags |= TERMP_NOBREAK | TERMP_HANG;
+ p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG;
p->trailspace = 1;
break;
case (LIST_tag):
if (MDOC_HEAD != n->type)
break;
- p->flags |= TERMP_NOBREAK;
+ p->flags |= TERMP_NOBREAK | TERMP_BRIND;
p->trailspace = 2;
if (NULL == n->next || NULL == n->next->child)
@@ -844,7 +844,7 @@ termp_it_pre(DECL_ARGS)
case (LIST_diag):
if (MDOC_HEAD != n->type)
break;
- p->flags |= TERMP_NOBREAK;
+ p->flags |= TERMP_NOBREAK | TERMP_BRIND;
p->trailspace = 1;
break;
default:
@@ -998,9 +998,8 @@ termp_it_post(DECL_ARGS)
* has munged them in the meanwhile.
*/
- p->flags &= ~TERMP_DANGLE;
- p->flags &= ~TERMP_NOBREAK;
- p->flags &= ~TERMP_HANG;
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND |
+ TERMP_DANGLE | TERMP_HANG);
p->trailspace = 0;
}
@@ -1037,7 +1036,7 @@ termp_nm_pre(DECL_ARGS)
synopsis_pre(p, n->parent);
if (MDOC_HEAD == n->type && n->next->child) {
- p->flags |= TERMP_NOSPACE | TERMP_NOBREAK;
+ p->flags |= TERMP_NOSPACE | TERMP_NOBREAK | TERMP_BRIND;
p->trailspace = 1;
p->rmargin = p->offset + term_len(p, 1);
if (NULL == n->child) {
@@ -1068,7 +1067,7 @@ termp_nm_post(DECL_ARGS)
p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
} else if (MDOC_HEAD == n->type && n->next->child) {
term_flushln(p);
- p->flags &= ~(TERMP_NOBREAK | TERMP_HANG);
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG);
p->trailspace = 0;
} else if (MDOC_BODY == n->type && n->child)
term_flushln(p);
@@ -1557,7 +1556,7 @@ termp_fn_pre(DECL_ARGS)
if (pretty) {
rmargin = p->rmargin;
p->rmargin = p->offset + term_len(p, 4);
- p->flags |= TERMP_NOBREAK | TERMP_HANG;
+ p->flags |= TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG;
}
assert(MDOC_TEXT == n->type);
@@ -1567,7 +1566,7 @@ termp_fn_pre(DECL_ARGS)
if (pretty) {
term_flushln(p);
- p->flags &= ~(TERMP_NOBREAK | TERMP_HANG);
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND | TERMP_HANG);
p->offset = p->rmargin;
p->rmargin = rmargin;
}
@@ -2059,14 +2058,16 @@ termp_fo_pre(DECL_ARGS)
if (pretty) {
rmargin = p->rmargin;
p->rmargin = p->offset + term_len(p, 4);
- p->flags |= TERMP_NOBREAK | TERMP_HANG;
+ p->flags |= TERMP_NOBREAK | TERMP_BRIND |
+ TERMP_HANG;
}
p->flags |= TERMP_NOSPACE;
term_word(p, "(");
p->flags |= TERMP_NOSPACE;
if (pretty) {
term_flushln(p);
- p->flags &= ~(TERMP_NOBREAK | TERMP_HANG);
+ p->flags &= ~(TERMP_NOBREAK | TERMP_BRIND |
+ TERMP_HANG);
p->offset = p->rmargin;
p->rmargin = rmargin;
}
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index de9f85c9ad6..30ed864bd7a 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.81 2014/04/05 21:17:48 schwarze Exp $ */
+/* $Id: term.c,v 1.82 2014/04/08 07:13:01 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -68,34 +68,27 @@ term_end(struct termp *p)
}
/*
- * Flush a line of text. A "line" is loosely defined as being something
- * that should be followed by a newline, regardless of whether it's
- * broken apart by newlines getting there. A line can also be a
- * fragment of a columnar list (`Bl -tag' or `Bl -column'), which does
- * not have a trailing newline.
- *
+ * Flush a chunk of text. By default, break the output line each time
+ * the right margin is reached, and continue output on the next line
+ * at the same offset as the chunk itself. By default, also break the
+ * output line at the end of the chunk.
* The following flags may be specified:
*
- * - TERMP_NOBREAK: this is the most important and is used when making
- * columns. In short: don't print a newline and instead expect the
- * next call to do the padding up to the start of the next column.
- * p->trailspace may be set to 0, 1, or 2, depending on how many
- * space characters are required at the end of the column.
- *
- * - TERMP_DANGLE: don't newline when TERMP_NOBREAK is specified and
- * the line is overrun, and don't pad-right if it's underrun.
- *
- * - TERMP_HANG: like TERMP_DANGLE, but doesn't newline when
- * overrunning, instead save the position and continue at that point
- * when the next invocation.
- *
- * In-line line breaking:
- *
- * If TERMP_NOBREAK is specified and the line overruns the right
- * margin, it will break and pad-right to the right margin after
- * writing. If maxrmargin is violated, it will break and continue
- * writing from the right-margin, which will lead to the above scenario
- * upon exit. Otherwise, the line will break at the right margin.
+ * - TERMP_NOBREAK: Do not break the output line at the right margin,
+ * but only at the max right margin. Also, do not break the output
+ * line at the end of the chunk, such that the next call can pad to
+ * the next column. However, if less than p->trailspace blanks,
+ * which can be 0, 1, or 2, remain to the right margin, the line
+ * will be broken.
+ * - TERMP_BRIND: If the chunk does not fit and the output line has
+ * to be broken, start the next line at the right margin instead
+ * of at the offset. Used together with TERMP_NOBREAK for the tags
+ * in various kinds of tagged lists.
+ * - TERMP_DANGLE: Do not break the output line at the right margin,
+ * append the next chunk after it even if this one is too long.
+ * To be used together with TERMP_NOBREAK.
+ * - TERMP_HANG: Like TERMP_DANGLE, and also suppress padding before
+ * the next chunk if this column is not full.
*/
void
term_flushln(struct termp *p)
@@ -197,7 +190,7 @@ term_flushln(struct termp *p)
vend -= vis;
(*p->endline)(p);
p->viscol = 0;
- if (TERMP_NOBREAK & p->flags) {
+ if (TERMP_BRIND & p->flags) {
vbl = p->rmargin;
vend += p->rmargin - p->offset;
} else
diff --git a/usr.bin/mandoc/term.h b/usr.bin/mandoc/term.h
index 6a63dd084e7..10cf8a330f7 100644
--- a/usr.bin/mandoc/term.h
+++ b/usr.bin/mandoc/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.43 2014/03/30 21:27:59 schwarze Exp $ */
+/* $Id: term.h,v 1.44 2014/04/08 07:13:01 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -77,11 +77,12 @@ struct termp {
#define TERMP_PREKEEP (1 << 6) /* ...starting with the next one. */
#define TERMP_SKIPCHAR (1 << 7) /* Skip the next character. */
#define TERMP_NOBREAK (1 << 8) /* See term_flushln(). */
-#define TERMP_DANGLE (1 << 9) /* See term_flushln(). */
-#define TERMP_HANG (1 << 10) /* See term_flushln(). */
-#define TERMP_NOSPLIT (1 << 11) /* See termp_an_pre/post(). */
-#define TERMP_SPLIT (1 << 12) /* See termp_an_pre/post(). */
-#define TERMP_ANPREC (1 << 13) /* See termp_an_pre(). */
+#define TERMP_BRIND (1 << 9) /* See term_flushln(). */
+#define TERMP_DANGLE (1 << 10) /* See term_flushln(). */
+#define TERMP_HANG (1 << 11) /* See term_flushln(). */
+#define TERMP_NOSPLIT (1 << 12) /* See termp_an_pre/post(). */
+#define TERMP_SPLIT (1 << 13) /* See termp_an_pre/post(). */
+#define TERMP_ANPREC (1 << 14) /* See termp_an_pre(). */
int *buf; /* Output buffer. */
enum termenc enc; /* Type of encoding. */
struct mchars *symtab; /* Encoded-symbol table. */