[BusyBox-cvs] busybox/coreutils ls.c,1.99,1.100

Erik Andersen andersen at busybox.net
Mon Sep 15 08:33:38 UTC 2003


Update of /var/cvs/busybox/coreutils
In directory winder:/tmp/cvs-serv10511/coreutils

Modified Files:
	ls.c 
Log Message:
Be entirely consistant when using ioctl(0, TIOCGWINSZ, &winsize)
to ensure proper fallback behavior on, i.e. serial consoles.
 -Erik


Index: ls.c
===================================================================
RCS file: /var/cvs/busybox/coreutils/ls.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -d -r1.99 -r1.100
--- ls.c	14 Jul 2003 19:20:46 -0000	1.99
+++ ls.c	15 Sep 2003 08:33:34 -0000	1.100
@@ -203,7 +203,7 @@
 #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 @@
 	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 @@
 		| 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




More information about the busybox-cvs mailing list