1mandoc upstream does not support zstd compression. However, Guix uses zstd
2compression for its man pages, therefore—without support for this compression
3method—mandoc would be quite useless. Hence, this patchset uses zlibWrapper
4from the zstd project to add zstd compression support to mandoc.
5
6diff -upr mandoc-1.14.6.orig/Makefile mandoc-1.14.6/Makefile
7--- mandoc-1.14.6.orig/Makefile 2025-01-11 16:20:31.511129163 +0100
8+++ mandoc-1.14.6/Makefile 2025-01-11 19:16:35.924788821 +0100
9@@ -251,7 +251,12 @@ LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
10 msec.o \
11 preconv.o \
12 read.o \
13- tag.o
14+ tag.o \
15+ zstd_zlibwrapper.o \
16+ gzclose.o \
17+ gzlib.o \
18+ gzread.o \
19+ gzwrite.o
20
21 ALL_COBJS = compat_err.o \
22 compat_fts.o \
23Only in mandoc-1.14.6: Makefile.orig
24diff -upr mandoc-1.14.6.orig/configure mandoc-1.14.6/configure
25--- mandoc-1.14.6.orig/configure 2025-01-11 16:20:31.511129163 +0100
26+++ mandoc-1.14.6/configure 2025-01-11 19:16:35.924788821 +0100
27@@ -430,7 +430,7 @@ fi
28 [ "${FATAL}" -eq 0 ] || exit 1
29
30 # --- LDADD ---
31-LDADD="${LDADD} ${LD_NANOSLEEP} ${LD_RECVMSG} ${LD_OHASH} -lz"
32+LDADD="${LDADD} ${LD_NANOSLEEP} ${LD_RECVMSG} ${LD_OHASH} -lz -lzstd"
33 echo "selected LDADD=\"${LDADD}\"" 1>&2
34 echo "selected LDADD=\"${LDADD}\"" 1>&3
35 echo 1>&3
36Only in mandoc-1.14.6: configure.orig
37diff -upr mandoc-1.14.6.orig/read.c mandoc-1.14.6/read.c
38--- mandoc-1.14.6.orig/read.c 2025-01-11 16:35:03.825441715 +0100
39+++ mandoc-1.14.6/read.c 2025-01-11 19:16:35.924788821 +0100
40@@ -37,7 +37,7 @@
41 #include <stdlib.h>
42 #include <string.h>
43 #include <unistd.h>
44-#include <zlib.h>
45+#include <zstd_zlibwrapper.h>
46
47 #include "mandoc_aux.h"
48 #include "mandoc.h"
49@@ -627,7 +627,7 @@ mparse_open(struct mparse *curp, const char *file)
50 int fd, save_errno;
51
52 cp = strrchr(file, '.');
53- curp->gzip = (cp != NULL && ! strcmp(cp + 1, "gz"));
54+ curp->gzip = (cp != NULL && (! strcmp(cp + 1, "gz") || ! strcmp(cp + 1, "zst")));
55
56 /* First try to use the filename as it is. */
57
58Only in mandoc-1.14.6: read.c.orig