summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/mandoc/main.c')
-rw-r--r--usr.bin/mandoc/main.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c
index e7b875aec04..6885e2e3269 100644
--- a/usr.bin/mandoc/main.c
+++ b/usr.bin/mandoc/main.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: main.c,v 1.206 2018/02/08 01:36:38 tb Exp $ */
+/* $OpenBSD: main.c,v 1.207 2018/04/13 19:55:13 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2012, 2014-2018 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -18,7 +18,9 @@
*/
#include <sys/types.h>
+#include <sys/ioctl.h>
#include <sys/param.h> /* MACHINE */
+#include <sys/termios.h>
#include <sys/wait.h>
#include <assert.h>
@@ -114,6 +116,7 @@ main(int argc, char *argv[])
struct manconf conf;
struct mansearch search;
struct curparse curp;
+ struct winsize ws;
struct tag_files *tag_files;
struct manpage *res, *resp;
const char *progname, *sec, *thisarg;
@@ -292,6 +295,15 @@ main(int argc, char *argv[])
!isatty(STDOUT_FILENO))
use_pager = 0;
+ if (use_pager &&
+ (conf.output.width == 0 || conf.output.indent == 0) &&
+ ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) != -1) {
+ if (conf.output.width == 0 && ws.ws_col < 79)
+ conf.output.width = ws.ws_col - 1;
+ if (conf.output.indent == 0 && ws.ws_col < 66)
+ conf.output.indent = 3;
+ }
+
if (!use_pager)
if (pledge("stdio rpath", NULL) == -1)
err((int)MANDOCLEVEL_SYSERR, "pledge");