From c1628626209899fa841c2befd8fedb97fe182b67 Mon Sep 17 00:00:00 2001 From: Mike Kazantsev Date: Sun, 6 Apr 2014 04:40:40 +0600 Subject: [PATCH] Change bsdcat behavior to process as many files as possible. Change is to match "cat" behavior of printing any errors (e.g. "unable to open file") and continue to the next file instead of exiting on first error encountered. --- cat/bsdcat.c | 18 +++++++++++------- cat/bsdcat.h | 1 + 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cat/bsdcat.c b/cat/bsdcat.c index c453201a2..46eadfa0f 100644 --- a/cat/bsdcat.c +++ b/cat/bsdcat.c @@ -64,18 +64,22 @@ bsdcat_next() archive_read_support_format_raw(a); } +void +bsdcat_print_error(void) +{ + lafe_warnc(0, "%s: %s", + bsdcat_current_path, archive_error_string(a)); +} + void bsdcat_read_to_stdout(char* filename) { if ((archive_read_open_filename(a, filename, BYTES_PER_BLOCK) != ARCHIVE_OK) || (archive_read_next_header(a, &ae) != ARCHIVE_OK) - || (archive_read_data_into_fd(a, 1) != ARCHIVE_OK) - || (archive_read_free(a) != ARCHIVE_OK)) - goto fail; - return; -fail: - lafe_errc(1, 0, "Error: %s - %s", - bsdcat_current_path, archive_error_string(a)); + || (archive_read_data_into_fd(a, 1) != ARCHIVE_OK)) + bsdcat_print_error(); + if (archive_read_free(a) != ARCHIVE_OK) + bsdcat_print_error(); } int diff --git a/cat/bsdcat.h b/cat/bsdcat.h index 5daf3cf3a..0f6e38e89 100644 --- a/cat/bsdcat.h +++ b/cat/bsdcat.h @@ -36,4 +36,5 @@ void usage(void); void bsdcat_next(void); +void bsdcat_print_error(void); void bsdcat_read_to_stdout(char* filename); -- 2.47.2