diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2007-04-04 13:59:49 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2007-04-04 13:59:49 +0000 |
commit | 3a60244ae94782a1a4065685cf6e7867cc306a25 (patch) | |
tree | 7dca211ac722c96544c571bf7f09a6756767c222 | |
parent | 0e6ab01c5a525fc0e298d44f4573a4f8972406f2 (diff) | |
download | busybox-w32-3a60244ae94782a1a4065685cf6e7867cc306a25.tar.gz busybox-w32-3a60244ae94782a1a4065685cf6e7867cc306a25.tar.bz2 busybox-w32-3a60244ae94782a1a4065685cf6e7867cc306a25.zip |
- 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
-rw-r--r-- | coreutils/stty.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/coreutils/stty.c b/coreutils/stty.c index 15cb05293..b13f1fb28 100644 --- a/coreutils/stty.c +++ b/coreutils/stty.c | |||
@@ -375,17 +375,22 @@ enum { | |||
375 | }; | 375 | }; |
376 | 376 | ||
377 | /* The width of the screen, for output wrapping */ | 377 | /* The width of the screen, for output wrapping */ |
378 | static unsigned max_col = 80; /* default */ | 378 | unsigned max_col = 80; /* default */ |
379 | /* Current position, to know when to wrap */ | 379 | |
380 | static unsigned current_col; | 380 | struct globals { |
381 | /* Current position, to know when to wrap */ | ||
382 | unsigned current_col; | ||
383 | char buf[10]; | ||
384 | }; | ||
385 | #define G (*(struct globals*)&bb_common_bufsiz1) | ||
386 | |||
381 | static const char *device_name = bb_msg_standard_input; | 387 | static const char *device_name = bb_msg_standard_input; |
382 | 388 | ||
383 | /* Return a string that is the printable representation of character CH */ | 389 | /* Return a string that is the printable representation of character CH */ |
384 | /* Adapted from 'cat' by Torbjorn Granlund */ | 390 | /* Adapted from 'cat' by Torbjorn Granlund */ |
385 | static const char *visible(unsigned int ch) | 391 | static const char *visible(unsigned int ch) |
386 | { | 392 | { |
387 | static char buf[10]; | 393 | char *bpout = G.buf; |
388 | char *bpout = buf; | ||
389 | 394 | ||
390 | if (ch == _POSIX_VDISABLE) | 395 | if (ch == _POSIX_VDISABLE) |
391 | return "<undef>"; | 396 | return "<undef>"; |
@@ -407,7 +412,7 @@ static const char *visible(unsigned int ch) | |||
407 | } | 412 | } |
408 | 413 | ||
409 | *bpout = '\0'; | 414 | *bpout = '\0'; |
410 | return buf; | 415 | return G.buf; |
411 | } | 416 | } |
412 | 417 | ||
413 | static tcflag_t *mode_type_flag(unsigned type, const struct termios *mode) | 418 | static tcflag_t *mode_type_flag(unsigned type, const struct termios *mode) |
@@ -466,20 +471,20 @@ static void wrapf(const char *message, ...) | |||
466 | somebody failed to adhere to this assumption just to be sure. */ | 471 | somebody failed to adhere to this assumption just to be sure. */ |
467 | if (!buflen || buflen >= sizeof(buf)) return; | 472 | if (!buflen || buflen >= sizeof(buf)) return; |
468 | 473 | ||
469 | if (current_col > 0) { | 474 | if (G.current_col > 0) { |
470 | current_col++; | 475 | G.current_col++; |
471 | if (buf[0] != '\n') { | 476 | if (buf[0] != '\n') { |
472 | if (current_col + buflen >= max_col) { | 477 | if (G.current_col + buflen >= max_col) { |
473 | putchar('\n'); | 478 | putchar('\n'); |
474 | current_col = 0; | 479 | G.current_col = 0; |
475 | } else | 480 | } else |
476 | putchar(' '); | 481 | putchar(' '); |
477 | } | 482 | } |
478 | } | 483 | } |
479 | fputs(buf, stdout); | 484 | fputs(buf, stdout); |
480 | current_col += buflen; | 485 | G.current_col += buflen; |
481 | if (buf[buflen-1] == '\n') | 486 | if (buf[buflen-1] == '\n') |
482 | current_col = 0; | 487 | G.current_col = 0; |
483 | } | 488 | } |
484 | 489 | ||
485 | static void set_window_size(const int rows, const int cols) | 490 | static void set_window_size(const int rows, const int cols) |
@@ -567,8 +572,8 @@ static int find_param(const char * const name) | |||
567 | "ospeed", | 572 | "ospeed", |
568 | NULL | 573 | NULL |
569 | }; | 574 | }; |
570 | int i = index_in_str_array(params, name); | 575 | smalluint i = index_in_str_array(params, name) + 1; |
571 | if (i < 0) | 576 | if (i == 0) |
572 | return 0; | 577 | return 0; |
573 | if (!(i == 4 || i == 5)) | 578 | if (!(i == 4 || i == 5)) |
574 | i |= 0x80; | 579 | i |= 0x80; |
@@ -669,14 +674,14 @@ static void do_display(const struct termios *mode, const int all) | |||
669 | if ((mode->c_lflag & ICANON) == 0) | 674 | if ((mode->c_lflag & ICANON) == 0) |
670 | #endif | 675 | #endif |
671 | wrapf("min = %d; time = %d;", mode->c_cc[VMIN], mode->c_cc[VTIME]); | 676 | wrapf("min = %d; time = %d;", mode->c_cc[VMIN], mode->c_cc[VTIME]); |
672 | if (current_col) wrapf("\n"); | 677 | if (G.current_col) wrapf("\n"); |
673 | 678 | ||
674 | for (i = 0; i < NUM_mode_info; ++i) { | 679 | for (i = 0; i < NUM_mode_info; ++i) { |
675 | if (mode_info[i].flags & OMIT) | 680 | if (mode_info[i].flags & OMIT) |
676 | continue; | 681 | continue; |
677 | if (mode_info[i].type != prev_type) { | 682 | if (mode_info[i].type != prev_type) { |
678 | /* wrapf("\n"); */ | 683 | /* wrapf("\n"); */ |
679 | if (current_col) wrapf("\n"); | 684 | if (G.current_col) wrapf("\n"); |
680 | prev_type = mode_info[i].type; | 685 | prev_type = mode_info[i].type; |
681 | } | 686 | } |
682 | 687 | ||
@@ -692,7 +697,7 @@ static void do_display(const struct termios *mode, const int all) | |||
692 | wrapf("-%s", mode_info[i].name); | 697 | wrapf("-%s", mode_info[i].name); |
693 | } | 698 | } |
694 | } | 699 | } |
695 | if (current_col) wrapf("\n"); | 700 | if (G.current_col) wrapf("\n"); |
696 | } | 701 | } |
697 | 702 | ||
698 | static void sane_mode(struct termios *mode) | 703 | static void sane_mode(struct termios *mode) |