Deleted Added
full compact
1
2/*-----------------------------------------------------------*/
3/*--- A block-sorting, lossless compressor bzip2.c ---*/
4/*-----------------------------------------------------------*/
5
6/*--
7 This file is a part of bzip2 and/or libbzip2, a program and
8 library for lossless, block-sorting data compression.
9
10 Copyright (C) 1996-2002 Julian R Seward. All rights reserved.
11
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
14 are met:
15
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
18

--- 17 unchanged lines hidden (view full) ---

36 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
37 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
40 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42
43 Julian Seward, Cambridge, UK.
44 jseward@acm.org
45 bzip2/libbzip2 version 1.0 of 21 March 2000
46
47 This program is based on (at least) the work of:
48 Mike Burrows
49 David Wheeler
50 Peter Fenwick
51 Alistair Moffat
52 Radford Neal

--- 467 unchanged lines hidden (view full) ---

520static
521Bool uncompressStream ( FILE *zStream, FILE *stream )
522{
523 BZFILE* bzf = NULL;
524 Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i;
525 UChar obuf[5000];
526 UChar unused[BZ_MAX_UNUSED];
527 Int32 nUnused;
528 UChar* unusedTmp;
529
530 nUnused = 0;
531 streamNo = 0;
532
533 SET_BINARY_MODE(stream);
534 SET_BINARY_MODE(zStream);
535

--- 13 unchanged lines hidden (view full) ---

549 nread = BZ2_bzRead ( &bzerr, bzf, obuf, 5000 );
550 if (bzerr == BZ_DATA_ERROR_MAGIC) goto trycat;
551 if ((bzerr == BZ_OK || bzerr == BZ_STREAM_END) && nread > 0)
552 fwrite ( obuf, sizeof(UChar), nread, stream );
553 if (ferror(stream)) goto errhandler_io;
554 }
555 if (bzerr != BZ_STREAM_END) goto errhandler;
556
557 BZ2_bzReadGetUnused ( &bzerr, bzf, (void**)(&unusedTmp), &nUnused );
558 if (bzerr != BZ_OK) panic ( "decompress:bzReadGetUnused" );
559
560 for (i = 0; i < nUnused; i++) unused[i] = unusedTmp[i];
561
562 BZ2_bzReadClose ( &bzerr, bzf );
563 if (bzerr != BZ_OK) panic ( "decompress:bzReadGetUnused" );
564
565 if (nUnused == 0 && myfeof(zStream)) break;
566 }
567

--- 66 unchanged lines hidden (view full) ---

634static
635Bool testStream ( FILE *zStream )
636{
637 BZFILE* bzf = NULL;
638 Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i;
639 UChar obuf[5000];
640 UChar unused[BZ_MAX_UNUSED];
641 Int32 nUnused;
642 UChar* unusedTmp;
643
644 nUnused = 0;
645 streamNo = 0;
646
647 SET_BINARY_MODE(zStream);
648 if (ferror(zStream)) goto errhandler_io;
649

--- 7 unchanged lines hidden (view full) ---

657 streamNo++;
658
659 while (bzerr == BZ_OK) {
660 nread = BZ2_bzRead ( &bzerr, bzf, obuf, 5000 );
661 if (bzerr == BZ_DATA_ERROR_MAGIC) goto errhandler;
662 }
663 if (bzerr != BZ_STREAM_END) goto errhandler;
664
665 BZ2_bzReadGetUnused ( &bzerr, bzf, (void**)(&unusedTmp), &nUnused );
666 if (bzerr != BZ_OK) panic ( "test:bzReadGetUnused" );
667
668 for (i = 0; i < nUnused; i++) unused[i] = unusedTmp[i];
669
670 BZ2_bzReadClose ( &bzerr, bzf );
671 if (bzerr != BZ_OK) panic ( "test:bzReadGetUnused" );
672 if (nUnused == 0 && myfeof(zStream)) break;
673
674 }
675

--- 147 unchanged lines hidden (view full) ---

823/*---------------------------------------------*/
824static
825void panic ( Char* s )
826{
827 fprintf ( stderr,
828 "\n%s: PANIC -- internal consistency error:\n"
829 "\t%s\n"
830 "\tThis is a BUG. Please report it to me at:\n"
831 "\tjseward@acm.org\n",
832 progName, s );
833 showFileNames();
834 cleanUpAndFail( 3 );
835}
836
837
838/*---------------------------------------------*/
839static

--- 63 unchanged lines hidden (view full) ---

903 " (1) This computer has unreliable memory or cache hardware\n"
904 " (a surprisingly common problem; try a different machine.)\n"
905 " (2) A bug in the compiler used to create this executable\n"
906 " (unlikely, if you didn't compile bzip2 yourself.)\n"
907 " (3) A real bug in bzip2 -- I hope this should never be the case.\n"
908 " The user's manual, Section 4.3, has more info on (1) and (2).\n"
909 " \n"
910 " If you suspect this is a bug in bzip2, or are unsure about (1)\n"
911 " or (2), feel free to report it to me at: jseward@acm.org.\n"
912 " Section 4.3 of the user's manual describes the info a useful\n"
913 " bug report should have. If the manual is available on your\n"
914 " system, please try and read it before mailing me. If you don't\n"
915 " have the manual or can't be bothered to read it, mail me anyway.\n"
916 "\n",
917 progName );
918 else
919 fprintf (

--- 6 unchanged lines hidden (view full) ---

926 " (2) This computer has unreliable memory or cache hardware\n"
927 " (a surprisingly common problem; try a different machine.)\n"
928 " (3) A bug in the compiler used to create this executable\n"
929 " (unlikely, if you didn't compile bzip2 yourself.)\n"
930 " (4) A real bug in bzip2 -- I hope this should never be the case.\n"
931 " The user's manual, Section 4.3, has more info on (2) and (3).\n"
932 " \n"
933 " If you suspect this is a bug in bzip2, or are unsure about (2)\n"
934 " or (3), feel free to report it to me at: jseward@acm.org.\n"
935 " Section 4.3 of the user's manual describes the info a useful\n"
936 " bug report should have. If the manual is available on your\n"
937 " system, please try and read it before mailing me. If you don't\n"
938 " have the manual or can't be bothered to read it, mail me anyway.\n"
939 "\n",
940 progName );
941
942 showFileNames();

--- 726 unchanged lines hidden (view full) ---

1669static
1670void license ( void )
1671{
1672 fprintf ( stderr,
1673
1674 "bzip2, a block-sorting file compressor. "
1675 "Version %s.\n"
1676 " \n"
1677 " Copyright (C) 1996-2002 by Julian Seward.\n"
1678 " \n"
1679 " This program is free software; you can redistribute it and/or modify\n"
1680 " it under the terms set out in the LICENSE file, which is included\n"
1681 " in the bzip2-1.0 source distribution.\n"
1682 " \n"
1683 " This program is distributed in the hope that it will be useful,\n"
1684 " but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
1685 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"

--- 418 unchanged lines hidden ---