diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-07-19 02:52:36 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-07-19 02:52:36 +0000 |
commit | ca54960f0d32763084cb9700485af46343660728 (patch) | |
tree | 8ea45ba04baad91e2071062b16e596facb488731 /usr.bin | |
parent | a373c6d4d13cb14415a0ff2585b7108090614af9 (diff) |
Figure out the tty width using TIOCGWINSZ early on. Will make tame(2)
integration easier in the future.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/kdump/kdump.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index 6fe9653bb99..4df6ae59b1f 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kdump.c,v 1.101 2015/04/18 18:28:37 deraadt Exp $ */ +/* $OpenBSD: kdump.c,v 1.102 2015/07/19 02:52:35 deraadt Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -164,6 +164,8 @@ static void clockname(int); static void sockoptlevelname(int); static void ktraceopname(int); +static int screenwidth; + int main(int argc, char *argv[]) { @@ -175,6 +177,16 @@ main(int argc, char *argv[]) def_emul = current = &emulations[0]; /* native */ + if (screenwidth == 0) { + struct winsize ws; + + if (fancy && ioctl(fileno(stderr), TIOCGWINSZ, &ws) != -1 && + ws.ws_col > 8) + screenwidth = ws.ws_col; + else + screenwidth = 80; + } + while ((ch = getopt(argc, argv, "e:f:dHlm:nRp:Tt:xX")) != -1) switch (ch) { case 'e': @@ -1177,19 +1189,9 @@ static void showbuf(unsigned char *dp, size_t datalen) { int i, j; - static int screenwidth; int col = 0, width, bpl; unsigned char visbuf[5], *cp, c; - if (screenwidth == 0) { - struct winsize ws; - - if (fancy && ioctl(fileno(stderr), TIOCGWINSZ, &ws) != -1 && - ws.ws_col > 8) - screenwidth = ws.ws_col; - else - screenwidth = 80; - } if (iohex == 1) { putchar('\t'); col = 8; |