swm_version: 1 base: distro_version: dev pins: {} mutations: - type: source_patch tarball: https://mandoc.bsd.lv/snapshots/mandoc-1.14.6.tar.gz sha256: 8bf0d570f01e70a6e124884088870cbed7537f36328d512909eb10cd53179d9c patches: - "BusyBox less doesn't support tag files (-T option), hence we previously\ndisabled tag file support in mandoc at compile-time (HAVE_LESS_T).\nHowever, on Alpine it is entirely possible to replace BusyBox less with\nan implementation that supports tag files (e.g. main/less). In order to\nsupport tag files when such an implementation is installed, we need to\ndetect at runtime whether -T is supported.\n\nThis patch achieves this by invoking the pager once with -T beforehand\nand checking if it terminates with a non-zero exit status.\n\ndiff -upr mandoc-1.14.6.orig/configure mandoc-1.14.6/configure\n--- mandoc-1.14.6.orig/configure\t2023-07-02 19:38:31.011639507 +0200\n+++ mandoc-1.14.6/configure\t2023-07-02 19:38:41.794998501 +0200\n@@ -67,7 +67,6 @@ HAVE_FTS_COMPARE_CONST=\n HAVE_GETLINE=\n HAVE_GETSUBOPT=\n HAVE_ISBLANK=\n-HAVE_LESS_T=\n HAVE_MKDTEMP=\n HAVE_MKSTEMPS=\n HAVE_NANOSLEEP=\n@@ -363,21 +362,6 @@ fi\n echo \"selected BINM_PAGER=${BINM_PAGER}${manual}\" 1>&2\n echo \"selected BINM_PAGER=${BINM_PAGER}${manual}\" 1>&3\n \n-# --- tagging support in the pager ---\n-if ismanual \"${BINM_PAGER} -T\" LESS_T ${HAVE_LESS_T}; then\n-\t:\n-elif ${BINM_PAGER} -T /dev/null test-noop.c 1>/dev/null 2>&3; then\n-\tHAVE_LESS_T=1\n-\techo \"tested ${BINM_PAGER} -T: yes\" 1>&2\n-\techo \"tested ${BINM_PAGER} -T: yes\" 1>&3\n-\techo 1>&3\n-else\n-\tHAVE_LESS_T=0\n-\techo \"tested ${BINM_PAGER} -T: no\" 1>&2\n-\techo \"tested ${BINM_PAGER} -T: no\" 1>&3\n-\techo 1>&3\n-fi\n-\n # --- wide character and locale support ---\n if get_locale; then\n \truntest wchar WCHAR \"-DUTF8_LOCALE=\\\"${UTF8_LOCALE}\\\"\" \\\n@@ -484,7 +468,6 @@ cat << __HEREDOC__\n #define HAVE_GETLINE ${HAVE_GETLINE}\n #define HAVE_GETSUBOPT ${HAVE_GETSUBOPT}\n #define HAVE_ISBLANK ${HAVE_ISBLANK}\n-#define HAVE_LESS_T ${HAVE_LESS_T}\n #define HAVE_MKDTEMP ${HAVE_MKDTEMP}\n #define HAVE_MKSTEMPS ${HAVE_MKSTEMPS}\n #define HAVE_NTOHL ${HAVE_NTOHL}\ndiff -upr mandoc-1.14.6.orig/main.c mandoc-1.14.6/main.c\n--- mandoc-1.14.6.orig/main.c\t2023-07-02 19:38:31.011639507 +0200\n+++ mandoc-1.14.6/main.c\t2023-07-02 19:38:50.635019538 +0200\n@@ -1271,6 +1271,44 @@ run_pager(struct outstate *outst, char *\n \t}\n }\n \n+static int\n+supports_tags(const char *pager, char *tagfile)\n+{\n+\tint\tfd;\n+\tpid_t\tpid;\n+\tint\twstatus;\n+\n+\tif (strcmp(pager, \"less\") != 0)\n+\t\treturn 0;\n+\n+\tpid = fork();\n+\tswitch (pid) {\n+\tcase -1:\n+\t\terr(1, \"fork\");\n+\tcase 0:\n+\t\tclose(STDIN_FILENO);\n+\t\tfd = open(\"/dev/null\", O_RDWR);\n+\t\tif (fd == -1)\n+\t\t\terr(1, \"open\");\n+\t\tassert(fd == STDIN_FILENO);\n+\n+\t\tclose(STDOUT_FILENO);\n+\t\tdup2(fd, STDOUT_FILENO);\n+\t\tclose(STDERR_FILENO);\n+\t\tdup2(fd, STDERR_FILENO);\n+\n+\t\t/* If the pager doesn't support -T we expect a non-zero exit code */\n+\t\texeclp(pager, pager, \"-T\", tagfile, \"-\", (char *)NULL);\n+\t\texit(EXIT_FAILURE);\n+\tdefault:\n+\t\tif (waitpid(pid, &wstatus, 0) == -1)\n+\t\t\terr(1, \"waitpid\");\n+\t\tbreak;\n+\t}\n+\n+\treturn wstatus == EXIT_SUCCESS;\n+}\n+\n static pid_t\n spawn_pager(struct outstate *outst, char *tag_target)\n {\n@@ -1279,9 +1317,7 @@ spawn_pager(struct outstate *outst, char\n \tchar\t\t*argv[MAX_PAGER_ARGS];\n \tconst char\t*pager;\n \tchar\t\t*cp;\n-#if HAVE_LESS_T\n \tsize_t\t\t cmdlen;\n-#endif\n \tint\t\t argc, use_ofn;\n \tpid_t\t\t pager_pid;\n \n@@ -1316,11 +1352,10 @@ spawn_pager(struct outstate *outst, char\n \t/* For less(1), use the tag file. */\n \n \tuse_ofn = 1;\n-#if HAVE_LESS_T\n \tif (*outst->tag_files->tfn != '\\0' &&\n \t (cmdlen = strlen(argv[0])) >= 4) {\n \t\tcp = argv[0] + cmdlen - 4;\n-\t\tif (strcmp(cp, \"less\") == 0) {\n+\t\tif (supports_tags(pager, outst->tag_files->tfn)) {\n \t\t\targv[argc++] = mandoc_strdup(\"-T\");\n \t\t\targv[argc++] = outst->tag_files->tfn;\n \t\t\tif (tag_target != NULL) {\n@@ -1330,7 +1365,7 @@ spawn_pager(struct outstate *outst, char\n \t\t\t}\n \t\t}\n \t}\n-#endif\n+\n \tif (use_ofn) {\n \t\tif (outst->outtype == OUTT_HTML && tag_target != NULL)\n \t\t\tmandoc_asprintf(&argv[argc], \"file://%s#%s\",\n" - "Patch-Source: https://cvsweb.bsd.lv/mandoc/tag.c.diff?r1=1.36&r2=1.37\n---\n===================================================================\nRCS file: /cvs/mandoc/tag.c,v\nretrieving revision 1.36\nretrieving revision 1.37\ndiff -u -p -r1.36 -r1.37\n--- mandoc/tag.c\t2020/04/19 16:36:16\t1.36\n+++ mandoc/tag.c\t2022/04/26 11:38:38\t1.37\n@@ -1,6 +1,7 @@\n-/* $Id: tag.c,v 1.36 2020/04/19 16:36:16 schwarze Exp $ */\n+/* $Id: tag.c,v 1.37 2022/04/26 11:38:38 schwarze Exp $ */\n /*\n- * Copyright (c) 2015,2016,2018,2019,2020 Ingo Schwarze \n+ * Copyright (c) 2015, 2016, 2018, 2019, 2020, 2022\n+ * Ingo Schwarze \n *\n * Permission to use, copy, modify, and distribute this software for any\n * purpose with or without fee is hereby granted, provided that the above\n@@ -80,7 +81,7 @@ tag_free(void)\n \n /*\n * Set a node where a term is defined,\n- * unless it is already defined at a lower priority.\n+ * unless the term is already defined at a lower priority.\n */\n void\n tag_put(const char *s, int prio, struct roff_node *n)\n@@ -93,6 +94,18 @@ tag_put(const char *s, int prio, struct roff_node *n)\n \n \tassert(prio <= TAG_FALLBACK);\n \n+\t/*\n+\t * If the node is already tagged, the existing tag is\n+\t * explicit and we are now about to add an implicit tag.\n+\t * Don't do that; just skip implicit tagging if the author\n+\t * specified an explicit tag.\n+\t */\n+\n+\tif (n->flags & NODE_ID)\n+\t\treturn;\n+\n+\t/* Determine the implicit tag. */\n+\n \tif (s == NULL) {\n \t\tif (n->child == NULL || n->child->type != ROFFT_TEXT)\n \t\t\treturn;\n@@ -150,7 +163,7 @@ tag_put(const char *s, int prio, struct roff_node *n)\n \t */\n \n \telse if (entry->prio < prio)\n-\t\t\treturn;\n+\t\treturn;\n \n \t/*\n \t * If the existing entry is worse, clear it.\n" - "On Alpine, apropos(1) is available in a separate subpackages and not\ninstalled by default. For this reason, having this warning enabled by\ndefault does not make much sense since we don't use mandoc.db by\ndefault.\n\ndiff -upr a/main.c b/main.c\n--- a/main.c\t2021-09-19 18:21:40.000000000 +0200\n+++ b/main.c\t2021-09-19 19:40:28.711594083 +0200\n@@ -822,8 +822,6 @@ fs_lookup(const struct manpaths *paths,\n \treturn globres;\n \n found:\n-\twarnx(\"outdated mandoc.db lacks %s(%s) entry, run %s %s\",\n-\t name, sec, BINM_MAKEWHATIS, paths->paths[ipath]);\n \tif (res == NULL)\n \t\tfree(file);\n \telse if (file == NULL)\n" - "Patch-Source: https://marc.info/?l=mandoc-discuss&m=175200050325256&w=2\n\n--- a/man_validate.c\n+++ b/man_validate.c\n@@ -481,7 +481,7 @@ post_TH(CHKARGS)\n \t/* ->TITLE<- MSEC DATE OS VOL */\n \n \tn = n->child;\n-\tif (n != NULL && n->string != NULL) {\n+\tif (n != NULL && n->string != NULL && *n->string != '\\0') {\n \t\tfor (p = n->string; *p != '\\0'; p++) {\n \t\t\t/* Only warn about this once... */\n \t\t\tif (isalpha((unsigned char)*p) &&\n@@ -494,8 +494,8 @@ post_TH(CHKARGS)\n \t\t}\n \t\tman->meta.title = mandoc_strdup(n->string);\n \t} else {\n-\t\tman->meta.title = mandoc_strdup(\"\");\n-\t\tmandoc_msg(MANDOCERR_TH_NOTITLE, nb->line, nb->pos, \"TH\");\n+\t\tman->meta.title = mandoc_strdup(\"UNTITLED\");\n+\t\tmandoc_msg(MANDOCERR_DT_NOTITLE, nb->line, nb->pos, \"TH\");\n \t}\n \n \t/* TITLE ->MSEC<- DATE OS VOL */\n--- a/regress/man/TH/noarg.out_ascii\n+++ b/regress/man/TH/noarg.out_ascii\n@@ -1,4 +1,4 @@\n-() ()\n+UNTITLED() UNTITLED()\n \n N\bNA\bAM\bME\bE\n TH-noarg - no arguments to the TH macro\n@@ -6,4 +6,4 @@ N\bNA\bAM\bME\bE\n D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN\n some text\n \n-OpenBSD ()\n+OpenBSD UNTITLED()\n--- a/regress/man/TH/noarg.out_lint\n+++ b/regress/man/TH/noarg.out_lint\n@@ -1,3 +1,3 @@\n-mandoc: noarg.in:2:2: WARNING: missing manual title, using \"\": TH\n-mandoc: noarg.in:2:2: WARNING: missing manual section, using \"\": TH \n+mandoc: noarg.in:2:2: WARNING: missing manual title, using UNTITLED: TH\n+mandoc: noarg.in:2:2: WARNING: missing manual section, using \"\": TH UNTITLED\n mandoc: noarg.in:2:2: WARNING: missing date, using \"\": TH\n\n" build: compiler: zig-cc target: x86_64-linux-musl link: static flags: [] phases: configure: | cat > configure.local <<'EOF' PREFIX=/usr BINDIR=/usr/bin SBINDIR=/usr/sbin LIBDIR=/usr/lib INCLUDEDIR=/usr/include MANDIR=/usr/share/man CC="zig cc -mcpu=baseline" AR="zig ar" LDFLAGS="-static" EOF ./configure compile: | make -j"$(nproc)" install: | _abuild_phase() { make -j1 DESTDIR="/out" base-install lib-install } _abuild_phase target_bin: /usr/bin/mandoc expected_hash: b3:1fcba510172f5ce5c62259b42af6fcd5497eb928499503fbf2655843e9ddc405 deps: build: - zlib - make runtime: []