From ca54960f0d32763084cb9700485af46343660728 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sun, 19 Jul 2015 02:52:36 +0000 Subject: Figure out the tty width using TIOCGWINSZ early on. Will make tame(2) integration easier in the future. --- usr.bin/kdump/kdump.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'usr.bin') 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; -- cgit v1.2.3