git: dd276946d561 - stable/14 - Merge mandoc snapshot 2024-09-22

From: Alexander Ziaee <ziaee_at_FreeBSD.org>
Date: Mon, 14 Jul 2025 16:47:15 UTC
The branch stable/14 has been updated by ziaee:

URL: https://cgit.FreeBSD.org/src/commit/?id=dd276946d56197947c47fa7a37255859aea6e942

commit dd276946d56197947c47fa7a37255859aea6e942
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2024-12-06 20:47:31 +0000
Commit:     Alexander Ziaee <ziaee@FreeBSD.org>
CommitDate: 2025-07-14 16:44:44 +0000

    Merge mandoc snapshot 2024-09-22
    
    (cherry picked from commit c1c95add8c80843ba15d784f95c361d795b1f593)
---
 contrib/mandoc/LICENSE                 |   5 +-
 contrib/mandoc/Makefile                |  13 +-
 contrib/mandoc/Makefile.depend         |  89 ++--
 contrib/mandoc/NEWS                    |   4 +-
 contrib/mandoc/TODO                    | 105 +++-
 contrib/mandoc/catman.c                |   4 +-
 contrib/mandoc/cgi.c                   | 121 +++--
 contrib/mandoc/chars.c                 |   5 +-
 contrib/mandoc/compat_strsep.c         |   4 +-
 contrib/mandoc/configure               |  13 +-
 contrib/mandoc/configure.local.example |  14 +-
 contrib/mandoc/dba_read.c              |   4 +-
 contrib/mandoc/demandoc.1              |   5 +-
 contrib/mandoc/demandoc.c              |  13 +-
 contrib/mandoc/eqn.c                   |  28 +-
 contrib/mandoc/eqn_parse.h             |   6 +-
 contrib/mandoc/html.c                  |  17 +-
 contrib/mandoc/html.h                  |   6 +-
 contrib/mandoc/main.c                  |  43 +-
 contrib/mandoc/makewhatis.8            |   8 +-
 contrib/mandoc/man.1                   |   8 +-
 contrib/mandoc/man.7                   |  34 +-
 contrib/mandoc/man.c                   |  43 +-
 contrib/mandoc/man.cgi.8               |  14 +-
 contrib/mandoc/man_html.c              | 112 +++--
 contrib/mandoc/man_macro.c             |  24 +-
 contrib/mandoc/man_term.c              | 108 +++--
 contrib/mandoc/man_validate.c          |  68 +--
 contrib/mandoc/mandoc.1                | 206 +++++---
 contrib/mandoc/mandoc.c                | 394 +--------------
 contrib/mandoc/mandoc.css              |  51 +-
 contrib/mandoc/mandoc.h                |  32 +-
 contrib/mandoc/mandoc_aux.c            |   5 +-
 contrib/mandoc/mandoc_aux.h            |   8 +-
 contrib/mandoc/mandoc_char.7           |  21 +-
 contrib/mandoc/mandoc_dbg.c            | 343 +++++++++++++
 contrib/mandoc/mandoc_dbg.h            |  55 +++
 contrib/mandoc/mandoc_dbg_init.3       | 280 +++++++++++
 contrib/mandoc/mandoc_escape.3         | 172 ++++---
 contrib/mandoc/mandoc_headers.3        |  37 +-
 contrib/mandoc/mandoc_html.3           |   8 +-
 contrib/mandoc/mandoc_msg.c            |  13 +-
 contrib/mandoc/mandocd.8               |   8 +-
 contrib/mandoc/mandocd.c               |  15 +-
 contrib/mandoc/mandocdb.c              |  75 ++-
 contrib/mandoc/manpath.c               |  87 ++--
 contrib/mandoc/mansearch.c             |   6 +-
 contrib/mandoc/mdoc.7                  |  75 +--
 contrib/mandoc/mdoc_html.c             |  81 ++--
 contrib/mandoc/mdoc_macro.c            |  12 +-
 contrib/mandoc/mdoc_man.c              |   4 +-
 contrib/mandoc/mdoc_markdown.c         |   6 +-
 contrib/mandoc/mdoc_state.c            |  53 +-
 contrib/mandoc/mdoc_term.c             |  29 +-
 contrib/mandoc/mdoc_validate.c         |  16 +-
 contrib/mandoc/out.c                   |  39 +-
 contrib/mandoc/out.h                   |   7 +-
 contrib/mandoc/read.c                  |   9 +-
 contrib/mandoc/roff.7                  |  43 +-
 contrib/mandoc/roff.c                  | 858 +++++++++++++++++----------------
 contrib/mandoc/roff.h                  |  27 +-
 contrib/mandoc/roff_escape.c           | 546 +++++++++++++++++++++
 contrib/mandoc/roff_int.h              |   5 +-
 contrib/mandoc/roff_term.c             |   4 +-
 contrib/mandoc/st.c                    |   5 +-
 contrib/mandoc/tag.c                   |  74 ++-
 contrib/mandoc/tbl.7                   |  12 +-
 contrib/mandoc/tbl_html.c              |  15 +-
 contrib/mandoc/tbl_term.c              |  23 +-
 contrib/mandoc/term.c                  | 137 ++++--
 contrib/mandoc/term.h                  |   7 +-
 contrib/mandoc/term_ascii.c            |   9 +-
 contrib/mandoc/term_tab.c              |  24 +-
 contrib/mandoc/tree.c                  |  14 +-
 usr.bin/mandoc/Makefile                |   2 +
 75 files changed, 3215 insertions(+), 1655 deletions(-)

diff --git a/contrib/mandoc/LICENSE b/contrib/mandoc/LICENSE
index 0a0fc1acd2ac..8b464f4e6aec 100644
--- a/contrib/mandoc/LICENSE
+++ b/contrib/mandoc/LICENSE
@@ -1,11 +1,11 @@
-$Id: LICENSE,v 1.22 2021/09/19 11:02:09 schwarze Exp $
+$Id: LICENSE,v 1.23 2022/06/25 12:44:25 schwarze Exp $
 
 With the exceptions noted below, all non-trivial files contained
 in the mandoc toolkit are protected by the Copyright of the following
 developers:
 
+Copyright (c) 2010-2022 Ingo Schwarze <schwarze@openbsd.org>
 Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
-Copyright (c) 2010-2021 Ingo Schwarze <schwarze@openbsd.org>
 Copyright (c) 1999, 2004, 2017 Marc Espie <espie@openbsd.org>
 Copyright (c) 2009, 2010, 2011, 2012 Joerg Sonnenberger <joerg@netbsd.org>
 Copyright (c) 2013 Franco Fichtner <franco@lastsummer.de>
@@ -13,6 +13,7 @@ Copyright (c) 2014 Baptiste Daroussin <bapt@freebsd.org>
 Copyright (c) 2016 Ed Maste <emaste@freebsd.org>
 Copyright (c) 2017 Michael Stapelberg <stapelberg@debian.org>
 Copyright (c) 2017 Anthony Bentley <bentley@openbsd.org>
