rename functions to more understandable names
This commit is contained in:
@@ -26,10 +26,10 @@ int cat_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
do {
|
||||
f = bb_wfopen_input(*argv);
|
||||
f = fopen_or_warn_stdin(*argv);
|
||||
if (f) {
|
||||
off_t r = bb_copyfd_eof(fileno(f), STDOUT_FILENO);
|
||||
bb_fclose_nonstdin(f);
|
||||
fclose_if_not_stdin(f);
|
||||
if (r >= 0) {
|
||||
continue;
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ int cksum_main(int argc, char **argv)
|
||||
int inp_stdin = (argc == optind) ? 1 : 0;
|
||||
|
||||
do {
|
||||
fp = bb_wfopen_input((inp_stdin) ? bb_msg_standard_input : *++argv);
|
||||
fp = fopen_or_warn_stdin((inp_stdin) ? bb_msg_standard_input : *++argv);
|
||||
|
||||
crc = 0;
|
||||
length = 0;
|
||||
|
@@ -27,10 +27,9 @@ static FILE *cmp_xfopen_input(const char * const filename)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = bb_wfopen_input(filename)) != NULL) {
|
||||
fp = fopen_or_warn_stdin(filename);
|
||||
if (fp)
|
||||
return fp;
|
||||
}
|
||||
|
||||
exit(xfunc_error_retval); /* We already output an error message. */
|
||||
}
|
||||
|
||||
|
@@ -272,7 +272,7 @@ int cut_main(int argc, char **argv)
|
||||
FILE *file;
|
||||
|
||||
for (; optind < argc; optind++) {
|
||||
file = bb_wfopen(argv[optind], "r");
|
||||
file = fopen_or_warn(argv[optind], "r");
|
||||
if (file) {
|
||||
cut_file(file);
|
||||
fclose(file);
|
||||
|
@@ -70,7 +70,7 @@ int fold_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
do {
|
||||
FILE *istream = bb_wfopen_input(*argv);
|
||||
FILE *istream = fopen_or_warn_stdin(*argv);
|
||||
int c;
|
||||
int column = 0; /* Screen column where next char will go. */
|
||||
int offset_out = 0; /* Index in `line_out' for next char. */
|
||||
@@ -144,7 +144,7 @@ rescan:
|
||||
fwrite(line_out, sizeof(char), (size_t) offset_out, stdout);
|
||||
}
|
||||
|
||||
if (ferror(istream) || bb_fclose_nonstdin(istream)) {
|
||||
if (ferror(istream) || fclose_if_not_stdin(istream)) {
|
||||
bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */
|
||||
errs |= EXIT_FAILURE;
|
||||
}
|
||||
|
@@ -112,7 +112,7 @@ int head_main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
do {
|
||||
fp = bb_wfopen_input(*argv);
|
||||
fp = fopen_or_warn_stdin(*argv);
|
||||
if (fp) {
|
||||
if (fp == stdin) {
|
||||
*argv = (char *) bb_msg_standard_input;
|
||||
@@ -127,7 +127,7 @@ int head_main(int argc, char **argv)
|
||||
}
|
||||
putchar(c);
|
||||
}
|
||||
if (bb_fclose_nonstdin(fp)) {
|
||||
if (fclose_if_not_stdin(fp)) {
|
||||
bb_perror_msg("%s", *argv); /* Avoid multibyte problems. */
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
|
@@ -162,7 +162,7 @@ int md5_sha1_sum_main(int argc, char **argv)
|
||||
bb_error_msg("WARNING: %d of %d computed checksums did NOT match",
|
||||
count_failed, count_total);
|
||||
}
|
||||
if (bb_fclose_nonstdin(pre_computed_stream) == EOF) {
|
||||
if (fclose_if_not_stdin(pre_computed_stream) == EOF) {
|
||||
bb_perror_msg_and_die("cannot close file %s", file_ptr);
|
||||
}
|
||||
} else {
|
||||
|
@@ -38,7 +38,7 @@ static int bsd_sum_file(const char *file, int print_name)
|
||||
fp = stdin;
|
||||
have_read_stdin++;
|
||||
} else {
|
||||
fp = bb_wfopen(file, "r");
|
||||
fp = fopen_or_warn(file, "r");
|
||||
if (fp == NULL)
|
||||
goto out;
|
||||
}
|
||||
@@ -52,11 +52,11 @@ static int bsd_sum_file(const char *file, int print_name)
|
||||
|
||||
if (ferror(fp)) {
|
||||
bb_perror_msg(file);
|
||||
bb_fclose_nonstdin(fp);
|
||||
fclose_if_not_stdin(fp);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (bb_fclose_nonstdin(fp) == EOF) {
|
||||
if (fclose_if_not_stdin(fp) == EOF) {
|
||||
bb_perror_msg(file);
|
||||
goto out;
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ int tee_main(int argc, char **argv)
|
||||
goto GOT_NEW_FILE;
|
||||
|
||||
do {
|
||||
if ((*p = bb_wfopen(*argv, mode)) == NULL) {
|
||||
if ((*p = fopen_or_warn(*argv, mode)) == NULL) {
|
||||
retval = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
|
@@ -174,7 +174,7 @@ int uudecode_main(int argc, char **argv)
|
||||
}
|
||||
free(line);
|
||||
ret = decode_fn_ptr(src_stream, dst_stream);
|
||||
bb_fclose_nonstdin(src_stream);
|
||||
fclose_if_not_stdin(src_stream);
|
||||
return(ret);
|
||||
}
|
||||
bb_error_msg_and_die("No `begin' line");
|
||||
|
@@ -107,7 +107,7 @@ int wc_main(int argc, char **argv)
|
||||
|
||||
while ((arg = *argv++) != 0) {
|
||||
++num_files;
|
||||
fp = bb_wfopen_input(arg);
|
||||
fp = fopen_or_warn_stdin(arg);
|
||||
if (!fp) {
|
||||
status = EXIT_FAILURE;
|
||||
continue;
|
||||
@@ -172,7 +172,7 @@ int wc_main(int argc, char **argv)
|
||||
}
|
||||
totals[WC_LENGTH] -= counts[WC_LENGTH];
|
||||
|
||||
bb_fclose_nonstdin(fp);
|
||||
fclose_if_not_stdin(fp);
|
||||
|
||||
OUTPUT:
|
||||
/* coreutils wc tries hard to print pretty columns
|
||||
|
Reference in New Issue
Block a user