From 552ae67d6bc6f43177819b14352c7e3fb901e8d6 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sat, 21 Mar 2020 00:17:02 +0000 Subject: When setting automatic tags, skip initial hyphens and minus signs, bringing the behaviour for mdoc(7) closer to what is already done for man(7). Triggered by the observation of kn@ that automatic tagging didn't work very well for find(1) primaries. OK kn@ --- usr.bin/mandoc/tag.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'usr.bin/mandoc') diff --git a/usr.bin/mandoc/tag.c b/usr.bin/mandoc/tag.c index 7d4790d873a..d8ea190e79f 100644 --- a/usr.bin/mandoc/tag.c +++ b/usr.bin/mandoc/tag.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tag.c,v 1.29 2020/03/13 16:14:14 schwarze Exp $ */ +/* $OpenBSD: tag.c,v 1.30 2020/03/21 00:17:01 schwarze Exp $ */ /* * Copyright (c) 2015,2016,2018,2019,2020 Ingo Schwarze * @@ -87,8 +87,24 @@ tag_put(const char *s, int prio, struct roff_node *n) if (n->child == NULL || n->child->type != ROFFT_TEXT) return; s = n->child->string; - if (s[0] == '\\' && (s[1] == '&' || s[1] == 'e')) - s += 2; + switch (s[0]) { + case '-': + s++; + break; + case '\\': + switch (s[1]) { + case '&': + case '-': + case 'e': + s += 2; + break; + default: + break; + } + break; + default: + break; + } } /* -- cgit v1.2.3