File: 01-check-columns-env-var.patch

package info (click to toggle)
diffstat 1.61-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,992 kB
  • ctags: 618
  • sloc: sh: 3,105; ansic: 2,514; makefile: 163
file content (30 lines) | stat: -rw-r--r-- 814 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Author: Michael B. Trausch <mike@trausch.us>
Author: Francois Marier <francois@debian.org>
Subject: Consider environment when determining default output columns
Origin: http://launchpadlibrarian.net/13009086/columns_for_tty.ubuntu.debdiff
Forwarded: yes
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/diffstat/+bug/209537
Last-Update: 2012-01-04

--- a/diffstat.c
+++ b/diffstat.c
@@ -2489,10 +2489,19 @@ int
 main(int argc, char *argv[])
 {
     int j;
+    const int STDOUT = 1;
+    char *env_columns;
     char version[80];
 
     max_width = 80;
 
+    env_columns = getenv("COLUMNS");
+    if(env_columns) {
+	if(isatty(STDOUT)) {
+	    max_width = atoi(env_columns);
+	}
+    }
+
     while ((j = getopt_helper(argc, argv,
 			      "bcCdD:e:Ef:hkKlmn:N:o:p:qr:RsS:tTuvVw:", 'h', 'V'))
 	   != -1) {