aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-09-26 18:34:07 -0700
committerMark Adler <madler@alumni.caltech.edu>2011-09-26 18:34:07 -0700
commit8e0d212910a42b3f856bbaebed970e8ddc081ca3 (patch)
treeba735fdcd32de6830eb6dc886837b12da3c0cba1
parent50e440f081a0edc293dcfe7333a91d764e3d15cd (diff)
downloadzlib-8e0d212910a42b3f856bbaebed970e8ddc081ca3.tar.gz
zlib-8e0d212910a42b3f856bbaebed970e8ddc081ca3.tar.bz2
zlib-8e0d212910a42b3f856bbaebed970e8ddc081ca3.zip
Simplify gzseek() now that raw after gzip is ignored.
-rw-r--r--gzguts.h1
-rw-r--r--gzlib.c2
-rw-r--r--gzread.c7
3 files changed, 4 insertions, 6 deletions
diff --git a/gzguts.h b/gzguts.h
index 0f8fb79..63b0c3f 100644
--- a/gzguts.h
+++ b/gzguts.h
@@ -98,7 +98,6 @@ typedef struct {
98 unsigned have; /* amount of output data unused at next */ 98 unsigned have; /* amount of output data unused at next */
99 int eof; /* true if end of input file reached */ 99 int eof; /* true if end of input file reached */
100 z_off64_t start; /* where the gzip data started, for rewinding */ 100 z_off64_t start; /* where the gzip data started, for rewinding */
101 z_off64_t raw; /* where the raw data started, for seeking */
102 int how; /* 0: get header, 1: copy, 2: decompress */ 101 int how; /* 0: get header, 1: copy, 2: decompress */
103 int direct; /* true if last read direct, false if gzip */ 102 int direct; /* true if last read direct, false if gzip */
104 /* just for writing */ 103 /* just for writing */
diff --git a/gzlib.c b/gzlib.c
index c59bcda..b26b0c2 100644
--- a/gzlib.c
+++ b/gzlib.c
@@ -310,7 +310,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
310 310
311 /* if within raw area while reading, just go there */ 311 /* if within raw area while reading, just go there */
312 if (state->mode == GZ_READ && state->how == COPY && 312 if (state->mode == GZ_READ && state->how == COPY &&
313 state->pos + offset >= state->raw) { 313 state->pos + offset >= 0) {
314 ret = LSEEK(state->fd, offset - state->have, SEEK_CUR); 314 ret = LSEEK(state->fd, offset - state->have, SEEK_CUR);
315 if (ret == -1) 315 if (ret == -1)
316 return -1; 316 return -1;
diff --git a/gzread.c b/gzread.c
index 960bf12..a41e5d9 100644
--- a/gzread.c
+++ b/gzread.c
@@ -144,10 +144,9 @@ local int gz_look(state)
144 return 0; 144 return 0;
145 } 145 }
146 146
147 /* doing raw i/o, save start of raw data for seeking, copy any leftover 147 /* doing raw i/o, copy any leftover input to output -- this assumes that
148 input to output -- this assumes that the output buffer is larger than 148 the output buffer is larger than the input buffer, which also assures
149 the input buffer, which also assures space for gzungetc() */ 149 space for gzungetc() */
150 state->raw = state->pos;
151 state->next = state->out; 150 state->next = state->out;
152 if (strm->avail_in) { 151 if (strm->avail_in) {
153 memcpy(state->next, strm->next_in, strm->avail_in); 152 memcpy(state->next, strm->next_in, strm->avail_in);