+ goto deflate_index_extract_ret;
+ if (ret == Z_STREAM_END) {
+ /* the raw deflate stream has ended */
+ if (index->gzip == 0)
+ /* this is a zlib stream that has ended -- done */
+ break;
+
+ /* near the end of a gzip member, which might be followed by
+ another gzip member -- skip the gzip trailer and see if
+ there is more input after it */
+ if (strm.avail_in < 8) {
+ fseeko(in, 8 - strm.avail_in, SEEK_CUR);
+ strm.avail_in = 0;
+ }
+ else {
+ strm.avail_in -= 8;
+ strm.next_in += 8;
+ }
+ if (strm.avail_in == 0 && ungetc(getc(in), in) == EOF)
+ /* the input ended after the gzip trailer -- done */
+ break;
+
+ /* there is more input, so another gzip member should follow --
+ validate and skip the gzip header */
+ ret = inflateReset2(&strm, 31);
+ if (ret != Z_OK)
+ goto deflate_index_extract_ret;
+ do {
+ if (strm.avail_in == 0) {
+ strm.avail_in = fread(input, 1, CHUNK, in);
+ if (ferror(in)) {
+ ret = Z_ERRNO;
+ goto deflate_index_extract_ret;
+ }
+ if (strm.avail_in == 0) {
+ ret = Z_DATA_ERROR;
+ goto deflate_index_extract_ret;
+ }
+ strm.next_in = input;
+ }
+ ret = inflate(&strm, Z_BLOCK);
+ if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR)
+ goto deflate_index_extract_ret;
+ } while ((strm.data_type & 128) == 0);
+
+ /* set up to continue decompression of the raw deflate stream
+ that follows the gzip header */
+ ret = inflateReset2(&strm, -15);
+ if (ret != Z_OK)
+ goto deflate_index_extract_ret;
+ }
+
+ /* continue to process the available input before reading more */