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).
-# $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
-HTML_TARGETS = column list warn
+HTML_TARGETS = column implicit list warn
--- /dev/null
+.\" $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
--- /dev/null
+TG-IMPLICIT(1) General Commands Manual TG-IMPLICIT(1)
+
+N\bNA\bAM\bME\bE
+ T\bTg\bg-\b-i\bim\bmp\bpl\bli\bic\bci\bit\bt - overriding implicit tagging
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+ BEGINTEST
+
+ i\bim\bmp\bpl\bli\bic\bci\bit\bt i\bis\bs u\bun\bns\bsu\bus\bse\bed\bd
+
+ ENDTEST
+
+OpenBSD April 26, 2022 OpenBSD
--- /dev/null
+<p class="Pp" id="explicit"><a class="permalink" href="#explicit"><b class="Sy">implicit
+ is unsused</b></a></p>
--- /dev/null
+TG-IMPLICIT(1) - General Commands Manual
+
+# NAME
+
+**Tg-implicit** - overriding implicit tagging
+
+# DESCRIPTION
+
+BEGINTEST
+
+**implicit is unsused**
+
+ENDTEST
+
+OpenBSD - April 26, 2022
--- /dev/null
+NAME implicit.mandoc_ascii 3
+DESCRIPTION implicit.mandoc_ascii 6
+explicit implicit.mandoc_ascii 9
-/* $Id: tag.c,v 1.36 2020/04/19 16:36:16 schwarze Exp $ */
+/* $Id: tag.c,v 1.37 2022/04/26 11:38:38 schwarze Exp $ */
- * Copyright (c) 2015,2016,2018,2019,2020 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2015, 2016, 2018, 2019, 2020, 2022
+ * 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
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
/*
* Set a node where a term is defined,
/*
* 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)
*/
void
tag_put(const char *s, int prio, struct roff_node *n)
assert(prio <= TAG_FALLBACK);
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;
if (s == NULL) {
if (n->child == NULL || n->child->type != ROFFT_TEXT)
return;
*/
else if (entry->prio < prio)
*/
else if (entry->prio < prio)
/*
* If the existing entry is worse, clear it.
/*
* If the existing entry is worse, clear it.