prevent breakable hyphens in segment identifiers
authorschwarze <schwarze@openbsd.org>
Tue, 9 Aug 2022 11:21:50 +0000 (11:21 +0000)
committerschwarze <schwarze@openbsd.org>
Tue, 9 Aug 2022 11:21:50 +0000 (11:21 +0000)
from being turned into underscores;
bug reported by <Eldred dot fr> Habert

usr.bin/mandoc/html.c

index 68db54b..20588aa 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: html.c,v 1.149 2022/07/06 14:27:55 schwarze Exp $ */
+/* $OpenBSD: html.c,v 1.150 2022/08/09 11:21:50 schwarze Exp $ */
 /*
  * Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2011-2015, 2017-2021 Ingo Schwarze <schwarze@openbsd.org>
@@ -401,10 +401,13 @@ html_make_id(const struct roff_node *n, int unique)
         * In addition, reserve '~' for ordinal suffixes.
         */
 
-       for (cp = buf; *cp != '\0'; cp++)
-               if (isalnum((unsigned char)*cp) == 0 &&
+       for (cp = buf; *cp != '\0'; cp++) {
+               if (*cp == ASCII_HYPH)
+                       *cp = '-';
+               else if (isalnum((unsigned char)*cp) == 0 &&
                    strchr("!$&'()*+,-./:;=?@_", *cp) == NULL)
                        *cp = '_';
+       }
 
        if (unique == 0)
                return buf;