Commit f93cd82a authored by Julian Seward's avatar Julian Seward

bzip2-0.9.5d

parent 977101ad
......@@ -43,3 +43,58 @@ In compress.c:
do a bit better on small files. This _does_ effect
bzip2.c.
0.9.5a
~~~~~~
Major change: add a fallback sorting algorithm (blocksort.c)
to give reasonable behaviour even for very repetitive inputs.
Nuked --repetitive-best and --repetitive-fast since they are
no longer useful.
Minor changes: mostly a whole bunch of small changes/
bugfixes in the driver (bzip2.c). Changes pertaining to the
user interface are:
allow decompression of symlink'd files to stdout
decompress/test files even without .bz2 extension
give more accurate error messages for I/O errors
when compressing/decompressing to stdout, don't catch control-C
read flags from BZIP2 and BZIP environment variables
decline to break hard links to a file unless forced with -f
allow -c flag even with no filenames
preserve file ownerships as far as possible
make -s -1 give the expected block size (100k)
add a flag -q --quiet to suppress nonessential warnings
stop decoding flags after --, so files beginning in - can be handled
resolved inconsistent naming: bzcat or bz2cat ?
bzip2 --help now returns 0
Programming-level changes are:
fixed syntax error in GET_LL4 for Borland C++ 5.02
let bzBuffToBuffDecompress return BZ_DATA_ERROR{_MAGIC}
fix overshoot of mode-string end in bzopen_or_bzdopen
wrapped bzlib.h in #ifdef __cplusplus ... extern "C" { ... }
close file handles under all error conditions
added minor mods so it compiles with DJGPP out of the box
fixed Makefile so it doesn't give problems with BSD make
fix uninitialised memory reads in dlltest.c
0.9.5b
~~~~~~
Open stdin/stdout in binary mode for DJGPP.
0.9.5c
~~~~~~
Changed BZ_N_OVERSHOOT to be ... + 2 instead of ... + 1. The + 1
version could cause the sorted order to be wrong in some extremely
obscure cases. Also changed setting of quadrant in blocksort.c.
0.9.5d
~~~~~~
The only functional change is to make bzlibVersion() in the library
return the correct string. This has no effect whatsoever on the
functioning of the bzip2 program or library. Added a couple of casts
so the library compiles without warnings at level 3 in MS Visual
Studio 6.0. Included a Y2K statement in the file Y2K_INFO. All other
changes are minor documentation changes.
This program, "bzip2" and associated library "libbzip2", are
copyright (C) 1996-1998 Julian R Seward. All rights reserved.
copyright (C) 1996-1999 Julian R Seward. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
......@@ -33,7 +33,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Guildford, Surrey, UK.
Julian Seward, Cambridge, UK.
jseward@acm.org
bzip2/libbzip2 version 0.9.0 of 28 June 1998
bzip2/libbzip2 version 0.9.5 of 24 May 1999
SHELL=/bin/sh
CC=gcc
CFLAGS=-Wall -O2 -fomit-frame-pointer -fno-strength-reduce
CFLAGS=-Wall -Winline -O2 -fomit-frame-pointer -fno-strength-reduce
OBJS= blocksort.o \
huffman.o \
......@@ -10,37 +11,93 @@ OBJS= blocksort.o \
decompress.o \
bzlib.o
all: lib bzip2 test
all: libbz2.a bzip2 bzip2recover test
bzip2: lib
$(CC) $(CFLAGS) -c bzip2.c
bzip2: libbz2.a bzip2.o
$(CC) $(CFLAGS) -o bzip2 bzip2.o -L. -lbz2
$(CC) $(CFLAGS) -o bzip2recover bzip2recover.c
lib: $(OBJS)
bzip2recover: bzip2recover.o
$(CC) $(CFLAGS) -o bzip2recover bzip2recover.o
libbz2.a: $(OBJS)
rm -f libbz2.a
ar clq libbz2.a $(OBJS)
ar cq libbz2.a $(OBJS)
@if ( test -f /usr/bin/ranlib -o -f /bin/ranlib -o \
-f /usr/ccs/bin/ranlib ) ; then \
echo ranlib libbz2.a ; \
ranlib libbz2.a ; \
fi
test: bzip2
@cat words1
./bzip2 -1 < sample1.ref > sample1.rb2
./bzip2 -2 < sample2.ref > sample2.rb2
./bzip2 -d < sample1.bz2 > sample1.tst
./bzip2 -d < sample2.bz2 > sample2.tst
@cat words2
./bzip2 -1 < sample1.ref > sample1.rb2
./bzip2 -2 < sample2.ref > sample2.rb2
./bzip2 -3 < sample3.ref > sample3.rb2
./bzip2 -d < sample1.bz2 > sample1.tst
./bzip2 -d < sample2.bz2 > sample2.tst
./bzip2 -ds < sample3.bz2 > sample3.tst
cmp sample1.bz2 sample1.rb2
cmp sample2.bz2 sample2.rb2
cmp sample3.bz2 sample3.rb2
cmp sample1.tst sample1.ref
cmp sample2.tst sample2.ref
cmp sample3.tst sample3.ref
@cat words3
PREFIX=/usr
install: bzip2 bzip2recover
if ( test ! -d $(PREFIX)/bin ) ; then mkdir $(PREFIX)/bin ; fi
if ( test ! -d $(PREFIX)/lib ) ; then mkdir $(PREFIX)/lib ; fi
if ( test ! -d $(PREFIX)/man ) ; then mkdir $(PREFIX)/man ; fi
if ( test ! -d $(PREFIX)/man/man1 ) ; then mkdir $(PREFIX)/man/man1 ; fi
if ( test ! -d $(PREFIX)/include ) ; then mkdir $(PREFIX)/include ; fi
cp -f bzip2 $(PREFIX)/bin/bzip2
cp -f bzip2 $(PREFIX)/bin/bunzip2
cp -f bzip2 $(PREFIX)/bin/bzcat
cp -f bzip2recover $(PREFIX)/bin/bzip2recover
chmod a+x $(PREFIX)/bin/bzip2
chmod a+x $(PREFIX)/bin/bunzip2
chmod a+x $(PREFIX)/bin/bzcat
chmod a+x $(PREFIX)/bin/bzip2recover
cp -f bzip2.1 $(PREFIX)/man/man1
chmod a+r $(PREFIX)/man/man1/bzip2.1
cp -f bzlib.h $(PREFIX)/include
chmod a+r $(PREFIX)/include/bzlib.h
cp -f libbz2.a $(PREFIX)/lib
chmod a+r $(PREFIX)/lib/libbz2.a
clean:
rm -f *.o libbz2.a bzip2 bzip2recover sample1.rb2 sample2.rb2 sample1.tst sample2.tst
rm -f *.o libbz2.a bzip2 bzip2recover \
sample1.rb2 sample2.rb2 sample3.rb2 \
sample1.tst sample2.tst sample3.tst
.c.o: $*.o bzlib.h bzlib_private.h
$(CC) $(CFLAGS) -c $*.c -o $*.o
blocksort.o: blocksort.c
$(CC) $(CFLAGS) -c blocksort.c
huffman.o: huffman.c
$(CC) $(CFLAGS) -c huffman.c
crctable.o: crctable.c
$(CC) $(CFLAGS) -c crctable.c
randtable.o: randtable.c
$(CC) $(CFLAGS) -c randtable.c
compress.o: compress.c
$(CC) $(CFLAGS) -c compress.c
decompress.o: decompress.c
$(CC) $(CFLAGS) -c decompress.c
bzlib.o: bzlib.c
$(CC) $(CFLAGS) -c bzlib.c
bzip2.o: bzip2.c
$(CC) $(CFLAGS) -c bzip2.c
bzip2recover.o: bzip2recover.c
$(CC) $(CFLAGS) -c bzip2recover.c
tarfile:
tar cvf interim.tar *.c *.h Makefile manual.texi manual.ps LICENSE bzip2.1 bzip2.1.preformatted bzip2.txt words1 words2 words3 sample1.ref sample2.ref sample1.bz2 sample2.bz2 *.html README CHANGES libbz2.def libbz2.dsp dlltest.dsp
tar cvf interim.tar blocksort.c huffman.c crctable.c \
randtable.c compress.c decompress.c bzlib.c bzip2.c \
bzip2recover.c bzlib.h bzlib_private.h Makefile manual.texi \
manual.ps LICENSE bzip2.1 bzip2.1.preformatted bzip2.txt \
words1 words2 words3 sample1.ref sample2.ref sample3.ref \
sample1.bz2 sample2.bz2 sample3.bz2 dlltest.c \
*.html README CHANGES libbz2.def libbz2.dsp \
dlltest.dsp makefile.msc Y2K_INFO
This is the README for bzip2, a block-sorting file compressor, version
0.9.0. This version is fully compatible with the previous public
release, bzip2-0.1pl2.
0.9.5d. This version is fully compatible with the previous public
releases, bzip2-0.1pl2 and bzip2-0.9.0.
bzip2-0.9.0 is distributed under a BSD-style license. For details,
bzip2-0.9.5 is distributed under a BSD-style license. For details,
see the file LICENSE.
Complete documentation is available in Postscript form (manual.ps)
or html (manual_toc.html). A plain-text version of the manual page is
available as bzip2.txt.
Complete documentation is available in Postscript form (manual.ps) or
html (manual_toc.html). A plain-text version of the manual page is
available as bzip2.txt. A statement about Y2K issues is now included
in the file Y2K_INFO.
HOW TO BUILD -- UNIX
Type `make'.
This creates binaries "bzip2" and "bzip2recover".
It also runs four compress-decompress tests to make sure things are
working properly. If all goes well, you should be up & running.
Please be sure to read the output from `make' just to be sure that the
tests went ok.
To install bzip2 properly:
* Copy the binaries "bzip2" and "bzip2recover" to a publically visible
place, possibly /usr/bin or /usr/local/bin.
Type `make'. This builds the library libbz2.a and then the
programs bzip2 and bzip2recover. Six self-tests are run.
If the self-tests complete ok, carry on to installation:
* In that directory, make "bunzip2" and "bzcat" be symbolic links
to "bzip2".
To install in /usr/bin, /usr/lib, /usr/man and /usr/include, type
make install
To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type
make install PREFIX=/xxx/yyy
If you are (justifiably) paranoid and want to see what 'make install'
is going to do, you can first do
make -n install or
make -n install PREFIX=/xxx/yyy respectively.
The -n instructs make to show the commands it would execute, but
not actually execute them.
* Copy the manual page, bzip2.1, to the relevant place.
Probably the right place is /usr/man/man1/.
If you want to program with the library, you'll need to copy libbz2.a
and bzlib.h to /usr/lib and /usr/include respectively.
HOW TO BUILD -- Windows 95, NT, DOS, Mac, etc.
It's difficult for me to support compilation on all these platforms.
My approach is to collect binaries for these platforms, and put them
on my web page (http://www.muraroa.demon.co.uk). Look there.
on my web page (http://www.muraroa.demon.co.uk). Look there. However
(FWIW), bzip2-0.9.5 is very standard ANSI C and should compile
unmodified with MS Visual C. For Win32, there is one important
caveat: in bzip2.c, you must set BZ_UNIX to 0 and BZ_LCCWIN32 to 1
before building.
VALIDATION
......@@ -112,26 +108,32 @@ WHAT'S NEW IN 0.9.0 (as compared to 0.1pl2) ?
* Much more documentation, i.e., a proper user manual
* Hopefully, improved portability (at least of the library)
WHAT'S NEW IN 0.9.5 ?
* Compression speed is much less sensitive to the input
data than in previous versions. Specifically, the very
slow performance caused by repetitive data is fixed.
* Many small improvements in file and flag handling.
* A Y2K statement.
I hope you find bzip2 useful. Feel free to contact me at
jseward@acm.org
if you have any suggestions or queries. Many people mailed me with
comments, suggestions and patches after the releases of bzip-0.15,
bzip-0.21 and bzip2-0.1pl2, and the changes in bzip2 are largely a
result of this feedback. I thank you for your comments.
bzip-0.21, bzip2-0.1pl2 and bzip2-0.9.0, and the changes in bzip2 are
largely a result of this feedback. I thank you for your comments.
At least for the time being, bzip2's "home" is
At least for the time being, bzip2's "home" is (or can be reached via)
http://www.muraroa.demon.co.uk.
Julian Seward
jseward@acm.org
Manchester, UK
18 July 1996 (version 0.15)
Cambridge, UK
18 July 1996 (version 0.15)
25 August 1996 (version 0.21)
Guildford, Surrey, UK
7 August 1997 (bzip2, version 0.1)
7 August 1997 (bzip2, version 0.1)
29 August 1997 (bzip2, version 0.1pl2)
23 August 1998 (bzip2, version 0.9.0)
8 June 1999 (bzip2, version 0.9.5)
4 Sept 1999 (bzip2, version 0.9.5d)
Y2K status of bzip2 and libbzip2, versions 0.1, 0.9.0 and 0.9.5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Informally speaking:
bzip2 is a compression program built on top of libbzip2,
a library which does the real work of compression and
decompression. As far as I am aware, libbzip2 does not have
any date-related code at all.
bzip2 itself copies dates from source to destination files
when compressing or decompressing, using the 'stat' and 'utime'
UNIX system calls. It doesn't examine, manipulate or store the
dates in any way. So as far as I can see, there shouldn't be any
problem with bzip2 providing 'stat' and 'utime' work correctly
on your system.
On non-unix platforms (those for which BZ_UNIX in bzip2.c is
not set to 1), bzip2 doesn't even do the date copying.
Overall, informally speaking, I don't think bzip2 or libbzip2
have a Y2K problem.
Formally speaking:
I am not prepared to offer you any assurance whatsoever
regarding Y2K issues in my software. You alone assume the
entire risk of using the software. The disclaimer of liability
in the LICENSE file in the bzip2 source distribution continues
to apply on this issue as with every other issue pertaining
to the software.
Julian Seward
Cambridge, UK
25 August 1999
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -7,9 +7,9 @@
/*--
This program is bzip2recover, a program to attempt data
salvage from damaged files created by the accompanying
bzip2-0.9.0c program.
bzip2-0.9.5 program.
Copyright (C) 1996-1998 Julian R Seward. All rights reserved.
Copyright (C) 1996-1999 Julian R Seward. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
......@@ -42,9 +42,9 @@
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Guildford, Surrey, UK.
Julian Seward, Cambridge, UK.
jseward@acm.org
bzip2/libbzip2 version 0.9.0c of 18 October 1998
bzip2/libbzip2 version 0.9.5 of 24 May 1999
--*/
/*--
......@@ -260,6 +260,12 @@ Bool endsInBz2 ( Char* name )
#define BLOCK_ENDMARK_HI 0x00001772UL
#define BLOCK_ENDMARK_LO 0x45385090UL
UInt32 bStart[20000];
UInt32 bEnd[20000];
UInt32 rbStart[20000];
UInt32 rbEnd[20000];
Int32 main ( Int32 argc, Char** argv )
{
FILE* inFile;
......@@ -267,11 +273,6 @@ Int32 main ( Int32 argc, Char** argv )
BitStream* bsIn, *bsWr;
Int32 currBlock, b, wrBlock;
UInt32 bitsRead;
UInt32 bStart[20000];
UInt32 bEnd[20000];
UInt32 rbStart[20000];
UInt32 rbEnd[20000];
Int32 rbCtr;
......@@ -281,7 +282,7 @@ Int32 main ( Int32 argc, Char** argv )
strcpy ( progName, argv[0] );
inFileName[0] = outFileName[0] = 0;
fprintf ( stderr, "bzip2recover v0.9.0c: extracts blocks from damaged .bz2 files.\n" );
fprintf ( stderr, "bzip2recover 0.9.5d: extracts blocks from damaged .bz2 files.\n" );
if (argc != 2) {
fprintf ( stderr, "%s: usage is `%s damaged_file_name'.\n",
......
......@@ -8,7 +8,7 @@
This file is a part of bzip2 and/or libbzip2, a program and
library for lossless, block-sorting data compression.
Copyright (C) 1996-1998 Julian R Seward. All rights reserved.
Copyright (C) 1996-1999 Julian R Seward. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
......@@ -41,9 +41,9 @@
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Guildford, Surrey, UK.
Julian Seward, Cambridge, UK.
jseward@acm.org
bzip2/libbzip2 version 0.9.0c of 18 October 1998
bzip2/libbzip2 version 0.9.5 of 24 May 1999
This program is based on (at least) the work of:
Mike Burrows
......@@ -86,14 +86,14 @@
void bz__AssertH__fail ( int errcode )
{
fprintf(stderr,
"\n\nbzip2/libbzip2, v0.9.0c: internal error number %d.\n"
"This is a bug in bzip2/libbzip2, v0.9.0c. Please report\n"
"\n\nbzip2/libbzip2, v0.9.5d: internal error number %d.\n"
"This is a bug in bzip2/libbzip2, v0.9.5d. Please report\n"
"it to me at: jseward@acm.org. If this happened when\n"
"you were using some program which uses libbzip2 as a\n"
"component, you should also report this bug to the author(s)\n"
"of that program. Please make an effort to report this bug;\n"
"timely and accurate bug reports eventually lead to higher\n"
"quality software. Thx. Julian Seward, 18 October 1998.\n\n",
"quality software. Thanks. Julian Seward, 4 Sept 1999.\n\n",
errcode
);
exit(3);
......@@ -171,29 +171,23 @@ int BZ_API(bzCompressInit)
if (s == NULL) return BZ_MEM_ERROR;
s->strm = strm;
s->block = NULL;
s->quadrant = NULL;
s->zptr = NULL;
s->ftab = NULL;
n = 100000 * blockSize100k;
s->block = BZALLOC( (n + BZ_NUM_OVERSHOOT_BYTES) * sizeof(UChar) );
s->quadrant = BZALLOC( (n + BZ_NUM_OVERSHOOT_BYTES) * sizeof(Int16) );
s->zptr = BZALLOC( n * sizeof(Int32) );
s->ftab = BZALLOC( 65537 * sizeof(Int32) );
if (s->block == NULL || s->quadrant == NULL ||
s->zptr == NULL || s->ftab == NULL) {
if (s->block != NULL) BZFREE(s->block);
if (s->quadrant != NULL) BZFREE(s->quadrant);
if (s->zptr != NULL) BZFREE(s->zptr);
if (s->ftab != NULL) BZFREE(s->ftab);
if (s != NULL) BZFREE(s);
s->arr1 = NULL;
s->arr2 = NULL;
s->ftab = NULL;
n = 100000 * blockSize100k;
s->arr1 = BZALLOC( n * sizeof(UInt32) );
s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
s->ftab = BZALLOC( 65537 * sizeof(UInt32) );
if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) {
if (s->arr1 != NULL) BZFREE(s->arr1);
if (s->arr2 != NULL) BZFREE(s->arr2);
if (s->ftab != NULL) BZFREE(s->ftab);
if (s != NULL) BZFREE(s);
return BZ_MEM_ERROR;
}
s->szptr = (UInt16*)(s->zptr);
s->blockNo = 0;
s->state = BZ_S_INPUT;
s->mode = BZ_M_RUNNING;
......@@ -202,7 +196,12 @@ int BZ_API(bzCompressInit)
s->nblockMAX = 100000 * blockSize100k - 19;
s->verbosity = verbosity;
s->workFactor = workFactor;
s->nBlocksRandomised = 0;
s->block = (UInt16*)s->arr2;
s->mtfv = (UInt16*)s->arr1;
s->zbits = NULL;
s->ptr = (UInt32*)s->arr1;
strm->state = s;
strm->total_in = 0;
strm->total_out = 0;
......@@ -224,24 +223,24 @@ void add_pair_to_block ( EState* s )
s->inUse[s->state_in_ch] = True;
switch (s->state_in_len) {
case 1:
s->block[s->nblock] = (UChar)ch; s->nblock++;
s->block[s->nblock] = (UInt16)ch; s->nblock++;
break;
case 2:
s->block[s->nblock] = (UChar)ch; s->nblock++;
s->block[s->nblock] = (UChar)ch; s->nblock++;
s->block[s->nblock] = (UInt16)ch; s->nblock++;
s->block[s->nblock] = (UInt16)ch; s->nblock++;
break;
case 3:
s->block[s->nblock] = (UChar)ch; s->nblock++;
s->block[s->nblock] = (UChar)ch; s->nblock++;
s->block[s->nblock] = (UChar)ch; s->nblock++;
s->block[s->nblock] = (UInt16)ch; s->nblock++;
s->block[s->nblock] = (UInt16)ch; s->nblock++;
s->block[s->nblock] = (UInt16)ch; s->nblock++;
break;
default:
s->inUse[s->state_in_len-4] = True;
s->block[s->nblock] = (UChar)ch; s->nblock++;
s->block[s->nblock] = (UChar)ch; s->nblock++;
s->block[s->nblock] = (UChar)ch; s->nblock++;
s->block[s->nblock] = (UChar)ch; s->nblock++;
s->block[s->nblock] = (UChar)(s->state_in_len-4);
s->block[s->nblock] = (UInt16)ch; s->nblock++;
s->block[s->nblock] = (UInt16)ch; s->nblock++;
s->block[s->nblock] = (UInt16)ch; s->nblock++;
s->block[s->nblock] = (UInt16)ch; s->nblock++;
s->block[s->nblock] = ((UInt16)(s->state_in_len-4));
s->nblock++;
break;
}
......@@ -267,7 +266,7 @@ void flush_RL ( EState* s )
UChar ch = (UChar)(zs->state_in_ch); \
BZ_UPDATE_CRC( zs->blockCRC, ch ); \
zs->inUse[zs->state_in_ch] = True; \
zs->block[zs->nblock] = (UChar)ch; \
zs->block[zs->nblock] = (UInt16)ch; \
zs->nblock++; \
zs->state_in_ch = zchh; \
} \
......@@ -343,7 +342,7 @@ Bool copy_output_until_stop ( EState* s )
if (s->state_out_pos >= s->numZ) break;
progress_out = True;
*(s->strm->next_out) = ((UChar*)(s->quadrant))[s->state_out_pos];
*(s->strm->next_out) = s->zbits[s->state_out_pos];
s->state_out_pos++;
s->strm->avail_out--;
s->strm->next_out++;
......@@ -382,7 +381,7 @@ Bool handle_compress ( bz_stream* strm )
progress_in |= copy_input_until_stop ( s );
if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) {
flush_RL ( s );
compressBlock ( s, s->mode == BZ_M_FINISHING );
compressBlock ( s, (Bool)(s->mode == BZ_M_FINISHING) );
s->state = BZ_S_OUTPUT;
}
else
......@@ -470,10 +469,9 @@ int BZ_API(bzCompressEnd) ( bz_stream *strm )
if (s == NULL) return BZ_PARAM_ERROR;
if (s->strm != strm) return BZ_PARAM_ERROR;
if (s->block != NULL) BZFREE(s->block);
if (s->quadrant != NULL) BZFREE(s->quadrant);
if (s->zptr != NULL) BZFREE(s->zptr);
if (s->ftab != NULL) BZFREE(s->ftab);
if (s->arr1 != NULL) BZFREE(s->arr1);
if (s->arr2 != NULL) BZFREE(s->arr2);
if (s->ftab != NULL) BZFREE(s->ftab);
BZFREE(strm->state);
strm->state = NULL;
......@@ -816,7 +814,8 @@ int BZ_API(bzDecompress) ( bz_stream *strm )
}
AssertH ( 0, 6001 );
/*notreached*/
return 0; /*NOTREACHED*/
}
......@@ -1284,7 +1283,7 @@ int BZ_API(bzBuffToBuffDecompress)
errhandler:
bzDecompressEnd ( &strm );
return BZ_SEQUENCE_ERROR;
return ret;
}
......@@ -1339,24 +1338,18 @@ BZFILE * bzopen_or_bzdopen
int smallMode = 0;
int nUnused = 0;
if(mode==NULL){return NULL;}
while(*mode){
switch(*mode){
if (mode == NULL) return NULL;
while (*mode) {
switch (*mode) {
case 'r':
writing = 0;break;
writing = 0; break;
case 'w':
writing = 1;break;
writing = 1; break;
case 's':
smallMode = 1;break;
smallMode = 1; break;
default:
if(isdigit(*mode)){
blockSize100k = 0;
while(isdigit(*mode)){
blockSize100k = blockSize100k*10 + *mode-'0';
mode++;
}
}else{
/* ignore */
if (isdigit((int)(*mode))) {
blockSize100k = *mode-'0';
}
}
mode++;
......@@ -1364,29 +1357,32 @@ BZFILE * bzopen_or_bzdopen
strcat(mode2, writing ? "w" : "r" );
strcat(mode2,"b"); /* binary mode */
if(open_mode==0){
if(path==NULL || strcmp(path,"")==0){
if (open_mode==0) {
if (path==NULL || strcmp(path,"")==0) {
fp = (writing ? stdout : stdin);
SET_BINARY_MODE(fp);
}else{
} else {
fp = fopen(path,mode2);
}
}else{
} else {
#ifdef BZ_STRICT_ANSI
fp = NULL;
#else
fp = fdopen(fd,mode2);
#endif
}
if(fp==NULL){return NULL;}
if (fp == NULL) return NULL;
if(writing){
if (writing) {
/* Guard against total chaos and anarchy -- JRS */
if (blockSize100k < 1) blockSize100k = 1;
if (blockSize100k > 9) blockSize100k = 9;
bzfp = bzWriteOpen(&bzerr,fp,blockSize100k,verbosity,workFactor);
}else{
} else {
bzfp = bzReadOpen(&bzerr,fp,verbosity,smallMode,unused,nUnused);
}
if(bzfp==NULL){
if(fp!=stdin && fp!=stdout) fclose(fp);
if (bzfp == NULL) {
if (fp != stdin && fp != stdout) fclose(fp);
return NULL;
}
return bzfp;
......@@ -1458,7 +1454,7 @@ void BZ_API(bzclose) (BZFILE* b)
int bzerr;
FILE *fp = ((bzFile *)b)->handle;
if(b==NULL){return;}
if (b==NULL) {return;}
if(((bzFile*)b)->writing){
bzWriteClose(&bzerr,b,0,NULL,NULL);
if(bzerr != BZ_OK){
......
......@@ -8,7 +8,7 @@
This file is a part of bzip2 and/or libbzip2, a program and
library for lossless, block-sorting data compression.
Copyright (C) 1996-1998 Julian R Seward. All rights reserved.
Copyright (C) 1996-1999 Julian R Seward. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
......@@ -41,9 +41,9 @@
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Guildford, Surrey, UK.
Julian Seward, Cambridge, UK.
jseward@acm.org
bzip2/libbzip2 version 0.9.0c of 18 October 1998
bzip2/libbzip2 version 0.9.5 of 24 May 1999
This program is based on (at least) the work of:
Mike Burrows
......@@ -62,6 +62,10 @@
#ifndef _BZLIB_H
#define _BZLIB_H
#ifdef __cplusplus
extern "C" {
#endif
#define BZ_RUN 0
#define BZ_FLUSH 1
#define BZ_FINISH 2
......@@ -291,6 +295,9 @@ BZ_EXTERN const char * BZ_API(bzerror) (
);
#endif
#ifdef __cplusplus
}
#endif
#endif
......
......@@ -8,7 +8,7 @@
This file is a part of bzip2 and/or libbzip2, a program and
library for lossless, block-sorting data compression.
Copyright (C) 1996-1998 Julian R Seward. All rights reserved.
Copyright (C) 1996-1999 Julian R Seward. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
......@@ -41,9 +41,9 @@
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Julian Seward, Guildford, Surrey, UK.
Julian Seward, Cambridge, UK.
jseward@acm.org
bzip2/libbzip2 version 0.9.0c of 18 October 1998
bzip2/libbzip2 version 0.9.5 of 24 May 1999
This program is based on (at least) the work of:
Mike Burrows
......@@ -76,7 +76,7 @@
/*-- General stuff. --*/
#define BZ_VERSION "0.9.0c"
#define BZ_VERSION "0.9.5d"
typedef char Char;
typedef unsigned char Bool;
......@@ -85,7 +85,7 @@ typedef int Int32;
typedef unsigned int UInt32;
typedef short Int16;
typedef unsigned short UInt16;