void-packages/srcpkgs/procps/patches/w_columns.patch

30 lines
886 B
Diff

Description: use COLUMNS environment if TIOCGWINSZ fails
Author: Craig Small <csmall@debian.org>
Index: b/w.c
===================================================================
--- a/w.c 2009-11-24 21:00:39.000000000 +1100
+++ b/w.c 2009-11-24 21:00:43.000000000 +1100
@@ -241,10 +241,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;
@@ -277,6 +277,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);