1Patch-Source: https://cvsweb.bsd.lv/mandoc/tag.c.diff?r1=1.36&r2=1.372---3===================================================================4RCS file: /cvs/mandoc/tag.c,v5retrieving revision 1.366retrieving revision 1.377diff -u -p -r1.36 -r1.378--- mandoc/tag.c 2020/04/19 16:36:16 1.369+++ mandoc/tag.c 2022/04/26 11:38:38 1.3710@@ -1,6 +1,7 @@11-/* $Id: tag.c,v 1.36 2020/04/19 16:36:16 schwarze Exp $ */12+/* $Id: tag.c,v 1.37 2022/04/26 11:38:38 schwarze Exp $ */13 /*14- * Copyright (c) 2015,2016,2018,2019,2020 Ingo Schwarze <schwarze@openbsd.org>15+ * Copyright (c) 2015, 2016, 2018, 2019, 2020, 202216+ * Ingo Schwarze <schwarze@openbsd.org>17 *18 * Permission to use, copy, modify, and distribute this software for any19 * purpose with or without fee is hereby granted, provided that the above20@@ -80,7 +81,7 @@ tag_free(void)2122 /*23 * Set a node where a term is defined,24- * unless it is already defined at a lower priority.25+ * unless the term is already defined at a lower priority.26 */27 void28 tag_put(const char *s, int prio, struct roff_node *n)29@@ -93,6 +94,18 @@ tag_put(const char *s, int prio, struct roff_node *n)3031 assert(prio <= TAG_FALLBACK);3233+ /*34+ * If the node is already tagged, the existing tag is35+ * explicit and we are now about to add an implicit tag.36+ * Don't do that; just skip implicit tagging if the author37+ * specified an explicit tag.38+ */39+40+ if (n->flags & NODE_ID)41+ return;42+43+ /* Determine the implicit tag. */44+45 if (s == NULL) {46 if (n->child == NULL || n->child->type != ROFFT_TEXT)47 return;48@@ -150,7 +163,7 @@ tag_put(const char *s, int prio, struct roff_node *n)49 */5051 else if (entry->prio < prio)52- return;53+ return;5455 /*56 * If the existing entry is worse, clear it.