- remove some bss users.

text    data     bss     dec     hex filename
   6220       8      14    6242    1862 stty.o.oorig
   6219       8       0    6227    1853 stty.o
This commit is contained in:
Bernhard Reutner-Fischer 2007-04-04 13:59:49 +00:00
parent 0e6ab01c5a
commit 3a60244ae9

View File

@ -375,17 +375,22 @@ enum {
}; };
/* The width of the screen, for output wrapping */ /* The width of the screen, for output wrapping */
static unsigned max_col = 80; /* default */ unsigned max_col = 80; /* default */
/* Current position, to know when to wrap */
static unsigned current_col; struct globals {
/* Current position, to know when to wrap */
unsigned current_col;
char buf[10];
};
#define G (*(struct globals*)&bb_common_bufsiz1)
static const char *device_name = bb_msg_standard_input; static const char *device_name = bb_msg_standard_input;
/* Return a string that is the printable representation of character CH */ /* Return a string that is the printable representation of character CH */
/* Adapted from 'cat' by Torbjorn Granlund */ /* Adapted from 'cat' by Torbjorn Granlund */
static const char *visible(unsigned int ch) static const char *visible(unsigned int ch)
{ {
static char buf[10]; char *bpout = G.buf;
char *bpout = buf;
if (ch == _POSIX_VDISABLE) if (ch == _POSIX_VDISABLE)
return "<undef>"; return "<undef>";
@ -407,7 +412,7 @@ static const char *visible(unsigned int ch)
} }
*bpout = '\0'; *bpout = '\0';
return buf; return G.buf;
} }
static tcflag_t *mode_type_flag(unsigned type, const struct termios *mode) static tcflag_t *mode_type_flag(unsigned type, const struct termios *mode)
@ -466,20 +471,20 @@ static void wrapf(const char *message, ...)
somebody failed to adhere to this assumption just to be sure. */ somebody failed to adhere to this assumption just to be sure. */
if (!buflen || buflen >= sizeof(buf)) return; if (!buflen || buflen >= sizeof(buf)) return;
if (current_col > 0) { if (G.current_col > 0) {
current_col++; G.current_col++;
if (buf[0] != '\n') { if (buf[0] != '\n') {
if (current_col + buflen >= max_col) { if (G.current_col + buflen >= max_col) {
putchar('\n'); putchar('\n');
current_col = 0; G.current_col = 0;
} else } else
putchar(' '); putchar(' ');
} }
} }
fputs(buf, stdout); fputs(buf, stdout);
current_col += buflen; G.current_col += buflen;
if (buf[buflen-1] == '\n') if (buf[buflen-1] == '\n')
current_col = 0; G.current_col = 0;
} }
static void set_window_size(const int rows, const int cols) static void set_window_size(const int rows, const int cols)
@ -567,8 +572,8 @@ static int find_param(const char * const name)
"ospeed", "ospeed",
NULL NULL
}; };
int i = index_in_str_array(params, name); smalluint i = index_in_str_array(params, name) + 1;
if (i < 0) if (i == 0)
return 0; return 0;
if (!(i == 4 || i == 5)) if (!(i == 4 || i == 5))
i |= 0x80; i |= 0x80;
@ -669,14 +674,14 @@ static void do_display(const struct termios *mode, const int all)
if ((mode->c_lflag & ICANON) == 0) if ((mode->c_lflag & ICANON) == 0)
#endif #endif
wrapf("min = %d; time = %d;", mode->c_cc[VMIN], mode->c_cc[VTIME]); wrapf("min = %d; time = %d;", mode->c_cc[VMIN], mode->c_cc[VTIME]);
if (current_col) wrapf("\n"); if (G.current_col) wrapf("\n");
for (i = 0; i < NUM_mode_info; ++i) { for (i = 0; i < NUM_mode_info; ++i) {
if (mode_info[i].flags & OMIT) if (mode_info[i].flags & OMIT)
continue; continue;
if (mode_info[i].type != prev_type) { if (mode_info[i].type != prev_type) {
/* wrapf("\n"); */ /* wrapf("\n"); */
if (current_col) wrapf("\n"); if (G.current_col) wrapf("\n");
prev_type = mode_info[i].type; prev_type = mode_info[i].type;
} }
@ -692,7 +697,7 @@ static void do_display(const struct termios *mode, const int all)
wrapf("-%s", mode_info[i].name); wrapf("-%s", mode_info[i].name);
} }
} }
if (current_col) wrapf("\n"); if (G.current_col) wrapf("\n");
} }
static void sane_mode(struct termios *mode) static void sane_mode(struct termios *mode)