diff options
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/hdparm.c | 113 | ||||
-rw-r--r-- | miscutils/less.c | 14 | ||||
-rw-r--r-- | miscutils/mountpoint.c | 2 | ||||
-rw-r--r-- | miscutils/strings.c | 4 | ||||
-rw-r--r-- | miscutils/time.c | 19 | ||||
-rw-r--r-- | miscutils/ttysize.c | 2 |
6 files changed, 71 insertions, 83 deletions
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index b3c240835..396328f72 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
@@ -482,19 +482,43 @@ static void print_value_on_off(const char *str, unsigned long argp) | |||
482 | } | 482 | } |
483 | 483 | ||
484 | #if ENABLE_FEATURE_HDPARM_GET_IDENTITY | 484 | #if ENABLE_FEATURE_HDPARM_GET_IDENTITY |
485 | static void print_ascii(uint16_t *p, uint8_t length); | 485 | static void print_ascii(const char *p, int length) |
486 | { | ||
487 | #if BB_BIG_ENDIAN | ||
488 | #define LE_ONLY(x) | ||
489 | enum { ofs = 0 }; | ||
490 | #else | ||
491 | #define LE_ONLY(x) x | ||
492 | /* every 16bit word is big-endian (i.e. inverted) */ | ||
493 | /* accessing bytes in 1,0, 3,2, 5,4... sequence */ | ||
494 | int ofs = 1; | ||
495 | #endif | ||
496 | |||
497 | length *= 2; | ||
498 | /* find first non-space & print it */ | ||
499 | while (length && p[ofs] != ' ') { | ||
500 | p++; | ||
501 | LE_ONLY(ofs = -ofs;) | ||
502 | length--; | ||
503 | } | ||
504 | while (length && p[ofs]) { | ||
505 | bb_putchar(p[ofs]); | ||
506 | p++; | ||
507 | LE_ONLY(ofs = -ofs;) | ||
508 | length--; | ||
509 | } | ||
510 | bb_putchar('\n'); | ||
511 | #undef LE_ONLY | ||
512 | } | ||
486 | 513 | ||
487 | static void xprint_ascii(uint16_t *val, int i, const char *string, int n) | 514 | static void xprint_ascii(uint16_t *val, int i, const char *string, int n) |
488 | { | 515 | { |
489 | if (val[i]) { | 516 | if (val[i]) { |
490 | printf("\t%-20s", string); | 517 | printf("\t%-20s", string); |
491 | print_ascii(&val[i], n); | 518 | print_ascii((void*)&val[i], n); |
492 | } | 519 | } |
493 | } | 520 | } |
494 | #endif | ||
495 | /* end of busybox specific stuff */ | ||
496 | 521 | ||
497 | #if ENABLE_FEATURE_HDPARM_GET_IDENTITY | ||
498 | static uint8_t mode_loop(uint16_t mode_sup, uint16_t mode_sel, int cc, uint8_t *have_mode) | 522 | static uint8_t mode_loop(uint16_t mode_sup, uint16_t mode_sel, int cc, uint8_t *have_mode) |
499 | { | 523 | { |
500 | uint16_t ii; | 524 | uint16_t ii; |
@@ -515,41 +539,11 @@ static uint8_t mode_loop(uint16_t mode_sup, uint16_t mode_sel, int cc, uint8_t * | |||
515 | return err_dma; | 539 | return err_dma; |
516 | } | 540 | } |
517 | 541 | ||
518 | static void print_ascii(uint16_t *p, uint8_t length) | ||
519 | { | ||
520 | uint8_t ii; | ||
521 | char cl; | ||
522 | |||
523 | /* find first non-space & print it */ | ||
524 | for (ii = 0; ii < length; ii++) { | ||
525 | if ((char)((*p)>>8) != ' ') | ||
526 | break; | ||
527 | cl = (char)(*p); | ||
528 | if (cl != ' ') { | ||
529 | if (cl != '\0') | ||
530 | printf("%c", cl); | ||
531 | p++; | ||
532 | ii++; | ||
533 | break; | ||
534 | } | ||
535 | p++; | ||
536 | } | ||
537 | /* print the rest */ | ||
538 | for (; ii< length; ii++) { | ||
539 | if (!(*p)) | ||
540 | break; /* some older devices have NULLs */ | ||
541 | printf("%c%c", (char)((*p)>>8), (char)(*p)); | ||
542 | p++; | ||
543 | } | ||
544 | puts(""); | ||
545 | } | ||
546 | |||
547 | // Parse 512 byte disk identification block and print much crap. | 542 | // Parse 512 byte disk identification block and print much crap. |
548 | 543 | ||
549 | static void identify(uint16_t *id_supplied) | 544 | static void identify(uint16_t *val) |
550 | { | 545 | { |
551 | uint16_t buf[256]; | 546 | uint16_t ii, jj, kk; |
552 | uint16_t *val, ii, jj, kk; | ||
553 | uint16_t like_std = 1, std = 0, min_std = 0xffff; | 547 | uint16_t like_std = 1, std = 0, min_std = 0xffff; |
554 | uint16_t dev = NO_DEV, eqpt = NO_DEV; | 548 | uint16_t dev = NO_DEV, eqpt = NO_DEV; |
555 | uint8_t have_mode = 0, err_dma = 0; | 549 | uint8_t have_mode = 0, err_dma = 0; |
@@ -557,19 +551,15 @@ static void identify(uint16_t *id_supplied) | |||
557 | uint32_t ll, mm, nn, oo; | 551 | uint32_t ll, mm, nn, oo; |
558 | uint64_t bbbig; /* (:) */ | 552 | uint64_t bbbig; /* (:) */ |
559 | const char *strng; | 553 | const char *strng; |
554 | #if BB_BIG_ENDIAN | ||
555 | uint16_t buf[256]; | ||
560 | 556 | ||
561 | // Adjust for endianness if necessary. | 557 | // Adjust for endianness |
562 | 558 | swab(val, buf, sizeof(buf)); | |
563 | if (BB_BIG_ENDIAN) { | 559 | val = buf; |
564 | swab(id_supplied, buf, sizeof(buf)); | 560 | #endif |
565 | val = buf; | ||
566 | } else | ||
567 | val = id_supplied; | ||
568 | |||
569 | chksum &= 0xff; | ||
570 | |||
571 | /* check if we recognise the device type */ | 561 | /* check if we recognise the device type */ |
572 | puts(""); | 562 | bb_putchar('\n'); |
573 | if (!(val[GEN_CONFIG] & NOT_ATA)) { | 563 | if (!(val[GEN_CONFIG] & NOT_ATA)) { |
574 | dev = ATA_DEV; | 564 | dev = ATA_DEV; |
575 | printf("ATA device, with "); | 565 | printf("ATA device, with "); |
@@ -686,7 +676,7 @@ static void identify(uint16_t *id_supplied) | |||
686 | else if (like_std > std) | 676 | else if (like_std > std) |
687 | printf("& some of %u\n", like_std); | 677 | printf("& some of %u\n", like_std); |
688 | else | 678 | else |
689 | puts(""); | 679 | bb_putchar('\n'); |
690 | } else { | 680 | } else { |
691 | /* TBD: do CDROM stuff more thoroughly. For now... */ | 681 | /* TBD: do CDROM stuff more thoroughly. For now... */ |
692 | kk = 0; | 682 | kk = 0; |
@@ -786,7 +776,7 @@ static void identify(uint16_t *id_supplied) | |||
786 | if (bbbig > 1000) | 776 | if (bbbig > 1000) |
787 | printf("(%"PRIu64" GB)\n", bbbig/1000); | 777 | printf("(%"PRIu64" GB)\n", bbbig/1000); |
788 | else | 778 | else |
789 | puts(""); | 779 | bb_putchar('\n'); |
790 | } | 780 | } |
791 | 781 | ||
792 | /* hw support of commands (capabilities) */ | 782 | /* hw support of commands (capabilities) */ |
@@ -829,7 +819,7 @@ static void identify(uint16_t *id_supplied) | |||
829 | if ((like_std > 3) && ((val[CAPAB_1] & VALID) == VALID_VAL)) | 819 | if ((like_std > 3) && ((val[CAPAB_1] & VALID) == VALID_VAL)) |
830 | printf(", %s device specific minimum\n", (val[CAPAB_1] & MIN_STANDBY_TIMER) ? "with" : "no"); | 820 | printf(", %s device specific minimum\n", (val[CAPAB_1] & MIN_STANDBY_TIMER) ? "with" : "no"); |
831 | else | 821 | else |
832 | puts(""); | 822 | bb_putchar('\n'); |
833 | } | 823 | } |
834 | printf("\tR/W multiple sector transfer: "); | 824 | printf("\tR/W multiple sector transfer: "); |
835 | if ((like_std < 3) && !(val[SECTOR_XFER_MAX] & SECTOR_XFER)) | 825 | if ((like_std < 3) && !(val[SECTOR_XFER_MAX] & SECTOR_XFER)) |
@@ -866,7 +856,7 @@ static void identify(uint16_t *id_supplied) | |||
866 | printf("\tOverlap support:"); | 856 | printf("\tOverlap support:"); |
867 | if (val[PKT_REL]) printf(" %uus to release bus.", val[PKT_REL]); | 857 | if (val[PKT_REL]) printf(" %uus to release bus.", val[PKT_REL]); |
868 | if (val[SVC_NBSY]) printf(" %uus to clear BSY after SERVICE cmd.", val[SVC_NBSY]); | 858 | if (val[SVC_NBSY]) printf(" %uus to clear BSY after SERVICE cmd.", val[SVC_NBSY]); |
869 | puts(""); | 859 | bb_putchar('\n'); |
870 | } | 860 | } |
871 | } | 861 | } |
872 | 862 | ||
@@ -893,7 +883,7 @@ static void identify(uint16_t *id_supplied) | |||
893 | err_dma += mode_loop(jj, kk, 'u', &have_mode); | 883 | err_dma += mode_loop(jj, kk, 'u', &have_mode); |
894 | } | 884 | } |
895 | if (err_dma || !have_mode) printf("(?)"); | 885 | if (err_dma || !have_mode) printf("(?)"); |
896 | puts(""); | 886 | bb_putchar('\n'); |
897 | 887 | ||
898 | if ((dev == ATAPI_DEV) && (eqpt != CDROM) && (val[CAPAB_0] & DMA_IL_SUP)) | 888 | if ((dev == ATAPI_DEV) && (eqpt != CDROM) && (val[CAPAB_0] & DMA_IL_SUP)) |
899 | printf("\t\tInterleaved DMA support\n"); | 889 | printf("\t\tInterleaved DMA support\n"); |
@@ -904,7 +894,7 @@ static void identify(uint16_t *id_supplied) | |||
904 | printf("\t\tCycle time:"); | 894 | printf("\t\tCycle time:"); |
905 | if (val[DMA_TIME_MIN]) printf(" min=%uns", val[DMA_TIME_MIN]); | 895 | if (val[DMA_TIME_MIN]) printf(" min=%uns", val[DMA_TIME_MIN]); |
906 | if (val[DMA_TIME_NORM]) printf(" recommended=%uns", val[DMA_TIME_NORM]); | 896 | if (val[DMA_TIME_NORM]) printf(" recommended=%uns", val[DMA_TIME_NORM]); |
907 | puts(""); | 897 | bb_putchar('\n'); |
908 | } | 898 | } |
909 | } | 899 | } |
910 | 900 | ||
@@ -918,11 +908,11 @@ static void identify(uint16_t *id_supplied) | |||
918 | if (jj & 0x0001) printf("pio%d ", ii); | 908 | if (jj & 0x0001) printf("pio%d ", ii); |
919 | jj >>=1; | 909 | jj >>=1; |
920 | } | 910 | } |
921 | puts(""); | 911 | bb_putchar('\n'); |
922 | } else if (((min_std < 5) || (eqpt == CDROM)) && (val[PIO_MODE] & MODE)) { | 912 | } else if (((min_std < 5) || (eqpt == CDROM)) && (val[PIO_MODE] & MODE)) { |
923 | for (ii = 0; ii <= val[PIO_MODE]>>8; ii++) | 913 | for (ii = 0; ii <= val[PIO_MODE]>>8; ii++) |
924 | printf("pio%d ", ii); | 914 | printf("pio%d ", ii); |
925 | puts(""); | 915 | bb_putchar('\n'); |
926 | } else | 916 | } else |
927 | printf("unknown\n"); | 917 | printf("unknown\n"); |
928 | 918 | ||
@@ -931,7 +921,7 @@ static void identify(uint16_t *id_supplied) | |||
931 | printf("\t\tCycle time:"); | 921 | printf("\t\tCycle time:"); |
932 | if (val[PIO_NO_FLOW]) printf(" no flow control=%uns", val[PIO_NO_FLOW]); | 922 | if (val[PIO_NO_FLOW]) printf(" no flow control=%uns", val[PIO_NO_FLOW]); |
933 | if (val[PIO_FLOW]) printf(" IORDY flow control=%uns", val[PIO_FLOW]); | 923 | if (val[PIO_FLOW]) printf(" IORDY flow control=%uns", val[PIO_FLOW]); |
934 | puts(""); | 924 | bb_putchar('\n'); |
935 | } | 925 | } |
936 | } | 926 | } |
937 | 927 | ||
@@ -982,7 +972,7 @@ static void identify(uint16_t *id_supplied) | |||
982 | printf("\t"); | 972 | printf("\t"); |
983 | if (jj) printf("%umin for %sSECURITY ERASE UNIT. ", jj==ERASE_BITS ? 508 : jj<<1, ""); | 973 | if (jj) printf("%umin for %sSECURITY ERASE UNIT. ", jj==ERASE_BITS ? 508 : jj<<1, ""); |
984 | if (kk) printf("%umin for %sSECURITY ERASE UNIT. ", kk==ERASE_BITS ? 508 : kk<<1, "ENHANCED "); | 974 | if (kk) printf("%umin for %sSECURITY ERASE UNIT. ", kk==ERASE_BITS ? 508 : kk<<1, "ENHANCED "); |
985 | puts(""); | 975 | bb_putchar('\n'); |
986 | } | 976 | } |
987 | } | 977 | } |
988 | 978 | ||
@@ -1134,7 +1124,7 @@ static void dump_identity(const struct hd_driveid *id) | |||
1134 | else | 1124 | else |
1135 | printf("off"); | 1125 | printf("off"); |
1136 | } | 1126 | } |
1137 | puts(""); | 1127 | bb_putchar('\n'); |
1138 | 1128 | ||
1139 | if (!(id->field_valid & 1)) | 1129 | if (!(id->field_valid & 1)) |
1140 | printf(" (maybe):"); | 1130 | printf(" (maybe):"); |
@@ -1905,7 +1895,7 @@ static void parse_xfermode(int flag, smallint *get, smallint *set, int *value) | |||
1905 | 1895 | ||
1906 | /*------- getopt short options --------*/ | 1896 | /*------- getopt short options --------*/ |
1907 | static const char hdparm_options[] ALIGN1 = | 1897 | static const char hdparm_options[] ALIGN1 = |
1908 | "gfu::n::p:r::m::c::k::a::B:tTh" | 1898 | "gfu::n::p:r::m::c::k::a::B:tT" |
1909 | USE_FEATURE_HDPARM_GET_IDENTITY("iI") | 1899 | USE_FEATURE_HDPARM_GET_IDENTITY("iI") |
1910 | USE_FEATURE_HDPARM_HDIO_GETSET_DMA("d::") | 1900 | USE_FEATURE_HDPARM_HDIO_GETSET_DMA("d::") |
1911 | #ifdef HDIO_DRIVE_CMD | 1901 | #ifdef HDIO_DRIVE_CMD |
@@ -1933,7 +1923,6 @@ int hdparm_main(int argc, char **argv) | |||
1933 | 1923 | ||
1934 | while ((c = getopt(argc, argv, hdparm_options)) >= 0) { | 1924 | while ((c = getopt(argc, argv, hdparm_options)) >= 0) { |
1935 | flagcount++; | 1925 | flagcount++; |
1936 | if (c == 'h') bb_show_usage(); /* EXIT */ | ||
1937 | USE_FEATURE_HDPARM_GET_IDENTITY(get_IDentity |= (c == 'I')); | 1926 | USE_FEATURE_HDPARM_GET_IDENTITY(get_IDentity |= (c == 'I')); |
1938 | USE_FEATURE_HDPARM_GET_IDENTITY(get_identity |= (c == 'i')); | 1927 | USE_FEATURE_HDPARM_GET_IDENTITY(get_identity |= (c == 'i')); |
1939 | get_geom |= (c == 'g'); | 1928 | get_geom |= (c == 'g'); |
@@ -1999,7 +1988,7 @@ int hdparm_main(int argc, char **argv) | |||
1999 | if (!*argv) { | 1988 | if (!*argv) { |
2000 | if (ENABLE_FEATURE_HDPARM_GET_IDENTITY && !isatty(STDIN_FILENO)) | 1989 | if (ENABLE_FEATURE_HDPARM_GET_IDENTITY && !isatty(STDIN_FILENO)) |
2001 | identify_from_stdin(); /* EXIT */ | 1990 | identify_from_stdin(); /* EXIT */ |
2002 | else bb_show_usage(); | 1991 | bb_show_usage(); |
2003 | } | 1992 | } |
2004 | 1993 | ||
2005 | do { | 1994 | do { |
diff --git a/miscutils/less.c b/miscutils/less.c index a2221cfca..ec9c00f24 100644 --- a/miscutils/less.c +++ b/miscutils/less.c | |||
@@ -173,7 +173,7 @@ static void less_exit(int code) | |||
173 | * and restore it when we exit. Less does this with the | 173 | * and restore it when we exit. Less does this with the |
174 | * "ti" and "te" termcap commands; can this be done with | 174 | * "ti" and "te" termcap commands; can this be done with |
175 | * only termios.h? */ | 175 | * only termios.h? */ |
176 | putchar('\n'); | 176 | bb_putchar('\n'); |
177 | fflush_stdout_and_exit(code); | 177 | fflush_stdout_and_exit(code); |
178 | } | 178 | } |
179 | 179 | ||
@@ -419,7 +419,7 @@ static void status_print(void) | |||
419 | 419 | ||
420 | clear_line(); | 420 | clear_line(); |
421 | if (cur_fline && cur_fline < max_fline - max_displayed_line) { | 421 | if (cur_fline && cur_fline < max_fline - max_displayed_line) { |
422 | putchar(':'); | 422 | bb_putchar(':'); |
423 | return; | 423 | return; |
424 | } | 424 | } |
425 | p = "(END)"; | 425 | p = "(END)"; |
@@ -755,7 +755,7 @@ static char* less_gets(int sz) | |||
755 | continue; | 755 | continue; |
756 | if (i >= width - sz - 1) | 756 | if (i >= width - sz - 1) |
757 | continue; /* len limit */ | 757 | continue; /* len limit */ |
758 | putchar(c); | 758 | bb_putchar(c); |
759 | result[i++] = c; | 759 | result[i++] = c; |
760 | result = xrealloc(result, i+1); | 760 | result = xrealloc(result, i+1); |
761 | result[i] = '\0'; | 761 | result[i] = '\0'; |
@@ -916,7 +916,7 @@ static void regex_process(void) | |||
916 | 916 | ||
917 | /* Get the uncompiled regular expression from the user */ | 917 | /* Get the uncompiled regular expression from the user */ |
918 | clear_line(); | 918 | clear_line(); |
919 | putchar((option_mask32 & LESS_STATE_MATCH_BACKWARDS) ? '?' : '/'); | 919 | bb_putchar((option_mask32 & LESS_STATE_MATCH_BACKWARDS) ? '?' : '/'); |
920 | uncomp_regex = less_gets(1); | 920 | uncomp_regex = less_gets(1); |
921 | if (!uncomp_regex[0]) { | 921 | if (!uncomp_regex[0]) { |
922 | free(uncomp_regex); | 922 | free(uncomp_regex); |
@@ -969,7 +969,7 @@ static void number_process(int first_digit) | |||
969 | num_input[i] = less_getch(); | 969 | num_input[i] = less_getch(); |
970 | if (!num_input[i] || !isdigit(num_input[i])) | 970 | if (!num_input[i] || !isdigit(num_input[i])) |
971 | break; | 971 | break; |
972 | putchar(num_input[i]); | 972 | bb_putchar(num_input[i]); |
973 | i++; | 973 | i++; |
974 | } | 974 | } |
975 | 975 | ||
@@ -1024,7 +1024,7 @@ static void flag_change(void) | |||
1024 | int keypress; | 1024 | int keypress; |
1025 | 1025 | ||
1026 | clear_line(); | 1026 | clear_line(); |
1027 | putchar('-'); | 1027 | bb_putchar('-'); |
1028 | keypress = less_getch(); | 1028 | keypress = less_getch(); |
1029 | 1029 | ||
1030 | switch (keypress) { | 1030 | switch (keypress) { |
@@ -1049,7 +1049,7 @@ static void show_flag_status(void) | |||
1049 | int flag_val; | 1049 | int flag_val; |
1050 | 1050 | ||
1051 | clear_line(); | 1051 | clear_line(); |
1052 | putchar('_'); | 1052 | bb_putchar('_'); |
1053 | keypress = less_getch(); | 1053 | keypress = less_getch(); |
1054 | 1054 | ||
1055 | switch (keypress) { | 1055 | switch (keypress) { |
diff --git a/miscutils/mountpoint.c b/miscutils/mountpoint.c index 1f17adadc..0f1e155ae 100644 --- a/miscutils/mountpoint.c +++ b/miscutils/mountpoint.c | |||
@@ -34,7 +34,7 @@ int mountpoint_main(int argc, char **argv) | |||
34 | return EXIT_SUCCESS; | 34 | return EXIT_SUCCESS; |
35 | } else { | 35 | } else { |
36 | if (opt & OPT_q) | 36 | if (opt & OPT_q) |
37 | putchar('\n'); | 37 | bb_putchar('\n'); |
38 | else | 38 | else |
39 | bb_error_msg("%s: not a block device", arg); | 39 | bb_error_msg("%s: not a block device", arg); |
40 | } | 40 | } |
diff --git a/miscutils/strings.c b/miscutils/strings.c index 835880214..b7f5a0b57 100644 --- a/miscutils/strings.c +++ b/miscutils/strings.c | |||
@@ -56,7 +56,7 @@ int strings_main(int argc, char **argv) | |||
56 | c = fgetc(file); | 56 | c = fgetc(file); |
57 | if (isprint(c) || c == '\t') { | 57 | if (isprint(c) || c == '\t') { |
58 | if (count > n) { | 58 | if (count > n) { |
59 | putchar(c); | 59 | bb_putchar(c); |
60 | } else { | 60 | } else { |
61 | string[count] = c; | 61 | string[count] = c; |
62 | if (count == n) { | 62 | if (count == n) { |
@@ -72,7 +72,7 @@ int strings_main(int argc, char **argv) | |||
72 | } | 72 | } |
73 | } else { | 73 | } else { |
74 | if (count > n) { | 74 | if (count > n) { |
75 | putchar('\n'); | 75 | bb_putchar('\n'); |
76 | } | 76 | } |
77 | count = 0; | 77 | count = 0; |
78 | } | 78 | } |
diff --git a/miscutils/time.c b/miscutils/time.c index e8473f702..8f79a51ec 100644 --- a/miscutils/time.c +++ b/miscutils/time.c | |||
@@ -188,8 +188,6 @@ static void summarize(const char *fmt, char **command, resource_t * resp) | |||
188 | #endif | 188 | #endif |
189 | if (!cpu_ticks) cpu_ticks = 1; /* we divide by it, must be nonzero */ | 189 | if (!cpu_ticks) cpu_ticks = 1; /* we divide by it, must be nonzero */ |
190 | 190 | ||
191 | /* putchar() != putc(stdout) in glibc! */ | ||
192 | |||
193 | while (*fmt) { | 191 | while (*fmt) { |
194 | /* Handle leading literal part */ | 192 | /* Handle leading literal part */ |
195 | int n = strcspn(fmt, "%\\"); | 193 | int n = strcspn(fmt, "%\\"); |
@@ -205,7 +203,7 @@ static void summarize(const char *fmt, char **command, resource_t * resp) | |||
205 | /* Usually we optimize for size, but there is a limit | 203 | /* Usually we optimize for size, but there is a limit |
206 | * for everything. With this we do a lot of 1-byte writes */ | 204 | * for everything. With this we do a lot of 1-byte writes */ |
207 | default: | 205 | default: |
208 | putc(*fmt, stdout); | 206 | bb_putchar(*fmt); |
209 | break; | 207 | break; |
210 | #endif | 208 | #endif |
211 | 209 | ||
@@ -215,11 +213,11 @@ static void summarize(const char *fmt, char **command, resource_t * resp) | |||
215 | /* Our format strings do not have these */ | 213 | /* Our format strings do not have these */ |
216 | /* and we do not take format str from user */ | 214 | /* and we do not take format str from user */ |
217 | default: | 215 | default: |
218 | putc('%', stdout); | 216 | bb_putchar('%'); |
219 | /*FALLTHROUGH*/ | 217 | /*FALLTHROUGH*/ |
220 | case '%': | 218 | case '%': |
221 | if (!*fmt) goto ret; | 219 | if (!*fmt) goto ret; |
222 | putc(*fmt, stdout); | 220 | bb_putchar(*fmt); |
223 | break; | 221 | break; |
224 | #endif | 222 | #endif |
225 | case 'C': /* The command that got timed. */ | 223 | case 'C': /* The command that got timed. */ |
@@ -351,17 +349,17 @@ static void summarize(const char *fmt, char **command, resource_t * resp) | |||
351 | case '\\': /* Format escape. */ | 349 | case '\\': /* Format escape. */ |
352 | switch (*++fmt) { | 350 | switch (*++fmt) { |
353 | default: | 351 | default: |
354 | putc('\\', stdout); | 352 | bb_putchar('\\'); |
355 | /*FALLTHROUGH*/ | 353 | /*FALLTHROUGH*/ |
356 | case '\\': | 354 | case '\\': |
357 | if (!*fmt) goto ret; | 355 | if (!*fmt) goto ret; |
358 | putc(*fmt, stdout); | 356 | bb_putchar(*fmt); |
359 | break; | 357 | break; |
360 | case 't': | 358 | case 't': |
361 | putc('\t', stdout); | 359 | bb_putchar('\t'); |
362 | break; | 360 | break; |
363 | case 'n': | 361 | case 'n': |
364 | putc('\n', stdout); | 362 | bb_putchar('\n'); |
365 | break; | 363 | break; |
366 | } | 364 | } |
367 | break; | 365 | break; |
@@ -370,7 +368,7 @@ static void summarize(const char *fmt, char **command, resource_t * resp) | |||
370 | ++fmt; | 368 | ++fmt; |
371 | } | 369 | } |
372 | /* ret: */ | 370 | /* ret: */ |
373 | putc('\n', stdout); | 371 | bb_putchar('\n'); |
374 | } | 372 | } |
375 | 373 | ||
376 | /* Run command CMD and return statistics on it. | 374 | /* Run command CMD and return statistics on it. |
@@ -437,6 +435,7 @@ int time_main(int argc, char **argv) | |||
437 | run_command(argv, &res); | 435 | run_command(argv, &res); |
438 | 436 | ||
439 | /* Cheat. printf's are shorter :) */ | 437 | /* Cheat. printf's are shorter :) */ |
438 | /* (but see bb_putchar() body for additional wrinkle!) */ | ||
440 | stdout = stderr; | 439 | stdout = stderr; |
441 | dup2(2, 1); /* just in case libc does something silly :( */ | 440 | dup2(2, 1); /* just in case libc does something silly :( */ |
442 | summarize(output_format, argv, &res); | 441 | summarize(output_format, argv, &res); |
diff --git a/miscutils/ttysize.c b/miscutils/ttysize.c index 5a3f5dcd4..292cfb876 100644 --- a/miscutils/ttysize.c +++ b/miscutils/ttysize.c | |||
@@ -39,6 +39,6 @@ int ttysize_main(int argc, char **argv) | |||
39 | fmt = "%u %u" + 2; /* " %u" */ | 39 | fmt = "%u %u" + 2; /* " %u" */ |
40 | } | 40 | } |
41 | } | 41 | } |
42 | putchar('\n'); | 42 | bb_putchar('\n'); |
43 | return 0; | 43 | return 0; |
44 | } | 44 | } |