build-package.sh: Update build go from 1.8rc2 to 1.8rc3
[termux-packages] / packages / man / term_ascii.c.patch
CommitLineData
80c266a7
FF
1The 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
2
3https://groups.google.com/forum/#!topic/fa.openbsd.tech/AEDMaZmzSU4
4
5diff -u -r ../mdocml-1.13.4/term_ascii.c ./term_ascii.c
6--- ../mdocml-1.13.4/term_ascii.c 2016-07-14 07:13:40.000000000 -0400
7+++ ./term_ascii.c 2016-09-26 18:06:08.339737451 -0400
8@@ -18,6 +18,7 @@
9 #include "config.h"
10
11 #include <sys/types.h>
12+#include <sys/ioctl.h>
13
14 #include <assert.h>
15 #if HAVE_WCHAR
16@@ -64,12 +65,22 @@
17 char *v;
18 #endif
19 struct termp *p;
20+ struct winsize ws;
21+ int tfd;
22
23 p = mandoc_calloc(1, sizeof(struct termp));
24
25 p->line = 1;
26 p->tabwidth = 5;
27 p->defrmargin = p->lastrmargin = 78;
28+ if ((tfd = open("/dev/tty", O_RDWR, 0)) != -1) {
29+ if (ioctl(tfd, TIOCGWINSZ, &ws) != -1) {
30+ if (ws.ws_col < 80)
31+ p->defrmargin = p->lastrmargin = ws.ws_col - 2;
32+ }
33+ close(tfd);
34+ }
35+
36 p->fontq = mandoc_reallocarray(NULL,
37 (p->fontsz = 8), sizeof(enum termfont));
38 p->fontq[0] = p->fontl = TERMFONT_NONE;