termux-packages/packages/man/term_ascii.c.patch

40 lines
947 B
Diff
Raw Normal View History

2017-08-18 21:05:24 +02:00
diff -u -r ../mandoc-1.14.3/term_ascii.c ./term_ascii.c
--- ../mandoc-1.14.3/term_ascii.c 2017-08-05 14:40:22.000000000 +0200
+++ ./term_ascii.c 2017-08-17 15:58:09.579116114 +0200
2017-03-02 16:14:05 +01:00
@@ -18,8 +18,10 @@
#include "config.h"
#include <sys/types.h>
+#include <sys/ioctl.h>
#include <assert.h>
2017-03-02 16:14:05 +01:00
+#include <fcntl.h>
#if HAVE_WCHAR
2017-03-02 16:14:05 +01:00
#include <locale.h>
#endif
2017-08-18 21:05:24 +02:00
@@ -64,6 +66,8 @@
char *v;
#endif
struct termp *p;
+ struct winsize ws;
+ int tfd;
2017-08-18 21:05:24 +02:00
p = mandoc_calloc(1, sizeof(*p));
p->tcol = p->tcols = mandoc_calloc(1, sizeof(*p->tcol));
@@ -71,6 +75,15 @@
p->line = 1;
p->defrmargin = p->lastrmargin = 78;
2017-08-18 21:05:24 +02:00
+
+ 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);
+ }
2017-08-18 21:05:24 +02:00
+
p->fontq = mandoc_reallocarray(NULL,
2017-08-18 21:05:24 +02:00
(p->fontsz = 8), sizeof(*p->fontq));
p->fontq[0] = p->fontl = TERMFONT_NONE;