summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2012-05-27 01:01:24 +0000
committerschwarze <schwarze@openbsd.org>2012-05-27 01:01:24 +0000
commitef8ef3ff36cc38861379946a6693d9ba450767f9 (patch)
tree365bb5c9857c3e87b4ba9d073c88bb6955d111b7
parentCorrect width of horizontal spans; relevant in case of centered or (diff)
downloadwireguard-openbsd-ef8ef3ff36cc38861379946a6693d9ba450767f9.tar.xz
wireguard-openbsd-ef8ef3ff36cc38861379946a6693d9ba450767f9.zip
Fix the vertical spacing around tbl(7) instances in man(7).
Groff forces the document author to manually request sufficient spacing after .TE - that is, at least .sp 1v after a table with the "box" option and at least .sp 2v after a table with the "doublebox" option - or else it clobbers the box. I consider that insane, so i'm not imitating groff in that respect. Instead, i add at least as much vertical space as groff, or more where required to avoid clobbering the box. Consequently, output will be identical for input that looks sane with groff, and mandoc will make output look better for input that looks bad with groff. As a side effect, having identical output for portable input makes it possible to set up the first regression tests for tbl(7).
-rw-r--r--regress/usr.bin/mandoc/man/TS/Makefile12
-rw-r--r--regress/usr.bin/mandoc/man/TS/vspace.in48
-rw-r--r--regress/usr.bin/mandoc/man/TS/vspace.out_ascii42
-rw-r--r--usr.bin/mandoc/tbl_term.c10
-rw-r--r--usr.bin/mandoc/term.c9
-rw-r--r--usr.bin/mandoc/term.h3
6 files changed, 117 insertions, 7 deletions
diff --git a/regress/usr.bin/mandoc/man/TS/Makefile b/regress/usr.bin/mandoc/man/TS/Makefile
new file mode 100644
index 00000000000..e464b63beb9
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/TS/Makefile
@@ -0,0 +1,12 @@
+# $OpenBSD: Makefile,v 1.1 2012/05/27 01:01:25 schwarze Exp $
+
+REGRESS_TARGETS=vspace
+
+TBL=/usr/local/bin/tbl
+
+.for t in ${REGRESS_TARGETS}
+${t}.out_ascii: ${t}.in
+ ${TBL} ${.ALLSRC} | ${NROFF} > ${.TARGET}
+.endfor
+
+.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/man/TS/vspace.in b/regress/usr.bin/mandoc/man/TS/vspace.in
new file mode 100644
index 00000000000..c3a2363f8b8
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/TS/vspace.in
@@ -0,0 +1,48 @@
+.TH TBL-VSPACE 1
+.SH NAME
+tbl-vspace \- vertical spacing around tables
+.SH DESCRIPTION
+normal text before table
+.TS
+L .
+table without box
+.TE
+normal text after table without box
+.TS
+box;
+L .
+table with box
+.TE
+.\" at least one vertical space is required here
+.\" or groff will clobber the box
+.sp 1v
+normal text after table with box
+.TS
+doublebox;
+L .
+table with double box
+.TE
+.\" at least two vertical spaces are required here
+.\" or groff will clobber the box
+.sp 2v
+normal text after table with double box
+.TS
+L .
+table without box
+.TE
+.TS
+box;
+L .
+table with box
+.TE
+.sp 1v
+.TS
+doublebox;
+L .
+table with double box
+.TE
+.sp 2v
+.TS
+L .
+table without box
+.TE
diff --git a/regress/usr.bin/mandoc/man/TS/vspace.out_ascii b/regress/usr.bin/mandoc/man/TS/vspace.out_ascii
new file mode 100644
index 00000000000..ddaab21ffd9
--- /dev/null
+++ b/regress/usr.bin/mandoc/man/TS/vspace.out_ascii
@@ -0,0 +1,42 @@
+TBL-VSPACE(1) OpenBSD Reference Manual TBL-VSPACE(1)
+
+
+
+NNAAMMEE
+ tbl-vspace - vertical spacing around tables
+
+DDEESSCCRRIIPPTTIIOONN
+ normal text before table
+
+ table without box
+ normal text after table without box
+
+ +---------------+
+ |table with box |
+ +---------------+
+ normal text after table with box
+
+ +----------------------+
+ +----------------------+
+ |table with double box |
+ +----------------------+
+ +----------------------+
+ normal text after table with double box
+
+ table without box
+
+ +---------------+
+ |table with box |
+ +---------------+
+
+ +----------------------+
+ +----------------------+
+ |table with double box |
+ +----------------------+
+ +----------------------+
+
+ table without box
+
+
+
+ TBL-VSPACE(1)
diff --git a/usr.bin/mandoc/tbl_term.c b/usr.bin/mandoc/tbl_term.c
index a64ddd6b9cf..02851c96a65 100644
--- a/usr.bin/mandoc/tbl_term.c
+++ b/usr.bin/mandoc/tbl_term.c
@@ -1,4 +1,4 @@
-/* $Id: tbl_term.c,v 1.12 2012/05/26 20:53:17 schwarze Exp $ */
+/* $Id: tbl_term.c,v 1.13 2012/05/27 01:01:24 schwarze Exp $ */
/*
* Copyright (c) 2009, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
@@ -167,10 +167,14 @@ term_tbl(struct termp *tp, const struct tbl_span *sp)
if (TBL_SPAN_LAST & sp->flags) {
if (TBL_OPT_DBOX & sp->tbl->opts ||
- TBL_OPT_BOX & sp->tbl->opts)
+ TBL_OPT_BOX & sp->tbl->opts) {
tbl_hframe(tp, sp, 0);
- if (TBL_OPT_DBOX & sp->tbl->opts)
+ tp->skipvsp = 1;
+ }
+ if (TBL_OPT_DBOX & sp->tbl->opts) {
tbl_hframe(tp, sp, 1);
+ tp->skipvsp = 2;
+ }
assert(tp->tbl.cols);
free(tp->tbl.cols);
tp->tbl.cols = NULL;
diff --git a/usr.bin/mandoc/term.c b/usr.bin/mandoc/term.c
index 075eb2b0a8a..acbe2c802ef 100644
--- a/usr.bin/mandoc/term.c
+++ b/usr.bin/mandoc/term.c
@@ -1,7 +1,7 @@
-/* $Id: term.c,v 1.62 2011/09/21 09:57:11 schwarze Exp $ */
+/* $Id: term.c,v 1.63 2012/05/27 01:01:24 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2011, 2012 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
@@ -312,7 +312,10 @@ term_vspace(struct termp *p)
term_newln(p);
p->viscol = 0;
- (*p->endline)(p);
+ if (0 < p->skipvsp)
+ p->skipvsp--;
+ else
+ (*p->endline)(p);
}
void
diff --git a/usr.bin/mandoc/term.h b/usr.bin/mandoc/term.h
index 3b7f4ed33c1..92a74e535a8 100644
--- a/usr.bin/mandoc/term.h
+++ b/usr.bin/mandoc/term.h
@@ -1,4 +1,4 @@
-/* $Id: term.h,v 1.34 2011/11/13 13:30:42 schwarze Exp $ */
+/* $Id: term.h,v 1.35 2012/05/27 01:01:24 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -63,6 +63,7 @@ struct termp {
int col; /* Bytes in buf. */
size_t viscol; /* Chars on current line. */
int overstep; /* See termp_flushln(). */
+ int skipvsp; /* Vertical space to skip. */
int flags;
#define TERMP_SENTENCE (1 << 1) /* Space before a sentence. */
#define TERMP_NOSPACE (1 << 2) /* No space before words. */