diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2021-07-04 15:38:26 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2021-07-04 15:38:26 +0000 |
commit | f832ec6c36e0404849c4a0c33bc812eb65f90a8c (patch) | |
tree | fba2f4e842ad314046f8a4bbfab78ebf800a27a1 /mdoc_man.c | |
parent | f3d3c83d9bff182a515c18874b5cf60c3dc740f5 (diff) | |
download | mandoc-f832ec6c36e0404849c4a0c33bc812eb65f90a8c.tar.gz |
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.
Diffstat (limited to 'mdoc_man.c')
-rw-r--r-- | mdoc_man.c | 32 |
1 files changed, 22 insertions, 10 deletions
@@ -1,6 +1,6 @@ /* $Id$ */ /* - * 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; } /* |