--- pgp/src/zdeflate.c 2018/04/24 16:41:16 1.1.1.5 +++ pgp/src/zdeflate.c 2018/04/24 16:45:45 1.1.1.7 @@ -70,6 +70,9 @@ #include "zunzip.h" #include "zip.h" +#ifdef MACTC5 +#include "Macutil3.h" +#endif /* =========================================================================== * Configuration parameters @@ -121,7 +124,7 @@ typedef unsigned IPos; */ #ifndef DYN_ALLOC - uch far window[2L*WSIZE]; + uch far slide[2L*WSIZE]; /* Sliding window. Input bytes are read into the second half of the window, * and move to the first half later to keep a dictionary of at least WSIZE * bytes. With this organization, matches are limited to a distance of @@ -139,9 +142,9 @@ typedef unsigned IPos; Pos far head[HASH_SIZE]; /* Heads of the hash chains or NIL */ #else - uch far * near window = NULL; + uch far * near slide = NULL; Pos far * near prev = NULL; - static void far *__window, *__prev; + static void far *__slide, *__prev; static Pos far * near head; #endif @@ -258,7 +261,7 @@ local void check_match OF((IPos start, * (except for the last MIN_MATCH-1 bytes of the input file). */ #define INSERT_STRING(s, match_head) \ - (UPDATE_HASH(ins_h, window[(s) + MIN_MATCH-1]), \ + (UPDATE_HASH(ins_h, slide[(s) + MIN_MATCH-1]), \ prev[(s) & WMASK] = match_head = head[ins_h], \ head[ins_h] = (s)) @@ -275,11 +278,11 @@ void lm_init (pack_level, flags) /* Use dynamic allocation if compiler does not like big static arrays: */ #ifdef DYN_ALLOC - __window = window = (uch far*) fcalloc(WSIZE*2*sizeof(uch)+16, 1); + __slide = slide = (uch far*) fcalloc(WSIZE*2*sizeof(uch)+16, 1); __prev = prev = (Pos far*) fcalloc(WSIZE*sizeof(Pos)+16, 1); head = (Pos far*) fcalloc(HASH_SIZE, sizeof(Pos)); - if (window == NULL || prev == NULL || head == NULL) { + if (slide == NULL || prev == NULL || head == NULL) { err(ZE_MEM, "window allocation"); } #endif /* DYN_ALLOC */ @@ -301,11 +304,11 @@ void lm_init (pack_level, flags) strstart = 0; block_start = 0L; -#if defined(MSDOS) && !defined(__32BIT__) +#if defined(MSDOS) && !defined(__32BIT__) && !defined(__GO32__) /* Can't read a 64K block under MSDOS */ - lookahead = read_buf((char*)window, (unsigned)WSIZE); + lookahead = read_buf((char*)slide, (unsigned)WSIZE); #else - lookahead = read_buf((char*)window, 2*WSIZE); + lookahead = read_buf((char*)slide, 2*WSIZE); #endif if (lookahead == 0 || lookahead == (unsigned)EOF) { eofile = 1, lookahead = 0; @@ -318,7 +321,7 @@ void lm_init (pack_level, flags) while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window(); ins_h = 0; - for (j=0; j (IPos)MAX_DIST ? strstart - (IPos)MAX_DIST : NIL; /* Stop when cur_match becomes <= limit. To simplify the code, - * we prevent matches with the string of window index 0. + * we prevent matches with the string of slide index 0. */ #ifdef UNALIGNED_OK register ush scan_start = *(ush*)scan; @@ -375,7 +384,7 @@ int longest_match(cur_match) do { Assert(cur_match < strstart, "no future"); - match = window + cur_match; + match = slide + cur_match; /* Skip to next match if the match length cannot increase * or if the match length is less than 2: @@ -451,8 +460,8 @@ local void check_match(start, match, len int length; { /* check that the match is indeed a match */ - if (memcmp((char*)window + match, - (char*)window + start, length) != EQUAL) { + if (memcmp((char*)slide + match, + (char*)slide + start, length) != EQUAL) { fprintf(stderr, " start %d, match %d, length %d\n", start, match, length); @@ -460,7 +469,8 @@ local void check_match(start, match, len } if (verbose > 1) { fprintf(stderr,"\\[%d,%d]", start-match, length); - do { putc(window[start++], stderr); } while (--length != 0); + /* putc a macro, not safe to modify args!! */ + do { putc(slide[start], stderr); start++; } while (--length!=0); } } #else @@ -493,7 +503,7 @@ local void fill_window() /* By the IN assertion, the window is not empty so we can't confuse * more == 0 with more == 64K on a 16 bit machine. */ - memcpy((char*)window, (char*)window+WSIZE, (unsigned)WSIZE); + memcpy((char*)slide, (char*)slide+WSIZE, (unsigned)WSIZE); match_start -= WSIZE; strstart -= WSIZE; /* strstart - WSIZE >= WSIZE - 1 - lookahead >= WSIZE - MIN_LOOKAHEAD @@ -519,7 +529,7 @@ local void fill_window() #endif } /* At this point, more >= 2 */ - n = read_buf((char*)window+strstart+lookahead, more); + n = read_buf((char*)slide+strstart+lookahead, more); if (n == 0 || n == (unsigned)EOF) { eofile = 1; } else { @@ -532,7 +542,7 @@ local void fill_window() * IN assertion: strstart is set to the end of the current match. */ #define FLUSH_BLOCK(eof) \ - flush_block(block_start >= 0L ? (char*)&window[block_start] : (char*)NULL,\ + flush_block(block_start >= 0L ? (char*)&slide[block_start] : (char*)NULL,\ (long)strstart - block_start, (eof)) /* =========================================================================== @@ -547,9 +557,12 @@ ulg deflate() prev_length = MIN_MATCH-1; while (lookahead != 0) { - /* Insert the string window[strstart .. strstart+2] in the + /* Insert the string slide[strstart .. strstart+2] in the * dictionary, and set hash_head to the head of the hash chain: */ +#ifdef MACTC5 + mac_poll_for_break(); +#endif INSERT_STRING(strstart, hash_head); /* Find the longest match, discarding those <= prev_length. @@ -557,7 +570,7 @@ ulg deflate() */ if (hash_head != NIL && strstart - hash_head <= MAX_DIST) { /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match + * of slide index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ match_length = longest_match (hash_head); @@ -582,7 +595,7 @@ ulg deflate() } while (--match_length != 0); } else { /* No match, output a literal byte */ - flush = ct_tally (0, window[strstart]); + flush = ct_tally (0, slide[strstart]); lookahead--; } strstart++; @@ -617,9 +630,12 @@ ulg deflate() /* Process the input block. */ while (lookahead != 0) { - /* Insert the string window[strstart .. strstart+2] in the + /* Insert the string slide[strstart .. strstart+2] in the * dictionary, and set hash_head to the head of the hash chain: */ +#ifdef MACTC5 + mac_poll_for_break(); +#endif INSERT_STRING(strstart, hash_head); /* Find the longest match, discarding those <= prev_length. @@ -630,7 +646,7 @@ ulg deflate() if (hash_head != NIL && prev_length < max_lazy_match && strstart - hash_head <= MAX_DIST) { /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match + * of slide index 0 (in particular we have to avoid a match * of the string with itself at the start of the input file). */ match_length = longest_match (hash_head); @@ -677,8 +693,8 @@ ulg deflate() * single literal. If there was a match but the current match * is longer, truncate the previous match to a single literal. */ - Tracevv((stderr,"%c",window[strstart-1])); - if (ct_tally (0, window[strstart-1])) { + Tracevv((stderr,"%c",slide[strstart-1])); + if (ct_tally (0, slide[strstart-1])) { FLUSH_BLOCK(0), block_start = strstart; } strstart++; @@ -702,7 +718,7 @@ ulg deflate() */ while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window(); } - if (match_available) ct_tally (0, window[strstart-1]); + if (match_available) ct_tally (0, slide[strstart-1]); return FLUSH_BLOCK(1); /* eof */ }