summaryrefslogtreecommitdiff
path: root/w.c
diff options
context:
space:
mode:
authorCraig Small <csmall@enc.com.au>2015-07-21 22:45:02 +1000
committerCraig Small <csmall@enc.com.au>2015-10-14 21:34:22 +1100
commit7b08ad19cc245e9a57c3364cd252ebab61d0394d (patch)
tree0252165e4a833786437541bff4a326f9e34096c6 /w.c
parent2f78b195adf5d87583604e50363d5a3f6d7a8b1a (diff)
downloadprocps-ng-7b08ad19cc245e9a57c3364cd252ebab61d0394d.tar.gz
w: Adjust command width
w would error out if the window size was smaller than 71 or some other fields through environment grew too big. The code was a little convoluted as well. The minimum length for command was 3, which is pretty useless. This change does the following: w doesn't care by default the window size w will adjust the command length up and down, to a minimum of 7 characters. if the fields don't fit, w will line-wrap each line. The idea being its better the line-wrap than it is to error out. References: https://bugs.debian.org/183394 Signed-off-by: Craig Small <csmall@enc.com.au> Ported-by: Jim Warner <james.warner@comcast.net> From original: commit 151c05b4978b2022eda1d6e509e65f74eb491312
Diffstat (limited to 'w.c')
-rw-r--r--w.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/w.c b/w.c
index e4e01cc..615cd4b 100644
--- a/w.c
+++ b/w.c
@@ -65,6 +65,7 @@ typedef struct utmp utmp_t;
#endif
#define MAX_CMD_WIDTH 512
+#define MIN_CMD_WIDTH 7
/*
* This routine is careful since some programs leave utmp strings
@@ -621,16 +622,11 @@ int main(int argc, char **argv)
maxcmd = atoi(p);
else
maxcmd = MAX_CMD_WIDTH;
- if (maxcmd < 71)
- xerrx(EXIT_FAILURE, _("%d column window is too narrow"), maxcmd);
- if (MAX_CMD_WIDTH < maxcmd) {
- xwarnx(_("%d column width exceeds command buffer size, truncating to %d"),
- maxcmd, MAX_CMD_WIDTH);
+ if (MAX_CMD_WIDTH < maxcmd)
maxcmd = MAX_CMD_WIDTH;
- }
maxcmd -= 21 + userlen + (from ? fromlen : 0) + (longform ? 20 : 0);
- if (maxcmd < 3)
- xwarnx(_("warning: screen width %d suboptimal"), win.ws_col);
+ if (maxcmd < MIN_CMD_WIDTH)
+ maxcmd = MIN_CMD_WIDTH;
if (header) {