diff options
author | Petter Rodhelind <petter.rodhelind@gmail.com> | 2020-01-14 11:41:08 +0100 |
---|---|---|
committer | Petter Rodhelind <petter.rodhelind@gmail.com> | 2020-01-14 11:41:08 +0100 |
commit | 02d7aa8915f9c3a3288dab01f321eb94ba219e3b (patch) | |
tree | f053238978479e408a2b83571443e132f30586ab /src/cmd/bzip2/lib | |
parent | c0c9d8f883dfd3a7f5a74499d91bb95884b15873 (diff) | |
parent | 3d1382b98a502d0c34d5ba2c462396acc515016e (diff) | |
download | plan9port-02d7aa8915f9c3a3288dab01f321eb94ba219e3b.tar.gz plan9port-02d7aa8915f9c3a3288dab01f321eb94ba219e3b.tar.bz2 plan9port-02d7aa8915f9c3a3288dab01f321eb94ba219e3b.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/cmd/bzip2/lib')
25 files changed, 509 insertions, 523 deletions
diff --git a/src/cmd/bzip2/lib/blocksort.c b/src/cmd/bzip2/lib/blocksort.c index f43d569e..e6d154b3 100644 --- a/src/cmd/bzip2/lib/blocksort.c +++ b/src/cmd/bzip2/lib/blocksort.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -57,8 +57,8 @@ For more information on these sources, see the manual. - To get some idea how the block sorting algorithms in this file - work, read my paper + To get some idea how the block sorting algorithms in this file + work, read my paper On the Performance of BWT Sorting Algorithms in Proceedings of the IEEE Data Compression Conference 2000, Snowbird, Utah, USA, 27-30 March 2000. The main sort in this @@ -75,11 +75,11 @@ /*---------------------------------------------*/ /*---------------------------------------------*/ -static +static __inline__ -void fallbackSimpleSort ( UInt32* fmap, - UInt32* eclass, - Int32 lo, +void fallbackSimpleSort ( UInt32* fmap, + UInt32* eclass, + Int32 lo, Int32 hi ) { Int32 i, j, tmp; @@ -138,9 +138,9 @@ void fallbackSimpleSort ( UInt32* fmap, static -void fallbackQSort3 ( UInt32* fmap, +void fallbackQSort3 ( UInt32* fmap, UInt32* eclass, - Int32 loSt, + Int32 loSt, Int32 hiSt ) { Int32 unLo, unHi, ltLo, gtHi, n, m; @@ -165,9 +165,9 @@ void fallbackQSort3 ( UInt32* fmap, } /* Random partitioning. Median of 3 sometimes fails to - avoid bad cases. Median of 9 seems to help but + avoid bad cases. Median of 9 seems to help but looks rather expensive. This too seems to work but - is cheaper. Guidance for the magic constants + is cheaper. Guidance for the magic constants 7621 and 32768 is taken from Sedgewick's algorithms book, chapter 35. */ @@ -184,10 +184,10 @@ void fallbackQSort3 ( UInt32* fmap, while (1) { if (unLo > unHi) break; n = (Int32)eclass[fmap[unLo]] - (Int32)med; - if (n == 0) { - fswap(fmap[unLo], fmap[ltLo]); - ltLo++; unLo++; - continue; + if (n == 0) { + fswap(fmap[unLo], fmap[ltLo]); + ltLo++; unLo++; + continue; }; if (n > 0) break; unLo++; @@ -195,10 +195,10 @@ void fallbackQSort3 ( UInt32* fmap, while (1) { if (unLo > unHi) break; n = (Int32)eclass[fmap[unHi]] - (Int32)med; - if (n == 0) { - fswap(fmap[unHi], fmap[gtHi]); - gtHi--; unHi--; - continue; + if (n == 0) { + fswap(fmap[unHi], fmap[gtHi]); + gtHi--; unHi--; + continue; }; if (n < 0) break; unHi--; @@ -257,8 +257,8 @@ void fallbackQSort3 ( UInt32* fmap, #define UNALIGNED_BH(zz) ((zz) & 0x01f) static -void fallbackSort ( UInt32* fmap, - UInt32* eclass, +void fallbackSort ( UInt32* fmap, + UInt32* eclass, UInt32* bhtab, Int32 nblock, Int32 verb ) @@ -299,7 +299,7 @@ void fallbackSort ( UInt32* fmap, --*/ /*-- set sentinel bits for block-end detection --*/ - for (i = 0; i < 32; i++) { + for (i = 0; i < 32; i++) { SET_BH(nblock + 2*i); CLEAR_BH(nblock + 2*i + 1); } @@ -308,7 +308,7 @@ void fallbackSort ( UInt32* fmap, H = 1; while (1) { - if (verb >= 4) + if (verb >= 4) VPrintf1 ( " depth %6d has ", H ); j = 0; @@ -353,14 +353,14 @@ void fallbackSort ( UInt32* fmap, } } - if (verb >= 4) + if (verb >= 4) VPrintf1 ( "%6d unresolved strings\n", nNotDone ); H *= 2; if (H > nblock || nNotDone == 0) break; } - /*-- + /*-- Reconstruct the original block in eclass8 [0 .. nblock-1], since the previous phase destroyed it. @@ -392,9 +392,9 @@ void fallbackSort ( UInt32* fmap, /*---------------------------------------------*/ static __inline__ -Bool mainGtU ( UInt32 i1, +Bool mainGtU ( UInt32 i1, UInt32 i2, - UChar* block, + UChar* block, UInt16* quadrant, UInt32 nblock, Int32* budget ) @@ -534,8 +534,8 @@ void mainSimpleSort ( UInt32* ptr, UChar* block, UInt16* quadrant, Int32 nblock, - Int32 lo, - Int32 hi, + Int32 lo, + Int32 hi, Int32 d, Int32* budget ) { @@ -559,8 +559,8 @@ void mainSimpleSort ( UInt32* ptr, if (i > hi) break; v = ptr[i]; j = i; - while ( mainGtU ( - ptr[j-h]+d, v+d, block, quadrant, nblock, budget + while ( mainGtU ( + ptr[j-h]+d, v+d, block, quadrant, nblock, budget ) ) { ptr[j] = ptr[j-h]; j = j - h; @@ -573,8 +573,8 @@ void mainSimpleSort ( UInt32* ptr, if (i > hi) break; v = ptr[i]; j = i; - while ( mainGtU ( - ptr[j-h]+d, v+d, block, quadrant, nblock, budget + while ( mainGtU ( + ptr[j-h]+d, v+d, block, quadrant, nblock, budget ) ) { ptr[j] = ptr[j-h]; j = j - h; @@ -587,8 +587,8 @@ void mainSimpleSort ( UInt32* ptr, if (i > hi) break; v = ptr[i]; j = i; - while ( mainGtU ( - ptr[j-h]+d, v+d, block, quadrant, nblock, budget + while ( mainGtU ( + ptr[j-h]+d, v+d, block, quadrant, nblock, budget ) ) { ptr[j] = ptr[j-h]; j = j - h; @@ -626,13 +626,13 @@ void mainSimpleSort ( UInt32* ptr, } \ } -static +static __inline__ UChar mmed3 ( UChar a, UChar b, UChar c ) { UChar t; if (a > b) { t = a; a = b; b = t; }; - if (b > c) { + if (b > c) { b = c; if (a > b) b = a; } @@ -670,8 +670,8 @@ void mainQSort3 ( UInt32* ptr, UChar* block, UInt16* quadrant, Int32 nblock, - Int32 loSt, - Int32 hiSt, + Int32 loSt, + Int32 hiSt, Int32 dSt, Int32* budget ) { @@ -694,14 +694,14 @@ void mainQSort3 ( UInt32* ptr, AssertH ( sp < MAIN_QSORT_STACK_SIZE, 1001 ); mpop ( lo, hi, d ); - if (hi - lo < MAIN_QSORT_SMALL_THRESH || + if (hi - lo < MAIN_QSORT_SMALL_THRESH || d > MAIN_QSORT_DEPTH_THRESH) { mainSimpleSort ( ptr, block, quadrant, nblock, lo, hi, d, budget ); if (*budget < 0) return; continue; } - med = (Int32) + med = (Int32) mmed3 ( block[ptr[ lo ]+d], block[ptr[ hi ]+d], block[ptr[ (lo+hi)>>1 ]+d] ); @@ -713,9 +713,9 @@ void mainQSort3 ( UInt32* ptr, while (True) { if (unLo > unHi) break; n = ((Int32)block[ptr[unLo]+d]) - med; - if (n == 0) { - mswap(ptr[unLo], ptr[ltLo]); - ltLo++; unLo++; continue; + if (n == 0) { + mswap(ptr[unLo], ptr[ltLo]); + ltLo++; unLo++; continue; }; if (n > 0) break; unLo++; @@ -723,9 +723,9 @@ void mainQSort3 ( UInt32* ptr, while (True) { if (unLo > unHi) break; n = ((Int32)block[ptr[unHi]+d]) - med; - if (n == 0) { - mswap(ptr[unHi], ptr[gtHi]); - gtHi--; unHi--; continue; + if (n == 0) { + mswap(ptr[unHi], ptr[gtHi]); + gtHi--; unHi--; continue; }; if (n < 0) break; unHi--; @@ -796,9 +796,9 @@ void mainQSort3 ( UInt32* ptr, #define CLEARMASK (~(SETMASK)) static -void mainSort ( UInt32* ptr, +void mainSort ( UInt32* ptr, UChar* block, - UInt16* quadrant, + UInt16* quadrant, UInt32* ftab, Int32 nblock, Int32 verb, @@ -926,7 +926,7 @@ void mainSort ( UInt32* ptr, /*-- Step 1: Complete the big bucket [ss] by quicksorting - any unsorted small buckets [ss, j], for j != ss. + any unsorted small buckets [ss, j], for j != ss. Hopefully previous pointer-scanning phases have already completed many of the small buckets [ss, j], so we don't have to sort them at all. @@ -942,10 +942,10 @@ void mainSort ( UInt32* ptr, VPrintf4 ( " qsort [0x%x, 0x%x] " "done %d this %d\n", ss, j, numQSorted, hi - lo + 1 ); - mainQSort3 ( - ptr, block, quadrant, nblock, - lo, hi, BZ_N_RADIX, budget - ); + mainQSort3 ( + ptr, block, quadrant, nblock, + lo, hi, BZ_N_RADIX, budget + ); numQSorted += (hi - lo + 1); if (*budget < 0) return; } @@ -977,7 +977,7 @@ void mainSort ( UInt32* ptr, for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) { k = ptr[j]-1; if (k < 0) k += nblock; c1 = block[k]; - if (!bigDone[c1]) + if (!bigDone[c1]) ptr[ copyEnd[c1]-- ] = k; } } @@ -996,7 +996,7 @@ void mainSort ( UInt32* ptr, updating for the last bucket is pointless. The quadrant array provides a way to incrementally - cache sort orderings, as they appear, so as to + cache sort orderings, as they appear, so as to make subsequent comparisons in fullGtU() complete faster. For repetitive blocks this makes a big difference (but not big enough to be able to avoid @@ -1006,9 +1006,9 @@ void mainSort ( UInt32* ptr, for 0 <= i < nblock and 0 <= j <= nblock - if block[i] != block[j], + if block[i] != block[j], - then the relative values of quadrant[i] and + then the relative values of quadrant[i] and quadrant[j] are meaningless. else { @@ -1071,7 +1071,7 @@ void mainSort ( UInt32* ptr, */ void BZ2_blockSort ( EState* s ) { - UInt32* ptr = s->ptr; + UInt32* ptr = s->ptr; UChar* block = s->block; UInt32* ftab = s->ftab; Int32 nblock = s->nblock; @@ -1095,8 +1095,8 @@ void BZ2_blockSort ( EState* s ) quadrant = (UInt16*)(&(block[i])); /* (wfact-1) / 3 puts the default-factor-30 - transition point at very roughly the same place as - with v0.1 and v0.9.0. + transition point at very roughly the same place as + with v0.1 and v0.9.0. Not that it particularly matters any more, since the resulting compressed stream is now the same regardless of whether or not we use the main sort or fallback sort. @@ -1107,14 +1107,14 @@ void BZ2_blockSort ( EState* s ) budget = budgetInit; mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget ); - if (verb >= 3) + if (verb >= 3) VPrintf3 ( " %d work, %d block, ratio %5.2f\n", budgetInit - budget, - nblock, + nblock, (float)(budgetInit - budget) / - (float)(nblock==0 ? 1 : nblock) ); + (float)(nblock==0 ? 1 : nblock) ); if (budget < 0) { - if (verb >= 2) + if (verb >= 2) VPrintf0 ( " too repetitive; using fallback" " sorting algorithm\n" ); fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb ); diff --git a/src/cmd/bzip2/lib/buffcompress.c b/src/cmd/bzip2/lib/buffcompress.c index 849c8ff0..cd350934 100644 --- a/src/cmd/bzip2/lib/buffcompress.c +++ b/src/cmd/bzip2/lib/buffcompress.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -89,30 +89,30 @@ #include "bzlib_private.h" /*---------------------------------------------------*/ -int BZ_API(BZ2_bzBuffToBuffCompress) - ( char* dest, +int BZ_API(BZ2_bzBuffToBuffCompress) + ( char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, - int blockSize100k, - int verbosity, + int blockSize100k, + int verbosity, int workFactor ) { bz_stream strm; int ret; - if (dest == NULL || destLen == NULL || + if (dest == NULL || destLen == NULL || source == NULL || blockSize100k < 1 || blockSize100k > 9 || verbosity < 0 || verbosity > 4 || - workFactor < 0 || workFactor > 250) + workFactor < 0 || workFactor > 250) return BZ_PARAM_ERROR; if (workFactor == 0) workFactor = 30; strm.bzalloc = NULL; strm.bzfree = NULL; strm.opaque = NULL; - ret = BZ2_bzCompressInit ( &strm, blockSize100k, + ret = BZ2_bzCompressInit ( &strm, blockSize100k, verbosity, workFactor ); if (ret != BZ_OK) return ret; @@ -126,7 +126,7 @@ int BZ_API(BZ2_bzBuffToBuffCompress) if (ret != BZ_STREAM_END) goto errhandler; /* normal termination */ - *destLen -= strm.avail_out; + *destLen -= strm.avail_out; BZ2_bzCompressEnd ( &strm ); return BZ_OK; @@ -138,4 +138,3 @@ int BZ_API(BZ2_bzBuffToBuffCompress) BZ2_bzCompressEnd ( &strm ); return ret; } - diff --git a/src/cmd/bzip2/lib/buffdecompress.c b/src/cmd/bzip2/lib/buffdecompress.c index 944166f3..47492470 100644 --- a/src/cmd/bzip2/lib/buffdecompress.c +++ b/src/cmd/bzip2/lib/buffdecompress.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -89,10 +89,10 @@ #include "bzlib_private.h" /*---------------------------------------------------*/ -int BZ_API(BZ2_bzBuffToBuffDecompress) - ( char* dest, +int BZ_API(BZ2_bzBuffToBuffDecompress) + ( char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, int small, int verbosity ) @@ -100,10 +100,10 @@ int BZ_API(BZ2_bzBuffToBuffDecompress) bz_stream strm; int ret; - if (dest == NULL || destLen == NULL || + if (dest == NULL || destLen == NULL || source == NULL || (small != 0 && small != 1) || - verbosity < 0 || verbosity > 4) + verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR; strm.bzalloc = NULL; @@ -133,11 +133,9 @@ int BZ_API(BZ2_bzBuffToBuffDecompress) } else { BZ2_bzDecompressEnd ( &strm ); return BZ_OUTBUFF_FULL; - }; + }; errhandler: BZ2_bzDecompressEnd ( &strm ); - return ret; + return ret; } - - diff --git a/src/cmd/bzip2/lib/bzassert.c b/src/cmd/bzip2/lib/bzassert.c index 56d58fc2..8a578bd0 100644 --- a/src/cmd/bzip2/lib/bzassert.c +++ b/src/cmd/bzip2/lib/bzassert.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -93,7 +93,7 @@ void BZ2_bz__AssertH__fail ( int errcode ) { - fprintf(stderr, + fprintf(stderr, "\n\nbzip2/libbzip2: internal error number %d.\n" "This is a bug in bzip2/libbzip2, %s.\n" "Please report it to me at: jseward@acm.org. If this happened\n" diff --git a/src/cmd/bzip2/lib/bzbuffcompress.c b/src/cmd/bzip2/lib/bzbuffcompress.c index 849c8ff0..cd350934 100644 --- a/src/cmd/bzip2/lib/bzbuffcompress.c +++ b/src/cmd/bzip2/lib/bzbuffcompress.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -89,30 +89,30 @@ #include "bzlib_private.h" /*---------------------------------------------------*/ -int BZ_API(BZ2_bzBuffToBuffCompress) - ( char* dest, +int BZ_API(BZ2_bzBuffToBuffCompress) + ( char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, - int blockSize100k, - int verbosity, + int blockSize100k, + int verbosity, int workFactor ) { bz_stream strm; int ret; - if (dest == NULL || destLen == NULL || + if (dest == NULL || destLen == NULL || source == NULL || blockSize100k < 1 || blockSize100k > 9 || verbosity < 0 || verbosity > 4 || - workFactor < 0 || workFactor > 250) + workFactor < 0 || workFactor > 250) return BZ_PARAM_ERROR; if (workFactor == 0) workFactor = 30; strm.bzalloc = NULL; strm.bzfree = NULL; strm.opaque = NULL; - ret = BZ2_bzCompressInit ( &strm, blockSize100k, + ret = BZ2_bzCompressInit ( &strm, blockSize100k, verbosity, workFactor ); if (ret != BZ_OK) return ret; @@ -126,7 +126,7 @@ int BZ_API(BZ2_bzBuffToBuffCompress) if (ret != BZ_STREAM_END) goto errhandler; /* normal termination */ - *destLen -= strm.avail_out; + *destLen -= strm.avail_out; BZ2_bzCompressEnd ( &strm ); return BZ_OK; @@ -138,4 +138,3 @@ int BZ_API(BZ2_bzBuffToBuffCompress) BZ2_bzCompressEnd ( &strm ); return ret; } - diff --git a/src/cmd/bzip2/lib/bzcompress.c b/src/cmd/bzip2/lib/bzcompress.c index d27e6757..7f3deec0 100644 --- a/src/cmd/bzip2/lib/bzcompress.c +++ b/src/cmd/bzip2/lib/bzcompress.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -125,8 +125,8 @@ Bool isempty_RL ( EState* s ) /*---------------------------------------------------*/ -int BZ_API(BZ2_bzCompressInit) - ( bz_stream* strm, +int BZ_API(BZ2_bzCompressInit) + ( bz_stream* strm, int blockSize100k, int verbosity, int workFactor ) @@ -136,7 +136,7 @@ int BZ_API(BZ2_bzCompressInit) if (!bz_config_ok()) return BZ_CONFIG_ERROR; - if (strm == NULL || + if (strm == NULL || blockSize100k < 1 || blockSize100k > 9 || workFactor < 0 || workFactor > 250) return BZ_PARAM_ERROR; @@ -279,7 +279,7 @@ Bool copy_input_until_stop ( EState* s ) /*-- no input? --*/ if (s->strm->avail_in == 0) break; progress_in = True; - ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); + ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); s->strm->next_in++; s->strm->avail_in--; s->strm->total_in_lo32++; @@ -297,7 +297,7 @@ Bool copy_input_until_stop ( EState* s ) /*-- flush/finish end? --*/ if (s->avail_in_expect == 0) break; progress_in = True; - ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); + ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) ); s->strm->next_in++; s->strm->avail_in--; s->strm->total_in_lo32++; @@ -343,18 +343,18 @@ Bool handle_compress ( bz_stream* strm ) Bool progress_in = False; Bool progress_out = False; EState* s = strm->state; - + while (True) { if (s->state == BZ_S_OUTPUT) { progress_out |= copy_output_until_stop ( s ); if (s->state_out_pos < s->numZ) break; - if (s->mode == BZ_M_FINISHING && + if (s->mode == BZ_M_FINISHING && s->avail_in_expect == 0 && isempty_RL(s)) break; prepare_new_block ( s ); s->state = BZ_S_INPUT; - if (s->mode == BZ_M_FLUSHING && + if (s->mode == BZ_M_FLUSHING && s->avail_in_expect == 0 && isempty_RL(s)) break; } @@ -402,7 +402,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) if (action == BZ_RUN) { progress = handle_compress ( strm ); return progress ? BZ_RUN_OK : BZ_PARAM_ERROR; - } + } else if (action == BZ_FLUSH) { s->avail_in_expect = strm->avail_in; @@ -415,12 +415,12 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) s->mode = BZ_M_FINISHING; goto preswitch; } - else + else return BZ_PARAM_ERROR; case BZ_M_FLUSHING: if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR; - if (s->avail_in_expect != s->strm->avail_in) + if (s->avail_in_expect != s->strm->avail_in) return BZ_SEQUENCE_ERROR; progress = handle_compress ( strm ); if (!progress) return BZ_SEQUENCE_ERROR; /*rsc added */ @@ -431,7 +431,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) case BZ_M_FINISHING: if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR; - if (s->avail_in_expect != s->strm->avail_in) + if (s->avail_in_expect != s->strm->avail_in) return BZ_SEQUENCE_ERROR; progress = handle_compress ( strm ); if (!progress) return BZ_SEQUENCE_ERROR; @@ -458,8 +458,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm ) if (s->ftab != NULL) BZFREE(s->ftab); BZFREE(strm->state); - strm->state = NULL; + strm->state = NULL; return BZ_OK; } - diff --git a/src/cmd/bzip2/lib/bzdecompress.c b/src/cmd/bzip2/lib/bzdecompress.c index 25ed9253..da3251fb 100644 --- a/src/cmd/bzip2/lib/bzdecompress.c +++ b/src/cmd/bzip2/lib/bzdecompress.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -93,8 +93,8 @@ /*---------------------------------------------------*/ /*---------------------------------------------------*/ -int BZ_API(BZ2_bzDecompressInit) - ( bz_stream* strm, +int BZ_API(BZ2_bzDecompressInit) + ( bz_stream* strm, int verbosity, int small ) { @@ -153,34 +153,34 @@ void unRLE_obuf_to_output_FAST ( DState* s ) s->strm->total_out_lo32++; if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; } - + /* can a new run be started? */ if (s->nblock_used == s->save_nblock+1) return; - - + + s->state_out_len = 1; s->state_out_ch = s->k0; - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 2; - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 3; - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - - BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; + + BZ_GET_FAST(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; s->state_out_len = ((Int32)k1) + 4; - BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK; + BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; s->nblock_used++; } @@ -217,7 +217,7 @@ void unRLE_obuf_to_output_FAST ( DState* s ) } s_state_out_len_eq_one: { - if (cs_avail_out == 0) { + if (cs_avail_out == 0) { c_state_out_len = 1; goto return_notr; }; *( (UChar*)(cs_next_out) ) = c_state_out_ch; @@ -225,29 +225,29 @@ void unRLE_obuf_to_output_FAST ( DState* s ) cs_next_out++; cs_avail_out--; } - } + } /* can a new run be started? */ if (c_nblock_used == s_save_nblockPP) { c_state_out_len = 0; goto return_notr; - }; + }; c_state_out_ch = c_k0; BZ_GET_FAST_C(k1); c_nblock_used++; - if (k1 != c_k0) { - c_k0 = k1; goto s_state_out_len_eq_one; + if (k1 != c_k0) { + c_k0 = k1; goto s_state_out_len_eq_one; }; - if (c_nblock_used == s_save_nblockPP) + if (c_nblock_used == s_save_nblockPP) goto s_state_out_len_eq_one; - + c_state_out_len = 2; BZ_GET_FAST_C(k1); c_nblock_used++; if (c_nblock_used == s_save_nblockPP) continue; if (k1 != c_k0) { c_k0 = k1; continue; }; - + c_state_out_len = 3; BZ_GET_FAST_C(k1); c_nblock_used++; if (c_nblock_used == s_save_nblockPP) continue; if (k1 != c_k0) { c_k0 = k1; continue; }; - + BZ_GET_FAST_C(k1); c_nblock_used++; c_state_out_len = ((Int32)k1) + 4; BZ_GET_FAST_C(c_k0); c_nblock_used++; @@ -311,34 +311,34 @@ void unRLE_obuf_to_output_SMALL ( DState* s ) s->strm->total_out_lo32++; if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; } - + /* can a new run be started? */ if (s->nblock_used == s->save_nblock+1) return; - - + + s->state_out_len = 1; s->state_out_ch = s->k0; - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 2; - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 3; - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - - BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; + + BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK; k1 ^= BZ_RAND_MASK; s->nblock_used++; s->state_out_len = ((Int32)k1) + 4; - BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK; + BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; s->nblock_used++; } @@ -357,26 +357,26 @@ void unRLE_obuf_to_output_SMALL ( DState* s ) s->strm->total_out_lo32++; if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++; } - + /* can a new run be started? */ if (s->nblock_used == s->save_nblock+1) return; - + s->state_out_len = 1; s->state_out_ch = s->k0; BZ_GET_SMALL(k1); s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 2; BZ_GET_SMALL(k1); s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + s->state_out_len = 3; BZ_GET_SMALL(k1); s->nblock_used++; if (s->nblock_used == s->save_nblock+1) continue; if (k1 != s->k0) { s->k0 = k1; continue; }; - + BZ_GET_SMALL(k1); s->nblock_used++; s->state_out_len = ((Int32)k1) + 4; BZ_GET_SMALL(s->k0); s->nblock_used++; @@ -403,14 +403,14 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) unRLE_obuf_to_output_FAST ( s ); if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) { BZ_FINALISE_CRC ( s->calculatedBlockCRC ); - if (s->verbosity >= 3) - VPrintf2 ( " {0x%x, 0x%x}", s->storedBlockCRC, + if (s->verbosity >= 3) + VPrintf2 ( " {0x%x, 0x%x}", s->storedBlockCRC, s->calculatedBlockCRC ); if (s->verbosity >= 2) VPrintf0 ( "]" ); if (s->calculatedBlockCRC != s->storedBlockCRC) return BZ_DATA_ERROR; - s->calculatedCombinedCRC - = (s->calculatedCombinedCRC << 1) | + s->calculatedCombinedCRC + = (s->calculatedCombinedCRC << 1) | (s->calculatedCombinedCRC >> 31); s->calculatedCombinedCRC ^= s->calculatedBlockCRC; s->state = BZ_X_BLKHDR_1; @@ -422,7 +422,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) Int32 r = BZ2_decompress ( s ); if (r == BZ_STREAM_END) { if (s->verbosity >= 3) - VPrintf2 ( "\n combined CRCs: stored = 0x%x, computed = 0x%x", + VPrintf2 ( "\n combined CRCs: stored = 0x%x, computed = 0x%x", s->storedCombinedCRC, s->calculatedCombinedCRC ); if (s->calculatedCombinedCRC != s->storedCombinedCRC) return BZ_DATA_ERROR; @@ -435,7 +435,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) /* AssertH ( 0, 6001 ); - return 0; + return 0; */ } @@ -458,4 +458,3 @@ int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm ) return BZ_OK; } - diff --git a/src/cmd/bzip2/lib/bzfeof.c b/src/cmd/bzip2/lib/bzfeof.c index 74e1f88d..c96974da 100644 --- a/src/cmd/bzip2/lib/bzfeof.c +++ b/src/cmd/bzip2/lib/bzfeof.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -97,4 +97,3 @@ Bool bz_feof ( FILE* f ) ungetc ( c, f ); return False; } - diff --git a/src/cmd/bzip2/lib/bzlib.c b/src/cmd/bzip2/lib/bzlib.c index 66b89a2e..12a4bf90 100644 --- a/src/cmd/bzip2/lib/bzlib.c +++ b/src/cmd/bzip2/lib/bzlib.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS diff --git a/src/cmd/bzip2/lib/bzlib.h b/src/cmd/bzip2/lib/bzlib.h index 0ece4e8a..fae78bcb 100644 --- a/src/cmd/bzip2/lib/bzlib.h +++ b/src/cmd/bzip2/lib/bzlib.h @@ -29,16 +29,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -96,7 +96,7 @@ extern "C" { #define BZ_OUTBUFF_FULL (-8) #define BZ_CONFIG_ERROR (-9) -typedef +typedef struct { char *next_in; unsigned int avail_in; @@ -113,7 +113,7 @@ typedef void *(*bzalloc)(void *,int,int); void (*bzfree)(void *,void *); void *opaque; - } + } bz_stream; @@ -144,57 +144,57 @@ typedef /*-- Core (low-level) library functions --*/ -BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( - bz_stream* strm, - int blockSize100k, - int verbosity, - int workFactor +BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( + bz_stream* strm, + int blockSize100k, + int verbosity, + int workFactor ); -BZ_EXTERN int BZ_API(BZ2_bzCompress) ( - bz_stream* strm, - int action +BZ_EXTERN int BZ_API(BZ2_bzCompress) ( + bz_stream* strm, + int action ); -BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( - bz_stream* strm +BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( + bz_stream* strm ); -BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( - bz_stream *strm, - int verbosity, +BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( + bz_stream *strm, + int verbosity, int small ); -BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( - bz_stream* strm +BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( + bz_stream* strm ); -BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( - bz_stream *strm +BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( + bz_stream *strm ); /*-- Utility functions --*/ -BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( - char* dest, +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( + char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, - int blockSize100k, - int verbosity, - int workFactor + int blockSize100k, + int verbosity, + int workFactor ); -BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( - char* dest, +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( + char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, - int small, - int verbosity + int small, + int verbosity ); diff --git a/src/cmd/bzip2/lib/bzlib_private.h b/src/cmd/bzip2/lib/bzlib_private.h index ad578706..002d79b3 100644 --- a/src/cmd/bzip2/lib/bzlib_private.h +++ b/src/cmd/bzip2/lib/bzlib_private.h @@ -29,16 +29,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -80,7 +80,7 @@ #ifndef __GNUC__ #define __inline__ /* */ -#endif +#endif /* these #defines can be overridden by bzlib_stdio.h */ extern void bz_internal_error ( int errcode ); @@ -257,19 +257,19 @@ typedef /*-- externs for compression. --*/ -extern void +extern void BZ2_blockSort ( EState* ); -extern void +extern void BZ2_compressBlock ( EState*, Bool ); -extern void +extern void BZ2_bsInitWrite ( EState* ); -extern void +extern void BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 ); -extern void +extern void BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 ); @@ -413,7 +413,7 @@ typedef Int32 save_N; Int32 save_curr; Int32 save_zt; - Int32 save_zn; + Int32 save_zn; Int32 save_zvec; Int32 save_zj; Int32 save_gSel; @@ -463,13 +463,13 @@ typedef /*-- externs for decompression. --*/ -extern Int32 +extern Int32 BZ2_indexIntoF ( Int32, Int32* ); -extern Int32 +extern Int32 BZ2_decompress ( DState* ); -extern void +extern void BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*, Int32, Int32, Int32 ); diff --git a/src/cmd/bzip2/lib/bzlib_stdio.h b/src/cmd/bzip2/lib/bzlib_stdio.h index 30d41d99..18805f0b 100644 --- a/src/cmd/bzip2/lib/bzlib_stdio.h +++ b/src/cmd/bzip2/lib/bzlib_stdio.h @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -99,17 +99,17 @@ BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( int fd, const char *mode ); - + BZ_EXTERN int BZ_API(BZ2_bzread) ( - BZFILE* b, - void* buf, - int len + BZFILE* b, + void* buf, + int len ); BZ_EXTERN int BZ_API(BZ2_bzwrite) ( - BZFILE* b, - void* buf, - int len + BZFILE* b, + void* buf, + int len ); BZ_EXTERN int BZ_API(BZ2_bzflush) ( @@ -121,70 +121,69 @@ BZ_EXTERN void BZ_API(BZ2_bzclose) ( ); BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( - BZFILE *b, + BZFILE *b, int *errnum ); /*-- High(er) level library functions --*/ -BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( - int* bzerror, - FILE* f, - int verbosity, +BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( + int* bzerror, + FILE* f, + int verbosity, int small, - void* unused, - int nUnused + void* unused, + int nUnused ); -BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( - int* bzerror, - BZFILE* b +BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( + int* bzerror, + BZFILE* b ); -BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( - int* bzerror, - BZFILE* b, - void** unused, - int* nUnused +BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( + int* bzerror, + BZFILE* b, + void** unused, + int* nUnused ); -BZ_EXTERN int BZ_API(BZ2_bzRead) ( - int* bzerror, - BZFILE* b, - void* buf, - int len +BZ_EXTERN int BZ_API(BZ2_bzRead) ( + int* bzerror, + BZFILE* b, + void* buf, + int len ); -BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( - int* bzerror, - FILE* f, - int blockSize100k, - int verbosity, - int workFactor +BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( + int* bzerror, + FILE* f, + int blockSize100k, + int verbosity, + int workFactor ); -BZ_EXTERN void BZ_API(BZ2_bzWrite) ( - int* bzerror, - BZFILE* b, - void* buf, - int len +BZ_EXTERN void BZ_API(BZ2_bzWrite) ( + int* bzerror, + BZFILE* b, + void* buf, + int len ); -BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( - int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in, - unsigned int* nbytes_out +BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in, + unsigned int* nbytes_out ); -BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( - int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in_lo32, - unsigned int* nbytes_in_hi32, - unsigned int* nbytes_out_lo32, +BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in_lo32, + unsigned int* nbytes_in_hi32, + unsigned int* nbytes_out_lo32, unsigned int* nbytes_out_hi32 ); - diff --git a/src/cmd/bzip2/lib/bzlib_stdio_private.h b/src/cmd/bzip2/lib/bzlib_stdio_private.h index 24b31144..caacf36a 100644 --- a/src/cmd/bzip2/lib/bzlib_stdio_private.h +++ b/src/cmd/bzip2/lib/bzlib_stdio_private.h @@ -53,7 +53,7 @@ extern void BZ2_bz__AssertH__fail ( int errcode ); if (bzf != NULL) bzf->lastErr = eee; \ } -typedef +typedef struct { FILE* handle; Char buf[BZ_MAX_UNUSED]; @@ -66,4 +66,3 @@ typedef bzFile; extern Bool bz_feof( FILE* ); - diff --git a/src/cmd/bzip2/lib/bzread.c b/src/cmd/bzip2/lib/bzread.c index 8bd03888..e523d249 100644 --- a/src/cmd/bzip2/lib/bzread.c +++ b/src/cmd/bzip2/lib/bzread.c @@ -19,16 +19,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -82,9 +82,9 @@ #include "bzlib_stdio_private.h" /*---------------------------------------------------*/ -BZFILE* BZ_API(BZ2_bzReadOpen) - ( int* bzerror, - FILE* f, +BZFILE* BZ_API(BZ2_bzReadOpen) + ( int* bzerror, + FILE* f, int verbosity, int small, void* unused, @@ -95,7 +95,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) BZ_SETERR(BZ_OK); - if (f == NULL || + if (f == NULL || (small != 0 && small != 1) || (verbosity < 0 || verbosity > 4) || (unused == NULL && nUnused != 0) || @@ -106,7 +106,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) { BZ_SETERR(BZ_IO_ERROR); return NULL; }; bzf = malloc ( sizeof(bzFile) ); - if (bzf == NULL) + if (bzf == NULL) { BZ_SETERR(BZ_MEM_ERROR); return NULL; }; BZ_SETERR(BZ_OK); @@ -118,7 +118,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) bzf->strm.bzalloc = NULL; bzf->strm.bzfree = NULL; bzf->strm.opaque = NULL; - + while (nUnused > 0) { bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++; unused = ((void*)( 1 + ((UChar*)(unused)) )); @@ -133,7 +133,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) bzf->strm.next_in = bzf->buf; bzf->initialisedOk = True; - return bzf; + return bzf; } @@ -156,10 +156,10 @@ void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b ) /*---------------------------------------------------*/ -int BZ_API(BZ2_bzRead) - ( int* bzerror, - BZFILE* b, - void* buf, +int BZ_API(BZ2_bzRead) + ( int* bzerror, + BZFILE* b, + void* buf, int len ) { Int32 n, ret; @@ -181,11 +181,11 @@ int BZ_API(BZ2_bzRead) while (True) { - if (ferror(bzf->handle)) + if (ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return 0; }; if (bzf->strm.avail_in == 0 && !bz_feof(bzf->handle)) { - n = fread ( bzf->buf, sizeof(UChar), + n = fread ( bzf->buf, sizeof(UChar), BZ_MAX_UNUSED, bzf->handle ); if (ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return 0; }; @@ -199,7 +199,7 @@ int BZ_API(BZ2_bzRead) if (ret != BZ_OK && ret != BZ_STREAM_END) { BZ_SETERR(ret); return 0; }; - if (ret == BZ_OK && bz_feof(bzf->handle) && + if (ret == BZ_OK && bz_feof(bzf->handle) && bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0) { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; }; @@ -208,7 +208,7 @@ int BZ_API(BZ2_bzRead) return len - bzf->strm.avail_out; }; if (bzf->strm.avail_out == 0) { BZ_SETERR(BZ_OK); return len; }; - + } /* return 0; not reached*/ @@ -216,10 +216,10 @@ int BZ_API(BZ2_bzRead) /*---------------------------------------------------*/ -void BZ_API(BZ2_bzReadGetUnused) - ( int* bzerror, - BZFILE* b, - void** unused, +void BZ_API(BZ2_bzReadGetUnused) + ( int* bzerror, + BZFILE* b, + void** unused, int* nUnused ) { bzFile* bzf = (bzFile*)b; diff --git a/src/cmd/bzip2/lib/bzstdio.c b/src/cmd/bzip2/lib/bzstdio.c index 3e1f2de5..31b0a768 100644 --- a/src/cmd/bzip2/lib/bzstdio.c +++ b/src/cmd/bzip2/lib/bzstdio.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -95,4 +95,3 @@ Bool bz_feof ( FILE* f ) ungetc ( c, f ); return False; } - diff --git a/src/cmd/bzip2/lib/bzversion.c b/src/cmd/bzip2/lib/bzversion.c index 5320144b..601d0c91 100644 --- a/src/cmd/bzip2/lib/bzversion.c +++ b/src/cmd/bzip2/lib/bzversion.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -96,4 +96,3 @@ const char * BZ_API(BZ2_bzlibVersion)(void) { return BZ_VERSION; } - diff --git a/src/cmd/bzip2/lib/bzwrite.c b/src/cmd/bzip2/lib/bzwrite.c index a37a66ba..086b6e2d 100644 --- a/src/cmd/bzip2/lib/bzwrite.c +++ b/src/cmd/bzip2/lib/bzwrite.c @@ -19,16 +19,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -82,10 +82,10 @@ #include "bzlib_stdio_private.h" /*---------------------------------------------------*/ -BZFILE* BZ_API(BZ2_bzWriteOpen) - ( int* bzerror, - FILE* f, - int blockSize100k, +BZFILE* BZ_API(BZ2_bzWriteOpen) + ( int* bzerror, + FILE* f, + int blockSize100k, int verbosity, int workFactor ) { @@ -117,23 +117,23 @@ BZFILE* BZ_API(BZ2_bzWriteOpen) bzf->strm.opaque = NULL; if (workFactor == 0) workFactor = 30; - ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, + ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k, verbosity, workFactor ); if (ret != BZ_OK) { BZ_SETERR(ret); free(bzf); return NULL; }; bzf->strm.avail_in = 0; bzf->initialisedOk = True; - return bzf; + return bzf; } /*---------------------------------------------------*/ void BZ_API(BZ2_bzWrite) - ( int* bzerror, - BZFILE* b, - void* buf, + ( int* bzerror, + BZFILE* b, + void* buf, int len ) { Int32 n, n2, ret; @@ -162,7 +162,7 @@ void BZ_API(BZ2_bzWrite) if (bzf->strm.avail_out < BZ_MAX_UNUSED) { n = BZ_MAX_UNUSED - bzf->strm.avail_out; - n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), + n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), n, bzf->handle ); if (n != n2 || ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return; }; @@ -176,20 +176,20 @@ void BZ_API(BZ2_bzWrite) /*---------------------------------------------------*/ void BZ_API(BZ2_bzWriteClose) - ( int* bzerror, - BZFILE* b, + ( int* bzerror, + BZFILE* b, int abandon, unsigned int* nbytes_in, unsigned int* nbytes_out ) { - BZ2_bzWriteClose64 ( bzerror, b, abandon, + BZ2_bzWriteClose64 ( bzerror, b, abandon, nbytes_in, NULL, nbytes_out, NULL ); } void BZ_API(BZ2_bzWriteClose64) - ( int* bzerror, - BZFILE* b, + ( int* bzerror, + BZFILE* b, int abandon, unsigned int* nbytes_in_lo32, unsigned int* nbytes_in_hi32, @@ -221,7 +221,7 @@ void BZ_API(BZ2_bzWriteClose64) if (bzf->strm.avail_out < BZ_MAX_UNUSED) { n = BZ_MAX_UNUSED - bzf->strm.avail_out; - n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), + n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar), n, bzf->handle ); if (n != n2 || ferror(bzf->handle)) { BZ_SETERR(BZ_IO_ERROR); return; }; @@ -250,4 +250,3 @@ void BZ_API(BZ2_bzWriteClose64) BZ2_bzCompressEnd ( &(bzf->strm) ); free ( bzf ); } - diff --git a/src/cmd/bzip2/lib/bzzlib.c b/src/cmd/bzip2/lib/bzzlib.c index 87b69128..56b0b7de 100644 --- a/src/cmd/bzip2/lib/bzzlib.c +++ b/src/cmd/bzip2/lib/bzzlib.c @@ -28,16 +28,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -128,7 +128,7 @@ BZFILE * bzopen_or_bzdopen int verbosity = 0; int workFactor = 30; int smallMode = 0; - int nUnused = 0; + int nUnused = 0; if (mode == NULL) return NULL; while (*mode) { @@ -168,7 +168,7 @@ BZFILE * bzopen_or_bzdopen if (writing) { /* Guard against total chaos and anarchy -- JRS */ if (blockSize100k < 1) blockSize100k = 1; - if (blockSize100k > 9) blockSize100k = 9; + if (blockSize100k > 9) blockSize100k = 9; bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k, verbosity,workFactor); } else { @@ -247,7 +247,7 @@ void BZ_API(BZ2_bzclose) (BZFILE* b) { int bzerr; FILE *fp = ((bzFile *)b)->handle; - + if (b==NULL) {return;} if(((bzFile*)b)->writing){ BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL); @@ -265,7 +265,7 @@ void BZ_API(BZ2_bzclose) (BZFILE* b) /*---------------------------------------------------*/ /*-- - return last error code + return last error code --*/ static char *bzerrorstrings[] = { "OK" diff --git a/src/cmd/bzip2/lib/compress.c b/src/cmd/bzip2/lib/compress.c index 96c55918..c7a1aa80 100644 --- a/src/cmd/bzip2/lib/compress.c +++ b/src/cmd/bzip2/lib/compress.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -66,7 +66,7 @@ 0.9.0a/b -- no changes in this file. 0.9.0c - * changed setting of nGroups in sendMTFValues() so as to + * changed setting of nGroups in sendMTFValues() so as to do a bit better on small files --*/ @@ -171,11 +171,11 @@ void generateMTFValues ( EState* s ) Int32 wr; Int32 EOB; - /* + /* After sorting (eg, here), s->arr1 [ 0 .. s->nblock-1 ] holds sorted order, and - ((UChar*)s->arr2) [ 0 .. s->nblock-1 ] + ((UChar*)s->arr2) [ 0 .. s->nblock-1 ] holds the original block data. The first thing to do is generate the MTF values, @@ -190,7 +190,7 @@ void generateMTFValues ( EState* s ) (UChar*) (&((UChar*)s->arr2)[s->nblock]) These storage aliases are set up in bzCompressInit(), - except for the last one, which is arranged in + except for the last one, which is arranged in compressBlock(). */ UInt32* ptr = s->ptr; @@ -213,7 +213,7 @@ void generateMTFValues ( EState* s ) ll_i = s->unseqToSeq[block[j]]; AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" ); - if (yy[0] == ll_i) { + if (yy[0] == ll_i) { zPend++; } else { @@ -221,11 +221,11 @@ void generateMTFValues ( EState* s ) zPend--; while (True) { if (zPend & 1) { - mtfv[wr] = BZ_RUNB; wr++; - s->mtfFreq[BZ_RUNB]++; + mtfv[wr] = BZ_RUNB; wr++; + s->mtfFreq[BZ_RUNB]++; } else { - mtfv[wr] = BZ_RUNA; wr++; - s->mtfFreq[BZ_RUNA]++; + mtfv[wr] = BZ_RUNA; wr++; + s->mtfFreq[BZ_RUNA]++; } if (zPend < 2) break; zPend = (zPend - 2) / 2; @@ -259,11 +259,11 @@ void generateMTFValues ( EState* s ) zPend--; while (True) { if (zPend & 1) { - mtfv[wr] = BZ_RUNB; wr++; - s->mtfFreq[BZ_RUNB]++; + mtfv[wr] = BZ_RUNB; wr++; + s->mtfFreq[BZ_RUNB]++; } else { - mtfv[wr] = BZ_RUNA; wr++; - s->mtfFreq[BZ_RUNA]++; + mtfv[wr] = BZ_RUNA; wr++; + s->mtfFreq[BZ_RUNA]++; } if (zPend < 2) break; zPend = (zPend - 2) / 2; @@ -306,7 +306,7 @@ void sendMTFValues ( EState* s ) if (s->verbosity >= 3) VPrintf3( " %d in block, %d after MTF & 1-2 coding, " - "%d+2 syms in use\n", + "%d+2 syms in use\n", s->nblock, s->nMTF, s->nInUse ); alphaSize = s->nInUse+2; @@ -323,7 +323,7 @@ void sendMTFValues ( EState* s ) nGroups = 6; /*--- Generate an initial set of coding tables ---*/ - { + { Int32 nPart, remF, tFreq, aFreq; nPart = nGroups; @@ -338,8 +338,8 @@ void sendMTFValues ( EState* s ) aFreq += s->mtfFreq[ge]; } - if (ge > gs - && nPart != nGroups && nPart != 1 + if (ge > gs + && nPart != nGroups && nPart != 1 && ((nGroups-nPart) % 2 == 1)) { aFreq -= s->mtfFreq[ge]; ge--; @@ -348,21 +348,21 @@ void sendMTFValues ( EState* s ) if (s->verbosity >= 3) VPrintf5( " initial group %d, [%d .. %d], " "has %d syms (%4.1f%%)\n", - nPart, gs, ge, aFreq, + nPart, gs, ge, aFreq, (100.0 * (float)aFreq) / (float)(s->nMTF) ); - + for (v = 0; v < alphaSize; v++) - if (v >= gs && v <= ge) + if (v >= gs && v <= ge) s->len[nPart-1][v] = BZ_LESSER_ICOST; else s->len[nPart-1][v] = BZ_GREATER_ICOST; - + nPart--; gs = ge+1; remF -= aFreq; } } - /*--- + /*--- Iterate up to BZ_N_ITERS times to improve the tables. ---*/ nSelectors = 40000; /* shut up some compilers' warnings about used and not set */ @@ -377,7 +377,7 @@ void sendMTFValues ( EState* s ) /*--- Set up an auxiliary length table which is used to fast-track - the common case (nGroups == 6). + the common case (nGroups == 6). ---*/ if (nGroups == 6) { for (v = 0; v < alphaSize; v++) { @@ -394,10 +394,10 @@ void sendMTFValues ( EState* s ) /*--- Set group start & end marks. --*/ if (gs >= s->nMTF) break; - ge = gs + BZ_G_SIZE - 1; + ge = gs + BZ_G_SIZE - 1; if (ge >= s->nMTF) ge = s->nMTF-1; - /*-- + /*-- Calculate the cost of this group as coded by each of the coding tables. --*/ @@ -434,13 +434,13 @@ void sendMTFValues ( EState* s ) } else { /*--- slow version which correctly handles all situations ---*/ - for (i = gs; i <= ge; i++) { + for (i = gs; i <= ge; i++) { UInt16 icv = mtfv[i]; for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv]; } } - - /*-- + + /*-- Find the coding table which is best for this group, and record its identity in the selector table. --*/ @@ -452,7 +452,7 @@ void sendMTFValues ( EState* s ) s->selector[nSelectors] = bt; nSelectors++; - /*-- + /*-- Increment the symbol frequencies for the selected table. --*/ if (nGroups == 6 && 50 == ge-gs+1) { @@ -482,7 +482,7 @@ void sendMTFValues ( EState* s ) gs = ge+1; } if (s->verbosity >= 3) { - VPrintf2 ( " pass %d: size is %d, grp uses are ", + VPrintf2 ( " pass %d: size is %d, grp uses are ", iter+1, totc/8 ); for (t = 0; t < nGroups; t++) VPrintf1 ( "%d ", fave[t] ); @@ -493,7 +493,7 @@ void sendMTFValues ( EState* s ) Recompute the tables based on the accumulated frequencies. --*/ for (t = 0; t < nGroups; t++) - BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]), + BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]), alphaSize, 20 ); } @@ -533,19 +533,19 @@ void sendMTFValues ( EState* s ) } AssertH ( !(maxLen > 20), 3004 ); AssertH ( !(minLen < 1), 3005 ); - BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]), + BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]), minLen, maxLen, alphaSize ); } /*--- Transmit the mapping table. ---*/ - { + { Bool inUse16[16]; for (i = 0; i < 16; i++) { inUse16[i] = False; for (j = 0; j < 16; j++) if (s->inUse[i * 16 + j]) inUse16[i] = True; } - + nBytes = s->numZ; for (i = 0; i < 16; i++) if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0); @@ -556,7 +556,7 @@ void sendMTFValues ( EState* s ) if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0); } - if (s->verbosity >= 3) + if (s->verbosity >= 3) VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes ); } @@ -564,7 +564,7 @@ void sendMTFValues ( EState* s ) nBytes = s->numZ; bsW ( s, 3, nGroups ); bsW ( s, 15, nSelectors ); - for (i = 0; i < nSelectors; i++) { + for (i = 0; i < nSelectors; i++) { for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1); bsW(s,1,0); } @@ -593,14 +593,14 @@ void sendMTFValues ( EState* s ) gs = 0; while (True) { if (gs >= s->nMTF) break; - ge = gs + BZ_G_SIZE - 1; + ge = gs + BZ_G_SIZE - 1; if (ge >= s->nMTF) ge = s->nMTF-1; AssertH ( s->selector[selCtr] < nGroups, 3006 ); if (nGroups == 6 && 50 == ge-gs+1) { /*--- fast track the common case ---*/ UInt16 mtfv_i; - UChar* s_len_sel_selCtr + UChar* s_len_sel_selCtr = &(s->len[s->selector[selCtr]][0]); Int32* s_code_sel_selCtr = &(s->code[s->selector[selCtr]][0]); @@ -627,7 +627,7 @@ void sendMTFValues ( EState* s ) } else { /*--- slow version which correctly handles all situations ---*/ for (i = gs; i <= ge; i++) { - bsW ( s, + bsW ( s, s->len [s->selector[selCtr]] [mtfv[i]], s->code [s->selector[selCtr]] [mtfv[i]] ); } @@ -682,8 +682,8 @@ void BZ2_compressBlock ( EState* s, Bool is_last_block ) /*-- Now the block's CRC, so it is in a known place. --*/ bsPutUInt32 ( s, s->blockCRC ); - /*-- - Now a single bit indicating (non-)randomisation. + /*-- + Now a single bit indicating (non-)randomisation. As of version 0.9.5, we use a better sorting algorithm which makes randomisation unnecessary. So always set the randomised bit to 'no'. Of course, the decoder diff --git a/src/cmd/bzip2/lib/crctable.c b/src/cmd/bzip2/lib/crctable.c index db1eb93f..efd1f8fb 100644 --- a/src/cmd/bzip2/lib/crctable.c +++ b/src/cmd/bzip2/lib/crctable.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS diff --git a/src/cmd/bzip2/lib/decompress.c b/src/cmd/bzip2/lib/decompress.c index 734bfee7..e9f8a59d 100644 --- a/src/cmd/bzip2/lib/decompress.c +++ b/src/cmd/bzip2/lib/decompress.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -169,7 +169,7 @@ Int32 BZ2_decompress ( DState* s ) Int32 N; Int32 curr; Int32 zt; - Int32 zn; + Int32 zn; Int32 zvec; Int32 zj; Int32 gSel; @@ -223,7 +223,7 @@ Int32 BZ2_decompress ( DState* s ) N = s->save_N; curr = s->save_curr; zt = s->save_zt; - zn = s->save_zn; + zn = s->save_zn; zvec = s->save_zvec; zj = s->save_zj; gSel = s->save_gSel; @@ -246,14 +246,14 @@ Int32 BZ2_decompress ( DState* s ) if (uc != 'h') RETURN(BZ_DATA_ERROR_MAGIC); GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8) - if (s->blockSize100k < '1' || + if (s->blockSize100k < '1' || s->blockSize100k > '9') RETURN(BZ_DATA_ERROR_MAGIC); s->blockSize100k -= '0'; if (s->smallDecompress) { s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) ); - s->ll4 = BZALLOC( - ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) + s->ll4 = BZALLOC( + ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) ); if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR); } else { @@ -279,7 +279,7 @@ Int32 BZ2_decompress ( DState* s ) s->currBlockNo++; if (s->verbosity >= 2) VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo ); - + s->storedBlockCRC = 0; GET_UCHAR(BZ_X_BCRC_1, uc); s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); @@ -302,14 +302,14 @@ Int32 BZ2_decompress ( DState* s ) if (s->origPtr < 0) RETURN(BZ_DATA_ERROR); - if (s->origPtr > 10 + 100000*s->blockSize100k) + if (s->origPtr > 10 + 100000*s->blockSize100k) RETURN(BZ_DATA_ERROR); /*--- Receive the mapping table ---*/ for (i = 0; i < 16; i++) { GET_BIT(BZ_X_MAPPING_1, uc); - if (uc == 1) - s->inUse16[i] = True; else + if (uc == 1) + s->inUse16[i] = True; else s->inUse16[i] = False; } @@ -345,7 +345,7 @@ Int32 BZ2_decompress ( DState* s ) { UChar pos[BZ_N_GROUPS], tmp, v; for (v = 0; v < nGroups; v++) pos[v] = v; - + for (i = 0; i < nSelectors; i++) { v = s->selectorMtf[i]; tmp = pos[v]; @@ -378,10 +378,10 @@ Int32 BZ2_decompress ( DState* s ) if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; if (s->len[t][i] < minLen) minLen = s->len[t][i]; } - BZ2_hbCreateDecodeTables ( - &(s->limit[t][0]), - &(s->base[t][0]), - &(s->perm[t][0]), + BZ2_hbCreateDecodeTables ( + &(s->limit[t][0]), + &(s->base[t][0]), + &(s->perm[t][0]), &(s->len[t][0]), minLen, maxLen, alphaSize ); @@ -473,23 +473,23 @@ Int32 BZ2_decompress ( DState* s ) s->mtfa[(z)-3] = s->mtfa[(z)-4]; nn -= 4; } - while (nn > 0) { - s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--; + while (nn > 0) { + s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--; }; s->mtfa[pp] = uc; - } else { + } else { /* general case */ lno = nn / MTFL_SIZE; off = nn % MTFL_SIZE; pp = s->mtfbase[lno] + off; uc = s->mtfa[pp]; - while (pp > s->mtfbase[lno]) { - s->mtfa[pp] = s->mtfa[pp-1]; pp--; + while (pp > s->mtfbase[lno]) { + s->mtfa[pp] = s->mtfa[pp-1]; pp--; }; s->mtfbase[lno]++; while (lno > 0) { s->mtfbase[lno]--; - s->mtfa[s->mtfbase[lno]] + s->mtfa[s->mtfbase[lno]] = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1]; lno--; } @@ -565,7 +565,7 @@ Int32 BZ2_decompress ( DState* s ) if (s->blockRandomised) { BZ_RAND_INIT_MASK; BZ_GET_SMALL(s->k0); s->nblock_used++; - BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; + BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; } else { BZ_GET_SMALL(s->k0); s->nblock_used++; } @@ -584,7 +584,7 @@ Int32 BZ2_decompress ( DState* s ) if (s->blockRandomised) { BZ_RAND_INIT_MASK; BZ_GET_FAST(s->k0); s->nblock_used++; - BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; + BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; } else { BZ_GET_FAST(s->k0); s->nblock_used++; } @@ -653,7 +653,7 @@ Int32 BZ2_decompress ( DState* s ) s->save_gBase = gBase; s->save_gPerm = gPerm; - return retVal; + return retVal; } diff --git a/src/cmd/bzip2/lib/huffman.c b/src/cmd/bzip2/lib/huffman.c index 9cad0970..9388ef21 100644 --- a/src/cmd/bzip2/lib/huffman.c +++ b/src/cmd/bzip2/lib/huffman.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -102,7 +102,7 @@ /*---------------------------------------------------*/ -void BZ2_hbMakeCodeLengths ( UChar *len, +void BZ2_hbMakeCodeLengths ( UChar *len, Int32 *freq, Int32 alphaSize, Int32 maxLen ) @@ -116,7 +116,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len, Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ]; Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ]; - Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ]; + Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ]; for (i = 0; i < alphaSize; i++) weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8; @@ -138,7 +138,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len, } AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 ); - + while (nHeap > 1) { n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); @@ -161,7 +161,7 @@ void BZ2_hbMakeCodeLengths ( UChar *len, len[i-1] = j; if (j > maxLen) tooLong = True; } - + if (! tooLong) break; for (i = 1; i < alphaSize; i++) { diff --git a/src/cmd/bzip2/lib/os.h b/src/cmd/bzip2/lib/os.h index aa196a87..1236e5d5 100644 --- a/src/cmd/bzip2/lib/os.h +++ b/src/cmd/bzip2/lib/os.h @@ -76,7 +76,7 @@ typedef int Int32; typedef unsigned int UInt32; typedef short Int16; typedef unsigned short UInt16; - + #define True ((Bool)1) #define False ((Bool)0) @@ -85,4 +85,3 @@ typedef unsigned short UInt16; Only here to avoid probs with 64-bit platforms. --*/ typedef int IntNative; - diff --git a/src/cmd/bzip2/lib/randtable.c b/src/cmd/bzip2/lib/randtable.c index 2ab1e952..c6d70773 100644 --- a/src/cmd/bzip2/lib/randtable.c +++ b/src/cmd/bzip2/lib/randtable.c @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -64,58 +64,58 @@ /*---------------------------------------------*/ -Int32 BZ2_rNums[512] = { - 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, - 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, - 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, - 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, - 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, - 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, - 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, - 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, - 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, - 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, - 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, - 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, - 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, - 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, - 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, - 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, - 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, - 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, - 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, - 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, - 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, - 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, - 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, - 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, - 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, - 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, - 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, - 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, - 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, - 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, - 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, - 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, - 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, - 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, - 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, - 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, - 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, - 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, - 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, - 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, - 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, - 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, - 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, - 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, - 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, - 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, - 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, - 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, - 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, - 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, - 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, +Int32 BZ2_rNums[512] = { + 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, + 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, + 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, + 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, + 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, + 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, + 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, + 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, + 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, + 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, + 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, + 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, + 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, + 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, + 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, + 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, + 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, + 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, + 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, + 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, + 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, + 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, + 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, + 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, + 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, + 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, + 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, + 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, + 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, + 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, + 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, + 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, + 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, + 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, + 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, + 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, + 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, + 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, + 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, + 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, + 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, + 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, + 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, + 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, + 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, + 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, + 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, + 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, + 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, + 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, + 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, 936, 638 }; diff --git a/src/cmd/bzip2/lib/unix.h b/src/cmd/bzip2/lib/unix.h index e47197b8..797ba118 100644 --- a/src/cmd/bzip2/lib/unix.h +++ b/src/cmd/bzip2/lib/unix.h @@ -5,4 +5,3 @@ #include <math.h> #include <errno.h> #include <ctype.h> - |