diff options
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/basename.c | 2 | ||||
| -rw-r--r-- | coreutils/cal.c | 10 | ||||
| -rw-r--r-- | coreutils/catv.c | 8 | ||||
| -rw-r--r-- | coreutils/cksum.c | 6 | ||||
| -rw-r--r-- | coreutils/cmp.c | 10 | ||||
| -rw-r--r-- | coreutils/dd.c | 2 | ||||
| -rw-r--r-- | coreutils/df.c | 51 | ||||
| -rw-r--r-- | coreutils/dirname.c | 2 | ||||
| -rw-r--r-- | coreutils/du.c | 6 | ||||
| -rw-r--r-- | coreutils/echo.c | 2 | ||||
| -rw-r--r-- | coreutils/env.c | 2 | ||||
| -rw-r--r-- | coreutils/expr.c | 4 | ||||
| -rw-r--r-- | coreutils/fold.c | 2 | ||||
| -rw-r--r-- | coreutils/head.c | 9 | ||||
| -rw-r--r-- | coreutils/hostid.c | 4 | ||||
| -rw-r--r-- | coreutils/id.c | 18 | ||||
| -rw-r--r-- | coreutils/logname.c | 2 | ||||
| -rw-r--r-- | coreutils/nice.c | 4 | ||||
| -rw-r--r-- | coreutils/printenv.c | 2 | ||||
| -rw-r--r-- | coreutils/pwd.c | 2 | ||||
| -rw-r--r-- | coreutils/realpath.c | 2 | ||||
| -rw-r--r-- | coreutils/sort.c | 2 | ||||
| -rw-r--r-- | coreutils/tee.c | 6 | ||||
| -rw-r--r-- | coreutils/tty.c | 2 | ||||
| -rw-r--r-- | coreutils/uname.c | 6 | ||||
| -rw-r--r-- | coreutils/uniq.c | 14 | ||||
| -rw-r--r-- | coreutils/uuencode.c | 10 | ||||
| -rw-r--r-- | coreutils/wc.c | 6 | ||||
| -rw-r--r-- | coreutils/whoami.c | 2 | ||||
| -rw-r--r-- | coreutils/yes.c | 4 |
30 files changed, 103 insertions, 99 deletions
diff --git a/coreutils/basename.c b/coreutils/basename.c index 446f486cd..30f76dc12 100644 --- a/coreutils/basename.c +++ b/coreutils/basename.c | |||
| @@ -46,5 +46,5 @@ int basename_main(int argc, char **argv) | |||
| 46 | 46 | ||
| 47 | puts(s); | 47 | puts(s); |
| 48 | 48 | ||
| 49 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); | 49 | fflush_stdout_and_exit(EXIT_SUCCESS); |
| 50 | } | 50 | } |
diff --git a/coreutils/cal.c b/coreutils/cal.c index e2bc5ab12..6f5f0a434 100644 --- a/coreutils/cal.c +++ b/coreutils/cal.c | |||
| @@ -139,7 +139,7 @@ int cal_main(int argc, char **argv) | |||
| 139 | 139 | ||
| 140 | day_array(month, year, dp); | 140 | day_array(month, year, dp); |
| 141 | len = sprintf(lineout, "%s %d", month_names[month - 1], year); | 141 | len = sprintf(lineout, "%s %d", month_names[month - 1], year); |
| 142 | bb_printf("%*s%s\n%s\n", | 142 | printf("%*s%s\n%s\n", |
| 143 | ((7*julian + WEEK_LEN) - len) / 2, "", | 143 | ((7*julian + WEEK_LEN) - len) / 2, "", |
| 144 | lineout, day_headings); | 144 | lineout, day_headings); |
| 145 | for (row = 0; row < 6; row++) { | 145 | for (row = 0; row < 6; row++) { |
| @@ -170,9 +170,9 @@ int cal_main(int argc, char **argv) | |||
| 170 | center(month_names[month + 1], week_len, HEAD_SEP); | 170 | center(month_names[month + 1], week_len, HEAD_SEP); |
| 171 | } | 171 | } |
| 172 | center(month_names[month + 2 - julian], week_len, 0); | 172 | center(month_names[month + 2 - julian], week_len, 0); |
| 173 | bb_printf("\n%s%*s%s", day_headings, HEAD_SEP, "", day_headings); | 173 | printf("\n%s%*s%s", day_headings, HEAD_SEP, "", day_headings); |
| 174 | if (!julian) { | 174 | if (!julian) { |
| 175 | bb_printf("%*s%s", HEAD_SEP, "", day_headings); | 175 | printf("%*s%s", HEAD_SEP, "", day_headings); |
| 176 | } | 176 | } |
| 177 | putchar('\n'); | 177 | putchar('\n'); |
| 178 | for (row = 0; row < (6*7); row += 7) { | 178 | for (row = 0; row < (6*7); row += 7) { |
| @@ -186,7 +186,7 @@ int cal_main(int argc, char **argv) | |||
| 186 | } | 186 | } |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | bb_fflush_stdout_and_exit(0); | 189 | fflush_stdout_and_exit(0); |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | /* | 192 | /* |
| @@ -281,7 +281,7 @@ static void center(char *str, int len, int separate) | |||
| 281 | { | 281 | { |
| 282 | int n = strlen(str); | 282 | int n = strlen(str); |
| 283 | len -= n; | 283 | len -= n; |
| 284 | bb_printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, ""); | 284 | printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, ""); |
| 285 | } | 285 | } |
| 286 | 286 | ||
| 287 | static void blank_string(char *buf, size_t buflen) | 287 | static void blank_string(char *buf, size_t buflen) |
diff --git a/coreutils/catv.c b/coreutils/catv.c index a5a8b43e4..66f30693a 100644 --- a/coreutils/catv.c +++ b/coreutils/catv.c | |||
| @@ -42,10 +42,10 @@ int catv_main(int argc, char **argv) | |||
| 42 | 42 | ||
| 43 | if (c > 126 && (flags & CATV_OPT_v)) { | 43 | if (c > 126 && (flags & CATV_OPT_v)) { |
| 44 | if (c == 127) { | 44 | if (c == 127) { |
| 45 | bb_printf("^?"); | 45 | printf("^?"); |
| 46 | continue; | 46 | continue; |
| 47 | } else { | 47 | } else { |
| 48 | bb_printf("M-"); | 48 | printf("M-"); |
| 49 | c -= 128; | 49 | c -= 128; |
| 50 | } | 50 | } |
| 51 | } | 51 | } |
| @@ -54,7 +54,7 @@ int catv_main(int argc, char **argv) | |||
| 54 | if (flags & CATV_OPT_e) | 54 | if (flags & CATV_OPT_e) |
| 55 | putchar('$'); | 55 | putchar('$'); |
| 56 | } else if (flags & (c==9 ? CATV_OPT_t : CATV_OPT_v)) { | 56 | } else if (flags & (c==9 ? CATV_OPT_t : CATV_OPT_v)) { |
| 57 | bb_printf("^%c", c+'@'); | 57 | printf("^%c", c+'@'); |
| 58 | continue; | 58 | continue; |
| 59 | } | 59 | } |
| 60 | } | 60 | } |
| @@ -65,5 +65,5 @@ int catv_main(int argc, char **argv) | |||
| 65 | close(fd); | 65 | close(fd); |
| 66 | } while (*++argv); | 66 | } while (*++argv); |
| 67 | 67 | ||
| 68 | return retval; | 68 | fflush_stdout_and_exit(retval); |
| 69 | } | 69 | } |
diff --git a/coreutils/cksum.c b/coreutils/cksum.c index 9bec3bff4..3a9b0b08c 100644 --- a/coreutils/cksum.c +++ b/coreutils/cksum.c | |||
| @@ -41,13 +41,13 @@ int cksum_main(int argc, char **argv) | |||
| 41 | crc ^= 0xffffffffL; | 41 | crc ^= 0xffffffffL; |
| 42 | 42 | ||
| 43 | if (inp_stdin) { | 43 | if (inp_stdin) { |
| 44 | bb_printf("%" PRIu32 " %li\n", crc, filesize); | 44 | printf("%" PRIu32 " %li\n", crc, filesize); |
| 45 | break; | 45 | break; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | bb_printf("%" PRIu32 " %li %s\n", crc, filesize, *argv); | 48 | printf("%" PRIu32 " %li %s\n", crc, filesize, *argv); |
| 49 | fclose(fp); | 49 | fclose(fp); |
| 50 | } while (*(argv + 1)); | 50 | } while (*(argv + 1)); |
| 51 | 51 | ||
| 52 | return EXIT_SUCCESS; | 52 | fflush_stdout_and_exit(EXIT_SUCCESS); |
| 53 | } | 53 | } |
diff --git a/coreutils/cmp.c b/coreutils/cmp.c index 07858c64e..2b923c845 100644 --- a/coreutils/cmp.c +++ b/coreutils/cmp.c | |||
| @@ -96,7 +96,7 @@ int cmp_main(int argc, char **argv) | |||
| 96 | c1 = c2; | 96 | c1 = c2; |
| 97 | } | 97 | } |
| 98 | if (c1 == EOF) { | 98 | if (c1 == EOF) { |
| 99 | xferror(fp1, filename1); | 99 | die_if_ferror(fp1, filename1); |
| 100 | fmt = fmt_eof; /* Well, no error, so it must really be EOF. */ | 100 | fmt = fmt_eof; /* Well, no error, so it must really be EOF. */ |
| 101 | outfile = stderr; | 101 | outfile = stderr; |
| 102 | /* There may have been output to stdout (option -l), so | 102 | /* There may have been output to stdout (option -l), so |
| @@ -107,7 +107,7 @@ int cmp_main(int argc, char **argv) | |||
| 107 | if (opt & CMP_OPT_l) { | 107 | if (opt & CMP_OPT_l) { |
| 108 | line_pos = c1; /* line_pos is unused in the -l case. */ | 108 | line_pos = c1; /* line_pos is unused in the -l case. */ |
| 109 | } | 109 | } |
| 110 | bb_fprintf(outfile, fmt, filename1, filename2, char_pos, line_pos, c2); | 110 | fprintf(outfile, fmt, filename1, filename2, char_pos, line_pos, c2); |
| 111 | if (opt) { /* This must be -l since not -s. */ | 111 | if (opt) { /* This must be -l since not -s. */ |
| 112 | /* If we encountered an EOF, | 112 | /* If we encountered an EOF, |
| 113 | * the while check will catch it. */ | 113 | * the while check will catch it. */ |
| @@ -121,8 +121,8 @@ int cmp_main(int argc, char **argv) | |||
| 121 | } | 121 | } |
| 122 | } while (c1 != EOF); | 122 | } while (c1 != EOF); |
| 123 | 123 | ||
| 124 | xferror(fp1, filename1); | 124 | die_if_ferror(fp1, filename1); |
| 125 | xferror(fp2, filename2); | 125 | die_if_ferror(fp2, filename2); |
| 126 | 126 | ||
| 127 | bb_fflush_stdout_and_exit(retval); | 127 | fflush_stdout_and_exit(retval); |
| 128 | } | 128 | } |
diff --git a/coreutils/dd.c b/coreutils/dd.c index d60192e7c..d72ca8b7e 100644 --- a/coreutils/dd.c +++ b/coreutils/dd.c | |||
| @@ -29,7 +29,7 @@ static off_t out_full, out_part, in_full, in_part; | |||
| 29 | 29 | ||
| 30 | static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal) | 30 | static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal) |
| 31 | { | 31 | { |
| 32 | bb_fprintf(stderr, OFF_FMT"+"OFF_FMT" records in\n" | 32 | fprintf(stderr, OFF_FMT"+"OFF_FMT" records in\n" |
| 33 | OFF_FMT"+"OFF_FMT" records out\n", | 33 | OFF_FMT"+"OFF_FMT" records out\n", |
| 34 | in_full, in_part, | 34 | in_full, in_part, |
| 35 | out_full, out_part); | 35 | out_full, out_part); |
diff --git a/coreutils/df.c b/coreutils/df.c index 94ead32eb..c569dae33 100644 --- a/coreutils/df.c +++ b/coreutils/df.c | |||
| @@ -51,25 +51,26 @@ int df_main(int argc, char **argv) | |||
| 51 | #ifdef CONFIG_FEATURE_HUMAN_READABLE | 51 | #ifdef CONFIG_FEATURE_HUMAN_READABLE |
| 52 | opt_complementary = "h-km:k-hm:m-hk"; | 52 | opt_complementary = "h-km:k-hm:m-hk"; |
| 53 | opt = getopt32(argc, argv, "hmk"); | 53 | opt = getopt32(argc, argv, "hmk"); |
| 54 | if(opt & 1) { | 54 | if (opt & 1) { |
| 55 | df_disp_hr = 0; | 55 | df_disp_hr = 0; |
| 56 | disp_units_hdr = " Size"; | 56 | disp_units_hdr = " Size"; |
| 57 | } | 57 | } |
| 58 | if(opt & 2) { | 58 | if (opt & 2) { |
| 59 | df_disp_hr = MEGABYTE; | 59 | df_disp_hr = MEGABYTE; |
| 60 | disp_units_hdr = "1M-blocks"; | 60 | disp_units_hdr = "1M-blocks"; |
| 61 | } | 61 | } |
| 62 | #else | 62 | #else |
| 63 | opt = getopt32(argc, argv, "k"); | 63 | opt = getopt32(argc, argv, "k"); |
| 64 | #endif | 64 | #endif |
| 65 | 65 | ||
| 66 | bb_printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n", | 66 | printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n", |
| 67 | "", disp_units_hdr); | 67 | "", disp_units_hdr); |
| 68 | 68 | ||
| 69 | mount_table = NULL; | 69 | mount_table = NULL; |
| 70 | argv += optind; | 70 | argv += optind; |
| 71 | if (optind >= argc) { | 71 | if (optind >= argc) { |
| 72 | if (!(mount_table = setmntent(bb_path_mtab_file, "r"))) { | 72 | mount_table = setmntent(bb_path_mtab_file, "r"); |
| 73 | if (!mount_table) { | ||
| 73 | bb_perror_msg_and_die(bb_path_mtab_file); | 74 | bb_perror_msg_and_die(bb_path_mtab_file); |
| 74 | } | 75 | } |
| 75 | } | 76 | } |
| @@ -79,16 +80,19 @@ int df_main(int argc, char **argv) | |||
| 79 | const char *mount_point; | 80 | const char *mount_point; |
| 80 | 81 | ||
| 81 | if (mount_table) { | 82 | if (mount_table) { |
| 82 | if (!(mount_entry = getmntent(mount_table))) { | 83 | mount_entry = getmntent(mount_table); |
| 84 | if (!mount_entry) { | ||
| 83 | endmntent(mount_table); | 85 | endmntent(mount_table); |
| 84 | break; | 86 | break; |
| 85 | } | 87 | } |
| 86 | } else { | 88 | } else { |
| 87 | if (!(mount_point = *argv++)) { | 89 | mount_point = *argv++; |
| 90 | if (!mount_point) { | ||
| 88 | break; | 91 | break; |
| 89 | } | 92 | } |
| 90 | if (!(mount_entry = find_mount_point(mount_point, bb_path_mtab_file))) { | 93 | mount_entry = find_mount_point(mount_point, bb_path_mtab_file); |
| 91 | bb_error_msg("%s: can't find mount point.", mount_point); | 94 | if (!mount_entry) { |
| 95 | bb_error_msg("%s: can't find mount point", mount_point); | ||
| 92 | SET_ERROR: | 96 | SET_ERROR: |
| 93 | status = EXIT_FAILURE; | 97 | status = EXIT_FAILURE; |
| 94 | continue; | 98 | continue; |
| @@ -108,8 +112,8 @@ int df_main(int argc, char **argv) | |||
| 108 | blocks_percent_used = 0; | 112 | blocks_percent_used = 0; |
| 109 | if (blocks_used + s.f_bavail) { | 113 | if (blocks_used + s.f_bavail) { |
| 110 | blocks_percent_used = (((long long) blocks_used) * 100 | 114 | blocks_percent_used = (((long long) blocks_used) * 100 |
| 111 | + (blocks_used + s.f_bavail)/2 | 115 | + (blocks_used + s.f_bavail)/2 |
| 112 | ) / (blocks_used + s.f_bavail); | 116 | ) / (blocks_used + s.f_bavail); |
| 113 | } | 117 | } |
| 114 | 118 | ||
| 115 | if (strcmp(device, "rootfs") == 0) { | 119 | if (strcmp(device, "rootfs") == 0) { |
| @@ -117,24 +121,25 @@ int df_main(int argc, char **argv) | |||
| 117 | } else if (strcmp(device, "/dev/root") == 0) { | 121 | } else if (strcmp(device, "/dev/root") == 0) { |
| 118 | /* Adjusts device to be the real root device, | 122 | /* Adjusts device to be the real root device, |
| 119 | * or leaves device alone if it can't find it */ | 123 | * or leaves device alone if it can't find it */ |
| 120 | if ((device = find_block_device("/")) == NULL) { | 124 | device = find_block_device("/"); |
| 125 | if (!device) { | ||
| 121 | goto SET_ERROR; | 126 | goto SET_ERROR; |
| 122 | } | 127 | } |
| 123 | } | 128 | } |
| 124 | 129 | ||
| 125 | #ifdef CONFIG_FEATURE_HUMAN_READABLE | 130 | #ifdef CONFIG_FEATURE_HUMAN_READABLE |
| 126 | bb_printf("%-20s %9s ", device, | 131 | printf("%-20s %9s ", device, |
| 127 | make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr)); | 132 | make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr)); |
| 128 | 133 | ||
| 129 | bb_printf("%9s ", | 134 | printf("%9s ", |
| 130 | make_human_readable_str( (s.f_blocks - s.f_bfree), | 135 | make_human_readable_str( (s.f_blocks - s.f_bfree), |
| 131 | s.f_bsize, df_disp_hr)); | 136 | s.f_bsize, df_disp_hr)); |
| 132 | 137 | ||
| 133 | bb_printf("%9s %3ld%% %s\n", | 138 | printf("%9s %3ld%% %s\n", |
| 134 | make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr), | 139 | make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr), |
| 135 | blocks_percent_used, mount_point); | 140 | blocks_percent_used, mount_point); |
| 136 | #else | 141 | #else |
| 137 | bb_printf("%-20s %9ld %9ld %9ld %3ld%% %s\n", | 142 | printf("%-20s %9ld %9ld %9ld %3ld%% %s\n", |
| 138 | device, | 143 | device, |
| 139 | kscale(s.f_blocks, s.f_bsize), | 144 | kscale(s.f_blocks, s.f_bsize), |
| 140 | kscale(s.f_blocks-s.f_bfree, s.f_bsize), | 145 | kscale(s.f_blocks-s.f_bfree, s.f_bsize), |
| @@ -145,5 +150,5 @@ int df_main(int argc, char **argv) | |||
| 145 | 150 | ||
| 146 | } while (1); | 151 | } while (1); |
| 147 | 152 | ||
| 148 | bb_fflush_stdout_and_exit(status); | 153 | fflush_stdout_and_exit(status); |
| 149 | } | 154 | } |
diff --git a/coreutils/dirname.c b/coreutils/dirname.c index 3471a2631..e986a9701 100644 --- a/coreutils/dirname.c +++ b/coreutils/dirname.c | |||
| @@ -22,5 +22,5 @@ int dirname_main(int argc, char **argv) | |||
| 22 | 22 | ||
| 23 | puts(dirname(argv[1])); | 23 | puts(dirname(argv[1])); |
| 24 | 24 | ||
| 25 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); | 25 | fflush_stdout_and_exit(EXIT_SUCCESS); |
| 26 | } | 26 | } |
diff --git a/coreutils/du.c b/coreutils/du.c index efc449097..cae76af38 100644 --- a/coreutils/du.c +++ b/coreutils/du.c | |||
| @@ -56,14 +56,14 @@ static void print(long size, const char * const filename) | |||
| 56 | { | 56 | { |
| 57 | /* TODO - May not want to defer error checking here. */ | 57 | /* TODO - May not want to defer error checking here. */ |
| 58 | #ifdef CONFIG_FEATURE_HUMAN_READABLE | 58 | #ifdef CONFIG_FEATURE_HUMAN_READABLE |
| 59 | bb_printf("%s\t%s\n", make_human_readable_str(size, 512, disp_hr), | 59 | printf("%s\t%s\n", make_human_readable_str(size, 512, disp_hr), |
| 60 | filename); | 60 | filename); |
| 61 | #else | 61 | #else |
| 62 | if (disp_k) { | 62 | if (disp_k) { |
| 63 | size++; | 63 | size++; |
| 64 | size >>= 1; | 64 | size >>= 1; |
| 65 | } | 65 | } |
| 66 | bb_printf("%ld\t%s\n", size, filename); | 66 | printf("%ld\t%s\n", size, filename); |
| 67 | #endif | 67 | #endif |
| 68 | } | 68 | } |
| 69 | 69 | ||
| @@ -246,5 +246,5 @@ int du_main(int argc, char **argv) | |||
| 246 | print(total, "total"); | 246 | print(total, "total"); |
| 247 | } | 247 | } |
| 248 | 248 | ||
| 249 | bb_fflush_stdout_and_exit(status); | 249 | fflush_stdout_and_exit(status); |
| 250 | } | 250 | } |
diff --git a/coreutils/echo.c b/coreutils/echo.c index d278c1143..99063ae52 100644 --- a/coreutils/echo.c +++ b/coreutils/echo.c | |||
| @@ -115,7 +115,7 @@ just_echo: | |||
| 115 | int echo_main(int argc, char** argv) | 115 | int echo_main(int argc, char** argv) |
| 116 | { | 116 | { |
| 117 | (void)bb_echo(argc, argv); | 117 | (void)bb_echo(argc, argv); |
| 118 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); | 118 | fflush_stdout_and_exit(EXIT_SUCCESS); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | /*- | 121 | /*- |
diff --git a/coreutils/env.c b/coreutils/env.c index d03318fea..2ce99b0ad 100644 --- a/coreutils/env.c +++ b/coreutils/env.c | |||
| @@ -90,7 +90,7 @@ int env_main(int argc, char** argv) | |||
| 90 | puts(*ep); | 90 | puts(*ep); |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | bb_fflush_stdout_and_exit(0); | 93 | fflush_stdout_and_exit(0); |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | /* | 96 | /* |
diff --git a/coreutils/expr.c b/coreutils/expr.c index ea99d8b5b..854a657f9 100644 --- a/coreutils/expr.c +++ b/coreutils/expr.c | |||
| @@ -87,11 +87,11 @@ int expr_main(int argc, char **argv) | |||
| 87 | bb_error_msg_and_die("syntax error"); | 87 | bb_error_msg_and_die("syntax error"); |
| 88 | 88 | ||
| 89 | if (v->type == integer) | 89 | if (v->type == integer) |
| 90 | bb_printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i); | 90 | printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i); |
| 91 | else | 91 | else |
| 92 | puts(v->u.s); | 92 | puts(v->u.s); |
| 93 | 93 | ||
| 94 | exit(null(v)); | 94 | fflush_stdout_and_exit(null(v)); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | /* Return a VALUE for I. */ | 97 | /* Return a VALUE for I. */ |
diff --git a/coreutils/fold.c b/coreutils/fold.c index 45f4472e4..e33be5594 100644 --- a/coreutils/fold.c +++ b/coreutils/fold.c | |||
| @@ -150,5 +150,5 @@ rescan: | |||
| 150 | } | 150 | } |
| 151 | } while (*++argv); | 151 | } while (*++argv); |
| 152 | 152 | ||
| 153 | bb_fflush_stdout_and_exit(errs); | 153 | fflush_stdout_and_exit(errs); |
| 154 | } | 154 | } |
diff --git a/coreutils/head.c b/coreutils/head.c index 060febcf7..2e9000df4 100644 --- a/coreutils/head.c +++ b/coreutils/head.c | |||
| @@ -112,12 +112,13 @@ int head_main(int argc, char **argv) | |||
| 112 | #endif | 112 | #endif |
| 113 | 113 | ||
| 114 | do { | 114 | do { |
| 115 | if ((fp = bb_wfopen_input(*argv)) != NULL) { | 115 | fp = bb_wfopen_input(*argv); |
| 116 | if (fp) { | ||
| 116 | if (fp == stdin) { | 117 | if (fp == stdin) { |
| 117 | *argv = (char *) bb_msg_standard_input; | 118 | *argv = (char *) bb_msg_standard_input; |
| 118 | } | 119 | } |
| 119 | if (header_threshhold) { | 120 | if (header_threshhold) { |
| 120 | bb_printf(fmt, *argv); | 121 | printf(fmt, *argv); |
| 121 | } | 122 | } |
| 122 | i = count; | 123 | i = count; |
| 123 | while (i && ((c = getc(fp)) != EOF)) { | 124 | while (i && ((c = getc(fp)) != EOF)) { |
| @@ -130,10 +131,10 @@ int head_main(int argc, char **argv) | |||
| 130 | bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */ | 131 | bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */ |
| 131 | retval = EXIT_FAILURE; | 132 | retval = EXIT_FAILURE; |
| 132 | } | 133 | } |
| 133 | xferror_stdout(); | 134 | die_if_ferror_stdout(); |
| 134 | } | 135 | } |
| 135 | fmt = header_fmt_str; | 136 | fmt = header_fmt_str; |
| 136 | } while (*++argv); | 137 | } while (*++argv); |
| 137 | 138 | ||
| 138 | bb_fflush_stdout_and_exit(retval); | 139 | fflush_stdout_and_exit(retval); |
| 139 | } | 140 | } |
diff --git a/coreutils/hostid.c b/coreutils/hostid.c index cda96726a..65447aa63 100644 --- a/coreutils/hostid.c +++ b/coreutils/hostid.c | |||
| @@ -19,7 +19,7 @@ int hostid_main(int argc, char ATTRIBUTE_UNUSED **argv) | |||
| 19 | bb_show_usage(); | 19 | bb_show_usage(); |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | bb_printf("%lx\n", gethostid()); | 22 | printf("%lx\n", gethostid()); |
| 23 | 23 | ||
| 24 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); | 24 | fflush_stdout_and_exit(EXIT_SUCCESS); |
| 25 | } | 25 | } |
diff --git a/coreutils/id.c b/coreutils/id.c index 9d605325c..66874a71e 100644 --- a/coreutils/id.c +++ b/coreutils/id.c | |||
| @@ -35,7 +35,7 @@ static short printf_full(unsigned int id, const char *arg, const char prefix) | |||
| 35 | fmt = "%cid=%u(%s)"; | 35 | fmt = "%cid=%u(%s)"; |
| 36 | status = EXIT_SUCCESS; | 36 | status = EXIT_SUCCESS; |
| 37 | } | 37 | } |
| 38 | bb_printf(fmt, prefix, id, arg); | 38 | printf(fmt, prefix, id, arg); |
| 39 | return status; | 39 | return status; |
| 40 | } | 40 | } |
| 41 | 41 | ||
| @@ -74,10 +74,10 @@ int id_main(int argc, char **argv) | |||
| 74 | /* bb_getpwuid and bb_getgrgid exit on failure so puts cannot segfault */ | 74 | /* bb_getpwuid and bb_getgrgid exit on failure so puts cannot segfault */ |
| 75 | puts((flags & JUST_USER) ? bb_getpwuid(NULL, uid, -1 ) : bb_getgrgid(NULL, gid, -1 )); | 75 | puts((flags & JUST_USER) ? bb_getpwuid(NULL, uid, -1 ) : bb_getgrgid(NULL, gid, -1 )); |
| 76 | } else { | 76 | } else { |
| 77 | bb_printf("%u\n", (flags & JUST_USER) ? uid : gid); | 77 | printf("%u\n", (flags & JUST_USER) ? uid : gid); |
| 78 | } | 78 | } |
| 79 | /* exit */ | 79 | /* exit */ |
| 80 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); | 80 | fflush_stdout_and_exit(EXIT_SUCCESS); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | /* Print full info like GNU id */ | 83 | /* Print full info like GNU id */ |
| @@ -96,16 +96,16 @@ int id_main(int argc, char **argv) | |||
| 96 | getcon(&mysid); | 96 | getcon(&mysid); |
| 97 | context[0] = '\0'; | 97 | context[0] = '\0'; |
| 98 | if (mysid) { | 98 | if (mysid) { |
| 99 | len = strlen(mysid)+1; | 99 | len = strlen(mysid)+1; |
| 100 | safe_strncpy(context, mysid, len); | 100 | safe_strncpy(context, mysid, len); |
| 101 | freecon(mysid); | 101 | freecon(mysid); |
| 102 | } else { | 102 | } else { |
| 103 | safe_strncpy(context, "unknown", 8); | 103 | safe_strncpy(context, "unknown", 8); |
| 104 | } | 104 | } |
| 105 | bb_printf(" context=%s", context); | 105 | printf(" context=%s", context); |
| 106 | } | 106 | } |
| 107 | #endif | 107 | #endif |
| 108 | 108 | ||
| 109 | putchar('\n'); | 109 | putchar('\n'); |
| 110 | bb_fflush_stdout_and_exit(status); | 110 | fflush_stdout_and_exit(status); |
| 111 | } | 111 | } |
diff --git a/coreutils/logname.c b/coreutils/logname.c index da8a1cfc9..695a736c6 100644 --- a/coreutils/logname.c +++ b/coreutils/logname.c | |||
| @@ -35,7 +35,7 @@ int logname_main(int argc, char ATTRIBUTE_UNUSED **argv) | |||
| 35 | 35 | ||
| 36 | if ((p = getlogin()) != NULL) { | 36 | if ((p = getlogin()) != NULL) { |
| 37 | puts(p); | 37 | puts(p); |
| 38 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); | 38 | fflush_stdout_and_exit(EXIT_SUCCESS); |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | bb_perror_msg_and_die("getlogin"); | 41 | bb_perror_msg_and_die("getlogin"); |
diff --git a/coreutils/nice.c b/coreutils/nice.c index dbd90648d..293861842 100644 --- a/coreutils/nice.c +++ b/coreutils/nice.c | |||
| @@ -17,8 +17,8 @@ int nice_main(int argc, char **argv) | |||
| 17 | old_priority = getpriority(PRIO_PROCESS, 0); | 17 | old_priority = getpriority(PRIO_PROCESS, 0); |
| 18 | 18 | ||
| 19 | if (!*++argv) { /* No args, so (GNU) output current nice value. */ | 19 | if (!*++argv) { /* No args, so (GNU) output current nice value. */ |
| 20 | bb_printf("%d\n", old_priority); | 20 | printf("%d\n", old_priority); |
| 21 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); | 21 | fflush_stdout_and_exit(EXIT_SUCCESS); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | adjustment = 10; /* Set default adjustment. */ | 24 | adjustment = 10; /* Set default adjustment. */ |
diff --git a/coreutils/printenv.c b/coreutils/printenv.c index aea88d701..ec50f7151 100644 --- a/coreutils/printenv.c +++ b/coreutils/printenv.c | |||
| @@ -37,5 +37,5 @@ int printenv_main(int argc, char **argv) | |||
| 37 | } | 37 | } |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | bb_fflush_stdout_and_exit(0); | 40 | fflush_stdout_and_exit(0); |
| 41 | } | 41 | } |
diff --git a/coreutils/pwd.c b/coreutils/pwd.c index b2d7c0e5f..bd36d627e 100644 --- a/coreutils/pwd.c +++ b/coreutils/pwd.c | |||
| @@ -17,7 +17,7 @@ int pwd_main(int argc, char **argv) | |||
| 17 | 17 | ||
| 18 | if ((buf = xgetcwd(NULL)) != NULL) { | 18 | if ((buf = xgetcwd(NULL)) != NULL) { |
| 19 | puts(buf); | 19 | puts(buf); |
| 20 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); | 20 | fflush_stdout_and_exit(EXIT_SUCCESS); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | return EXIT_FAILURE; | 23 | return EXIT_FAILURE; |
diff --git a/coreutils/realpath.c b/coreutils/realpath.c index 0fd2c7625..5f3242fb5 100644 --- a/coreutils/realpath.c +++ b/coreutils/realpath.c | |||
| @@ -44,5 +44,5 @@ int realpath_main(int argc, char **argv) | |||
| 44 | RELEASE_CONFIG_BUFFER(resolved_path); | 44 | RELEASE_CONFIG_BUFFER(resolved_path); |
| 45 | #endif | 45 | #endif |
| 46 | 46 | ||
| 47 | bb_fflush_stdout_and_exit(retval); | 47 | fflush_stdout_and_exit(retval); |
| 48 | } | 48 | } |
diff --git a/coreutils/sort.c b/coreutils/sort.c index c23c14226..972477bab 100644 --- a/coreutils/sort.c +++ b/coreutils/sort.c | |||
| @@ -318,5 +318,5 @@ int sort_main(int argc, char **argv) | |||
| 318 | /* Print it */ | 318 | /* Print it */ |
| 319 | if(!outfile) outfile=stdout; | 319 | if(!outfile) outfile=stdout; |
| 320 | for(i=0;i<linecount;i++) fprintf(outfile,"%s\n",lines[i]); | 320 | for(i=0;i<linecount;i++) fprintf(outfile,"%s\n",lines[i]); |
| 321 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); | 321 | fflush_stdout_and_exit(EXIT_SUCCESS); |
| 322 | } | 322 | } |
diff --git a/coreutils/tee.c b/coreutils/tee.c index a194153e0..f0e1fad86 100644 --- a/coreutils/tee.c +++ b/coreutils/tee.c | |||
| @@ -85,7 +85,7 @@ int tee_main(int argc, char **argv) | |||
| 85 | * output files. Since we know that the first entry in the output | 85 | * output files. Since we know that the first entry in the output |
| 86 | * file table is stdout, we can save one "if ferror" test by | 86 | * file table is stdout, we can save one "if ferror" test by |
| 87 | * setting the first entry to stdin and checking stdout error | 87 | * setting the first entry to stdin and checking stdout error |
| 88 | * status with bb_fflush_stdout_and_exit()... although fflush()ing | 88 | * status with fflush_stdout_and_exit()... although fflush()ing |
| 89 | * is unnecessary here. */ | 89 | * is unnecessary here. */ |
| 90 | 90 | ||
| 91 | p = files; | 91 | p = files; |
| @@ -93,8 +93,8 @@ int tee_main(int argc, char **argv) | |||
| 93 | do { /* Now check for (input and) output errors. */ | 93 | do { /* Now check for (input and) output errors. */ |
| 94 | /* Checking ferror should be sufficient, but we may want to fclose. | 94 | /* Checking ferror should be sufficient, but we may want to fclose. |
| 95 | * If we do, remember not to close stdin! */ | 95 | * If we do, remember not to close stdin! */ |
| 96 | xferror(*p, filenames[(int)(p - files)]); | 96 | die_if_ferror(*p, filenames[(int)(p - files)]); |
| 97 | } while (*++p); | 97 | } while (*++p); |
| 98 | 98 | ||
| 99 | bb_fflush_stdout_and_exit(retval); | 99 | fflush_stdout_and_exit(retval); |
| 100 | } | 100 | } |
diff --git a/coreutils/tty.c b/coreutils/tty.c index 579e6f73c..b2ab862ec 100644 --- a/coreutils/tty.c +++ b/coreutils/tty.c | |||
| @@ -41,5 +41,5 @@ int tty_main(int argc, char **argv) | |||
| 41 | puts(s); | 41 | puts(s); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | bb_fflush_stdout_and_exit(retval); | 44 | fflush_stdout_and_exit(retval); |
| 45 | } | 45 | } |
diff --git a/coreutils/uname.c b/coreutils/uname.c index 575fb525c..5a3eafe92 100644 --- a/coreutils/uname.c +++ b/coreutils/uname.c | |||
| @@ -91,10 +91,10 @@ int uname_main(int argc, char **argv) | |||
| 91 | 91 | ||
| 92 | strcpy(uname_info.processor, "unknown"); | 92 | strcpy(uname_info.processor, "unknown"); |
| 93 | 93 | ||
| 94 | delta=utsname_offset; | 94 | delta = utsname_offset; |
| 95 | do { | 95 | do { |
| 96 | if (toprint & 1) { | 96 | if (toprint & 1) { |
| 97 | bb_printf(((char *)(&uname_info)) + *delta); | 97 | printf(((char *)(&uname_info)) + *delta); |
| 98 | if (toprint > 1) { | 98 | if (toprint > 1) { |
| 99 | putchar(' '); | 99 | putchar(' '); |
| 100 | } | 100 | } |
| @@ -103,5 +103,5 @@ int uname_main(int argc, char **argv) | |||
| 103 | } while (toprint >>= 1); | 103 | } while (toprint >>= 1); |
| 104 | putchar('\n'); | 104 | putchar('\n'); |
| 105 | 105 | ||
| 106 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); | 106 | fflush_stdout_and_exit(EXIT_SUCCESS); |
| 107 | } | 107 | } |
diff --git a/coreutils/uniq.c b/coreutils/uniq.c index a7b7a8e07..100f2be00 100644 --- a/coreutils/uniq.c +++ b/coreutils/uniq.c | |||
| @@ -37,7 +37,7 @@ int uniq_main(int argc, char **argv) | |||
| 37 | 37 | ||
| 38 | while ((opt = getopt(argc, argv, uniq_opts)) > 0) { | 38 | while ((opt = getopt(argc, argv, uniq_opts)) > 0) { |
| 39 | if ((opt == 'f') || (opt == 's')) { | 39 | if ((opt == 'f') || (opt == 's')) { |
| 40 | int t = xatoul(optarg); | 40 | unsigned long t = xatoul(optarg); |
| 41 | if (opt == 'f') { | 41 | if (opt == 'f') { |
| 42 | skip_fields = t; | 42 | skip_fields = t; |
| 43 | } else { | 43 | } else { |
| @@ -71,13 +71,13 @@ int uniq_main(int argc, char **argv) | |||
| 71 | /* gnu uniq ignores newlines */ | 71 | /* gnu uniq ignores newlines */ |
| 72 | while ((s1 = xmalloc_getline(in)) != NULL) { | 72 | while ((s1 = xmalloc_getline(in)) != NULL) { |
| 73 | e1 = s1; | 73 | e1 = s1; |
| 74 | for (i=skip_fields ; i ; i--) { | 74 | for (i = skip_fields; i; i--) { |
| 75 | e1 = skip_whitespace(e1); | 75 | e1 = skip_whitespace(e1); |
| 76 | while (*e1 && !isspace(*e1)) { | 76 | while (*e1 && !isspace(*e1)) { |
| 77 | ++e1; | 77 | ++e1; |
| 78 | } | 78 | } |
| 79 | } | 79 | } |
| 80 | for (i = skip_chars ; *e1 && i ; i--) { | 80 | for (i = skip_chars; *e1 && i; i--) { |
| 81 | ++e1; | 81 | ++e1; |
| 82 | } | 82 | } |
| 83 | 83 | ||
| @@ -90,14 +90,14 @@ int uniq_main(int argc, char **argv) | |||
| 90 | 90 | ||
| 91 | if (s0) { | 91 | if (s0) { |
| 92 | if (!(uniq_flags & (2 << !!dups))) { | 92 | if (!(uniq_flags & (2 << !!dups))) { |
| 93 | bb_fprintf(out, "\0%d " + (uniq_flags & 1), dups + 1); | 93 | fprintf(out, "\0%d " + (uniq_flags & 1), dups + 1); |
| 94 | bb_fprintf(out, "%s\n", s0); | 94 | fprintf(out, "%s\n", s0); |
| 95 | } | 95 | } |
| 96 | free((void *)s0); | 96 | free((void *)s0); |
| 97 | } | 97 | } |
| 98 | } while (s1); | 98 | } while (s1); |
| 99 | 99 | ||
| 100 | xferror(in, input_filename); | 100 | die_if_ferror(in, input_filename); |
| 101 | 101 | ||
| 102 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); | 102 | fflush_stdout_and_exit(EXIT_SUCCESS); |
| 103 | } | 103 | } |
diff --git a/coreutils/uuencode.c b/coreutils/uuencode.c index 58538365e..e8f8d541c 100644 --- a/coreutils/uuencode.c +++ b/coreutils/uuencode.c | |||
| @@ -47,12 +47,12 @@ int uuencode_main(int argc, char **argv) | |||
| 47 | bb_show_usage(); | 47 | bb_show_usage(); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | bb_printf("begin%s %o %s", tbl == bb_uuenc_tbl_std ? "" : "-base64", mode, argv[argc - 1]); | 50 | printf("begin%s %o %s", tbl == bb_uuenc_tbl_std ? "" : "-base64", mode, argv[argc - 1]); |
| 51 | 51 | ||
| 52 | while ((size = fread(src_buf, 1, src_buf_size, src_stream)) > 0) { | 52 | while ((size = fread(src_buf, 1, src_buf_size, src_stream)) > 0) { |
| 53 | if (size != src_buf_size) { | 53 | if (size != src_buf_size) { |
| 54 | /* write_size is always 60 until the last line */ | 54 | /* write_size is always 60 until the last line */ |
| 55 | write_size=(4 * ((size + 2) / 3)); | 55 | write_size = (4 * ((size + 2) / 3)); |
| 56 | /* pad with 0s so we can just encode extra bits */ | 56 | /* pad with 0s so we can just encode extra bits */ |
| 57 | memset(&src_buf[size], 0, src_buf_size - size); | 57 | memset(&src_buf[size], 0, src_buf_size - size); |
| 58 | } | 58 | } |
| @@ -67,9 +67,9 @@ int uuencode_main(int argc, char **argv) | |||
| 67 | bb_perror_msg_and_die(bb_msg_write_error); | 67 | bb_perror_msg_and_die(bb_msg_write_error); |
| 68 | } | 68 | } |
| 69 | } | 69 | } |
| 70 | bb_printf(tbl == bb_uuenc_tbl_std ? "\n`\nend\n" : "\n====\n"); | 70 | printf(tbl == bb_uuenc_tbl_std ? "\n`\nend\n" : "\n====\n"); |
| 71 | 71 | ||
| 72 | xferror(src_stream, "source"); /* TODO - Fix this! */ | 72 | die_if_ferror(src_stream, "source"); /* TODO - Fix this! */ |
| 73 | 73 | ||
| 74 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); | 74 | fflush_stdout_and_exit(EXIT_SUCCESS); |
| 75 | } | 75 | } |
diff --git a/coreutils/wc.c b/coreutils/wc.c index 359d9fd6d..ebae5f69f 100644 --- a/coreutils/wc.c +++ b/coreutils/wc.c | |||
| @@ -182,12 +182,12 @@ int wc_main(int argc, char **argv) | |||
| 182 | u = 0; | 182 | u = 0; |
| 183 | do { | 183 | do { |
| 184 | if (print_type & (1 << u)) { | 184 | if (print_type & (1 << u)) { |
| 185 | bb_printf(s, pcounts[u]); | 185 | printf(s, pcounts[u]); |
| 186 | s = " %9"COUNT_FMT; /* Ok... restore the leading space. */ | 186 | s = " %9"COUNT_FMT; /* Ok... restore the leading space. */ |
| 187 | } | 187 | } |
| 188 | totals[u] += pcounts[u]; | 188 | totals[u] += pcounts[u]; |
| 189 | } while (++u < 4); | 189 | } while (++u < 4); |
| 190 | bb_printf(fname_fmt, arg); | 190 | printf(fname_fmt, arg); |
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | /* If more than one file was processed, we want the totals. To save some | 193 | /* If more than one file was processed, we want the totals. To save some |
| @@ -202,5 +202,5 @@ int wc_main(int argc, char **argv) | |||
| 202 | goto OUTPUT; | 202 | goto OUTPUT; |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | bb_fflush_stdout_and_exit(status); | 205 | fflush_stdout_and_exit(status); |
| 206 | } | 206 | } |
diff --git a/coreutils/whoami.c b/coreutils/whoami.c index 5cdec922b..df714f22c 100644 --- a/coreutils/whoami.c +++ b/coreutils/whoami.c | |||
| @@ -21,5 +21,5 @@ int whoami_main(int argc, char **argv) | |||
| 21 | 21 | ||
| 22 | puts(bb_getpwuid(NULL, geteuid(), -1)); | 22 | puts(bb_getpwuid(NULL, geteuid(), -1)); |
| 23 | /* exits on error */ | 23 | /* exits on error */ |
| 24 | bb_fflush_stdout_and_exit(EXIT_SUCCESS); | 24 | fflush_stdout_and_exit(EXIT_SUCCESS); |
| 25 | } | 25 | } |
diff --git a/coreutils/yes.c b/coreutils/yes.c index 97b4fe54c..894506a89 100644 --- a/coreutils/yes.c +++ b/coreutils/yes.c | |||
| @@ -14,8 +14,6 @@ | |||
| 14 | * Size reductions and removed redundant applet name prefix from error messages. | 14 | * Size reductions and removed redundant applet name prefix from error messages. |
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include <stdio.h> | ||
| 18 | #include <stdlib.h> | ||
| 19 | #include "busybox.h" | 17 | #include "busybox.h" |
| 20 | 18 | ||
| 21 | int yes_main(int argc, char **argv) | 19 | int yes_main(int argc, char **argv) |
| @@ -33,7 +31,7 @@ int yes_main(int argc, char **argv) | |||
| 33 | do { | 31 | do { |
| 34 | fmt = fmt_str + 1; | 32 | fmt = fmt_str + 1; |
| 35 | do { | 33 | do { |
| 36 | bb_printf(fmt, *argv); | 34 | printf(fmt, *argv); |
| 37 | fmt = fmt_str; | 35 | fmt = fmt_str; |
| 38 | } while (*++argv); | 36 | } while (*++argv); |
| 39 | argv = first_arg; | 37 | argv = first_arg; |
