From: Mike Kazantsev Date: Sat, 5 Apr 2014 22:40:40 +0000 (+0600) Subject: Change bsdcat behavior to process as many files as possible. X-Git-Tag: v3.1.900a~308^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1628626209899fa841c2befd8fedb97fe182b67;p=thirdparty%2Flibarchive.git 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. --- 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);