From 8efe967018dd79aacfe3ca1e2583f115d744e466 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Mon, 15 Sep 2003 08:33:45 +0000 Subject: Be entirely consistant when using ioctl(0, TIOCGWINSZ, &winsize) to ensure proper fallback behavior on, i.e. serial consoles. -Erik --- coreutils/ls.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'coreutils/ls.c') diff --git a/coreutils/ls.c b/coreutils/ls.c index a7f036b61..727529255 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c @@ -203,7 +203,7 @@ static int is_flask_enabled_flag; #endif #ifdef CONFIG_FEATURE_AUTOWIDTH -static unsigned short terminal_width = TERMINAL_WIDTH; +static int terminal_width = TERMINAL_WIDTH; static unsigned short tabstops = COLUMN_GAP; #else #define tabstops COLUMN_GAP @@ -915,10 +915,6 @@ extern int ls_main(int argc, char **argv) is_flask_enabled_flag = is_flask_enabled(); #endif -#ifdef CONFIG_FEATURE_AUTOWIDTH - struct winsize win = { 0, 0, 0, 0 }; -#endif - all_fmt = LIST_SHORT | DISP_NORMAL | STYLE_AUTO #ifdef CONFIG_FEATURE_LS_TIMESTAMPS | TIME_MOD @@ -927,11 +923,10 @@ extern int ls_main(int argc, char **argv) | SORT_NAME | SORT_ORDER_FORWARD #endif ; -#ifdef CONFIG_FEATURE_AUTOWIDTH - ioctl(fileno(stdout), TIOCGWINSZ, &win); - if (win.ws_col > 0) - terminal_width = win.ws_col - 1; -#endif + /* Obtain the terminal width. */ + get_terminal_width_height(0, &terminal_width, NULL); + /* Go one less... */ + terminal_width--; nfiles = 0; #ifdef CONFIG_FEATURE_LS_COLOR -- cgit v1.2.3