diff options
author | Jan-Benedict Glaw <jbglaw@lug-owl.de> | 2004-07-13 19:59:40 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-07-13 19:59:40 -0700 |
commit | 7b1eb3e7cea007a1d61bc34c53e6d0adde3af3cc (patch) | |
tree | 0cff7962a355e9f2ffa6cda3ed46cc9fe6c49181 /scripts/kconfig/mconf.c | |
parent | 8b04e5149cdddd4fdea3b0307b03cecae653874a (diff) | |
download | history-7b1eb3e7cea007a1d61bc34c53e6d0adde3af3cc.tar.gz |
[PATCH] mconf.c: Honor $LINES and $COLUMNS if TIOCGWINSZ failed
While reading code, I found this buglet. If the TIOCGWINSZ fails,
mconf.c assumes 24/80 as screen size, without honoring the LINES and
COLUMNS environment variables. This is the shorter and IMHO more
correct version.
Signed-off-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'scripts/kconfig/mconf.c')
-rw-r--r-- | scripts/kconfig/mconf.c | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index b3c24cb98bfe3..6f8bf9904da98 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -87,7 +87,7 @@ static char filename[PATH_MAX+1] = ".config"; static char *args[1024], **argptr = args; static int indent; static struct termios ios_org; -static int rows, cols; +static int rows = 0, cols = 0; static struct menu *current_menu; static int child_count; static int do_resize; @@ -113,26 +113,24 @@ static void init_wsize(void) struct winsize ws; char *env; - if (ioctl(1, TIOCGWINSZ, &ws) == -1) { - rows = 24; - cols = 80; - } else { + if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) { rows = ws.ws_row; cols = ws.ws_col; - if (!rows) { - env = getenv("LINES"); - if (env) - rows = atoi(env); - if (!rows) - rows = 24; - } - if (!cols) { - env = getenv("COLUMNS"); - if (env) - cols = atoi(env); - if (!cols) - cols = 80; - } + } + + if (!rows) { + env = getenv("LINES"); + if (env) + rows = atoi(env); + if (!rows) + rows = 24; + } + if (!cols) { + env = getenv("COLUMNS"); + if (env) + cols = atoi(env); + if (!cols) + cols = 80; } if (rows < 19 || cols < 80) { |