summaryrefslogtreecommitdiffstats
path: root/patches/procps-3.2.7/generic/30_w-columns.dpatch
blob: 57c94aeda381715accd30b46af786db5d3e90315 (plain)
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
31
32
33
34
#! /bin/sh /usr/share/dpatch/dpatch-run
## 30_w-columns.dpatch by  <csmall@localhost.localdomain>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: use COLUMNS environment if TIOCGWINSZ fails

@DPATCH@
diff -urNad --exclude=CVS --exclude=.svn ./w.c /tmp/dpep-work.0retPU/procps-3.2.6/w.c
--- ./w.c	2005-10-31 12:41:33.000000000 +1100
+++ /tmp/dpep-work.0retPU/procps-3.2.6/w.c	2005-10-31 12:41:55.000000000 +1100
@@ -231,10 +231,10 @@
 
 /***** main */
 int main(int argc, char **argv) {
-    char *user = NULL;
+    char *user = NULL, *p;
     utmp_t *u;
     struct winsize win;
-    int header=1, longform=1, from=1, args, maxcmd=80, ch;
+    int header=1, longform=1, from=1, args, maxcmd, ch;
 
 #ifndef W_SHOWFROM
     from = 0;
@@ -267,6 +267,10 @@
 
     if (ioctl(1, TIOCGWINSZ, &win) != -1 && win.ws_col > 0)
 	maxcmd = win.ws_col;
+    else if (p = getenv("COLUMNS"))
+        maxcmd = atoi(p);
+    else
+	maxcmd = 80;
     if (maxcmd < 71) {
 	fprintf(stderr, "%d column window is too narrow\n", maxcmd);
 	exit(1);