Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/gzip fix support for multi-section bzip2 files, as c...
details: https://anonhg.NetBSD.org/src/rev/6a263b55d828
branches: trunk
changeset: 748037:6a263b55d828
user: mrg <mrg%NetBSD.org@localhost>
date: Sun Oct 11 05:17:20 2009 +0000
description:
fix support for multi-section bzip2 files, as created by pbzip2.
diffstat:
usr.bin/gzip/unbzip2.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
diffs (54 lines):
diff -r c36238cc0992 -r 6a263b55d828 usr.bin/gzip/unbzip2.c
--- a/usr.bin/gzip/unbzip2.c Sun Oct 11 01:55:28 2009 +0000
+++ b/usr.bin/gzip/unbzip2.c Sun Oct 11 05:17:20 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: unbzip2.c,v 1.11 2008/04/28 20:24:13 martin Exp $ */
+/* $NetBSD: unbzip2.c,v 1.12 2009/10/11 05:17:20 mrg Exp $ */
/*-
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
if (bytes_in)
*bytes_in = prelen;
- while (ret >= BZ_OK && ret != BZ_STREAM_END) {
+ while (ret == BZ_OK) {
if (bzs.avail_in == 0 && !end_of_file) {
ssize_t n;
@@ -86,7 +86,7 @@
case BZ_OK:
if (ret == BZ_OK && end_of_file)
maybe_err("read");
- if (!tflag) {
+ if (!tflag && bzs.avail_out != BUFLEN) {
ssize_t n;
n = write(out, outbuf, BUFLEN - bzs.avail_out);
@@ -94,7 +94,13 @@
maybe_err("write");
bytes_out += n;
}
- break;
+ if (ret == BZ_STREAM_END && !end_of_file) {
+ if (BZ2_bzDecompressEnd(&bzs) != BZ_OK ||
+ BZ2_bzDecompressInit(&bzs, 0, 0) != BZ_OK)
+ maybe_errx("bzip2 re-init");
+ ret = BZ_OK;
+ }
+ break;
case BZ_DATA_ERROR:
maybe_warnx("bzip2 data integrity error");
@@ -107,7 +113,10 @@
case BZ_MEM_ERROR:
maybe_warnx("bzip2 out of memory");
break;
-
+
+ default:
+ maybe_warnx("unknown bzip2 error: %d", ret);
+ break;
}
}
Home |
Main Index |
Thread Index |
Old Index