#include <time.h>
#endif
#include <string.h>
+#include <stdlib.h>
+
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/ioctl.h>
#ifndef NAJOR
#define MAJOR(dev) (((dev)>>8)&0xff)
static unsigned short column_width;
static unsigned short tabstops;
#else
-# define column_width COLUMN_WIDTH
+static unsigned short column_width = COLUMN_WIDTH;
#endif
static int status = EXIT_SUCCESS;
int opt;
int oi, ac;
char **av;
+#ifdef BB_FEATURE_AUTOWIDTH
+ struct winsize win = { 0, 0, 0, 0 };
+#endif
disp_opts= DISP_NORMAL;
style_fmt= STYLE_AUTO;
time_fmt= TIME_MOD;
#endif
#ifdef BB_FEATURE_AUTOWIDTH
- terminal_width = TERMINAL_WIDTH;
- column_width = COLUMN_WIDTH;
- tabstops = 8;
+ ioctl(fileno(stdout), TIOCGWINSZ, &win);
+ if (win.ws_row > 4)
+ column_width = win.ws_row - 2;
+ if (win.ws_col > 0)
+ terminal_width = win.ws_col - 1;
#endif
+ tabstops = 8;
nfiles=0;
/* process options */
showdirs(dnd, dndirs);
}
}
-
return(status);
print_usage_message: