From 68aec08431c8f04e11b3a4933b1dd0fba2592abd Mon Sep 17 00:00:00 2001
From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
Date: Sun, 6 Feb 2022 18:22:11 -0600
Subject: system/mandoc: Update to 1.14.6, miss Max terribly

---
 system/mandoc/APKBUILD                   | 18 ++++------
 system/mandoc/cgi-adelie.patch           | 14 ++++----
 system/mandoc/cgi-search.patch           |  2 +-
 system/mandoc/configure.patch            | 11 ------
 system/mandoc/doc.patch                  | 16 ++++-----
 system/mandoc/empty-tbl-null-deref.patch | 62 --------------------------------
 system/mandoc/less.patch                 | 27 ++++----------
 system/mandoc/tbl-colwidth-oob.patch     | 62 --------------------------------
 8 files changed, 31 insertions(+), 181 deletions(-)
 delete mode 100644 system/mandoc/empty-tbl-null-deref.patch
 delete mode 100644 system/mandoc/tbl-colwidth-oob.patch

diff --git a/system/mandoc/APKBUILD b/system/mandoc/APKBUILD
index b3a4c018c..870e3d3be 100644
--- a/system/mandoc/APKBUILD
+++ b/system/mandoc/APKBUILD
@@ -1,6 +1,6 @@
 # Maintainer: Max Rees <maxcrees@me.com>
 pkgname=mandoc
-pkgver=1.14.5
+pkgver=1.14.6
 pkgrel=0
 pkgdesc="Manual page database, compiler, and viewer"
 url="https://mandoc.bsd.lv/"
@@ -15,8 +15,6 @@ install="$pkgname.post-deinstall"
 triggers="$pkgname.trigger=/usr/share/man"
 source="https://mandoc.bsd.lv/snapshots/mandoc-$pkgver.tar.gz
 	configure.patch
-	empty-tbl-null-deref.patch
-	tbl-colwidth-oob.patch
 	less.patch
 	doc.patch
 	cgi-adelie.patch
@@ -83,12 +81,10 @@ cgi() {
 		"$subpkgdir"/var/lib
 }
 
-sha512sums="848f290847f3095757f25647e6d73eb7044018b145bf6f9dc8b5db164b1421911efdc5b3b9022ec3a2c5af9687a84d5acedee810f2bd2f7caaa9242dadb2cc52  mandoc-1.14.5.tar.gz
-074dc73b45c71b5c178750db6c7a4a45e97d97b5388fa5d6028faa90600358dd2b954781280ca41d17da3c577ad5a1a7a13ddc4dbea72ac5e86f1652e03ecde7  configure.patch
-c4055371a92be958f0d385c83b4788dc4c18bc990b1f780137309c83e174b8d3e65cae077aba3c5286a97fcee1514d61f6b7507ca25bd5155b8d577a7e8acd3a  empty-tbl-null-deref.patch
-9a8953f17e2db75bf3667e1d51c7db21ccc5e3042c59035ed6178094963eac919b7367f96708c9bcc81450ffc13842d12c23edd9bca3330be730149625db88e7  tbl-colwidth-oob.patch
-4b17b144b53ee30f9aae87c7824597151e16e6f5ad795e7b03e701f2d13ca47a62c696cb837689c75d5f34d3c190255c8f0583bc91a0f83f61afde7563a6fb2b  less.patch
-f35268ed507d5c6431f8cafe5a311d1ffe990083c6e1d22f5db479e19745d486cd45a699b64c4fb6757d1c0ab588c3e8d0778bfd75e98e751d1a786e89e8b925  doc.patch
-0dfe9e39570a2b6764303708b98f29b2b57114e124a0f37e9c77d4d33f25d474a79d271df46babd700e4cc93e3385a02356f19caa44ebe4e9b056fa4be96b95b  cgi-adelie.patch
+sha512sums="54286070812a47b629f68757046d3c9a1bdd2b5d1c3b84a5c8e4cb92f1331afa745443f7238175835d8cfbe5b8dd442e00c75c3a5b5b8f8efd8d2ec8f636dad4  mandoc-1.14.6.tar.gz
+08d11f7f0ae66e1630796d928c3906914f4133906928f74b93a1b08207484d16d412577ed739a920cd87abcec720b69fe121da1338a59d2580b978feadeedf32  configure.patch
+dac7b07cff35899b004a334e2926662647da274f7a946ccbc5131e8dd81e32e14073dc93110410baa183da1ffcc53b653c415d89071a1bd941dbf0e88091dee0  less.patch
+c7e3afdf9c9a3c51237e860841902074e17e143433f314961b6f804b7b3a0f176855648180dd9a836848b1c54506344b09dab3577dea58e2ddf5bf5915196419  doc.patch
+098af21312c4acdec33b5817a60f3ed5e91685fc225ec051ad5326d8df3f5ab52a4725d30d52a3fef580de7e7d7ff16e8e7352b9d387edbea56dd816b04e3f19  cgi-adelie.patch
 957bbaef888fb2ea15f9b795b15952332e65aed70d2e70f3142305a4fb9313ade455eae6dfc923af3ef008834e771b1a85d71389b86cd0ff9a1c31e84fef861c  cgi-gz.patch
