man: Patch to adjust output width to terminal
authorFredrik Fornwall <fredrik@fornwall.net>
Mon, 26 Sep 2016 22:18:43 +0000 (18:18 -0400)
committerFredrik Fornwall <fredrik@fornwall.net>
Mon, 26 Sep 2016 22:18:43 +0000 (18:18 -0400)
Fixes https://github.com/termux/termux-app/issues/162

packages/man/build.sh
packages/man/term_ascii.c.patch [new file with mode: 0644]

index edfbed1..08f29ea 100644 (file)
@@ -1,7 +1,7 @@
 TERMUX_PKG_HOMEPAGE=http://mdocml.bsd.lv/
 TERMUX_PKG_DESCRIPTION="Man page viewer from the mandoc toolset"
 TERMUX_PKG_VERSION=1.13.4
-TERMUX_PKG_BUILD_REVISION=2
+TERMUX_PKG_BUILD_REVISION=3
 TERMUX_PKG_SRCURL=http://mdocml.bsd.lv/snapshots/mdocml-${TERMUX_PKG_VERSION}.tar.gz
 TERMUX_PKG_DEPENDS="less,libandroid-glob,libsqlite"
 TERMUX_PKG_BUILD_IN_SRC=yes
diff --git a/packages/man/term_ascii.c.patch b/packages/man/term_ascii.c.patch
new file mode 100644 (file)
index 0000000..b0f07c5
--- /dev/null
@@ -0,0 +1,38 @@
+The man implementation from mandoc does not adjust its output size to the terminal. As this is nice to have on smaller screens such as Termux we patch this in using the following patch adapted from
+
+https://groups.google.com/forum/#!topic/fa.openbsd.tech/AEDMaZmzSU4
+
+diff -u -r ../mdocml-1.13.4/term_ascii.c ./term_ascii.c
+--- ../mdocml-1.13.4/term_ascii.c      2016-07-14 07:13:40.000000000 -0400
++++ ./term_ascii.c     2016-09-26 18:06:08.339737451 -0400
+@@ -18,6 +18,7 @@
+ #include "config.h"
+ #include <sys/types.h>
++#include <sys/ioctl.h>
+ #include <assert.h>
+ #if HAVE_WCHAR
+@@ -64,12 +65,22 @@
+       char            *v;
+ #endif
+       struct termp    *p;
++      struct winsize  ws;
++      int             tfd;
+       p = mandoc_calloc(1, sizeof(struct termp));
+       p->line = 1;
+       p->tabwidth = 5;
+       p->defrmargin = p->lastrmargin = 78;
++      if ((tfd = open("/dev/tty", O_RDWR, 0)) != -1) {
++              if (ioctl(tfd, TIOCGWINSZ, &ws) != -1) {
++                      if (ws.ws_col < 80)
++                              p->defrmargin = p->lastrmargin = ws.ws_col - 2;
++              }
++              close(tfd);
++      }
++
+       p->fontq = mandoc_reallocarray(NULL,
+            (p->fontsz = 8), sizeof(enum termfont));
+       p->fontq[0] = p->fontl = TERMFONT_NONE;