aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2021-07-04 15:38:26 +0000
committerIngo Schwarze <schwarze@openbsd.org>2021-07-04 15:38:26 +0000
commit38564fb72f1972ec44f0dd16e2ae4802adc9d3c9 (patch)
tree8fcb369483727b656742f258c9875c50e59f215b
parent297de1c8ac72f2de64a49c98141c097cad06e90f (diff)
downloadmandoc-38564fb72f1972ec44f0dd16e2ae4802adc9d3c9.tar.gz
mandoc-38564fb72f1972ec44f0dd16e2ae4802adc9d3c9.tar.zst
mandoc-38564fb72f1972ec44f0dd16e2ae4802adc9d3c9.zip
The mandoc(1) manual already mentions that -T man output mode
neither supports tbl(7) nor eqn(7) input. If an input file contains such code anyway, tell the user rather than failing an assert(3)ion. Fixing a crash reported by Bjarni Ingi Gislason <bjarniig at rhi dot hi dot is> in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901636 which the Debian maintainer of mandoc, Michael at Stapelberg dot ch, forwarded to me.
-rw-r--r--TODO7
-rw-r--r--mandoc.122
-rw-r--r--mandoc.h6
-rw-r--r--mandoc_msg.c4
-rw-r--r--mdoc_man.c34
5 files changed, 57 insertions, 16 deletions
diff --git a/TODO b/TODO
index 917b0cbb..b28c0d46 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,6 @@
************************************************************************
* Official mandoc TODO.
-* $Id: TODO,v 1.315 2021/06/27 17:29:02 schwarze Exp $
+* $Id: TODO,v 1.316 2021/07/04 15:38:26 schwarze Exp $
************************************************************************
Many issues are annotated for difficulty as follows:
@@ -228,6 +228,10 @@ are mere guesses, and some may be wrong.
--- missing tbl features -----------------------------------------------
+- fully support the "nospaces" option;
+ Oliver Corff mentioned usefulness 20 Jun 2021 09:41:06 +0200
+ loc * exist * algo * size * imp *
+
- vertical centering in cells vertically spanned with ^
pali dot rohar at gmail dot com 16 Jul 2018 13:03:35 +0200
loc * exist *** algo *** size ** imp *
@@ -284,6 +288,7 @@ are mere guesses, and some may be wrong.
- -T man does not handle eqn(7) and tbl(7)
Stephen Gregoratto 16 Feb 2020 01:28:07 +1100
+ also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901636
loc ** exist ** algo ** size *** imp **
- man -ks 1,8 route; kn@ Jul 13, 2018 orally
diff --git a/mandoc.1 b/mandoc.1
index 00e7eec3..669cf9fb 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: June 28 2021 $
+.Dd $Mdocdate: July 4 2021 $
.Dt MANDOC 1
.Os
.Sh NAME
@@ -2314,6 +2314,26 @@ or
macro or of an undefined macro.
The macro is ignored, and its arguments are handled
as if they were a text line.
+.It Sy "skipping tbl in -Tman mode"
+.Pq mdoc , tbl
+An input file contains the
+.Ic \&TS
+macro.
+This message is only generated in
+.Fl T Cm man
+output mode, where
+.Xr tbl 7
+input is not supported.
+.It Sy "skipping eqn in -Tman mode"
+.Pq mdoc , eqn
+An input file contains the
+.Ic \&EQ
+macro.
+This message is only generated in
+.Fl T Cm man
+output mode, where
+.Xr eqn 7
+input is not supported.
.El
.Ss Bad command line arguments
.Bl -ohang
diff --git a/mandoc.h b/mandoc.h
index 3f68e9d4..8f4895b2 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,6 +1,6 @@
-/* $Id: mandoc.h,v 1.271 2021/06/27 17:57:54 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.272 2021/07/04 15:38:26 schwarze Exp $ */
/*
- * Copyright (c) 2012-2020 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2012-2021 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -245,6 +245,8 @@ enum mandocerr {
MANDOCERR_TBLOPT_EQN, /* eqn delim option in tbl: arg */
MANDOCERR_TBLLAYOUT_MOD, /* unsupported tbl layout modifier: m */
MANDOCERR_TBLMACRO, /* ignoring macro in table: macro */
+ MANDOCERR_TBL_TMAN, /* skipping tbl in -Tman mode */
+ MANDOCERR_EQN_TMAN, /* skipping eqn in -Tman mode */
MANDOCERR_BADARG, /* ===== start of bad invocations ===== */
diff --git a/mandoc_msg.c b/mandoc_msg.c
index 64355ddc..8867bb4b 100644
--- a/mandoc_msg.c
+++ b/mandoc_msg.c
@@ -1,6 +1,6 @@
/* $OpenBSD: mandoc_msg.c,v 1.8 2020/01/19 17:59:01 schwarze Exp $ */
/*
- * Copyright (c) 2014-2020 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2014-2021 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -245,6 +245,8 @@ static const char *const type_message[MANDOCERR_MAX] = {
"eqn delim option in tbl",
"unsupported tbl layout modifier",
"ignoring macro in table",
+ "skipping tbl in -Tman mode",
+ "skipping eqn in -Tman mode",
/* bad command line arguments */
NULL,
diff --git a/mdoc_man.c b/mdoc_man.c
index d7b42fac..0964cc61 100644
--- a/mdoc_man.c
+++ b/mdoc_man.c
@@ -1,6 +1,6 @@
-/* $Id: mdoc_man.c,v 1.136 2020/02/27 01:43:52 schwarze Exp $ */
+/* $Id: mdoc_man.c,v 1.137 2021/07/04 15:38:26 schwarze Exp $ */
/*
- * Copyright (c) 2011-2020 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011-2021 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
@@ -660,7 +660,20 @@ print_node(DECL_ARGS)
do_sub = 1;
n->flags &= ~NODE_ENDED;
- if (n->type == ROFFT_TEXT) {
+ switch (n->type) {
+ case ROFFT_EQN:
+ case ROFFT_TBL:
+ mandoc_msg(n->type == ROFFT_EQN ? MANDOCERR_EQN_TMAN :
+ MANDOCERR_TBL_TMAN, n->line, n->pos, NULL);
+ outflags |= MMAN_PP | MMAN_sp | MMAN_nl;
+ print_word("The");
+ print_line(".B \\-T man", MMAN_nl);
+ print_word("output mode does not support");
+ print_word(n->type == ROFFT_EQN ? "eqn(7)" : "tbl(7)");
+ print_word("input.");
+ outflags |= MMAN_PP | MMAN_sp | MMAN_nl;
+ return;
+ case ROFFT_TEXT:
/*
* Make sure that we don't happen to start with a
* control character at the start of a line.
@@ -680,19 +693,18 @@ print_node(DECL_ARGS)
outflags &= ~(MMAN_spc | MMAN_spc_force);
else if (outflags & MMAN_Sm)
outflags |= MMAN_spc;
- } else if (n->tok < ROFF_MAX) {
- (*roff_man_acts[n->tok])(meta, n);
- return;
- } else {
- /*
- * Conditionally run the pre-node action handler for a
- * node.
- */
+ break;
+ default:
+ if (n->tok < ROFF_MAX) {
+ (*roff_man_acts[n->tok])(meta, n);
+ return;
+ }
act = mdoc_man_act(n->tok);
cond = act->cond == NULL || (*act->cond)(meta, n);
if (cond && act->pre != NULL &&
(n->end == ENDBODY_NOT || n->child != NULL))
do_sub = (*act->pre)(meta, n);
+ break;
}
/*