Skip to content

Commit 3c0c462

Browse files
committed
Major fix for gcc/64: using "uInt" instead of "ulg" for 32-bit unsigned integers: gcc/64 uses 64-bit integers for "long" types, and this is not what assumed to be used here.
Other: removed "real_len" variable.
1 parent 2cdeefd commit 3c0c462

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

Sources/match.h

+11-13
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ local uInt longest_match(s, cur_match)
2828
register Bytef *scan = s->window + s->strstart; /* current string */
2929
register Bytef *match; /* matched string */
3030
register int len; /* length of current match */
31-
int best_len = s->prev_length; /* ignore strings, shorter or of the same length; rename ?? */
32-
int real_len = best_len; /* length of longest found match */
31+
int best_len = s->prev_length; /* ignore strings, shorter or of the same length */
3332
int nice_match = s->nice_match; /* stop if match long enough */
3433
int offset = 0; /* offset of current hash chain */
3534
IPos limit_base = s->strstart > (IPos)MAX_DIST(s) ?
@@ -57,8 +56,7 @@ local uInt longest_match(s, cur_match)
5756
register Bytef *strend = s->window + s->strstart + MAX_MATCH-1;
5857
/* points to last byte for maximal-length scan */
5958
register ush scan_start = *(ushf*)scan; /* 1st 2 bytes of scan */
60-
typedef ulg FAR ulgf; /*?? should be declared in zutil.h */
61-
ulg scan_start_l = *(ulgf*)scan; /* 1st 4 bytes of scan */
59+
uInt scan_start32 = *(uIntf*)scan; /* 1st 4 bytes of scan */
6260
register ush scan_end; /* last byte of scan + next one */
6361

6462
#if (MIN_MATCH != 3) || (MAX_MATCH != 258)
@@ -140,13 +138,13 @@ local uInt longest_match(s, cur_match)
140138
/* current len > MIN_MATCH (>= 4 bytes); compare 1st 4 bytes and last 2 bytes */
141139
for (;;) {
142140
if (*(ushf*)(match_base2 + cur_match) == scan_end &&
143-
*(ulgf*)(match_base + cur_match) == scan_start_l) break;
141+
*(uIntf*)(match_base + cur_match) == scan_start32) break;
144142
NEXT_CHAIN;
145143
}
146144
} else {
147145
/* current len is exactly MIN_MATCH (3 bytes); compare 4 bytes */
148146
for (;;) {
149-
if (*(ulgf*)(match_base + cur_match) == scan_start_l) break;
147+
if (*(uIntf*)(match_base + cur_match) == scan_start32) break;
150148
NEXT_CHAIN;
151149
}
152150
}
@@ -177,7 +175,7 @@ local uInt longest_match(s, cur_match)
177175
#endif
178176
/* new string is longer than previous - remember it */
179177
s->match_start = cur_match - offset;
180-
real_len = best_len = len;
178+
best_len = len;
181179
if (len >= nice_match) break;
182180
UPDATE_SCAN_END;
183181
/* look for better string offset */
@@ -251,18 +249,18 @@ local uInt longest_match(s, cur_match)
251249
warned = 1;
252250
printf("WARNING: compiled with PARANOID_CHECK\n");
253251
}
254-
if (real_len > s->lookahead) real_len = s->lookahead;
255-
if (real_len > MAX_MATCH) {
252+
if (best_len > s->lookahead) best_len = s->lookahead;
253+
if (best_len > MAX_MATCH) {
256254
error = 1;
257255
printf("match too long\n");
258256
}
259257
if (s->match_start < limit_base) {
260258
error = 1;
261-
printf("too far $%X -> $%X [%d] (dist+=%X)\n", s->strstart, s->match_start, real_len, limit_base-s->match_start);
259+
printf("too far $%X -> $%X [%d] (dist+=%X)\n", s->strstart, s->match_start, best_len, limit_base-s->match_start);
262260
}
263-
if (zmemcmp(s->window + s->strstart, s->window + s->match_start, real_len)) {
261+
if (zmemcmp(s->window + s->strstart, s->window + s->match_start, best_len)) {
264262
error = 1;
265-
printf("invalid match $%X -- $%X [%d]\n", s->strstart, s->match_start, real_len);
263+
printf("invalid match $%X -- $%X [%d]\n", s->strstart, s->match_start, best_len);
266264
}
267265
if (error) {
268266
FILE *f = fopen("match.dmp", "wb");
@@ -276,6 +274,6 @@ local uInt longest_match(s, cur_match)
276274
}
277275
}
278276
#endif /* PARANOID_CHECK */
279-
if ((uInt)real_len <= s->lookahead) return (uInt)real_len;
277+
if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
280278
return s->lookahead;
281279
}

0 commit comments

Comments
 (0)