From 3f3c303a935a299746b862b5e231f2cc83364e19 Mon Sep 17 00:00:00 2001 From: schwarze Date: Fri, 28 Apr 2023 20:14:19 +0000 Subject: [PATCH] Do not rewrite MAN_LP and MAN_P to MAN_PP because doing that causes confusing warning messages complaining about macros that don't even appear in the input file. As a welcome side effect, this also shortens the code... Fixing a minibug reported by Alejandro Colomar . --- usr.bin/mandoc/man_html.c | 15 ++++----------- usr.bin/mandoc/man_term.c | 14 +++----------- usr.bin/mandoc/man_validate.c | 35 ++++++++--------------------------- 3 files changed, 15 insertions(+), 49 deletions(-) diff --git a/usr.bin/mandoc/man_html.c b/usr.bin/mandoc/man_html.c index 8c45d7c4316..5e0bffebd53 100644 --- a/usr.bin/mandoc/man_html.c +++ b/usr.bin/mandoc/man_html.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man_html.c,v 1.137 2022/07/06 16:02:52 schwarze Exp $ */ +/* $OpenBSD: man_html.c,v 1.138 2023/04/28 20:14:19 schwarze Exp $ */ /* * Copyright (c) 2013-2015,2017-2020,2022 Ingo Schwarze * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons @@ -58,7 +58,6 @@ static int man_SH_pre(MAN_ARGS); static int man_SM_pre(MAN_ARGS); static int man_SY_pre(MAN_ARGS); static int man_UR_pre(MAN_ARGS); -static int man_abort_pre(MAN_ARGS); static int man_alt_pre(MAN_ARGS); static int man_ign_pre(MAN_ARGS); static int man_in_pre(MAN_ARGS); @@ -73,9 +72,9 @@ static const struct man_html_act man_html_acts[MAN_MAX - MAN_TH] = { { man_SH_pre, NULL }, /* SS */ { man_IP_pre, NULL }, /* TP */ { man_IP_pre, NULL }, /* TQ */ - { man_abort_pre, NULL }, /* LP */ + { man_PP_pre, NULL }, /* LP */ { man_PP_pre, NULL }, /* PP */ - { man_abort_pre, NULL }, /* P */ + { man_PP_pre, NULL }, /* P */ { man_IP_pre, NULL }, /* IP */ { man_PP_pre, NULL }, /* HP */ { man_SM_pre, NULL }, /* SM */ @@ -404,7 +403,7 @@ man_PP_pre(MAN_ARGS) if (n->child != NULL && (n->child->flags & NODE_NOFILL) == 0) print_otag(h, TAG_P, "c", - n->tok == MAN_PP ? "Pp" : "Pp HP"); + n->tok == MAN_HP ? "Pp HP" : "Pp"); break; default: abort(); @@ -633,9 +632,3 @@ man_UR_pre(MAN_ARGS) print_man_nodelist(man, n->child, h); return 0; } - -static int -man_abort_pre(MAN_ARGS) -{ - abort(); -} diff --git a/usr.bin/mandoc/man_term.c b/usr.bin/mandoc/man_term.c index 10fc859a4fd..75b2744da8a 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.194 2022/08/28 09:55:58 schwarze Exp $ */ +/* $OpenBSD: man_term.c,v 1.195 2023/04/28 20:14:19 schwarze Exp $ */ /* * Copyright (c) 2010-2015,2017-2020,2022 Ingo Schwarze * Copyright (c) 2008-2012 Kristaps Dzonsons @@ -81,7 +81,6 @@ static int pre_SS(DECL_ARGS); static int pre_SY(DECL_ARGS); static int pre_TP(DECL_ARGS); static int pre_UR(DECL_ARGS); -static int pre_abort(DECL_ARGS); static int pre_alternate(DECL_ARGS); static int pre_ign(DECL_ARGS); static int pre_in(DECL_ARGS); @@ -101,9 +100,9 @@ static const struct man_term_act man_term_acts[MAN_MAX - MAN_TH] = { { pre_SS, post_SH, 0 }, /* SS */ { pre_TP, post_TP, 0 }, /* TP */ { pre_TP, post_TP, 0 }, /* TQ */ - { pre_abort, NULL, 0 }, /* LP */ + { pre_PP, NULL, 0 }, /* LP */ { pre_PP, NULL, 0 }, /* PP */ - { pre_abort, NULL, 0 }, /* P */ + { pre_PP, NULL, 0 }, /* P */ { pre_IP, post_IP, 0 }, /* IP */ { pre_HP, post_HP, 0 }, /* HP */ { NULL, NULL, 0 }, /* SM */ @@ -223,13 +222,6 @@ print_bvspace(struct termp *p, struct roff_node *n, int pardist) term_vspace(p); } - -static int -pre_abort(DECL_ARGS) -{ - abort(); -} - static int pre_ign(DECL_ARGS) { diff --git a/usr.bin/mandoc/man_validate.c b/usr.bin/mandoc/man_validate.c index 56c3f46c400..c83e5a2baf7 100644 --- a/usr.bin/mandoc/man_validate.c +++ b/usr.bin/mandoc/man_validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man_validate.c,v 1.127 2022/08/02 11:55:51 schwarze Exp $ */ +/* $OpenBSD: man_validate.c,v 1.128 2023/04/28 20:14:19 schwarze Exp $ */ /* * Copyright (c) 2010, 2012-2020 Ingo Schwarze * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons @@ -42,7 +42,6 @@ typedef void (*v_check)(CHKARGS); -static void check_abort(CHKARGS) __attribute__((__noreturn__)); static void check_par(CHKARGS); static void check_part(CHKARGS); static void check_root(CHKARGS); @@ -67,9 +66,9 @@ static const v_check man_valids[MAN_MAX - MAN_TH] = { post_SH, /* SS */ post_TP, /* TP */ post_TP, /* TQ */ - check_abort,/* LP */ + check_par, /* LP */ check_par, /* PP */ - check_abort,/* P */ + check_par, /* P */ post_IP, /* IP */ NULL, /* HP */ NULL, /* SM */ @@ -109,26 +108,12 @@ man_validate(struct roff_man *man) struct roff_node *n; const v_check *cp; - /* - * Translate obsolete macros such that later code - * does not need to look for them. - */ - - n = man->last; - switch (n->tok) { - case MAN_LP: - case MAN_P: - n->tok = MAN_PP; - break; - default: - break; - } - /* * Iterate over all children, recursing into each one * in turn, depth-first. */ + n = man->last; man->last = man->last->child; while (man->last != NULL) { man_validate(man); @@ -198,12 +183,6 @@ check_root(CHKARGS) "(OpenBSD)" : "(NetBSD)"); } -static void -check_abort(CHKARGS) -{ - abort(); -} - /* * Skip leading whitespace, dashes, backslashes, and font escapes, * then create a tag if the first following byte is a letter. @@ -338,7 +317,8 @@ post_SH(CHKARGS) return; } - if (nc->tok == MAN_PP && nc->body->child != NULL) { + if ((nc->tok == MAN_LP || nc->tok == MAN_PP || nc->tok == MAN_P) && + nc->body->child != NULL) { while (nc->body->last != NULL) { man->next = ROFF_NEXT_CHILD; roff_node_relink(man, nc->body->last); @@ -346,7 +326,8 @@ post_SH(CHKARGS) } } - if (nc->tok == MAN_PP || nc->tok == ROFF_sp || nc->tok == ROFF_br) { + if (nc->tok == MAN_LP || nc->tok == MAN_PP || nc->tok == MAN_P || + nc->tok == ROFF_sp || nc->tok == ROFF_br) { mandoc_msg(MANDOCERR_PAR_SKIP, nc->line, nc->pos, "%s after %s", roff_name[nc->tok], roff_name[n->tok]); roff_node_delete(man, nc); -- 2.20.1