]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Change bsdcat behavior to process as many files as possible.
authorMike Kazantsev <mk.fraggod@gmail.com>
Sat, 5 Apr 2014 22:40:40 +0000 (04:40 +0600)
committerfraggod@sacrilege <mk.fraggod@gmail.com>
Sat, 5 Apr 2014 22:44:34 +0000 (04:44 +0600)
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
cat/bsdcat.h

index c453201a2e9b770b851eef67f08051f227883bd4..46eadfa0f119a06de572c0513aa9dd843b11a8b8 100644 (file)
@@ -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
index 5daf3cf3ac6b602cca68e0c58d8718014368ac36..0f6e38e89445a3d5c6740f550ab93c21ea5d07f4 100644 (file)
@@ -36,4 +36,5 @@
 
 void usage(void);
 void bsdcat_next(void);
+void bsdcat_print_error(void);
 void bsdcat_read_to_stdout(char* filename);