summaryrefslogtreecommitdiff
path: root/deflate.c
diff options
context:
space:
mode:
Diffstat (limited to 'deflate.c')
-rw-r--r--deflate.c194
1 files changed, 78 insertions, 116 deletions
diff --git a/deflate.c b/deflate.c
index 31b090e..46ddc55 100644
--- a/deflate.c
+++ b/deflate.c
@@ -1,5 +1,5 @@
1/* deflate.c -- compress data using the deflation algorithm 1/* deflate.c -- compress data using the deflation algorithm
2 * Copyright (C) 1995-1996 Jean-loup Gailly. 2 * Copyright (C) 1995 Jean-loup Gailly.
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
@@ -51,7 +51,7 @@
51 51
52#include "deflate.h" 52#include "deflate.h"
53 53
54char deflate_copyright[] = " deflate 1.0 Copyright 1995-1996 Jean-loup Gailly "; 54char deflate_copyright[] = " deflate 1.0 Copyright 1995 Jean-loup Gailly ";
55/* 55/*
56 If you use the zlib library in a product, an acknowledgment is welcome 56 If you use the zlib library in a product, an acknowledgment is welcome
57 in the documentation of your product. If for some reason you cannot 57 in the documentation of your product. If for some reason you cannot
@@ -60,8 +60,9 @@ char deflate_copyright[] = " deflate 1.0 Copyright 1995-1996 Jean-loup Gailly ";
60 */ 60 */
61 61
62/* =========================================================================== 62/* ===========================================================================
63 * Function prototypes. 63 * Prototypes for local functions.
64 */ 64 */
65
65local void fill_window OF((deflate_state *s)); 66local void fill_window OF((deflate_state *s));
66local int deflate_stored OF((deflate_state *s, int flush)); 67local int deflate_stored OF((deflate_state *s, int flush));
67local int deflate_fast OF((deflate_state *s, int flush)); 68local int deflate_fast OF((deflate_state *s, int flush));
@@ -168,36 +169,26 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
168 zmemzero((charf *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); 169 zmemzero((charf *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
169 170
170/* ========================================================================= */ 171/* ========================================================================= */
171int deflateInit_(strm, level, version, stream_size) 172int deflateInit (strm, level)
172 z_stream *strm; 173 z_stream *strm;
173 int level; 174 int level;
174 const char *version;
175 int stream_size;
176{ 175{
177 return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, 176 return deflateInit2 (strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, 0);
178 Z_DEFAULT_STRATEGY, version, stream_size);
179 /* To do: ignore strm->next_in if we use it as window */ 177 /* To do: ignore strm->next_in if we use it as window */
180} 178}
181 179
182/* ========================================================================= */ 180/* ========================================================================= */
183int deflateInit2_(strm, level, method, windowBits, memLevel, strategy, 181int deflateInit2 (strm, level, method, windowBits, memLevel, strategy)
184 version, stream_size)
185 z_stream *strm; 182 z_stream *strm;
186 int level; 183 int level;
187 int method; 184 int method;
188 int windowBits; 185 int windowBits;
189 int memLevel; 186 int memLevel;
190 int strategy; 187 int strategy;
191 const char *version;
192 int stream_size;
193{ 188{
194 deflate_state *s; 189 deflate_state *s;
195 int noheader = 0; 190 int noheader = 0;
196 191
197 if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
198 stream_size != sizeof(z_stream)) {
199 return Z_VERSION_ERROR;
200 }
201 if (strm == Z_NULL) return Z_STREAM_ERROR; 192 if (strm == Z_NULL) return Z_STREAM_ERROR;
202 193
203 strm->msg = Z_NULL; 194 strm->msg = Z_NULL;
@@ -243,7 +234,7 @@ int deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
243 234
244 if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || 235 if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
245 s->pending_buf == Z_NULL) { 236 s->pending_buf == Z_NULL) {
246 strm->msg = ERR_MSG(Z_MEM_ERROR); 237 strm->msg = z_errmsg[1-Z_MEM_ERROR];
247 deflateEnd (strm); 238 deflateEnd (strm);
248 return Z_MEM_ERROR; 239 return Z_MEM_ERROR;
249 } 240 }
@@ -261,41 +252,32 @@ int deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
261 return deflateReset(strm); 252 return deflateReset(strm);
262} 253}
263 254
264/* ========================================================================= */ 255/* =========================================================================
265int deflateSetDictionary (strm, dictionary, dictLength) 256 * Undocumented function to return the Adler32 of a stream. It can be
257 * called immediately after a flush with Z_SYNC_FLUSH, to allow later
258 * resumption of the compressor with deflateSetAdler32.
259 */
260uLong deflateGetAdler32 (strm)
266 z_stream *strm; 261 z_stream *strm;
267 const Bytef *dictionary;
268 uInt dictLength;
269{ 262{
270 deflate_state *s; 263 if (strm == Z_NULL || strm->state == Z_NULL) return (uLong)Z_STREAM_ERROR;
271 uInt length = dictLength; 264 /* Z_STREAM_ERROR happens to be an invalid Adler32 value. */
272 uInt n;
273 IPos hash_head;
274
275 if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
276 strm->state->status != INIT_STATE) return Z_STREAM_ERROR;
277 265
278 s = strm->state; 266 return strm->state->adler;
279 strm->adler = adler32(strm->adler, dictionary, dictLength); 267}
280 268
281 if (length < MIN_MATCH) return Z_OK; 269/* =========================================================================
282 if (length > MAX_DIST(s)) { 270 * Undocumented function to set the Adler32 of a stream. It can be called
283 length = MAX_DIST(s); 271 * immediately after deflateInit to reset the Adler32 of a compression
284 dictionary += dictLength - length; 272 * stream which had been interrupted.
285 } 273 */
286 zmemcpy((charf *)s->window, dictionary, length); 274int deflateSetAdler32 (strm, adler)
287 s->strstart = length; 275 z_stream *strm;
288 s->block_start = (long)length; 276 uLong adler;
277{
278 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
289 279
290 /* Insert all strings in the hash table (except for the last two bytes). 280 strm->state->adler = adler;
291 * s->lookahead stays null, so s->ins_h will be recomputed at the next
292 * call of fill_window.
293 */
294 s->ins_h = s->window[0];
295 UPDATE_HASH(s, s->ins_h, s->window[1]);
296 for (n = 0; n <= length - MIN_MATCH; n++) {
297 INSERT_STRING(s, n, hash_head);
298 }
299 return Z_OK; 281 return Z_OK;
300} 282}
301 283
@@ -320,10 +302,10 @@ int deflateReset (strm)
320 s->noheader = 0; /* was set to -1 by deflate(..., Z_FINISH); */ 302 s->noheader = 0; /* was set to -1 by deflate(..., Z_FINISH); */
321 } 303 }
322 s->status = s->noheader ? BUSY_STATE : INIT_STATE; 304 s->status = s->noheader ? BUSY_STATE : INIT_STATE;
323 strm->adler = 1; 305 s->adler = 1;
324 s->last_flush = Z_NO_FLUSH; 306 s->last_flush = Z_NO_FLUSH;
325 307
326 _tr_init(s); 308 tr_init(s);
327 lm_init(s); 309 lm_init(s);
328 310
329 return Z_OK; 311 return Z_OK;
@@ -410,47 +392,36 @@ int deflate (strm, flush)
410 int flush; 392 int flush;
411{ 393{
412 int old_flush; /* value of flush param for previous deflate call */ 394 int old_flush; /* value of flush param for previous deflate call */
413 deflate_state *s;
414 395
415 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; 396 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
416 397
417 s = strm->state;
418
419 if (strm->next_out == Z_NULL || 398 if (strm->next_out == Z_NULL ||
420 (strm->next_in == Z_NULL && strm->avail_in != 0) || 399 (strm->next_in == Z_NULL && strm->avail_in != 0) ||
421 (s->status == FINISH_STATE && flush != Z_FINISH)) { 400 (strm->state->status == FINISH_STATE && flush != Z_FINISH)) {
422 ERR_RETURN(strm, Z_STREAM_ERROR); 401 ERR_RETURN(strm, Z_STREAM_ERROR);
423 } 402 }
424 if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); 403 if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
425 404
426 s->strm = strm; /* just in case */ 405 strm->state->strm = strm; /* just in case */
427 old_flush = s->last_flush; 406 old_flush = strm->state->last_flush;
428 s->last_flush = flush; 407 strm->state->last_flush = flush;
429 408
430 /* Write the zlib header */ 409 /* Write the zlib header */
431 if (s->status == INIT_STATE) { 410 if (strm->state->status == INIT_STATE) {
432 411
433 uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; 412 uInt header = (Z_DEFLATED + ((strm->state->w_bits-8)<<4)) << 8;
434 uInt level_flags = (s->level-1) >> 1; 413 uInt level_flags = (strm->state->level-1) >> 1;
435 414
436 if (level_flags > 3) level_flags = 3; 415 if (level_flags > 3) level_flags = 3;
437 header |= (level_flags << 6); 416 header |= (level_flags << 6);
438 if (s->strstart != 0) header |= PRESET_DICT;
439 header += 31 - (header % 31); 417 header += 31 - (header % 31);
440 418
441 s->status = BUSY_STATE; 419 strm->state->status = BUSY_STATE;
442 putShortMSB(s, header); 420 putShortMSB(strm->state, header);
443
444 /* Save the adler32 of the preset dictionary: */
445 if (s->strstart != 0) {
446 putShortMSB(s, (uInt)(strm->adler >> 16));
447 putShortMSB(s, (uInt)(strm->adler & 0xffff));
448 strm->adler = 1L;
449 }
450 } 421 }
451 422
452 /* Flush as much pending output as possible */ 423 /* Flush as much pending output as possible */
453 if (s->pending != 0) { 424 if (strm->state->pending != 0) {
454 flush_pending(strm); 425 flush_pending(strm);
455 if (strm->avail_out == 0) return Z_OK; 426 if (strm->avail_out == 0) return Z_OK;
456 427
@@ -464,20 +435,21 @@ int deflate (strm, flush)
464 } 435 }
465 436
466 /* User must not provide more input after the first FINISH: */ 437 /* User must not provide more input after the first FINISH: */
467 if (s->status == FINISH_STATE && strm->avail_in != 0) { 438 if (strm->state->status == FINISH_STATE && strm->avail_in != 0) {
468 ERR_RETURN(strm, Z_BUF_ERROR); 439 ERR_RETURN(strm, Z_BUF_ERROR);
469 } 440 }
470 441
471 /* Start a new block or continue the current one. 442 /* Start a new block or continue the current one.
472 */ 443 */
473 if (strm->avail_in != 0 || s->lookahead != 0 || 444 if (strm->avail_in != 0 || strm->state->lookahead != 0 ||
474 (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { 445 (flush != Z_NO_FLUSH && strm->state->status != FINISH_STATE)) {
475 int quit; 446 int quit;
476 447
477 if (flush == Z_FINISH) { 448 if (flush == Z_FINISH) {
478 s->status = FINISH_STATE; 449 strm->state->status = FINISH_STATE;
479 } 450 }
480 quit = (*(configuration_table[s->level].func))(s, flush); 451 quit = (*(configuration_table[strm->state->level].func))
452 (strm->state, flush);
481 453
482 if (quit || strm->avail_out == 0) return Z_OK; 454 if (quit || strm->avail_out == 0) return Z_OK;
483 /* If flush != Z_NO_FLUSH && avail_out == 0, the next call 455 /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
@@ -489,14 +461,14 @@ int deflate (strm, flush)
489 */ 461 */
490 if (flush != Z_NO_FLUSH && flush != Z_FINISH) { 462 if (flush != Z_NO_FLUSH && flush != Z_FINISH) {
491 if (flush == Z_PARTIAL_FLUSH) { 463 if (flush == Z_PARTIAL_FLUSH) {
492 _tr_align(s); 464 tr_align(strm->state);
493 } else { /* FULL_FLUSH or SYNC_FLUSH */ 465 } else { /* FULL_FLUSH or SYNC_FLUSH */
494 _tr_stored_block(s, (char*)0, 0L, 0); 466 tr_stored_block(strm->state, (char*)0, 0L, 0);
495 /* For a full flush, this empty block will be recognized 467 /* For a full flush, this empty block will be recognized
496 * as a special marker by inflate_sync(). 468 * as a special marker by inflate_sync().
497 */ 469 */
498 if (flush == Z_FULL_FLUSH) { 470 if (flush == Z_FULL_FLUSH) {
499 CLEAR_HASH(s); /* forget history */ 471 CLEAR_HASH(strm->state); /* forget history */
500 } 472 }
501 } 473 }
502 flush_pending(strm); 474 flush_pending(strm);
@@ -506,25 +478,23 @@ int deflate (strm, flush)
506 Assert(strm->avail_out > 0, "bug2"); 478 Assert(strm->avail_out > 0, "bug2");
507 479
508 if (flush != Z_FINISH) return Z_OK; 480 if (flush != Z_FINISH) return Z_OK;
509 if (s->noheader) return Z_STREAM_END; 481 if (strm->state->noheader) return Z_STREAM_END;
510 482
511 /* Write the zlib trailer (adler32) */ 483 /* Write the zlib trailer (adler32) */
512 putShortMSB(s, (uInt)(strm->adler >> 16)); 484 putShortMSB(strm->state, (uInt)(strm->state->adler >> 16));
513 putShortMSB(s, (uInt)(strm->adler & 0xffff)); 485 putShortMSB(strm->state, (uInt)(strm->state->adler & 0xffff));
514 flush_pending(strm); 486 flush_pending(strm);
515 /* If avail_out is zero, the application will call deflate again 487 /* If avail_out is zero, the application will call deflate again
516 * to flush the rest. 488 * to flush the rest.
517 */ 489 */
518 s->noheader = -1; /* write the trailer only once! */ 490 strm->state->noheader = -1; /* write the trailer only once! */
519 return s->pending != 0 ? Z_OK : Z_STREAM_END; 491 return strm->state->pending != 0 ? Z_OK : Z_STREAM_END;
520} 492}
521 493
522/* ========================================================================= */ 494/* ========================================================================= */
523int deflateEnd (strm) 495int deflateEnd (strm)
524 z_stream *strm; 496 z_stream *strm;
525{ 497{
526 int status;
527
528 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; 498 if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
529 499
530 /* Deallocate in reverse order of allocations: */ 500 /* Deallocate in reverse order of allocations: */
@@ -533,11 +503,10 @@ int deflateEnd (strm)
533 TRY_FREE(strm, strm->state->prev); 503 TRY_FREE(strm, strm->state->prev);
534 TRY_FREE(strm, strm->state->window); 504 TRY_FREE(strm, strm->state->window);
535 505
536 status = strm->state->status;
537 ZFREE(strm, strm->state); 506 ZFREE(strm, strm->state);
538 strm->state = Z_NULL; 507 strm->state = Z_NULL;
539 508
540 return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; 509 return Z_OK;
541} 510}
542 511
543/* ========================================================================= */ 512/* ========================================================================= */
@@ -580,7 +549,7 @@ local int read_buf(strm, buf, size)
580 strm->avail_in -= len; 549 strm->avail_in -= len;
581 550
582 if (!strm->state->noheader) { 551 if (!strm->state->noheader) {
583 strm->adler = adler32(strm->adler, strm->next_in, len); 552 strm->state->adler = adler32(strm->state->adler, strm->next_in, len);
584 } 553 }
585 zmemcpy(buf, strm->next_in, len); 554 zmemcpy(buf, strm->next_in, len);
586 strm->next_in += len; 555 strm->next_in += len;
@@ -624,7 +593,6 @@ local void lm_init (s)
624 * garbage. 593 * garbage.
625 * IN assertions: cur_match is the head of the hash chain for the current 594 * IN assertions: cur_match is the head of the hash chain for the current
626 * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 595 * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
627 * OUT assertion: the match length is not greater than s->lookahead.
628 */ 596 */
629#ifndef ASMV 597#ifndef ASMV
630/* For 80x86 and 680x0, an optimized version will be provided in match.asm or 598/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
@@ -639,7 +607,6 @@ local int longest_match(s, cur_match)
639 register Bytef *match; /* matched string */ 607 register Bytef *match; /* matched string */
640 register int len; /* length of current match */ 608 register int len; /* length of current match */
641 int best_len = s->prev_length; /* best match length so far */ 609 int best_len = s->prev_length; /* best match length so far */
642 int nice_match = s->nice_match; /* stop if match long enough */
643 IPos limit = s->strstart > (IPos)MAX_DIST(s) ? 610 IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
644 s->strstart - (IPos)MAX_DIST(s) : NIL; 611 s->strstart - (IPos)MAX_DIST(s) : NIL;
645 /* Stop when cur_match becomes <= limit. To simplify the code, 612 /* Stop when cur_match becomes <= limit. To simplify the code,
@@ -670,11 +637,6 @@ local int longest_match(s, cur_match)
670 if (s->prev_length >= s->good_match) { 637 if (s->prev_length >= s->good_match) {
671 chain_length >>= 2; 638 chain_length >>= 2;
672 } 639 }
673 /* Do not look for matches beyond the end of the input. This is necessary
674 * to make deflate deterministic.
675 */
676 if (nice_match > s->lookahead) nice_match = s->lookahead;
677
678 Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); 640 Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
679 641
680 do { 642 do {
@@ -753,7 +715,7 @@ local int longest_match(s, cur_match)
753 if (len > best_len) { 715 if (len > best_len) {
754 s->match_start = cur_match; 716 s->match_start = cur_match;
755 best_len = len; 717 best_len = len;
756 if (len >= nice_match) break; 718 if (len >= s->nice_match) break;
757#ifdef UNALIGNED_OK 719#ifdef UNALIGNED_OK
758 scan_end = *(ushf*)(scan+best_len-1); 720 scan_end = *(ushf*)(scan+best_len-1);
759#else 721#else
@@ -764,8 +726,7 @@ local int longest_match(s, cur_match)
764 } while ((cur_match = prev[cur_match & wmask]) > limit 726 } while ((cur_match = prev[cur_match & wmask]) > limit
765 && --chain_length != 0); 727 && --chain_length != 0);
766 728
767 if (best_len <= s->lookahead) return best_len; 729 return best_len;
768 return s->lookahead;
769} 730}
770#endif /* ASMV */ 731#endif /* ASMV */
771 732
@@ -779,13 +740,13 @@ local void check_match(s, start, match, length)
779 int length; 740 int length;
780{ 741{
781 /* check that the match is indeed a match */ 742 /* check that the match is indeed a match */
782 if (zmemcmp((charf *)s->window + match, 743 if (memcmp((charf *)s->window + match,
783 (charf *)s->window + start, length) != EQUAL) { 744 (charf *)s->window + start, length) != EQUAL) {
784 fprintf(stderr, " start %u, match %u, length %d\n", 745 fprintf(stderr,
785 start, match, length); 746 " start %u, match %u, length %d\n",
786 do { 747 start, match, length);
787 fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); 748 do { fprintf(stderr, "%c%c", s->window[match++],
788 } while (--length != 0); 749 s->window[start++]); } while (--length != 0);
789 z_error("invalid match"); 750 z_error("invalid match");
790 } 751 }
791 if (verbose > 1) { 752 if (verbose > 1) {
@@ -901,11 +862,9 @@ local void fill_window(s)
901 * IN assertion: strstart is set to the end of the current match. 862 * IN assertion: strstart is set to the end of the current match.
902 */ 863 */
903#define FLUSH_BLOCK_ONLY(s, eof) { \ 864#define FLUSH_BLOCK_ONLY(s, eof) { \
904 _tr_flush_block(s, (s->block_start >= 0L ? \ 865 tr_flush_block(s, (s->block_start >= 0L ? \
905 (charf *)&s->window[(unsigned)s->block_start] : \ 866 (charf *)&s->window[(unsigned)s->block_start] : \
906 (charf *)Z_NULL), \ 867 (charf *)Z_NULL), (long)s->strstart - s->block_start, (eof)); \
907 (ulg)((long)s->strstart - s->block_start), \
908 (eof)); \
909 s->block_start = s->strstart; \ 868 s->block_start = s->strstart; \
910 flush_pending(s->strm); \ 869 flush_pending(s->strm); \
911 Tracev((stderr,"[FLUSH]")); \ 870 Tracev((stderr,"[FLUSH]")); \
@@ -1008,12 +967,14 @@ local int deflate_fast(s, flush)
1008 s->match_length = longest_match (s, hash_head); 967 s->match_length = longest_match (s, hash_head);
1009 } 968 }
1010 /* longest_match() sets match_start */ 969 /* longest_match() sets match_start */
970
971 if (s->match_length > s->lookahead) s->match_length = s->lookahead;
1011 } 972 }
1012 if (s->match_length >= MIN_MATCH) { 973 if (s->match_length >= MIN_MATCH) {
1013 check_match(s, s->strstart, s->match_start, s->match_length); 974 check_match(s, s->strstart, s->match_start, s->match_length);
1014 975
1015 bflush = _tr_tally(s, s->strstart - s->match_start, 976 bflush = tr_tally(s, s->strstart - s->match_start,
1016 s->match_length - MIN_MATCH); 977 s->match_length - MIN_MATCH);
1017 978
1018 s->lookahead -= s->match_length; 979 s->lookahead -= s->match_length;
1019 980
@@ -1046,7 +1007,7 @@ local int deflate_fast(s, flush)
1046 } else { 1007 } else {
1047 /* No match, output a literal byte */ 1008 /* No match, output a literal byte */
1048 Tracevv((stderr,"%c", s->window[s->strstart])); 1009 Tracevv((stderr,"%c", s->window[s->strstart]));
1049 bflush = _tr_tally (s, 0, s->window[s->strstart]); 1010 bflush = tr_tally (s, 0, s->window[s->strstart]);
1050 s->lookahead--; 1011 s->lookahead--;
1051 s->strstart++; 1012 s->strstart++;
1052 } 1013 }
@@ -1104,6 +1065,7 @@ local int deflate_slow(s, flush)
1104 s->match_length = longest_match (s, hash_head); 1065 s->match_length = longest_match (s, hash_head);
1105 } 1066 }
1106 /* longest_match() sets match_start */ 1067 /* longest_match() sets match_start */
1068 if (s->match_length > s->lookahead) s->match_length = s->lookahead;
1107 1069
1108 if (s->match_length <= 5 && (s->strategy == Z_FILTERED || 1070 if (s->match_length <= 5 && (s->strategy == Z_FILTERED ||
1109 (s->match_length == MIN_MATCH && 1071 (s->match_length == MIN_MATCH &&
@@ -1124,8 +1086,8 @@ local int deflate_slow(s, flush)
1124 1086
1125 check_match(s, s->strstart-1, s->prev_match, s->prev_length); 1087 check_match(s, s->strstart-1, s->prev_match, s->prev_length);
1126 1088
1127 bflush = _tr_tally(s, s->strstart -1 - s->prev_match, 1089 bflush = tr_tally(s, s->strstart -1 - s->prev_match,
1128 s->prev_length - MIN_MATCH); 1090 s->prev_length - MIN_MATCH);
1129 1091
1130 /* Insert in hash table all strings up to the end of the match. 1092 /* Insert in hash table all strings up to the end of the match.
1131 * strstart-1 and strstart are already inserted. If there is not 1093 * strstart-1 and strstart are already inserted. If there is not
@@ -1151,7 +1113,7 @@ local int deflate_slow(s, flush)
1151 * is longer, truncate the previous match to a single literal. 1113 * is longer, truncate the previous match to a single literal.
1152 */ 1114 */
1153 Tracevv((stderr,"%c", s->window[s->strstart-1])); 1115 Tracevv((stderr,"%c", s->window[s->strstart-1]));
1154 if (_tr_tally (s, 0, s->window[s->strstart-1])) { 1116 if (tr_tally (s, 0, s->window[s->strstart-1])) {
1155 FLUSH_BLOCK_ONLY(s, 0); 1117 FLUSH_BLOCK_ONLY(s, 0);
1156 } 1118 }
1157 s->strstart++; 1119 s->strstart++;
@@ -1169,7 +1131,7 @@ local int deflate_slow(s, flush)
1169 Assert (flush != Z_NO_FLUSH, "no flush?"); 1131 Assert (flush != Z_NO_FLUSH, "no flush?");
1170 if (s->match_available) { 1132 if (s->match_available) {
1171 Tracevv((stderr,"%c", s->window[s->strstart-1])); 1133 Tracevv((stderr,"%c", s->window[s->strstart-1]));
1172 _tr_tally (s, 0, s->window[s->strstart-1]); 1134 tr_tally (s, 0, s->window[s->strstart-1]);
1173 s->match_available = 0; 1135 s->match_available = 0;
1174 } 1136 }
1175 FLUSH_BLOCK(s, flush == Z_FINISH); 1137 FLUSH_BLOCK(s, flush == Z_FINISH);