aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
authorCem Keylan <cem@ckyln.com>2020-10-17 15:32:39 +0300
committerCem Keylan <cem@ckyln.com>2020-10-17 15:32:39 +0300
commitbfac636f78f60edcfc2d425ada43705aeb818000 (patch)
tree4c37d7d3eef7c7826dca898a7dc7ebff2f84d04c /usr.bin/mandoc
parentbf1a9e6ee5f2e51e6e947b9125d5d27f89b0edb0 (diff)
downloadotools-bfac636f78f60edcfc2d425ada43705aeb818000.tar.gz
mandoc: don't remove less -T support, make it optional1.1
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/main.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c
index 6f2174a..acdbd91 100644
--- a/usr.bin/mandoc/main.c
+++ b/usr.bin/mandoc/main.c
@@ -1185,6 +1185,9 @@ spawn_pager(struct tag_files *tag_files, char *tag_target)
char *argv[MAX_PAGER_ARGS];
const char *pager;
char *cp;
+#ifdef HAVE_LESS_T
+ size_t cmdlen;
+#endif
int argc, use_ofn;
pid_t pager_pid;
@@ -1219,6 +1222,20 @@ spawn_pager(struct tag_files *tag_files, char *tag_target)
/* For more(1) and less(1), use the tag file. */
use_ofn = 1;
+#ifdef HAVE_LESS_T
+ if (*tag_files->tfn != '\0' && (cmdlen = strlen(argv[0])) >= 4) {
+ cp = argv[0] + cmdlen - 4;
+ if (strcmp(cp, "less") == 0 || strcmp(cp, "more") == 0) {
+ argv[argc++] = mandoc_strdup("-T");
+ argv[argc++] = tag_files->tfn;
+ if (tag_target != NULL) {
+ argv[argc++] = mandoc_strdup("-t");
+ argv[argc++] = tag_target;
+ use_ofn = 0;
+ }
+ }
+ }
+#endif
if (use_ofn)
argv[argc++] = tag_files->ofn;
argv[argc] = NULL;