summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cat/bsdcat.c18
-rw-r--r--cat/bsdcat.h1
2 files changed, 12 insertions, 7 deletions
diff --git a/cat/bsdcat.c b/cat/bsdcat.c
index c453201a..46eadfa0 100644
--- a/cat/bsdcat.c
+++ b/cat/bsdcat.c
@@ -65,17 +65,21 @@ bsdcat_next()
}
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 5daf3cf3..0f6e38e8 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);