diff options
Diffstat (limited to 'archival')
-rw-r--r-- | archival/bz/bzlib.c | 8 | ||||
-rw-r--r-- | archival/dpkg.c | 10 | ||||
-rw-r--r-- | archival/gzip.c | 8 | ||||
-rw-r--r-- | archival/lzo1x_9x.c | 166 | ||||
-rw-r--r-- | archival/lzop.c | 9 |
5 files changed, 106 insertions, 95 deletions
diff --git a/archival/bz/bzlib.c b/archival/bz/bzlib.c index 9957c2fbd..834179403 100644 --- a/archival/bz/bzlib.c +++ b/archival/bz/bzlib.c | |||
@@ -393,10 +393,12 @@ int BZ2_bzBuffToBuffCompress(char* dest, | |||
393 | bz_stream strm; | 393 | bz_stream strm; |
394 | int ret; | 394 | int ret; |
395 | 395 | ||
396 | if (dest == NULL || destLen == NULL || | 396 | if (dest == NULL || destLen == NULL |
397 | source == NULL || | 397 | || source == NULL |
398 | blockSize100k < 1 || blockSize100k > 9) | 398 | || blockSize100k < 1 || blockSize100k > 9 |
399 | ) { | ||
399 | return BZ_PARAM_ERROR; | 400 | return BZ_PARAM_ERROR; |
401 | } | ||
400 | 402 | ||
401 | BZ2_bzCompressInit(&strm, blockSize100k); | 403 | BZ2_bzCompressInit(&strm, blockSize100k); |
402 | 404 | ||
diff --git a/archival/dpkg.c b/archival/dpkg.c index 9f58b54e6..7187ad6a0 100644 --- a/archival/dpkg.c +++ b/archival/dpkg.c | |||
@@ -858,8 +858,9 @@ static void write_status_file(deb_file_t **deb_file) | |||
858 | if (field_name == NULL) { | 858 | if (field_name == NULL) { |
859 | break; | 859 | break; |
860 | } | 860 | } |
861 | if ((strcmp(field_name, "Priority") == 0) || | 861 | if ((strcmp(field_name, "Priority") == 0) |
862 | (strcmp(field_name, "Section") == 0)) { | 862 | || (strcmp(field_name, "Section") == 0) |
863 | ) { | ||
863 | fprintf(new_status_file, "%s: %s\n", field_name, field_value); | 864 | fprintf(new_status_file, "%s: %s\n", field_name, field_value); |
864 | } | 865 | } |
865 | } | 866 | } |
@@ -1079,8 +1080,9 @@ static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count | |||
1079 | 1080 | ||
1080 | package_num = search_package_hashtable(package_edge->name, package_edge->version, package_edge->operator); | 1081 | package_num = search_package_hashtable(package_edge->name, package_edge->version, package_edge->operator); |
1081 | 1082 | ||
1082 | if (package_edge->type == EDGE_PRE_DEPENDS || | 1083 | if (package_edge->type == EDGE_PRE_DEPENDS |
1083 | package_edge->type == EDGE_DEPENDS) { | 1084 | || package_edge->type == EDGE_DEPENDS |
1085 | ) { | ||
1084 | int result=1; | 1086 | int result=1; |
1085 | status_num = 0; | 1087 | status_num = 0; |
1086 | 1088 | ||
diff --git a/archival/gzip.c b/archival/gzip.c index 139eaacea..f9c8e4d4b 100644 --- a/archival/gzip.c +++ b/archival/gzip.c | |||
@@ -620,10 +620,12 @@ static int longest_match(IPos cur_match) | |||
620 | /* Skip to next match if the match length cannot increase | 620 | /* Skip to next match if the match length cannot increase |
621 | * or if the match length is less than 2: | 621 | * or if the match length is less than 2: |
622 | */ | 622 | */ |
623 | if (match[best_len] != scan_end || | 623 | if (match[best_len] != scan_end |
624 | match[best_len - 1] != scan_end1 || | 624 | || match[best_len - 1] != scan_end1 |
625 | *match != *scan || *++match != scan[1]) | 625 | || *match != *scan || *++match != scan[1] |
626 | ) { | ||
626 | continue; | 627 | continue; |
628 | } | ||
627 | 629 | ||
628 | /* The check at best_len-1 can be removed because it will be made | 630 | /* The check at best_len-1 can be removed because it will be made |
629 | * again later. (This heuristic is not always a win.) | 631 | * again later. (This heuristic is not always a win.) |
diff --git a/archival/lzo1x_9x.c b/archival/lzo1x_9x.c index f2d4fac1b..0baed5469 100644 --- a/archival/lzo1x_9x.c +++ b/archival/lzo1x_9x.c | |||
@@ -176,7 +176,7 @@ static int swd_init(lzo_swd_p s) | |||
176 | if (s->look > 0) { | 176 | if (s->look > 0) { |
177 | if (s->look > SWD_F) | 177 | if (s->look > SWD_F) |
178 | s->look = SWD_F; | 178 | s->look = SWD_F; |
179 | memcpy(&s->b[s->ip],s->c->ip,s->look); | 179 | memcpy(&s->b[s->ip], s->c->ip, s->look); |
180 | s->c->ip += s->look; | 180 | s->c->ip += s->look; |
181 | s->ip += s->look; | 181 | s->ip += s->look; |
182 | } | 182 | } |
@@ -256,8 +256,8 @@ static void swd_accept(lzo_swd_p s, unsigned n) | |||
256 | swd_remove_node(s,s->rp); | 256 | swd_remove_node(s,s->rp); |
257 | 257 | ||
258 | /* add bp into HEAD3 */ | 258 | /* add bp into HEAD3 */ |
259 | key = HEAD3(s->b,s->bp); | 259 | key = HEAD3(s->b, s->bp); |
260 | s->succ3[s->bp] = s_get_head3(s,key); | 260 | s->succ3[s->bp] = s_get_head3(s, key); |
261 | s->head3[key] = s->bp; | 261 | s->head3[key] = s->bp; |
262 | s->best3[s->bp] = SWD_F + 1; | 262 | s->best3[s->bp] = SWD_F + 1; |
263 | s->llen3[key]++; | 263 | s->llen3[key]++; |
@@ -265,7 +265,7 @@ static void swd_accept(lzo_swd_p s, unsigned n) | |||
265 | 265 | ||
266 | #ifdef HEAD2 | 266 | #ifdef HEAD2 |
267 | /* add bp into HEAD2 */ | 267 | /* add bp into HEAD2 */ |
268 | key = HEAD2(s->b,s->bp); | 268 | key = HEAD2(s->b, s->bp); |
269 | s->head2[key] = s->bp; | 269 | s->head2[key] = s->bp; |
270 | #endif | 270 | #endif |
271 | 271 | ||
@@ -298,18 +298,19 @@ static void swd_search(lzo_swd_p s, unsigned node, unsigned cnt) | |||
298 | 298 | ||
299 | assert(m_len < s->look); | 299 | assert(m_len < s->look); |
300 | 300 | ||
301 | if (p2[m_len - 1] == scan_end1 && | 301 | if (p2[m_len - 1] == scan_end1 |
302 | p2[m_len] == p1[m_len] && | 302 | && p2[m_len] == p1[m_len] |
303 | p2[0] == p1[0] && | 303 | && p2[0] == p1[0] |
304 | p2[1] == p1[1]) { | 304 | && p2[1] == p1[1] |
305 | ) { | ||
305 | unsigned i; | 306 | unsigned i; |
306 | assert(lzo_memcmp(bp,&b[node],3) == 0); | 307 | assert(lzo_memcmp(bp, &b[node], 3) == 0); |
307 | 308 | ||
308 | p1 += 2; p2 += 2; | 309 | p1 += 2; p2 += 2; |
309 | do {} while (++p1 < px && *p1 == *++p2); | 310 | do {} while (++p1 < px && *p1 == *++p2); |
310 | i = p1-bp; | 311 | i = p1-bp; |
311 | 312 | ||
312 | assert(lzo_memcmp(bp,&b[node],i) == 0); | 313 | assert(lzo_memcmp(bp, &b[node], i) == 0); |
313 | 314 | ||
314 | #if defined(SWD_BEST_OFF) | 315 | #if defined(SWD_BEST_OFF) |
315 | if (i < SWD_BEST_OFF) { | 316 | if (i < SWD_BEST_OFF) { |
@@ -345,10 +346,10 @@ static int swd_search2(lzo_swd_p s) | |||
345 | assert(s->look >= 2); | 346 | assert(s->look >= 2); |
346 | assert(s->m_len > 0); | 347 | assert(s->m_len > 0); |
347 | 348 | ||
348 | key = s->head2[ HEAD2(s->b,s->bp) ]; | 349 | key = s->head2[HEAD2(s->b, s->bp)]; |
349 | if (key == NIL2) | 350 | if (key == NIL2) |
350 | return 0; | 351 | return 0; |
351 | assert(lzo_memcmp(&s->b[s->bp],&s->b[key],2) == 0); | 352 | assert(lzo_memcmp(&s->b[s->bp], &s->b[key], 2) == 0); |
352 | #if defined(SWD_BEST_OFF) | 353 | #if defined(SWD_BEST_OFF) |
353 | if (s->best_pos[2] == 0) | 354 | if (s->best_pos[2] == 0) |
354 | s->best_pos[2] = key + 1; | 355 | s->best_pos[2] = key + 1; |
@@ -377,7 +378,7 @@ static void swd_findbest(lzo_swd_p s) | |||
377 | 378 | ||
378 | /* get current head, add bp into HEAD3 */ | 379 | /* get current head, add bp into HEAD3 */ |
379 | key = HEAD3(s->b,s->bp); | 380 | key = HEAD3(s->b,s->bp); |
380 | node = s->succ3[s->bp] = s_get_head3(s,key); | 381 | node = s->succ3[s->bp] = s_get_head3(s, key); |
381 | cnt = s->llen3[key]++; | 382 | cnt = s->llen3[key]++; |
382 | assert(s->llen3[key] <= SWD_N + SWD_F); | 383 | assert(s->llen3[key] <= SWD_N + SWD_F); |
383 | if (cnt > s->max_chain) | 384 | if (cnt > s->max_chain) |
@@ -396,7 +397,7 @@ static void swd_findbest(lzo_swd_p s) | |||
396 | if (swd_search2(s)) | 397 | if (swd_search2(s)) |
397 | #endif | 398 | #endif |
398 | if (s->look >= 3) | 399 | if (s->look >= 3) |
399 | swd_search(s,node,cnt); | 400 | swd_search(s, node, cnt); |
400 | if (s->m_len > len) | 401 | if (s->m_len > len) |
401 | s->m_off = swd_pos2off(s,s->m_pos); | 402 | s->m_off = swd_pos2off(s,s->m_pos); |
402 | s->best3[s->bp] = s->m_len; | 403 | s->best3[s->bp] = s->m_len; |
@@ -404,11 +405,12 @@ static void swd_findbest(lzo_swd_p s) | |||
404 | #if defined(SWD_BEST_OFF) | 405 | #if defined(SWD_BEST_OFF) |
405 | if (s->use_best_off) { | 406 | if (s->use_best_off) { |
406 | int i; | 407 | int i; |
407 | for (i = 2; i < SWD_BEST_OFF; i++) | 408 | for (i = 2; i < SWD_BEST_OFF; i++) { |
408 | if (s->best_pos[i] > 0) | 409 | if (s->best_pos[i] > 0) |
409 | s->best_off[i] = swd_pos2off(s,s->best_pos[i]-1); | 410 | s->best_off[i] = swd_pos2off(s, s->best_pos[i]-1); |
410 | else | 411 | else |
411 | s->best_off[i] = 0; | 412 | s->best_off[i] = 0; |
413 | } | ||
412 | } | 414 | } |
413 | #endif | 415 | #endif |
414 | } | 416 | } |
@@ -417,7 +419,7 @@ static void swd_findbest(lzo_swd_p s) | |||
417 | 419 | ||
418 | #ifdef HEAD2 | 420 | #ifdef HEAD2 |
419 | /* add bp into HEAD2 */ | 421 | /* add bp into HEAD2 */ |
420 | key = HEAD2(s->b,s->bp); | 422 | key = HEAD2(s->b, s->bp); |
421 | s->head2[key] = s->bp; | 423 | s->head2[key] = s->bp; |
422 | #endif | 424 | #endif |
423 | } | 425 | } |
@@ -467,7 +469,7 @@ static int find_match(lzo1x_999_t *c, lzo_swd_p s, | |||
467 | s->m_len = 1; | 469 | s->m_len = 1; |
468 | #ifdef SWD_BEST_OFF | 470 | #ifdef SWD_BEST_OFF |
469 | if (s->use_best_off) | 471 | if (s->use_best_off) |
470 | memset(s->best_pos,0,sizeof(s->best_pos)); | 472 | memset(s->best_pos, 0, sizeof(s->best_pos)); |
471 | #endif | 473 | #endif |
472 | swd_findbest(s); | 474 | swd_findbest(s); |
473 | c->m_len = s->m_len; | 475 | c->m_len = s->m_len; |
@@ -505,7 +507,8 @@ static uint8_t *code_match(lzo1x_999_t *c, | |||
505 | assert(op > c->out); | 507 | assert(op > c->out); |
506 | if (m_len == 2) { | 508 | if (m_len == 2) { |
507 | assert(m_off <= M1_MAX_OFFSET); | 509 | assert(m_off <= M1_MAX_OFFSET); |
508 | assert(c->r1_lit > 0); assert(c->r1_lit < 4); | 510 | assert(c->r1_lit > 0); |
511 | assert(c->r1_lit < 4); | ||
509 | m_off -= 1; | 512 | m_off -= 1; |
510 | *op++ = M1_MARKER | ((m_off & 3) << 2); | 513 | *op++ = M1_MARKER | ((m_off & 3) << 2); |
511 | *op++ = m_off >> 2; | 514 | *op++ = m_off >> 2; |
@@ -529,11 +532,10 @@ static uint8_t *code_match(lzo1x_999_t *c, | |||
529 | else { | 532 | else { |
530 | m_len -= M3_MAX_LEN; | 533 | m_len -= M3_MAX_LEN; |
531 | *op++ = M3_MARKER | 0; | 534 | *op++ = M3_MARKER | 0; |
532 | while (m_len > 255) | 535 | while (m_len > 255) { |
533 | { | 536 | m_len -= 255; |
534 | m_len -= 255; | 537 | *op++ = 0; |
535 | *op++ = 0; | 538 | } |
536 | } | ||
537 | assert(m_len > 0); | 539 | assert(m_len > 0); |
538 | *op++ = m_len; | 540 | *op++ = m_len; |
539 | } | 541 | } |
@@ -543,7 +545,8 @@ static uint8_t *code_match(lzo1x_999_t *c, | |||
543 | unsigned k; | 545 | unsigned k; |
544 | 546 | ||
545 | assert(m_len >= 3); | 547 | assert(m_len >= 3); |
546 | assert(m_off > 0x4000); assert(m_off <= 0xbfff); | 548 | assert(m_off > 0x4000); |
549 | assert(m_off <= 0xbfff); | ||
547 | m_off -= 0x4000; | 550 | m_off -= 0x4000; |
548 | k = (m_off & 0x4000) >> 11; | 551 | k = (m_off & 0x4000) >> 11; |
549 | if (m_len <= M4_MAX_LEN) | 552 | if (m_len <= M4_MAX_LEN) |
@@ -551,11 +554,10 @@ static uint8_t *code_match(lzo1x_999_t *c, | |||
551 | else { | 554 | else { |
552 | m_len -= M4_MAX_LEN; | 555 | m_len -= M4_MAX_LEN; |
553 | *op++ = M4_MARKER | k | 0; | 556 | *op++ = M4_MARKER | k | 0; |
554 | while (m_len > 255) | 557 | while (m_len > 255) { |
555 | { | 558 | m_len -= 255; |
556 | m_len -= 255; | 559 | *op++ = 0; |
557 | *op++ = 0; | 560 | } |
558 | } | ||
559 | assert(m_len > 0); | 561 | assert(m_len > 0); |
560 | *op++ = m_len; | 562 | *op++ = m_len; |
561 | } | 563 | } |
@@ -598,7 +600,7 @@ static uint8_t *code_run(lzo1x_999_t *c, uint8_t *op, const uint8_t *ii, | |||
598 | { | 600 | { |
599 | if (lit > 0) { | 601 | if (lit > 0) { |
600 | assert(m_len >= 2); | 602 | assert(m_len >= 2); |
601 | op = STORE_RUN(c,op,ii,lit); | 603 | op = STORE_RUN(c, op, ii, lit); |
602 | } else { | 604 | } else { |
603 | assert(m_len >= 3); | 605 | assert(m_len >= 3); |
604 | } | 606 | } |
@@ -681,32 +683,32 @@ static void better_match(const lzo_swd_p swd, | |||
681 | return; | 683 | return; |
682 | 684 | ||
683 | /* M3/M4 -> M2 */ | 685 | /* M3/M4 -> M2 */ |
684 | if (*m_off > M2_MAX_OFFSET && | 686 | if (*m_off > M2_MAX_OFFSET |
685 | *m_len >= M2_MIN_LEN + 1 && *m_len <= M2_MAX_LEN + 1 && | 687 | && *m_len >= M2_MIN_LEN + 1 && *m_len <= M2_MAX_LEN + 1 |
686 | swd->best_off[*m_len-1] && swd->best_off[*m_len-1] <= M2_MAX_OFFSET) | 688 | && swd->best_off[*m_len-1] && swd->best_off[*m_len-1] <= M2_MAX_OFFSET |
687 | { | 689 | ) { |
688 | *m_len = *m_len - 1; | 690 | *m_len = *m_len - 1; |
689 | *m_off = swd->best_off[*m_len]; | 691 | *m_off = swd->best_off[*m_len]; |
690 | return; | 692 | return; |
691 | } | 693 | } |
692 | 694 | ||
693 | /* M4 -> M2 */ | 695 | /* M4 -> M2 */ |
694 | if (*m_off > M3_MAX_OFFSET && | 696 | if (*m_off > M3_MAX_OFFSET |
695 | *m_len >= M4_MAX_LEN + 1 && *m_len <= M2_MAX_LEN + 2 && | 697 | && *m_len >= M4_MAX_LEN + 1 && *m_len <= M2_MAX_LEN + 2 |
696 | swd->best_off[*m_len-2] && swd->best_off[*m_len-2] <= M2_MAX_OFFSET) | 698 | && swd->best_off[*m_len-2] && swd->best_off[*m_len-2] <= M2_MAX_OFFSET |
697 | { | 699 | ) { |
698 | *m_len = *m_len - 2; | 700 | *m_len = *m_len - 2; |
699 | *m_off = swd->best_off[*m_len]; | 701 | *m_off = swd->best_off[*m_len]; |
700 | return; | 702 | return; |
701 | } | 703 | } |
702 | /* M4 -> M3 */ | 704 | /* M4 -> M3 */ |
703 | if (*m_off > M3_MAX_OFFSET && | 705 | if (*m_off > M3_MAX_OFFSET |
704 | *m_len >= M4_MAX_LEN + 1 && *m_len <= M3_MAX_LEN + 1 && | 706 | && *m_len >= M4_MAX_LEN + 1 && *m_len <= M3_MAX_LEN + 1 |
705 | swd->best_off[*m_len-1] && swd->best_off[*m_len-1] <= M3_MAX_OFFSET) | 707 | && swd->best_off[*m_len-1] && swd->best_off[*m_len-1] <= M3_MAX_OFFSET |
706 | { | 708 | ) { |
707 | *m_len = *m_len - 1; | 709 | *m_len = *m_len - 1; |
708 | *m_off = swd->best_off[*m_len]; | 710 | *m_off = swd->best_off[*m_len]; |
709 | } | 711 | } |
710 | } | 712 | } |
711 | 713 | ||
712 | #endif | 714 | #endif |
@@ -728,8 +730,8 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len, | |||
728 | unsigned lit; | 730 | unsigned lit; |
729 | unsigned m_len, m_off; | 731 | unsigned m_len, m_off; |
730 | lzo1x_999_t cc; | 732 | lzo1x_999_t cc; |
731 | lzo1x_999_t * const c = &cc; | 733 | lzo1x_999_t *const c = &cc; |
732 | lzo_swd_p const swd = (lzo_swd_p) wrkmem; | 734 | const lzo_swd_p swd = (lzo_swd_p) wrkmem; |
733 | int r; | 735 | int r; |
734 | 736 | ||
735 | c->init = 0; | 737 | c->init = 0; |
@@ -766,18 +768,18 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len, | |||
766 | assert(ii + lit == c->bp); | 768 | assert(ii + lit == c->bp); |
767 | assert(swd->b_char == *(c->bp)); | 769 | assert(swd->b_char == *(c->bp)); |
768 | 770 | ||
769 | if ( m_len < 2 || | 771 | if (m_len < 2 |
770 | (m_len == 2 && (m_off > M1_MAX_OFFSET || lit == 0 || lit >= 4)) || | 772 | || (m_len == 2 && (m_off > M1_MAX_OFFSET || lit == 0 || lit >= 4)) |
771 | /* Do not accept this match for compressed-data compatibility | 773 | /* Do not accept this match for compressed-data compatibility |
772 | * with LZO v1.01 and before | 774 | * with LZO v1.01 and before |
773 | * [ might be a problem for decompress() and optimize() ] | 775 | * [ might be a problem for decompress() and optimize() ] |
774 | */ | 776 | */ |
775 | (m_len == 2 && op == out) || | 777 | || (m_len == 2 && op == out) |
776 | (op == out && lit == 0)) | 778 | || (op == out && lit == 0) |
777 | { | 779 | ) { |
778 | /* a literal */ | 780 | /* a literal */ |
779 | m_len = 0; | 781 | m_len = 0; |
780 | } | 782 | } |
781 | else if (m_len == M2_MIN_LEN) { | 783 | else if (m_len == M2_MIN_LEN) { |
782 | /* compression ratio improves if we code a literal in some cases */ | 784 | /* compression ratio improves if we code a literal in some cases */ |
783 | if (m_off > MX_MAX_OFFSET && lit >= 4) | 785 | if (m_off > MX_MAX_OFFSET && lit >= 4) |
@@ -788,7 +790,7 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len, | |||
788 | /* a literal */ | 790 | /* a literal */ |
789 | lit++; | 791 | lit++; |
790 | swd->max_chain = max_chain; | 792 | swd->max_chain = max_chain; |
791 | r = find_match(c,swd,1,0); | 793 | r = find_match(c, swd, 1, 0); |
792 | assert(r == 0); | 794 | assert(r == 0); |
793 | continue; | 795 | continue; |
794 | } | 796 | } |
@@ -796,7 +798,7 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len, | |||
796 | /* a match */ | 798 | /* a match */ |
797 | #if defined(SWD_BEST_OFF) | 799 | #if defined(SWD_BEST_OFF) |
798 | if (swd->use_best_off) | 800 | if (swd->use_best_off) |
799 | better_match(swd,&m_len,&m_off); | 801 | better_match(swd, &m_len, &m_off); |
800 | #endif | 802 | #endif |
801 | 803 | ||
802 | /* shall we try a lazy match ? */ | 804 | /* shall we try a lazy match ? */ |
@@ -807,7 +809,7 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len, | |||
807 | max_ahead = 0; | 809 | max_ahead = 0; |
808 | } else { | 810 | } else { |
809 | /* yes, try a lazy match */ | 811 | /* yes, try a lazy match */ |
810 | l1 = len_of_coded_match(m_len,m_off,lit); | 812 | l1 = len_of_coded_match(m_len, m_off, lit); |
811 | assert(l1 > 0); | 813 | assert(l1 > 0); |
812 | max_ahead = LZO_MIN(2, (unsigned)l1 - 1); | 814 | max_ahead = LZO_MIN(2, (unsigned)l1 - 1); |
813 | } | 815 | } |
@@ -820,7 +822,7 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len, | |||
820 | swd->max_chain = max_chain >> 2; | 822 | swd->max_chain = max_chain >> 2; |
821 | else | 823 | else |
822 | swd->max_chain = max_chain; | 824 | swd->max_chain = max_chain; |
823 | r = find_match(c,swd,1,0); | 825 | r = find_match(c, swd, 1, 0); |
824 | ahead++; | 826 | ahead++; |
825 | 827 | ||
826 | assert(r == 0); | 828 | assert(r == 0); |
@@ -833,23 +835,23 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len, | |||
833 | continue; | 835 | continue; |
834 | #if defined(SWD_BEST_OFF) | 836 | #if defined(SWD_BEST_OFF) |
835 | if (swd->use_best_off) | 837 | if (swd->use_best_off) |
836 | better_match(swd,&c->m_len,&c->m_off); | 838 | better_match(swd, &c->m_len, &c->m_off); |
837 | #endif | 839 | #endif |
838 | l2 = len_of_coded_match(c->m_len,c->m_off,lit+ahead); | 840 | l2 = len_of_coded_match(c->m_len, c->m_off, lit+ahead); |
839 | if (l2 < 0) | 841 | if (l2 < 0) |
840 | continue; | 842 | continue; |
841 | 843 | ||
842 | /* compressed-data compatibility [see above] */ | 844 | /* compressed-data compatibility [see above] */ |
843 | l3 = (op == out) ? -1 : len_of_coded_match(ahead,m_off,lit); | 845 | l3 = (op == out) ? -1 : len_of_coded_match(ahead, m_off, lit); |
844 | 846 | ||
845 | lazy_match_min_gain = min_gain(ahead,lit,lit+ahead,l1,l2,l3); | 847 | lazy_match_min_gain = min_gain(ahead, lit, lit+ahead, l1, l2, l3); |
846 | if (c->m_len >= m_len + lazy_match_min_gain) { | 848 | if (c->m_len >= m_len + lazy_match_min_gain) { |
847 | if (l3 > 0) { | 849 | if (l3 > 0) { |
848 | /* code previous run */ | 850 | /* code previous run */ |
849 | op = code_run(c,op,ii,lit); | 851 | op = code_run(c, op, ii, lit); |
850 | lit = 0; | 852 | lit = 0; |
851 | /* code shortened match */ | 853 | /* code shortened match */ |
852 | op = code_match(c,op,ahead,m_off); | 854 | op = code_match(c, op, ahead, m_off); |
853 | } else { | 855 | } else { |
854 | lit += ahead; | 856 | lit += ahead; |
855 | assert(ii + lit == c->bp); | 857 | assert(ii + lit == c->bp); |
@@ -861,13 +863,13 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len, | |||
861 | assert(ii + lit + ahead == c->bp); | 863 | assert(ii + lit + ahead == c->bp); |
862 | 864 | ||
863 | /* 1 - code run */ | 865 | /* 1 - code run */ |
864 | op = code_run(c,op,ii,lit); | 866 | op = code_run(c, op, ii, lit); |
865 | lit = 0; | 867 | lit = 0; |
866 | 868 | ||
867 | /* 2 - code match */ | 869 | /* 2 - code match */ |
868 | op = code_match(c,op,m_len,m_off); | 870 | op = code_match(c, op, m_len, m_off); |
869 | swd->max_chain = max_chain; | 871 | swd->max_chain = max_chain; |
870 | r = find_match(c,swd,m_len,1+ahead); | 872 | r = find_match(c, swd, m_len, 1+ahead); |
871 | assert(r == 0); | 873 | assert(r == 0); |
872 | 874 | ||
873 | lazy_match_done: ; | 875 | lazy_match_done: ; |
@@ -875,7 +877,7 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len, | |||
875 | 877 | ||
876 | /* store final run */ | 878 | /* store final run */ |
877 | if (lit > 0) | 879 | if (lit > 0) |
878 | op = STORE_RUN(c,op,ii,lit); | 880 | op = STORE_RUN(c, op, ii, lit); |
879 | 881 | ||
880 | #if defined(LZO_EOF_CODE) | 882 | #if defined(LZO_EOF_CODE) |
881 | *op++ = M4_MARKER | 1; | 883 | *op++ = M4_MARKER | 1; |
diff --git a/archival/lzop.c b/archival/lzop.c index 46aa2d3d1..a752a9d89 100644 --- a/archival/lzop.c +++ b/archival/lzop.c | |||
@@ -166,9 +166,12 @@ static NOINLINE int lzo1x_optimize(uint8_t *in, unsigned in_len, | |||
166 | o_m1_a++; | 166 | o_m1_a++; |
167 | } | 167 | } |
168 | /* test if a literal run follows */ | 168 | /* test if a literal run follows */ |
169 | else if (nl == 0 && ip[0] < 16 && ip[0] != 0 && | 169 | else |
170 | (lit + 2 + ip[0] < 16)) | 170 | if (nl == 0 |
171 | { | 171 | && ip[0] < 16 |
172 | && ip[0] != 0 | ||
173 | && (lit + 2 + ip[0] < 16) | ||
174 | ) { | ||
172 | t = *ip++; | 175 | t = *ip++; |
173 | /* remove short run */ | 176 | /* remove short run */ |
174 | *litp &= ~3; | 177 | *litp &= ~3; |