-37be119308814b060ed9d5517b54eb02b210d677ffb085385929b6aa0e8e8bef2c6c1ab2055713ed8c72f2bc85593bf8744d2d0f163dd1aff65ce439c474b640  cgi-search.patch"
+be7d734ceb436764ad9bd23ac8c4c4b486ad88521e54302524aeb3fc00b4f27939a19495c920ed1be1f82c58fcc72bbb930757a2ac5ad99532929b3e6b3d7d77  cgi-search.patch"
diff --git a/system/mandoc/cgi-adelie.patch b/system/mandoc/cgi-adelie.patch
index 66ce6a9ba..fff862240 100644
--- a/system/mandoc/cgi-adelie.patch
+++ b/system/mandoc/cgi-adelie.patch
@@ -2,7 +2,7 @@ Adjustments for Adélie manual sections and architecture names.
 
 --- mandoc-1.14.5/cgi.c	2019-03-10 04:56:43.000000000 -0500
 +++ mandoc-1.14.5/cgi.c	2020-06-05 15:54:05.681060852 -0500
-@@ -101,36 +101,28 @@ static	const char	 *scriptname = SCRIPT_
+@@ -101,38 +101,28 @@ static	const char	 *scriptname = SCRIPT_
  
  static	const int sec_prios[] = {1, 4, 5, 8, 6, 3, 7, 2, 9};
  static	const char *const sec_numbers[] = {
@@ -32,16 +32,18 @@ Adjustments for Adélie manual sections and architecture names.
  static	const int sec_MAX = sizeof(sec_names) / sizeof(char *);
  
  static	const char *const arch_names[] = {
--    "amd64",       "alpha",       "armv7",	"arm64",
--    "hppa",        "i386",        "landisk",
--    "loongson",    "luna88k",     "macppc",      "mips64",
--    "octeon",      "sgi",         "socppc",      "sparc64",
+-    "amd64",       "alpha",       "armv7",       "arm64",
+-    "hppa",        "i386",        "landisk",     "loongson",
+-    "luna88k",     "macppc",      "mips64",      "octeon",
+-    "powerpc64",   "riscv64",     "sparc64",
+-
 -    "amiga",       "arc",         "armish",      "arm32",
 -    "atari",       "aviion",      "beagle",      "cats",
 -    "hppa64",      "hp300",
 -    "ia64",        "mac68k",      "mvme68k",     "mvme88k",
 -    "mvmeppc",     "palm",        "pc532",       "pegasos",
--    "pmax",        "powerpc",     "solbourne",   "sparc",
+-    "pmax",        "powerpc",     "sgi",         "socppc",
+-    "solbourne",   "sparc",
 -    "sun3",        "vax",         "wgrisc",      "x68k",
 -    "zaurus"
 +    "aarch64",     "armv7",       "pmmx",
diff --git a/system/mandoc/cgi-search.patch b/system/mandoc/cgi-search.patch
index dd74be9ef..387e25dbd 100644
--- a/system/mandoc/cgi-search.patch
+++ b/system/mandoc/cgi-search.patch
@@ -24,7 +24,7 @@ manpage in mansearch.h) and skip them later.
 +	}
 +
 +	if (! results) {
-+		pg_noresult(req, "No results found.");
++		pg_noresult(req, 404, "Not Found", "No results found.");
  		return;
  	}
  