+Copyright (c) 2022 Anna Vyalkova <cyber@sysrq.in>
 Copyright (c) 1998, 2004, 2010, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
 Copyright (c) 2008, 2017 Otto Moerbeek <otto@drijf.net>
 Copyright (c) 2004 Ted Unangst <tedu@openbsd.org>
diff --git a/contrib/mandoc/Makefile b/contrib/mandoc/Makefile
index 48c4741812b6..cd3f16652069 100644
--- a/contrib/mandoc/Makefile
+++ b/contrib/mandoc/Makefile
@@ -1,6 +1,6 @@
-# $Id: Makefile,v 1.540 2021/09/21 11:04:40 schwarze Exp $
+# $Id: Makefile,v 1.543 2023/10/19 11:45:42 schwarze Exp $
 #
-# Copyright (c) 2011, 2013-2021 Ingo Schwarze <schwarze@openbsd.org>
+# Copyright (c) 2011, 2013-2022 Ingo Schwarze <schwarze@openbsd.org>
 # Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
 #
 # Permission to use, copy, modify, and distribute this software for any
@@ -100,6 +100,7 @@ SRCS		 = arch.c \
 		   man_validate.c \
 		   mandoc.c \
 		   mandoc_aux.c \
+		   mandoc_dbg.c \
 		   mandoc_msg.c \
 		   mandoc_ohash.c \
 		   mandoc_xr.c \
@@ -121,6 +122,7 @@ SRCS		 = arch.c \
 		   preconv.c \
 		   read.c \
 		   roff.c \
+		   roff_escape.c \
 		   roff_html.c \
 		   roff_term.c \
 		   roff_validate.c \
@@ -186,6 +188,8 @@ DISTFILES	 = INSTALL \
 		   mandoc.h \
 		   mandoc_aux.h \
 		   mandoc_char.7 \
+		   mandoc_dbg.h \
+		   mandoc_dbg_init.3 \
 		   mandoc_escape.3 \
 		   mandoc_headers.3 \
 		   mandoc_html.3 \
@@ -232,6 +236,7 @@ LIBMDOC_OBJS	 = att.o \
 
 LIBROFF_OBJS	 = eqn.o \
 		   roff.o \
+		   roff_escape.o \
 		   roff_validate.o \
 		   tbl.o \
 		   tbl_data.o \
@@ -241,6 +246,7 @@ LIBROFF_OBJS	 = eqn.o \
 LIBMANDOC_OBJS	 = $(LIBMAN_OBJS) \
 		   $(LIBMDOC_OBJS) \
 		   $(LIBROFF_OBJS) \
+		   $(DEBUG_OBJS) \
 		   arch.o \
 		   chars.o \
 		   mandoc.o \
@@ -333,6 +339,7 @@ WWW_MANS	 = apropos.1.html \
 		   soelim.1.html \
 		   man.cgi.3.html \
 		   mandoc.3.html \
+		   mandoc_dbg_init.3.html \
 		   mandoc_escape.3.html \
 		   mandoc_headers.3.html \
 		   mandoc_html.3.html \
@@ -409,6 +416,7 @@ base-install: mandoc demandoc soelim
 	mkdir -p $(DESTDIR)$(MANDIR)/man5
 	mkdir -p $(DESTDIR)$(MANDIR)/man7
 	mkdir -p $(DESTDIR)$(MANDIR)/man8
+	mkdir -p $(DESTDIR)$(MISCDIR)
 	$(INSTALL_PROGRAM) mandoc demandoc $(DESTDIR)$(BINDIR)
 	$(INSTALL_PROGRAM) soelim $(DESTDIR)$(BINDIR)/$(BINM_SOELIM)
 	cd $(DESTDIR)$(BINDIR) && $(LN) mandoc $(BINM_MAN)
@@ -431,6 +439,7 @@ base-install: mandoc demandoc soelim
 	$(INSTALL_MAN) mandoc_char.7 $(DESTDIR)$(MANDIR)/man7
 	$(INSTALL_MAN) makewhatis.8 \
 		$(DESTDIR)$(MANDIR)/man8/$(BINM_MAKEWHATIS).8
+	$(INSTALL_DATA) mandoc.css $(DESTDIR)$(MISCDIR)
 
 lib-install: libmandoc.a
 	mkdir -p $(DESTDIR)$(LIBDIR)
diff --git a/contrib/mandoc/Makefile.depend b/contrib/mandoc/Makefile.depend
index d5f6556c3e7e..5179e95d4715 100644
--- a/contrib/mandoc/Makefile.depend
+++ b/contrib/mandoc/Makefile.depend
@@ -1,8 +1,8 @@
 arch.o: arch.c config.h roff.h
 att.o: att.c config.h roff.h libmdoc.h
 catman.o: catman.c config.h compat_fts.h
-cgi.o: cgi.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h main.h manconf.h mansearch.h cgi.h
-chars.o: chars.c config.h mandoc.h mandoc_aux.h mandoc_ohash.h compat_ohash.h libmandoc.h
+cgi.o: cgi.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h main.h manconf.h mansearch.h cgi.h
+chars.o: chars.c config.h mandoc.h mandoc_aux.h mandoc_dbg.h mandoc_ohash.h compat_ohash.h libmandoc.h
 compat_err.o: compat_err.c config.h
 compat_fts.o: compat_fts.c config.h compat_fts.h
 compat_getline.o: compat_getline.c config.h
@@ -22,62 +22,63 @@ compat_strndup.o: compat_strndup.c config.h
 compat_strsep.o: compat_strsep.c config.h
 compat_strtonum.o: compat_strtonum.c config.h
 compat_vasprintf.o: compat_vasprintf.c config.h
-dba.o: dba.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mansearch.h dba_write.h dba_array.h dba.h
-dba_array.o: dba_array.c config.h mandoc_aux.h dba_write.h dba_array.h
-dba_read.o: dba_read.c config.h mandoc_aux.h mansearch.h dba_array.h dba.h dbm.h
+dba.o: dba.c config.h mandoc_aux.h mandoc_dbg.h mandoc_ohash.h compat_ohash.h mansearch.h dba_write.h dba_array.h dba.h
+dba_array.o: dba_array.c config.h mandoc_aux.h mandoc_dbg.h dba_write.h dba_array.h
+dba_read.o: dba_read.c config.h mandoc_aux.h mandoc_dbg.h mansearch.h dba_array.h dba.h dbm.h
 dba_write.o: dba_write.c config.h dba_write.h
 dbm.o: dbm.c config.h mansearch.h dbm_map.h dbm.h
 dbm_map.o: dbm_map.c config.h mansearch.h dbm_map.h dbm.h
