aboutsummaryrefslogtreecommitdiff
path: root/archival/libarchive/bz/compress.c
diff options
context:
space:
mode:
Diffstat (limited to 'archival/libarchive/bz/compress.c')
-rw-r--r--archival/libarchive/bz/compress.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/archival/libarchive/bz/compress.c b/archival/libarchive/bz/compress.c
index fc6af6595..7efa533b0 100644
--- a/archival/libarchive/bz/compress.c
+++ b/archival/libarchive/bz/compress.c
@@ -162,7 +162,7 @@ void generateMTFValues(EState* s)
162{ 162{
163 uint8_t yy[256]; 163 uint8_t yy[256];
164 int32_t i, j; 164 int32_t i, j;
165 int32_t zPend; 165 int zPend;
166 int32_t wr; 166 int32_t wr;
167 int32_t EOB; 167 int32_t EOB;
168 168
@@ -217,6 +217,7 @@ void generateMTFValues(EState* s)
217 if (zPend > 0) { 217 if (zPend > 0) {
218 zPend--; 218 zPend--;
219 while (1) { 219 while (1) {
220#if 0
220 if (zPend & 1) { 221 if (zPend & 1) {
221 mtfv[wr] = BZ_RUNB; wr++; 222 mtfv[wr] = BZ_RUNB; wr++;
222 s->mtfFreq[BZ_RUNB]++; 223 s->mtfFreq[BZ_RUNB]++;
@@ -224,10 +225,18 @@ void generateMTFValues(EState* s)
224 mtfv[wr] = BZ_RUNA; wr++; 225 mtfv[wr] = BZ_RUNA; wr++;
225 s->mtfFreq[BZ_RUNA]++; 226 s->mtfFreq[BZ_RUNA]++;
226 } 227 }
227 if (zPend < 2) break; 228#else /* same as above, since BZ_RUNA is 0 and BZ_RUNB is 1 */
228 zPend = (uint32_t)(zPend - 2) / 2; 229 unsigned run = zPend & 1;
230 mtfv[wr] = run;
231 wr++;
232 s->mtfFreq[run]++;
233#endif
234 zPend -= 2;
235 if (zPend < 0)
236 break;
237 zPend = (unsigned)zPend / 2;
229 /* bbox: unsigned div is easier */ 238 /* bbox: unsigned div is easier */
230 }; 239 }
231 zPend = 0; 240 zPend = 0;
232 } 241 }
233 { 242 {
@@ -244,7 +253,7 @@ void generateMTFValues(EState* s)
244 rtmp2 = rtmp; 253 rtmp2 = rtmp;
245 rtmp = *ryy_j; 254 rtmp = *ryy_j;
246 *ryy_j = rtmp2; 255 *ryy_j = rtmp2;
247 }; 256 }
248 yy[0] = rtmp; 257 yy[0] = rtmp;
249 j = ryy_j - &(yy[0]); 258 j = ryy_j - &(yy[0]);
250 mtfv[wr] = j+1; 259 mtfv[wr] = j+1;
@@ -257,6 +266,7 @@ void generateMTFValues(EState* s)
257 if (zPend > 0) { 266 if (zPend > 0) {
258 zPend--; 267 zPend--;
259 while (1) { 268 while (1) {
269#if 0
260 if (zPend & 1) { 270 if (zPend & 1) {
261 mtfv[wr] = BZ_RUNB; 271 mtfv[wr] = BZ_RUNB;
262 wr++; 272 wr++;
@@ -266,12 +276,18 @@ void generateMTFValues(EState* s)
266 wr++; 276 wr++;
267 s->mtfFreq[BZ_RUNA]++; 277 s->mtfFreq[BZ_RUNA]++;
268 } 278 }
269 if (zPend < 2) 279#else /* same as above, since BZ_RUNA is 0 and BZ_RUNB is 1 */
280 unsigned run = zPend & 1;
281 mtfv[wr] = run;
282 wr++;
283 s->mtfFreq[run]++;
284#endif
285 zPend -= 2;
286 if (zPend < 0)
270 break; 287 break;
271 zPend = (uint32_t)(zPend - 2) / 2; 288 zPend = (unsigned)zPend / 2;
272 /* bbox: unsigned div is easier */ 289 /* bbox: unsigned div is easier */
273 }; 290 }
274 zPend = 0;
275 } 291 }
276 292
277 mtfv[wr] = EOB; 293 mtfv[wr] = EOB;
@@ -528,11 +544,11 @@ void sendMTFValues(EState* s)
528 tmp2 = tmp; 544 tmp2 = tmp;
529 tmp = pos[j]; 545 tmp = pos[j];
530 pos[j] = tmp2; 546 pos[j] = tmp2;
531 }; 547 }
532 pos[0] = tmp; 548 pos[0] = tmp;
533 s->selectorMtf[i] = j; 549 s->selectorMtf[i] = j;
534 } 550 }
535 }; 551 }
536 552
537 /*--- Assign actual codes for the tables. --*/ 553 /*--- Assign actual codes for the tables. --*/
538 for (t = 0; t < nGroups; t++) { 554 for (t = 0; t < nGroups; t++) {
@@ -595,8 +611,8 @@ void sendMTFValues(EState* s)
595 unsigned curr = s->len[t][0]; 611 unsigned curr = s->len[t][0];
596 bsW(s, 5, curr); 612 bsW(s, 5, curr);
597 for (i = 0; i < alphaSize; i++) { 613 for (i = 0; i < alphaSize; i++) {
598 while (curr < s->len[t][i]) { bsW(s, 2, 2); curr++; /* 10 */ }; 614 while (curr < s->len[t][i]) { bsW(s, 2, 2); curr++; /* 10 */ }
599 while (curr > s->len[t][i]) { bsW(s, 2, 3); curr--; /* 11 */ }; 615 while (curr > s->len[t][i]) { bsW(s, 2, 3); curr--; /* 11 */ }
600 bsW1_0(s); 616 bsW1_0(s);
601 } 617 }
602 } 618 }