diff options
| -rw-r--r-- | gzread.c | 9 | ||||
| -rw-r--r-- | zlib.h | 12 |
2 files changed, 15 insertions, 6 deletions
| @@ -207,6 +207,15 @@ local int gz_head(state) | |||
| 207 | } | 207 | } |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | /* no gzip header -- if we were decoding gzip before, then this is trailing | ||
| 211 | garbage. Ignore the trailing garbage and finish. */ | ||
| 212 | if (state->direct == 0) { | ||
| 213 | strm->avail_in = 0; | ||
| 214 | state->eof = 1; | ||
| 215 | state->have = 0; | ||
| 216 | return 0; | ||
| 217 | } | ||
| 218 | |||
| 210 | /* doing raw i/o, save start of raw data for seeking, copy any leftover | 219 | /* doing raw i/o, save start of raw data for seeking, copy any leftover |
| 211 | input to output -- this assumes that the output buffer is larger than | 220 | input to output -- this assumes that the output buffer is larger than |
| 212 | the input buffer, which also assures space for gzungetc() */ | 221 | the input buffer, which also assures space for gzungetc() */ |
| @@ -1259,14 +1259,14 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); | |||
| 1259 | ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); | 1259 | ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); |
| 1260 | /* | 1260 | /* |
| 1261 | Reads the given number of uncompressed bytes from the compressed file. If | 1261 | Reads the given number of uncompressed bytes from the compressed file. If |
| 1262 | the input file was not in gzip format, gzread copies the given number of | 1262 | the input file is not in gzip format, gzread copies the given number of |
| 1263 | bytes into the buffer. | 1263 | bytes into the buffer directly from the file. |
| 1264 | 1264 | ||
| 1265 | After reaching the end of a gzip stream in the input, gzread will continue | 1265 | After reaching the end of a gzip stream in the input, gzread will continue |
| 1266 | to read, looking for another gzip stream, or failing that, reading the rest | 1266 | to read, looking for another gzip stream. Any number of gzip streams may be |
| 1267 | of the input file directly without decompression. The entire input file | 1267 | concatenated in the input file, and will all be decompressed by gzread(). |
| 1268 | will be read if gzread is called until it returns less than the requested | 1268 | If something other than a gzip stream is encountered after a gzip stream, |
| 1269 | len. | 1269 | that remaining trailing garbage is ignored (and no error is returned). |
| 1270 | 1270 | ||
| 1271 | gzread returns the number of uncompressed bytes actually read, less than | 1271 | gzread returns the number of uncompressed bytes actually read, less than |
| 1272 | len for end of file, or -1 for error. | 1272 | len for end of file, or -1 for error. |
