1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00
elinks/contrib/bzip2-pipe.patch
Witold Filipczyk 36146ffd3b bzip2: removed unclean my BZ2_bzRead2.
Use the patched bzlib instead. I put the bzip2-pipe.patch
in the contrib directory.
2006-12-15 13:44:59 +01:00

37 lines
1.3 KiB
Diff

--- bzip2-1.0.3/bzlib.c.old 2006-12-15 11:00:53.000000000 +0100
+++ bzip2-1.0.3/bzlib.c 2006-12-15 11:10:57.000000000 +0100
@@ -1209,6 +1209,7 @@
int len )
{
Int32 n, ret;
+ Int32 pi = 0;
bzFile* bzf = (bzFile*)b;
BZ_SETERR(BZ_OK);
@@ -1233,8 +1234,10 @@
if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) {
n = fread ( bzf->buf, sizeof(UChar),
BZ_MAX_UNUSED, bzf->handle );
- if (ferror(bzf->handle))
- { BZ_SETERR(BZ_IO_ERROR); return 0; };
+ if (ferror(bzf->handle)) {
+ if (n >= 0) pi = 1;
+ else { BZ_SETERR(BZ_IO_ERROR); return 0; }
+ }
bzf->bufN = n;
bzf->strm.avail_in = bzf->bufN;
bzf->strm.next_in = bzf->buf;
@@ -1246,8 +1249,10 @@
{ BZ_SETERR(ret); return 0; };
if (ret == BZ_OK && myfeof(bzf->handle) &&
- bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0)
- { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; };
+ bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0) {
+ if (!pi) { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; }
+ else return len - bzf->strm.avail_out;
+ }
if (ret == BZ_STREAM_END)
{ BZ_SETERR(BZ_STREAM_END);