summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorEric Andersen2003-09-15 08:33:45 +0000
committerEric Andersen2003-09-15 08:33:45 +0000
commit8efe967018dd79aacfe3ca1e2583f115d744e466 (patch)
tree7590704be6cf03c87242043f5909e12eb4150356 /coreutils
parentc4f72d1426e03f046ac54a00d733a4a52c3a5d4b (diff)
downloadbusybox-8efe967018dd79aacfe3ca1e2583f115d744e466.zip
busybox-8efe967018dd79aacfe3ca1e2583f115d744e466.tar.gz
Be entirely consistant when using ioctl(0, TIOCGWINSZ, &winsize)
to ensure proper fallback behavior on, i.e. serial consoles. -Erik
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/ls.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/coreutils/ls.c b/coreutils/ls.c
index a7f036b..7275292 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