diff options
Diffstat (limited to 'gzlib.c')
-rw-r--r-- | gzlib.c | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -3,8 +3,6 @@ | |||
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 | ||
6 | #ifndef OLD_GZIO | ||
7 | |||
8 | #include "gzguts.h" | 6 | #include "gzguts.h" |
9 | 7 | ||
10 | #ifdef _LARGEFILE64_SOURCE | 8 | #ifdef _LARGEFILE64_SOURCE |
@@ -214,16 +212,15 @@ gzFile ZEXPORT gzdopen(fd, mode) | |||
214 | int fd; | 212 | int fd; |
215 | const char *mode; | 213 | const char *mode; |
216 | { | 214 | { |
217 | char path[46]; /* identifier for error messages */ | 215 | char *path; /* identifier for error messages */ |
216 | gzFile gz; | ||
218 | 217 | ||
219 | if (fd == -1) | 218 | if (fd == -1 || (path = malloc(7 + 3 * sizeof(int))) == NULL) |
220 | return NULL; | 219 | return NULL; |
221 | #ifdef NO_snprintf | 220 | sprintf(path, "<fd:%d>", fd); |
222 | sprintf(path, "<fd:%d>", fd); /* big enough for 128-bit integers */ | 221 | gz = gz_open(path, fd, mode); |
223 | #else | 222 | free(path); |
224 | snprintf(path, sizeof(path), "<fd:%d>", fd); | 223 | return gz; |
225 | #endif | ||
226 | return gz_open(path, fd, mode); | ||
227 | } | 224 | } |
228 | 225 | ||
229 | /* -- see zlib.h -- */ | 226 | /* -- see zlib.h -- */ |
@@ -301,6 +298,9 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence) | |||
301 | /* normalize offset to a SEEK_CUR specification */ | 298 | /* normalize offset to a SEEK_CUR specification */ |
302 | if (whence == SEEK_SET) | 299 | if (whence == SEEK_SET) |
303 | offset -= state->pos; | 300 | offset -= state->pos; |
301 | else if (state->seek) | ||
302 | offset += state->skip; | ||
303 | state->seek = 0; | ||
304 | 304 | ||
305 | /* if within raw area while reading, just go there */ | 305 | /* if within raw area while reading, just go there */ |
306 | if (state->mode == GZ_READ && state->how == COPY && | 306 | if (state->mode == GZ_READ && state->how == COPY && |
@@ -532,5 +532,3 @@ unsigned ZEXPORT gz_intmax() | |||
532 | return q >> 1; | 532 | return q >> 1; |
533 | } | 533 | } |
534 | #endif | 534 | #endif |
535 | |||
536 | #endif /* !OLD_GZIO */ | ||