diff --git a/system/mandoc/configure.patch b/system/mandoc/configure.patch
index 2fda25409..ba26b53d5 100644
--- a/system/mandoc/configure.patch
+++ b/system/mandoc/configure.patch
@@ -8,14 +8,3 @@
 +	struct msghdr buf;
 +	return recvmsg(-1, &buf, 0) != -1;
  }
---- mandoc-1.14.5/configure	2019-03-10 04:56:43.000000000 -0500
-+++ mandoc-1.14.5/configure	2020-06-04 20:03:24.790295729 -0500
-@@ -41,7 +41,7 @@ OSENUM=
- OSNAME=
- UTF8_LOCALE=
- 
--CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | env -i make -sf -`
-+CC=cc
- CFLAGS=
- LDADD=
- LDFLAGS=
diff --git a/system/mandoc/doc.patch b/system/mandoc/doc.patch
index 955a5f205..09b1f93d9 100644
--- a/system/mandoc/doc.patch
+++ b/system/mandoc/doc.patch
@@ -1,14 +1,14 @@
 --- mandoc-1.14.5/mandoc.1	2019-03-10 04:56:43.000000000 -0500
 +++ mandoc-1.14.5/mandoc.1	2020-06-05 02:12:50.320533119 -0500
-@@ -897,7 +897,7 @@ An
- macro references a manual page that is not found in the base system.
- The path to look for base system manuals is configurable at compile
- time and defaults to
--.Pa /usr/share/man : /usr/X11R6/man .
+@@ -1016,7 +1016,7 @@ An
+ When running with
+ .Fl W Cm base ,
+ the search is restricted to the base system, by default to
+-.Pa /usr/share/man : Ns Pa /usr/X11R6/man .
 +.Pa /usr/share/man .
- .El
- .Ss Style suggestions
- .Bl -ohang
+ This path can be configured at compile time using the
+ .Dv MANPATH_BASE
+ preprocessor macro.
 --- mandoc-1.14.5/mandoc.db.5	2019-03-10 04:56:43.000000000 -0500
 +++ mandoc-1.14.5/mandoc.db.5	2020-06-05 02:14:48.380534383 -0500
 @@ -189,10 +189,6 @@ followed by the number 0.
diff --git a/system/mandoc/empty-tbl-null-deref.patch b/system/mandoc/empty-tbl-null-deref.patch
deleted file mode 100644
index 3e14ce32b..000000000
--- a/system/mandoc/empty-tbl-null-deref.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-From mboxrd@z Thu Jan  1 00:00:00 1970
-Received: from localhost (fantadrom.bsd.lv [local])
-	by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id 25e99424
-	for <source@mandoc.bsd.lv>;
-	Mon, 18 Mar 2019 03:01:04 -0500 (EST)
-Date: Mon, 18 Mar 2019 03:01:04 -0500 (EST)
-X-Mailinglist: mandoc-source
-Reply-To: source@mandoc.bsd.lv
-MIME-Version: 1.0
-From: schwarze@mandoc.bsd.lv
-To: source@mandoc.bsd.lv
-Subject: mandoc: fix a NULL pointer access on empty tbl(7) data cells that 
-X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/
-Content-Type: text/plain; charset=utf-8
-Message-ID: <e3f22222366ad31d@fantadrom.bsd.lv>
-Archived-At: <http://inbox.vuxu.org/mandoc-source/e3f22222366ad31d@fantadrom.bsd.lv/>
-List-Archive: <http://inbox.vuxu.org/mandoc-source/>
-List-Post: <mailto:source@mandoc.bsd.lv>
-
-Log Message:
------------
-fix a NULL pointer access on empty tbl(7) data cells
-that bentley@ found in syncthing-bep(7)
-
-Modified Files:
---------------
-    mandoc:
-        tbl_term.c
-
-Revision Data
--------------
-Index: tbl_term.c
-===================================================================
-RCS file: /home/cvs/mandoc/mandoc/tbl_term.c,v
-retrieving revision 1.69
-retrieving revision 1.70
-diff -Ltbl_term.c -Ltbl_term.c -u -p -r1.69 -r1.70
---- a/tbl_term.c
-+++ b/tbl_term.c
-@@ -629,7 +629,8 @@ tbl_hrule(struct termp *tp, const struct
- 
- 		lw = cpp == NULL || cpn == NULL ||
- 		    (cpn->pos != TBL_CELL_DOWN &&
--		     (dpn == NULL || strcmp(dpn->string, "\\^") != 0))
-+		     (dpn == NULL || dpn->string == NULL ||
-+		      strcmp(dpn->string, "\\^") != 0))
- 		    ? hw : 0;
- 		tbl_direct_border(tp, BHORIZ * lw,
- 		    col->width + col->spacing / 2);
-@@ -675,7 +676,8 @@ tbl_hrule(struct termp *tp, const struct
- 
- 		rw = cpp == NULL || cpn == NULL ||
- 		    (cpn->pos != TBL_CELL_DOWN &&
--		     (dpn == NULL || strcmp(dpn->string, "\\^") != 0))
-+		     (dpn == NULL || dpn->string == NULL ||
-+		      strcmp(dpn->string, "\\^") != 0))
- 		    ? hw : 0;
- 
- 		/* The line crossing at the end of this column. */
---
- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
-
diff --git a/system/mandoc/less.patch b/system/mandoc/less.patch
index 19d567365..51f79c453 100644
--- a/system/mandoc/less.patch
+++ b/system/mandoc/less.patch
@@ -7,24 +7,13 @@ function - maybe add it at some point.
 
 --- mandoc-1.14.5/main.c	2019-03-10 04:56:43.000000000 -0500
 +++ mandoc-1.14.5/main.c	2020-06-05 01:59:10.640524340 -0500
-@@ -1170,8 +1170,9 @@ spawn_pager(struct tag_files *tag_files)
- 	pager = getenv("MANPAGER");
- 	if (pager == NULL || *pager == '\0')
- 		pager = getenv("PAGER");
--	if (pager == NULL || *pager == '\0')
--		pager = "more -s";
-+	if (pager == NULL || *pager == '\0') {
-+		pager = "less";
-+	}
- 	cp = mandoc_strdup(pager);
- 
- 	/*
-@@ -1195,10 +1196,24 @@ spawn_pager(struct tag_files *tag_files)
+@@ -1316,11 +1316,25 @@ spawn_pager(struct tag_files *tag_files)
  	/* For less(1), use the tag file. */
  
  	use_ofn = 1;
 -#if HAVE_LESS_T
- 	if ((cmdlen = strlen(argv[0])) >= 4) {
+ 	if (*outst->tag_files->tfn != '\0' &&
+ 	    (cmdlen = strlen(argv[0])) >= 4) {
  		cp = argv[0] + cmdlen - 4;
  		if (strcmp(cp, "less") == 0) {
 +			/*
@@ -43,16 +32,14 @@ function - maybe add it at some point.
 +				"$";
 +#if HAVE_LESS_T
  			argv[argc++] = mandoc_strdup("-T");
- 			argv[argc++] = tag_files->tfn;
+ 			argv[argc++] = outst->tag_files->tfn;
  			if (tag_files->tagname != NULL) {
-@@ -1206,9 +1221,9 @@ spawn_pager(struct tag_files *tag_files)
- 				argv[argc++] = tag_files->tagname;
+@@ -1327,7 +1342,7 @@ spawn_pager(struct tag_files *tag_files)
+ 				argv[argc++] = tag_target;
  				use_ofn = 0;
  			}
 +#endif
  		}
  	}
 -#endif
- 	if (use_ofn)
- 		argv[argc++] = tag_files->ofn;
- 	argv[argc] = NULL;
+ 	if (use_ofn) {
diff --git a/system/mandoc/tbl-colwidth-oob.patch b/system/mandoc/tbl-colwidth-oob.patch
deleted file mode 100644
index 0b7b0acad..000000000
--- a/system/mandoc/tbl-colwidth-oob.patch
+++ /dev/null
@@ -1,62 +0,0 @@
-From mboxrd@z Thu Jan  1 00:00:00 1970
-Received: from localhost (fantadrom.bsd.lv [local])
-	by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id 0ff00a97
-	for <source@mandoc.bsd.lv>;
-	Fri, 29 Mar 2019 16:27:36 -0500 (EST)
-Date: Fri, 29 Mar 2019 16:27:36 -0500 (EST)
-X-Mailinglist: mandoc-source
-Reply-To: source@mandoc.bsd.lv
-MIME-Version: 1.0
-From: schwarze@mandoc.bsd.lv
-To: source@mandoc.bsd.lv
-Subject: mandoc: Set the maximum column index in a tbl(7) to the maximum *right* 
-X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/
-Content-Type: text/plain; charset=utf-8
-Message-ID: <e3fceff42218668d@fantadrom.bsd.lv>
-Archived-At: <http://inbox.vuxu.org/mandoc-source/e3fceff42218668d@fantadrom.bsd.lv/>
-List-Archive: <http://inbox.vuxu.org/mandoc-source/>
-List-Post: <mailto:source@mandoc.bsd.lv>
-
-Log Message:
------------
-Set the maximum column index in a tbl(7) to the maximum *right* edge 
-of any cell span, not to the maximum *left* edge, which may be smaller 
-if the last column of the table is only reached by horizontal spans,
-but not by any regular cell in any row of the table.
-Otherwise, the algorithm calculating column widths accessed memomy
-after the end of the colwidth[] array, while it was trying to handle 
-the rightmost column(s).
-
-Crash reported by Jason Thorpe <thorpej at NetBSD>
-via https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=54069
-and via Thomas Klausner (wiz@).
-Christos@ Zoulas sent a (correct, but slightly confusing) patch.
-The patch i'm committing here is easier to understand.
-
-Modified Files:
---------------
-    mandoc:
-        out.c
-
-Revision Data
--------------
-Index: out.c
-===================================================================
-RCS file: /home/cvs/mandoc/mandoc/out.c,v
-retrieving revision 1.77
-retrieving revision 1.78
-diff -Lout.c -Lout.c -u -p -r1.77 -r1.78
---- a/out.c
-+++ b/out.c
-@@ -149,7 +149,7 @@ tblcalc(struct rofftbl *tbl, const struc
- 		gp = &first_group;
- 		for (dp = sp->first; dp != NULL; dp = dp->next) {
- 			icol = dp->layout->col;
--			while (icol > maxcol)
-+			while (maxcol < icol + dp->hspans)
- 				tbl->cols[++maxcol].spacing = SIZE_MAX;
- 			col = tbl->cols + icol;
- 			col->flags |= dp->layout->flags;
---
- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
-
-- 
cgit v1.2.3-70-g09d2