Deleted Added
full compact
bzip2.c (90067) bzip2.c (146293)
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
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.
10 Copyright (C) 1996-2005 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.
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
44 jseward@bzip.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;
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 void* unusedTmpV;
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
529 UChar* unusedTmp;
530
531 nUnused = 0;
532 streamNo = 0;
533
534 SET_BINARY_MODE(stream);
535 SET_BINARY_MODE(zStream);
536

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

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

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

636static
637Bool testStream ( FILE *zStream )
638{
639 BZFILE* bzf = NULL;
640 Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i;
641 UChar obuf[5000];
642 UChar unused[BZ_MAX_UNUSED];
643 Int32 nUnused;
644 void* unusedTmpV;
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
645 UChar* unusedTmp;
646
647 nUnused = 0;
648 streamNo = 0;
649
650 SET_BINARY_MODE(zStream);
651 if (ferror(zStream)) goto errhandler_io;
652

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

660 streamNo++;
661
662 while (bzerr == BZ_OK) {
663 nread = BZ2_bzRead ( &bzerr, bzf, obuf, 5000 );
664 if (bzerr == BZ_DATA_ERROR_MAGIC) goto errhandler;
665 }
666 if (bzerr != BZ_STREAM_END) goto errhandler;
667
665 BZ2_bzReadGetUnused ( &bzerr, bzf, (void**)(&unusedTmp), &nUnused );
668 BZ2_bzReadGetUnused ( &bzerr, bzf, &unusedTmpV, &nUnused );
666 if (bzerr != BZ_OK) panic ( "test:bzReadGetUnused" );
667
669 if (bzerr != BZ_OK) panic ( "test:bzReadGetUnused" );
670
671 unusedTmp = (UChar*)unusedTmpV;
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"
672 for (i = 0; i < nUnused; i++) unused[i] = unusedTmp[i];
673
674 BZ2_bzReadClose ( &bzerr, bzf );
675 if (bzerr != BZ_OK) panic ( "test:bzReadGetUnused" );
676 if (nUnused == 0 && myfeof(zStream)) break;
677
678 }
679

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

827/*---------------------------------------------*/
828static
829void panic ( Char* s )
830{
831 fprintf ( stderr,
832 "\n%s: PANIC -- internal consistency error:\n"
833 "\t%s\n"
834 "\tThis is a BUG. Please report it to me at:\n"
831 "\tjseward@acm.org\n",
835 "\tjseward@bzip.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"
836 progName, s );
837 showFileNames();
838 cleanUpAndFail( 3 );
839}
840
841
842/*---------------------------------------------*/
843static

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

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

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

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

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

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

--- 418 unchanged lines hidden ---