-demandoc.o: demandoc.c config.h mandoc.h roff.h man.h mdoc.h mandoc_parse.h
-eqn.o: eqn.c config.h mandoc_aux.h mandoc.h roff.h eqn.h libmandoc.h eqn_parse.h
+demandoc.o: demandoc.c config.h mandoc.h mandoc_dbg.h roff.h man.h mdoc.h mandoc_parse.h
+eqn.o: eqn.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h roff.h eqn.h libmandoc.h eqn_parse.h
 eqn_html.o: eqn_html.c config.h mandoc.h roff.h eqn.h out.h html.h
 eqn_term.o: eqn_term.c config.h eqn.h out.h term.h
-html.o: html.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h out.h html.h manconf.h main.h
+html.o: html.c config.h mandoc_aux.h mandoc_dbg.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h out.h html.h manconf.h main.h
 lib.o: lib.c config.h roff.h libmdoc.h lib.in
-main.o: main.c config.h mandoc_aux.h mandoc.h mandoc_xr.h roff.h mdoc.h man.h mandoc_parse.h tag.h term_tag.h main.h manconf.h mansearch.h
-man.o: man.c config.h mandoc_aux.h mandoc.h roff.h man.h libmandoc.h roff_int.h libman.h
-man_html.o: man_html.c config.h mandoc_aux.h mandoc.h roff.h man.h out.h html.h main.h
-man_macro.o: man_macro.c config.h mandoc.h roff.h man.h libmandoc.h roff_int.h libman.h
-man_term.o: man_term.c config.h mandoc_aux.h mandoc.h roff.h man.h out.h term.h term_tag.h main.h
-man_validate.o: man_validate.c config.h mandoc_aux.h mandoc.h roff.h man.h libmandoc.h roff_int.h libman.h tag.h
-mandoc.o: mandoc.c config.h mandoc_aux.h mandoc.h roff.h libmandoc.h roff_int.h
-mandoc_aux.o: mandoc_aux.c config.h mandoc.h mandoc_aux.h
+main.o: main.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h mandoc_xr.h roff.h mdoc.h man.h mandoc_parse.h tag.h term_tag.h main.h manconf.h mansearch.h
+man.o: man.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h roff.h man.h libmandoc.h roff_int.h libman.h
+man_html.o: man_html.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h roff.h man.h out.h html.h main.h
+man_macro.o: man_macro.c config.h mandoc_dbg.h mandoc.h roff.h man.h libmandoc.h roff_int.h libman.h
+man_term.o: man_term.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h roff.h man.h out.h term.h term_tag.h main.h
+man_validate.o: man_validate.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h roff.h man.h libmandoc.h roff_int.h libman.h tag.h
+mandoc.o: mandoc.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h roff.h libmandoc.h roff_int.h
+mandoc_aux.o: mandoc_aux.c config.h mandoc.h mandoc_aux.h mandoc_dbg.h
+mandoc_dbg.o: mandoc_dbg.c config.h compat_ohash.h mandoc_aux.h mandoc_dbg.h mandoc.h
 mandoc_msg.o: mandoc_msg.c config.h mandoc.h
-mandoc_ohash.o: mandoc_ohash.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h
-mandoc_xr.o: mandoc_xr.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc_xr.h
-mandocd.o: mandocd.c config.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h main.h manconf.h
-mandocdb.o: mandocdb.c config.h compat_fts.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h manconf.h mansearch.h dba_array.h dba.h
-manpath.o: manpath.c config.h mandoc_aux.h mandoc.h manconf.h
-mansearch.o: mansearch.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h manconf.h mansearch.h dbm.h
-mdoc.o: mdoc.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h
-mdoc_argv.o: mdoc_argv.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h
-mdoc_html.o: mdoc_html.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h out.h html.h main.h
-mdoc_macro.o: mdoc_macro.c config.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h
-mdoc_man.o: mdoc_man.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h out.h main.h
-mdoc_markdown.o: mdoc_markdown.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h main.h
-mdoc_state.o: mdoc_state.c config.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h
-mdoc_term.o: mdoc_term.c config.h mandoc_aux.h roff.h mdoc.h out.h term.h term_tag.h main.h
-mdoc_validate.o: mdoc_validate.c config.h mandoc_aux.h mandoc.h mandoc_xr.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h tag.h
+mandoc_ohash.o: mandoc_ohash.c config.h mandoc_aux.h mandoc_dbg.h mandoc_ohash.h compat_ohash.h
+mandoc_xr.o: mandoc_xr.c config.h mandoc_aux.h mandoc_dbg.h mandoc_ohash.h compat_ohash.h mandoc_xr.h
+mandocd.o: mandocd.c config.h mandoc.h mandoc_dbg.h roff.h mdoc.h man.h mandoc_parse.h main.h manconf.h
+mandocdb.o: mandocdb.c config.h compat_fts.h mandoc_aux.h mandoc_dbg.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h manconf.h mansearch.h dba_array.h dba.h
+manpath.o: manpath.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h manconf.h
+mansearch.o: mansearch.c config.h mandoc_aux.h mandoc_dbg.h mandoc_ohash.h compat_ohash.h manconf.h mansearch.h dbm.h
+mdoc.o: mdoc.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h
+mdoc_argv.o: mdoc_argv.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h
+mdoc_html.o: mdoc_html.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h roff.h mdoc.h out.h html.h main.h
+mdoc_macro.o: mdoc_macro.c config.h mandoc_dbg.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h
+mdoc_man.o: mdoc_man.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h roff.h mdoc.h man.h out.h main.h
+mdoc_markdown.o: mdoc_markdown.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h roff.h mdoc.h main.h
+mdoc_state.o: mdoc_state.c config.h mandoc_dbg.h mandoc.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h
+mdoc_term.o: mdoc_term.c config.h mandoc_aux.h mandoc_dbg.h roff.h mdoc.h out.h term.h term_tag.h main.h
+mdoc_validate.o: mdoc_validate.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h mandoc_xr.h roff.h mdoc.h libmandoc.h roff_int.h libmdoc.h tag.h
 msec.o: msec.c config.h mandoc.h libmandoc.h msec.in
-out.o: out.c config.h mandoc_aux.h mandoc.h tbl.h out.h
+out.o: out.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h tbl.h out.h
 preconv.o: preconv.c config.h mandoc.h roff.h mandoc_parse.h libmandoc.h
-read.o: read.c config.h mandoc_aux.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h libmandoc.h roff_int.h tag.h
-roff.o: roff.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h mandoc_parse.h libmandoc.h roff_int.h tbl_parse.h eqn_parse.h predefs.in
+read.o: read.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h roff.h mdoc.h man.h mandoc_parse.h libmandoc.h roff_int.h tag.h
+roff.o: roff.c config.h mandoc_aux.h mandoc_dbg.h mandoc_ohash.h compat_ohash.h mandoc.h roff.h mandoc_parse.h libmandoc.h roff_int.h tbl_parse.h eqn_parse.h predefs.in
 roff_html.o: roff_html.c config.h mandoc.h roff.h out.h html.h
 roff_term.o: roff_term.c config.h mandoc.h roff.h out.h term.h
 roff_validate.o: roff_validate.c config.h mandoc.h roff.h libmandoc.h roff_int.h
 soelim.o: soelim.c config.h compat_stringlist.h
 st.o: st.c config.h mandoc.h roff.h libmdoc.h
-tag.o: tag.c config.h mandoc_aux.h mandoc_ohash.h compat_ohash.h roff.h mdoc.h roff_int.h tag.h
-tbl.o: tbl.c config.h mandoc_aux.h mandoc.h tbl.h libmandoc.h tbl_parse.h tbl_int.h
-tbl_data.o: tbl_data.c config.h mandoc_aux.h mandoc.h tbl.h libmandoc.h tbl_int.h
-tbl_html.o: tbl_html.c config.h mandoc.h roff.h tbl.h out.h html.h
-tbl_layout.o: tbl_layout.c config.h mandoc_aux.h mandoc.h tbl.h libmandoc.h tbl_int.h
+tag.o: tag.c config.h mandoc_aux.h mandoc_dbg.h mandoc_ohash.h compat_ohash.h roff.h mdoc.h roff_int.h tag.h
+tbl.o: tbl.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h tbl.h libmandoc.h tbl_parse.h tbl_int.h
+tbl_data.o: tbl_data.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h tbl.h libmandoc.h tbl_int.h
+tbl_html.o: tbl_html.c config.h mandoc_dbg.h mandoc.h roff.h tbl.h out.h html.h
+tbl_layout.o: tbl_layout.c config.h mandoc_aux.h mandoc_dbg.h mandoc.h tbl.h libmandoc.h tbl_int.h
 tbl_opts.o: tbl_opts.c config.h mandoc.h tbl.h libmandoc.h tbl_int.h
-tbl_term.o: tbl_term.c config.h mandoc.h tbl.h out.h term.h
-term.o: term.c config.h mandoc.h mandoc_aux.h out.h term.h main.h
-term_ascii.o: term_ascii.c config.h mandoc.h mandoc_aux.h out.h term.h manconf.h main.h
-term_ps.o: term_ps.c config.h mandoc_aux.h out.h term.h manconf.h main.h
-term_tab.o: term_tab.c config.h mandoc_aux.h out.h term.h
+tbl_term.o: tbl_term.c config.h mandoc_dbg.h mandoc.h tbl.h out.h term.h
+term.o: term.c config.h mandoc.h mandoc_aux.h mandoc_dbg.h out.h term.h main.h
+term_ascii.o: term_ascii.c config.h mandoc.h mandoc_aux.h mandoc_dbg.h out.h term.h manconf.h main.h
+term_ps.o: term_ps.c config.h mandoc_aux.h mandoc_dbg.h out.h term.h manconf.h main.h
+term_tab.o: term_tab.c config.h mandoc_aux.h mandoc_dbg.h out.h term.h
 term_tag.o: term_tag.c config.h mandoc.h roff.h roff_int.h tag.h term_tag.h
 tree.o: tree.c config.h mandoc.h roff.h mdoc.h man.h tbl.h eqn.h main.h
diff --git a/contrib/mandoc/NEWS b/contrib/mandoc/NEWS
index 634ffaf6ccfa..fdec026e9fec 100644
--- a/contrib/mandoc/NEWS
+++ b/contrib/mandoc/NEWS
@@ -1,4 +1,4 @@
-$Id: NEWS,v 1.40 2021/09/23 18:03:00 schwarze Exp $
+$Id: NEWS,v 1.41 2021/09/25 15:42:08 schwarze Exp $
 
 This file lists the most important changes in the mandoc.bsd.lv distribution.
 
@@ -195,7 +195,7 @@ Changes in version 1.14.6, released on September 23, 2021
    for an additional regression test
  * Michal Nowak for reporting several code style issues
  * TJ Townsend (OpenBSD) for help with CSS
- * Sevan Janiyan (NetBSD) and Robert Mustacchi (Illumos) 
+ * Sevan Janiyan (Viewpoint Linux) and Robert Mustacchi (Illumos) 
    for extensive release testing
  * Job Snijders, Kinichiro INOGUCHI, and Martijn van Duren (OpenBSD)
    for checking patches
diff --git a/contrib/mandoc/TODO b/contrib/mandoc/TODO
index 4135a3eca6c8..58d0d6937746 100644
--- a/contrib/mandoc/TODO
+++ b/contrib/mandoc/TODO
@@ -1,6 +1,6 @@
 ************************************************************************
 * Official mandoc TODO.
-* $Id: TODO,v 1.319 2021/09/21 17:58:13 schwarze Exp $
+* $Id: TODO,v 1.335 2024/09/21 12:08:54 schwarze Exp $
 ************************************************************************
 
 Many issues are annotated for difficulty as follows:
@@ -68,6 +68,14 @@ are mere guesses, and some may be wrong.
   but watch out for regressions in the high-level parsers
   maybe it should not even remove comments? - consider T{\"
 
+- In the body of conditional requests, escape sequence expansion
+  must not be performed if the condition is false.  This implies
+  the first part of a request line must be expanded before
+  request parsing (like it is now), but expansion in the second
+  part must be delayed.
+  to Nab 8 Aug 2023 20:05:32 +0200 Subject: if/ie d condition always true
+  loc **  exist ***  algo ***  size **  imp *
+
 
 ************************************************************************
 * missing features
@@ -149,6 +157,11 @@ are mere guesses, and some may be wrong.
 
 --- missing mdoc features ----------------------------------------------
 
+- support mixed case for section names
+  also, first section is not "NAME" should not appear more than once per page
+  Alejandro Colomar 28 Apr 2023 16:57:49 +0200
+  loc * exist * algo * size * imp ***
+
 - .Sh and .Ss should be parsed and partially callable, see groff_mdoc(7)
   reed at reedmedia dot net Sat, 21 Dec 2019 17:13:07 -0600
   loc **  exist **  algo **  size **  imp *
@@ -292,7 +305,11 @@ are mere guesses, and some may be wrong.
 
 --- missing misc features ----------------------------------------------
 
-- conisder whether man(1) fallback code in main.c/fs_*() can find files
+- use the default volume headers for sections with suffixes
+  certainly affects man(7); possibly mdoc(7)?; and also groff(1)
+  Alejandro Colomar 21 Aug 2022
+
+- consider whether man(1) fallback code in main.c/fs_*() can find files
   like man3c/fopen.3c (illumos, Solaris) and man3p/fopen.3p (POSIX)
   discussed with Robert Mustacchi 21 Sep 2021 10:39:40 -0700
   loc *  exist *  algo **  size *  imp **
@@ -302,6 +319,11 @@ are mere guesses, and some may be wrong.
   mail to sternenseemann 19 Aug 2021 19:11:50 +0200
   loc *  exist **  algo **  size *  imp **
 
+- handle Unicode letters in tags in both HTML and terminal output
+  thread "section headers with diacritics" starting with
+  Mario Blaettermann 24 Mar 2022 18:13:23 +0100
+  loc **  exist *  algo *  size *  imp **
+
 - -T man does not handle eqn(7) and tbl(7)
   Stephen Gregoratto 16 Feb 2020 01:28:07 +1100
   also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=901636
@@ -325,6 +347,10 @@ are mere guesses, and some may be wrong.
   (3) undefined, just output the character -> perhaps WARNING
   loc ***  exist **  algo **  size **  imp *** (parser reorg helps)
 
+- man.conf(5) alias aliasname dirname or just -Mb -Mx -Mp
+  mail to jmc@ Mar 23, 2015 03:53:14PM +0100
+  loc *  exist *  algo *  size *  imp **
+
 - kettenis wants base roff, ms, and me  Fri, 1 Jan 2010 22:13:15 +0100 (CET)
   loc **  exist **  algo **  size ***  imp *
 
@@ -443,6 +469,10 @@ are mere guesses, and some may be wrong.
   reminded by jmc@  Thu, 23 Sep 2010 18:13:39 +0059
   loc *  exist **  algo ***  size *  imp ***
 
+- the man(7) single-font macros (e.g. .B) use .itc,
+  so ".B foo\c" followed by "bar" prints "bar" in bold
+  gbranden@ Sun, 5 Jun 2022 18:08:46 -0500
+
 - a line starting with "\fB something" counts as starting with whitespace
   and triggers a line break; found in audio/normalize-mp3(1)
   This will become easier once escape sequences are represented
@@ -468,20 +498,46 @@ are mere guesses, and some may be wrong.
 
 --- HTML issues --------------------------------------------------------
 
-- make the HTML scaffolding customozable with -O skip=...
+- support the idiom .TP .IP .TP for multi-paragraph list item bodies
+  to: Alejandro Colomar Thu, 19 Oct 2023 16:45:21 +0200
+  loc **  exist **  algo **  size **  imp **
+
+- .Nm without an argument and .Bx cause premature </pre>
+  Nab Sun, 5 Jun 2022 18:30:09 +0200
+
+- .Aq Mt could set and reset "white-space: nowrap";
+  Check whether other enclosure macros could profit from similar handling,
+  or whether that is covered by Unicode line-breaking classes WJ, ZW, GL, ZWJ.
+  John Gardner 25 Mar 2022 04:44:27 +1100
+
+- make the HTML scaffolding customizable with -O skip=...
   mail to Oliver Corff  3 Jun 2021 17:28:02 +0200
   more feedback from Oliver  3 Jun 2021 18:27:56 +0200
   more feedback from Oliver  3 Jun 2021 23:37:18 +0200
+  would also be useful for
+  https://github.com/gbdev/rgbds-www/blob/master/
+  maintainer/support/man_postproc.awk
 
 - .Bd -unfilled should not use monospaced font
   anton@  4 Mar 2021 08:19:35 +0100
   loc **  exist *  algo *  size *  imp **
 
-- HTML formatting of .nf should avoid <br/>
+- HTML formatting of .nf should avoid <br/>,
+  even when input lines start with whitespace,
   and not close and re-open <pre> on .P
   my mail to ports@ 27 Jun 2021 16:09:20 +0200
+  reported again by Mohamed Akram 25 Jun 2022 16:28:18 +0000
   loc **  exist **  algo *  size *  imp **
 
+- tbl(7) HTML output does not implement column width specifications
+  reported by Ted Bullock 11 Jan 2022 16:00:44 -0700
+  loc *  exist *  algo ?  size ?  imp *
+
+- link from flags in the SYNOPSIS to their descriptions
+  https://github.com/gbdev/rgbds-www/blob/master/
+  maintainer/support/man_postproc.awk
+  loc *  exist *  algo **  size *  imp *
+
 - get rid of the last handful of style= attributes such that
   Content-Security-Policy: can be enabled without unsafe-inline
   suggested by bentley@  Nov 10, 2019 at 06:02:49AM -0700
@@ -504,19 +560,18 @@ are mere guesses, and some may be wrong.
   does this affect other characters, other source macros...?
   Jackson Pauls  29 Aug 2017 16:56:27 +0100
 
-- The tables used to render the three-part page headers actually force
-  the width of the <body> to the max-width given for <html>.
-  Not yet sure how to fix that...
-  Observed by an Anonymous Coward on undeadly.org:
-  http://undeadly.org/cgi?action=article&sid=20140925064244&pid=1
-  loc *  exist *  algo **  size *  imp ***
-
 - generate <img> tags in HTML
   idea from florian@  Tue, 7 Apr 2015 00:26:28 +0000
   may be possible to implement with .Lk img://something.png alt_text
 
 - check https://github.com/trentm/mdocml
 
+--- CSS issues ---------------------------------------------------------
+
+- use flexbox for .Bl-tag instead of the fragile float/clear mechanism
+  John Gardner 25 Mar 2022 04:44:27 +1100
+
+
 ************************************************************************
 * formatting issues: gratuitous differences
 ************************************************************************
@@ -527,7 +582,17 @@ are mere guesses, and some may be wrong.
   Steffen Nurpmeso  Sat, 08 Nov 2014 13:34:59 +0100
   loc *  exist **  algo **  size *  imp **
 
-- In .Bl -enum -width 0n, groff continues one the same line after
+- Multiple issues with .In below SYNOPSIS; groff behaviour is:
+  text line + .In -> no line break before #include
+  called .In -> no line break before angle bracket
+  .In + .In -> second one gets #include, too
+  two arguments -> line break before second
+  child macro -> line break before child
+  .In + text line -> line break before the text line
+  Evan Silberman  Fri, 20 Sep 2024 16:48:19 -0700
+  loc **  exist **  algo *  size *  imp *
+
+- In .Bl -enum -width 0n, groff continues on the same line after
   the number, mandoc breaks the line.
   mail to kristaps@  Mon, 20 Jul 2009 02:21:39 +0200
   loc *  exist **  algo **  size *  imp **
@@ -562,6 +627,10 @@ are mere guesses, and some may be wrong.
   reported again by Nicolas Joly Thu, 1 Mar 2012 13:41:26 +0100 via wiz@ 5 Mar
   reported again by Franco Fichtner Fri, 27 Sep 2013 21:02:28 +0200
   reported again by Bruce Evans Fri, 17 Feb 2017 21:22:44 +0100 via bapt@
+  https://reviews.freebsd.org/D35245
+  even groff_mdoc(7) uses this: Nab Sun, 5 Jun 2022 22:16:37 +0200
+  When implementing this, try to avoid breaking existing manuals,
+  or at least fix them: Jan Stary Sun, 5 Jun 2022 22:48:05 +0200
   loc ***  exist ***  algo ***  size **  imp ***
   An easy partial fix has been implemented as skip_leading_dot_word().
 
@@ -574,6 +643,10 @@ are mere guesses, and some may be wrong.
   with .ps and .nf/.fi produce execessive blank lines, see libJudy
   and graphics/dcmtk.  The parser reorg may help with this.
 
+- The man(7) .UR macro produces UTF-8 angle brackets in -Tutf8 output mode
+  with groff, but ASCII <> with mandoc
+  Alejandro Colomar Mon, 7 Aug 2023 17:13:29 +0200 Subject: hostname
+
 - trailing whitespace must be ignored even when followed by a font escape,
   see for example
     makes
@@ -590,6 +663,14 @@ are mere guesses, and some may be wrong.
   To: deraadt@ 25 Oct 2020 23:37:01 +0100
   loc **  exist *  algo *  size **  imp ***
 
+- warn about \\ and \. in interpretation mode
+  gbranden@, groff issue #62776, 10 Nov 2023 01:57:32 -0500
+
+- warn about output lines exceeding 80 characters
+  Alejandro Colomar Aug 22, 2022
+  not trivial because -T lint does not call any formatter
+  loc ***  exist *  algo **  size **  imp **
+
 - warn about duplicate .Sh/.Ss heads
   gre(4): Rename duplicate sections 20 Apr 2018 15:27:33 +0200
   loc *  exist *  algo *  size *  imp **
diff --git a/contrib/mandoc/catman.c b/contrib/mandoc/catman.c
index b1bab0f68c4b..e46613eb0e8c 100644
--- a/contrib/mandoc/catman.c
+++ b/contrib/mandoc/catman.c
@@ -1,4 +1,4 @@
-/*	$Id: catman.c,v 1.22 2020/06/14 23:40:31 schwarze Exp $ */
+/*	$Id: catman.c,v 1.23 2021/10/15 15:04:02 schwarze Exp $ */
 /*
  * Copyright (c) 2017 Michael Stapelberg <stapelberg@debian.org>
  * Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -62,7 +62,7 @@ run_mandocd(int sockfd, const char *outtype, const char* defos)
 	else
 		execlp("mandocd", "mandocd", "-T", outtype,
 		    "-I", defos, sockfdstr, (char *)NULL);
-	err(1, "exec");
+	err(1, "exec(mandocd)");
 }
 
 ssize_t
diff --git a/contrib/mandoc/cgi.c b/contrib/mandoc/cgi.c
index 91310ce404b4..57f3bb7a6e16 100644
--- a/contrib/mandoc/cgi.c
+++ b/contrib/mandoc/cgi.c
@@ -1,7 +1,8 @@
-/* $Id: cgi.c,v 1.175 2021/08/19 15:23:36 schwarze Exp $ */
+/* $Id: cgi.c,v 1.181 2023/04/28 19:11:03 schwarze Exp $ */
 /*
- * Copyright (c) 2014-2019, 2021 Ingo Schwarze <schwarze@usta.de>
+ * Copyright (c) 2014-2019, 2021, 2022 Ingo Schwarze <schwarze@usta.de>
  * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2022 Anna Vyalkova <cyber@sysrq.in>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -86,10 +87,10 @@ static	void		 pg_search(const struct req *);
 static	void		 pg_searchres(const struct req *,
 				struct manpage *, size_t);
 static	void		 pg_show(struct req *, const char *);
-static	void		 resp_begin_html(int, const char *, const char *);
+static	int		 resp_begin_html(int, const char *, const char *);
 static	void		 resp_begin_http(int, const char *);
 static	void		 resp_catman(const struct req *, const char *);
-static	void		 resp_copy(const char *);
+static	int		 resp_copy(const char *, const char *);
 static	void		 resp_end_html(void);
 static	void		 resp_format(const struct req *, const char *);
 static	void		 resp_searchform(const struct req *, enum focus);
@@ -352,22 +353,26 @@ resp_begin_http(int code, const char *msg)
 	fflush(stdout);
 }
 
-static void
-resp_copy(const char *filename)
+static int
+resp_copy(const char *element, const char *filename)
 {
 	char	 buf[4096];
 	ssize_t	 sz;
 	int	 fd;
 
-	if ((fd = open(filename, O_RDONLY)) != -1) {
-		fflush(stdout);
-		while ((sz = read(fd, buf, sizeof(buf))) > 0)
-			write(STDOUT_FILENO, buf, sz);
-		close(fd);
-	}
+	if ((fd = open(filename, O_RDONLY)) == -1)
+		return 0;
+
+	if (element != NULL)
+		printf("<%s>\n", element);
+	fflush(stdout);
+	while ((sz = read(fd, buf, sizeof(buf))) > 0)
+		write(STDOUT_FILENO, buf, sz);
+	close(fd);
+	return 1;
 }
 
-static void
+static int
 resp_begin_html(int code, const char *msg, const char *file)
 {
 	const char	*name, *sec, *cp;
@@ -413,14 +418,14 @@ resp_begin_html(int code, const char *msg, const char *file)
 	       "<body>\n",
 	       CUSTOMIZE_TITLE);
 
-	resp_copy(MAN_DIR "/header.html");
+	return resp_copy("header", MAN_DIR "/header.html");
 }
 
 static void
 resp_end_html(void)
 {
-
-	resp_copy(MAN_DIR "/footer.html");
+	if (resp_copy("footer", MAN_DIR "/footer.html"))
+		puts("</footer>");
 
 	puts("</body>\n"
 	     "</html>");
@@ -431,7 +436,7 @@ resp_searchform(const struct req *req, enum focus focus)
 {
 	int		 i;
 
-	printf("<form action=\"/%s\" method=\"get\" "
+	printf("<form role=\"search\" action=\"/%s\" method=\"get\" "
 	       "autocomplete=\"off\" autocapitalize=\"none\">\n"
 	       "  <fieldset>\n"
 	       "    <legend>Manual Page Search Parameters</legend>\n",
@@ -439,13 +444,14 @@ resp_searchform(const struct req *req, enum focus focus)
 
 	/* Write query input box. */
 
-	printf("    <input type=\"search\" name=\"query\" value=\"");
+	printf("    <label>Search query:\n"
+	       "      <input type=\"search\" name=\"query\" value=\"");
 	if (req->q.query != NULL)
 		html_print(req->q.query);
-	printf( "\" size=\"40\"");
+	printf("\" size=\"40\"");
 	if (focus == FOCUS_QUERY)
 		printf(" autofocus");
-	puts(">");
+	puts(">\n    </label>");
 
 	/* Write submission buttons. */
 
@@ -457,7 +463,7 @@ resp_searchform(const struct req *req, enum focus focus)
 
 	/* Write section selector. */
 
-	puts("    <select name=\"sec\">");
+	puts("    <select name=\"sec\" aria-label=\"Manual section\">");
 	for (i = 0; i < sec_MAX; i++) {
 		printf("      <option value=\"%s\"", sec_numbers[i]);
 		if (NULL != req->q.sec &&
@@ -469,7 +475,7 @@ resp_searchform(const struct req *req, enum focus focus)
 
 	/* Write architecture selector. */
 
-	printf(	"    <select name=\"arch\">\n"
+	printf(	"    <select name=\"arch\" aria-label=\"CPU architecture\">\n"
 		"      <option value=\"default\"");
 	if (NULL == req->q.arch)
 		printf(" selected=\"selected\"");
@@ -486,7 +492,8 @@ resp_searchform(const struct req *req, enum focus focus)
 	/* Write manpath selector. */
 
 	if (req->psz > 1) {
-		puts("    <select name=\"manpath\">");
+		puts("    <select name=\"manpath\""
+		     " aria-label=\"Manual path\">");
 		for (i = 0; i < (int)req->psz; i++) {
 			printf("      <option");
 			if (strcmp(req->q.manpath, req->p[i]) == 0)
@@ -554,16 +561,21 @@ validate_filename(const char *file)
 static void
 pg_index(const struct req *req)
 {
-
-	resp_begin_html(200, NULL, NULL);
+	if (resp_begin_html(200, NULL, NULL) == 0)
+		puts("<header>");
 	resp_searchform(req, FOCUS_QUERY);
-	printf("<p>\n"
+	printf("</header>\n"
+	       "<main>\n"
+	       "<p role=\"doc-notice\" aria-label=\"Usage\">\n"
 	       "This web interface is documented in the\n"
-	       "<a class=\"Xr\" href=\"/%s%sman.cgi.8\">man.cgi(8)</a>\n"
+	       "<a class=\"Xr\" href=\"/%s%sman.cgi.8\""
+	       " aria-label=\"man dot CGI, section 8\">man.cgi(8)</a>\n"
 	       "manual, and the\n"
-	       "<a class=\"Xr\" href=\"/%s%sapropos.1\">apropos(1)</a>\n"
+	       "<a class=\"Xr\" href=\"/%s%sapropos.1\""
+	       " aria-label=\"apropos, section 1\">apropos(1)</a>\n"
 	       "manual explains the query syntax.\n"
-	       "</p>\n",
+	       "</p>\n"
+	       "</main>\n",
 	       scriptname, *scriptname == '\0' ? "" : "/",
 	       scriptname, *scriptname == '\0' ? "" : "/");
 	resp_end_html();
@@ -573,33 +585,40 @@ static void
 pg_noresult(const struct req *req, int code, const char *http_msg,
     const char *user_msg)
 {
-	resp_begin_html(code, http_msg, NULL);
+	if (resp_begin_html(code, http_msg, NULL) == 0)
+		puts("<header>");
 	resp_searchform(req, FOCUS_QUERY);
-	puts("<p>");
+	puts("</header>");
+	puts("<main>");
+	puts("<p role=\"doc-notice\" aria-label=\"No result\">");
 	puts(user_msg);
 	puts("</p>");
+	puts("</main>");
 	resp_end_html();
 }
 
 static void
 pg_error_badrequest(const char *msg)
 {
-
-	resp_begin_html(400, "Bad Request", NULL);
-	puts("<h1>Bad Request</h1>\n"
-	     "<p>\n");
+	if (resp_begin_html(400, "Bad Request", NULL))
+		puts("</header>");
+	puts("<main>\n"
+	     "<h1>Bad Request</h1>\n"
+	     "<p role=\"doc-notice\" aria-label=\"Bad Request\">");
 	puts(msg);
 	printf("Try again from the\n"
 	       "<a href=\"/%s\">main page</a>.\n"
-	       "</p>", scriptname);
+	       "</p>\n"
+	       "</main>\n", scriptname);
 	resp_end_html();
 }
 
 static void
 pg_error_internal(void)
 {
-	resp_begin_html(500, "Internal Server Error", NULL);
-	puts("<p>Internal Server Error</p>");
+	if (resp_begin_html(500, "Internal Server Error", NULL))
+		puts("</header>");
+	puts("<main><p role=\"doc-notice\">Internal Server Error</p></main>");
 	resp_end_html();
 }
 
@@ -630,6 +649,7 @@ pg_searchres(const struct req *req, struct manpage *r, size_t sz)
 	size_t		 i, iuse;
 	int		 archprio, archpriouse;
 	int		 prio, priouse;
+	int		 have_header;
 
 	for (i = 0; i < sz; i++) {
 		if (validate_filename(r[i].file))
@@ -696,14 +716,18 @@ pg_searchres(const struct req *req, struct manpage *r, size_t sz)
 			priouse = prio;
 			iuse = i;
 		}
-		resp_begin_html(200, NULL, r[iuse].file);
+		have_header = resp_begin_html(200, NULL, r[iuse].file);
 	} else
-		resp_begin_html(200, NULL, NULL);
+		have_header = resp_begin_html(200, NULL, NULL);
 
+	if (have_header == 0)
+		puts("<header>");
 	resp_searchform(req,
 	    req->q.equal || sz == 1 ? FOCUS_NONE : FOCUS_QUERY);
+	puts("</header>");
 
 	if (sz > 1) {
+		puts("<nav>");
 		puts("<table class=\"results\">");
 		for (i = 0; i < sz; i++) {
 			printf("  <tr>\n"
@@ -722,6 +746,7 @@ pg_searchres(const struct req *req, struct manpage *r, size_t sz)
 			     "  </tr>");
 		}
 		puts("</table>");
+		puts("</nav>");
 	}
 
 	if (req->q.equal || sz == 1) {
@@ -743,7 +768,9 @@ resp_catman(const struct req *req, const char *file)
 	int		 italic, bold;
 
 	if ((f = fopen(file, "r")) == NULL) {
-		puts("<p>You specified an invalid manual file.</p>");
+		puts("<p role=\"doc-notice\">\n"
+		     "  You specified an invalid manual file.\n"
+		     "</p>");
 		return;
 	}
 
@@ -879,8 +906,10 @@ resp_format(const struct req *req, const char *file)
 	int		 fd;
 	int		 usepath;
 
-	if (-1 == (fd = open(file, O_RDONLY, 0))) {
-		puts("<p>You specified an invalid manual file.</p>");
+	if (-1 == (fd = open(file, O_RDONLY))) {
+		puts("<p role=\"doc-notice\">\n"
+		     "  You specified an invalid manual file.\n"
+		     "</p>");
 		return;
 	}
 
@@ -966,8 +995,10 @@ pg_show(struct req *req, const char *fullpath)
 		return;
 	}
 
-	resp_begin_html(200, NULL, file);
+	if (resp_begin_html(200, NULL, file) == 0)
+		puts("<header>");
 	resp_searchform(req, FOCUS_NONE);
+	puts("</header>");
 	resp_show(req, file);
 	resp_end_html();
 }
@@ -1066,7 +1097,7 @@ main(void)
 #if HAVE_PLEDGE
 	/*
 	 * The "rpath" pledge could be revoked after mparse_readfd()
-	 * if the file desciptor to "/footer.html" would be opened
+	 * if the file descriptor to "/footer.html" would be opened
 	 * up front, but it's probably not worth the complication
 	 * of the code it would cause: it would require scattering
 	 * pledge() calls in multiple low-level resp_*() functions.
diff --git a/contrib/mandoc/chars.c b/contrib/mandoc/chars.c
index d54fc458aea2..72fe8df67e83 100644
--- a/contrib/mandoc/chars.c
+++ b/contrib/mandoc/chars.c
@@ -1,4 +1,4 @@
-/*	$Id: chars.c,v 1.79 2020/02/13 16:18:29 schwarze Exp $ */
+/* $Id: chars.c,v 1.81 2022/06/26 20:33:43 schwarze Exp $ */
 /*
  * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2011, 2014, 2015, 2017, 2018, 2020
@@ -92,7 +92,6 @@ static struct ln lines[] = {
 	{ "en",			"-",		0x2013	},
 	{ "hy",			"-",		0x2010	},
 	{ "e",			"\\",		0x005c	},
-	{ ".",			".",		0x002e	},
 	{ "r!",			"!",		0x00a1	},
 	{ "r?",			"?",		0x00bf	},
 
@@ -365,7 +364,7 @@ static struct ln lines[] = {
 	{ "de",			"<degree>",	0x00b0	},
 	{ "%0",			"<permille>",	0x2030	},
 	{ "fm",			"\'",		0x2032	},
-	{ "sd",			"''",		0x2033	},
+	{ "sd",			"\"",		0x2033	},
 	{ "mc",			"<micro>",	0x00b5	},
 	{ "Of",			"_\ba",		0x00aa	},
 	{ "Om",			"_\bo",		0x00ba	},
diff --git a/contrib/mandoc/compat_strsep.c b/contrib/mandoc/compat_strsep.c
index 9765ac823eeb..29865ba4a468 100644
--- a/contrib/mandoc/compat_strsep.c
+++ b/contrib/mandoc/compat_strsep.c
@@ -1,4 +1,4 @@
-/*	$Id: compat_strsep.c,v 1.5 2020/06/15 01:37:15 schwarze Exp $	*/
+/*	$Id: compat_strsep.c,v 1.6 2022/06/21 10:34:14 schwarze Exp $	*/
 /*	$OpenBSD: strsep.c,v 1.8 2015/08/31 02:53:57 guenther Exp $	*/
 
 /*-
@@ -31,6 +31,8 @@
  */
 #include "config.h"
 
+#include <stddef.h>
+
 /*
  * Get next token from string *stringp, where tokens are possibly-empty
  * strings separated by characters from delim.  
diff --git a/contrib/mandoc/configure b/contrib/mandoc/configure
index 5cf4e081c2cb..7f5fa1976806 100755
--- a/contrib/mandoc/configure
+++ b/contrib/mandoc/configure
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $Id: configure,v 1.81 2021/09/20 10:19:51 schwarze Exp $
+# $Id: configure,v 1.83 2023/10/19 11:45:42 schwarze Exp $
 #
 # Copyright (c) 2014-2021 Ingo Schwarze <schwarze@openbsd.org>
 #
@@ -37,6 +37,7 @@ SOURCEDIR=`dirname "${0}"`
 
 MANPATH_BASE="/usr/share/man:/usr/X11R6/man"
 MANPATH_DEFAULT="/usr/share/man:/usr/X11R6/man:/usr/local/man"
+DEBUG_MEMORY=0
 OSENUM=
 OSNAME=
 UTF8_LOCALE=
@@ -99,6 +100,7 @@ NEED_GNU_SOURCE=0
 NEED_OPENBSD_SOURCE=0
 NEED_XPG4_2=0
 
+DEBUG_OBJS=
 MANDOC_COBJS=
 SOELIM_COBJS=
 
@@ -109,6 +111,7 @@ BIN_FROM_SBIN=
 INCLUDEDIR=
 LIBDIR=
 MANDIR=
+MISCDIR=
 READ_ALLOWED_PATH=
 
 WWWPREFIX="/var/www"
@@ -334,6 +337,7 @@ runtest vasprintf	VASPRINTF	"" -D_GNU_SOURCE || true
 
 # --- fts ---
 if [ "${1}" = "-depend" ]; then
+	DEBUG_MEMORY=1
 	HAVE_FTS=0
 	HAVE_FTS_COMPARE_CONST=0
 	echo "tested fts: HAVE_FTS=0 (for make depend)" 1>&2
@@ -461,6 +465,10 @@ echo
 echo "#define MAN_CONF_FILE \"/etc/${MANM_MANCONF}\""
 echo "#define MANPATH_BASE \"${MANPATH_BASE}\""
 echo "#define MANPATH_DEFAULT \"${MANPATH_DEFAULT}\""
+if [ ${DEBUG_MEMORY} -ne 0 ]; then
+	echo "#define DEBUG_MEMORY ${DEBUG_MEMORY}"
+	DEBUG_OBJS=mandoc_dbg.o
+fi
 echo "#define OSENUM ${OSENUM}"
 [ -n "${OSNAME}" ] && echo "#define OSNAME \"${OSNAME}\""
 [ -n "${UTF8_LOCALE}" ] && echo "#define UTF8_LOCALE \"${UTF8_LOCALE}\""
@@ -613,6 +621,7 @@ exec > Makefile.local
 [ -z "${INCLUDEDIR}"      ] && INCLUDEDIR="${PREFIX}/include/mandoc"
 [ -z "${LIBDIR}"          ] && LIBDIR="${PREFIX}/lib/mandoc"
 [ -z "${MANDIR}"          ] && MANDIR="${PREFIX}/man"
+[ -z "${MISCDIR}"         ] && MISCDIR="${PREFIX}/share/misc"
 
 [ -z "${HTDOCDIR}"        ] && HTDOCDIR="${WWWPREFIX}/htdocs"
 [ -z "${CGIBINDIR}"       ] && CGIBINDIR="${WWWPREFIX}/cgi-bin"
@@ -640,6 +649,7 @@ CC		= ${CC}
 CFLAGS		= ${CFLAGS}
 LDADD		= ${LDADD}
 LDFLAGS		= ${LDFLAGS}
+DEBUG_OBJS	= ${DEBUG_OBJS}
 MANDOC_COBJS	= ${MANDOC_COBJS}
 SOELIM_COBJS	= ${SOELIM_COBJS}
 STATIC		= ${STATIC}
@@ -650,6 +660,7 @@ BIN_FROM_SBIN	= ${BIN_FROM_SBIN}
*** 7903 LINES SKIPPED ***