From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20248 invoked from network); 26 Apr 2022 11:38:43 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 26 Apr 2022 11:38:43 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id 28dd9b3d for ; Tue, 26 Apr 2022 06:38:40 -0500 (EST) Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id dd628e60 for ; Tue, 26 Apr 2022 06:38:40 -0500 (EST) Date: Tue, 26 Apr 2022 06:38:40 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: If a node is tagged explicitly, skip implicit tagging for that X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: <3365177c52c722b7@mandoc.bsd.lv> Log Message: ----------- If a node is tagged explicitly, skip implicit tagging for that node. Apart from making sense in the first place, this fixes an assertion failure that happened when the calculated implicit tag did not match the string value of the first child of the node, Bug found by tb@ using afl(1). Modified Files: -------------- mandoc: tag.c mandoc/regress/mdoc/Tg: Makefile Added Files: ----------- mandoc/regress/mdoc/Tg: implicit.in implicit.out_ascii implicit.out_html implicit.out_markdown implicit.out_tag Revision Data ------------- Index: tag.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/tag.c,v retrieving revision 1.36 retrieving revision 1.37 diff -Ltag.c -Ltag.c -u -p -r1.36 -r1.37 --- tag.c +++ tag.c @@ -1,6 +1,7 @@ /* $Id$ */ /* - * Copyright (c) 2015,2016,2018,2019,2020 Ingo Schwarze + * Copyright (c) 2015, 2016, 2018, 2019, 2020, 2022 + * Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -80,7 +81,7 @@ tag_free(void) /* * Set a node where a term is defined, - * unless it is already defined at a lower priority. + * unless the term is already defined at a lower priority. */ void tag_put(const char *s, int prio, struct roff_node *n) @@ -93,6 +94,18 @@ tag_put(const char *s, int prio, struct assert(prio <= TAG_FALLBACK); + /* + * If the node is already tagged, the existing tag is + * explicit and we are now about to add an implicit tag. + * Don't do that; just skip implicit tagging if the author + * specified an explicit tag. + */ + + if (n->flags & NODE_ID) + return; + + /* Determine the implicit tag. */ + if (s == NULL) { if (n->child == NULL || n->child->type != ROFFT_TEXT) return; @@ -150,7 +163,7 @@ tag_put(const char *s, int prio, struct */ else if (entry->prio < prio) - return; + return; /* * If the existing entry is worse, clear it. --- /dev/null +++ regress/mdoc/Tg/implicit.out_tag @@ -0,0 +1,3 @@ +NAME implicit.mandoc_ascii 3 +DESCRIPTION implicit.mandoc_ascii 6 +explicit implicit.mandoc_ascii 9 --- /dev/null +++ regress/mdoc/Tg/implicit.out_ascii @@ -0,0 +1,13 @@ +TG-IMPLICIT(1) General Commands Manual TG-IMPLICIT(1) + +NNAAMMEE + TTgg--iimmpplliicciitt - overriding implicit tagging + +DDEESSCCRRIIPPTTIIOONN + BEGINTEST + + iimmpplliicciitt iiss uunnssuusseedd + + ENDTEST + +OpenBSD April 26, 2022 OpenBSD --- /dev/null +++ regress/mdoc/Tg/implicit.out_html @@ -0,0 +1,2 @@ +

Index: Makefile =================================================================== RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Tg/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -Lregress/mdoc/Tg/Makefile -Lregress/mdoc/Tg/Makefile -u -p -r1.2 -r1.3 --- regress/mdoc/Tg/Makefile +++ regress/mdoc/Tg/Makefile @@ -1,9 +1,9 @@ -# $OpenBSD: Makefile,v 1.2 2020/04/06 09:55:50 schwarze Exp $ +# $OpenBSD: Makefile,v 1.3 2022/04/26 11:28:35 schwarze Exp $ -REGRESS_TARGETS = column list warn -TAG_TARGETS = column list warn +REGRESS_TARGETS = column implicit list warn +TAG_TARGETS = column implicit list warn LINT_TARGETS = warn -HTML_TARGETS = column list warn +HTML_TARGETS = column implicit list warn SKIP_TMAN = column --- /dev/null +++ regress/mdoc/Tg/implicit.out_markdown @@ -0,0 +1,15 @@ +TG-IMPLICIT(1) - General Commands Manual + +# NAME + +**Tg-implicit** - overriding implicit tagging + +# DESCRIPTION + +BEGINTEST + +**implicit is unsused** + +ENDTEST + +OpenBSD - April 26, 2022 --- /dev/null +++ regress/mdoc/Tg/implicit.in @@ -0,0 +1,14 @@ +.\" $OpenBSD: implicit.in,v 1.1 2022/04/26 11:28:35 schwarze Exp $ +.Dd $Mdocdate: April 26 2022 $ +.Dt TG-IMPLICIT 1 +.Os +.Sh NAME +.Nm Tg-implicit +.Nd overriding implicit tagging +.Sh DESCRIPTION +BEGINTEST +.Pp +.Tg explicit +.Sy implicit is unsused +.Pp +ENDTEST -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv