diff options
Diffstat (limited to 'gzlib.c')
-rw-r--r-- | gzlib.c | 36 |
1 files changed, 28 insertions, 8 deletions
@@ -36,13 +36,13 @@ char ZEXPORT *gz_strwinerror (error) | |||
36 | wchar_t *msgbuf; | 36 | wchar_t *msgbuf; |
37 | DWORD lasterr = GetLastError(); | 37 | DWORD lasterr = GetLastError(); |
38 | DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | 38 | DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
39 | | FORMAT_MESSAGE_ALLOCATE_BUFFER, | 39 | | FORMAT_MESSAGE_ALLOCATE_BUFFER, |
40 | NULL, | 40 | NULL, |
41 | error, | 41 | error, |
42 | 0, /* Default language */ | 42 | 0, /* Default language */ |
43 | (LPVOID)&msgbuf, | 43 | (LPVOID)&msgbuf, |
44 | 0, | 44 | 0, |
45 | NULL); | 45 | NULL); |
46 | if (chars != 0) { | 46 | if (chars != 0) { |
47 | /* If there is an \r\n appended, zap it. */ | 47 | /* If there is an \r\n appended, zap it. */ |
48 | if (chars >= 2 | 48 | if (chars >= 2 |
@@ -330,7 +330,8 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence) | |||
330 | 330 | ||
331 | /* if reading, skip what's in output buffer (one less gzgetc() check) */ | 331 | /* if reading, skip what's in output buffer (one less gzgetc() check) */ |
332 | if (state->mode == GZ_READ) { | 332 | if (state->mode == GZ_READ) { |
333 | n = state->have > offset ? (unsigned)offset : state->have; | 333 | n = GT_OFF(state->have) || (z_off64_t)state->have > offset ? |
334 | (unsigned)offset : state->have; | ||
334 | state->have -= n; | 335 | state->have -= n; |
335 | state->next += n; | 336 | state->next += n; |
336 | state->pos += n; | 337 | state->pos += n; |
@@ -513,4 +514,23 @@ void ZEXPORT gz_error(state, err, msg) | |||
513 | return; | 514 | return; |
514 | } | 515 | } |
515 | 516 | ||
517 | #ifndef INT_MAX | ||
518 | /* portably return maximum value for an int (when limits.h presumed not | ||
519 | available) -- we need to do this to cover cases where 2's complement not | ||
520 | used, since C standard permits 1's complement and sign-bit representations, | ||
521 | otherwise we could just use ((unsigned)-1) >> 1 */ | ||
522 | unsigned ZEXPORT gz_intmax() | ||
523 | { | ||
524 | unsigned p, q; | ||
525 | |||
526 | p = 1; | ||
527 | do { | ||
528 | q = p; | ||
529 | p <<= 1; | ||
530 | p++; | ||
531 | } while (p > q); | ||
532 | return q >> 1; | ||
533 | } | ||
534 | #endif | ||
535 | |||
516 | #endif /* !OLD_GZIO */ | 536 | #endif /* !OLD_GZIO */ |