chiark / gitweb /
busybox: Update from 1.28.2 to 1.28.3
[termux-packages] / packages / man / term_ascii.c.patch
index b0f07c576c74e5a612eac001a87934b32308b196..70c6594dc5d77bb8c384a6e8ea049cdf54f895b1 100644 (file)
@@ -1,30 +1,31 @@
-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 @@
+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
+@@ -18,8 +18,10 @@
  #include "config.h"
  
  #include <sys/types.h>
 +#include <sys/ioctl.h>
  
  #include <assert.h>
++#include <fcntl.h>
  #if HAVE_WCHAR
-@@ -64,12 +65,22 @@
+ #include <locale.h>
+ #endif
+@@ -64,6 +66,8 @@
        char            *v;
  #endif
        struct termp    *p;
 +      struct winsize  ws;
 +      int             tfd;
  
-       p = mandoc_calloc(1, sizeof(struct termp));
+       p = mandoc_calloc(1, sizeof(*p));
+       p->tcol = p->tcols = mandoc_calloc(1, sizeof(*p->tcol));
+@@ -71,6 +75,15 @@
  
        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)
@@ -32,7 +33,7 @@ diff -u -r ../mdocml-1.13.4/term_ascii.c ./term_ascii.c
 +              }
 +              close(tfd);
 +      }
-+
++      
        p->fontq = mandoc_reallocarray(NULL,
-            (p->fontsz = 8), sizeof(enum termfont));
+            (p->fontsz = 8), sizeof(*p->fontq));
        p->fontq[0] = p->fontl = TERMFONT_NONE;