From: millert Date: Wed, 17 Aug 2016 12:02:38 +0000 (+0000) Subject: When returning the file size info, only use z_total_in/z_total_out X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1bcc27159ef1f8bda31e58313fae72f09fbb15c1;p=openbsd When returning the file size info, only use z_total_in/z_total_out for the read (inflate) case where there might be multiple streams. For the write (deflate) case there can only be a single stream so just use the per-stream total_in/total_out. Fixes "gzip -v" byte counts. OK henning@. --- diff --git a/usr.bin/compress/gzopen.c b/usr.bin/compress/gzopen.c index d9cf6cad9f3..1d9c36dfe4e 100644 --- a/usr.bin/compress/gzopen.c +++ b/usr.bin/compress/gzopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gzopen.c,v 1.31 2016/04/29 13:50:35 millert Exp $ */ +/* $OpenBSD: gzopen.c,v 1.32 2016/08/17 12:02:38 millert Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -209,8 +209,14 @@ gz_close(void *cookie, struct z_info *info, const char *name, struct stat *sb) info->mtime = s->z_time; info->crc = s->z_crc; info->hlen = s->z_hlen; - info->total_in = s->z_total_in; - info->total_out = s->z_total_out; + if (s->z_mode == 'r') { + info->total_in = s->z_total_in; + info->total_out = s->z_total_out; + } else { + info->total_in = s->z_stream.total_in; + info->total_out = s->z_stream.total_out; + } + } setfile(name, s->z_fd, sb); @@ -509,8 +515,6 @@ gz_write(void *cookie, const char *buf, int len) break; } s->z_crc = crc32(s->z_crc, buf, len); - s->z_total_in += s->z_stream.total_in; - s->z_total_out += s->z_stream.total_out; return (int)(len - s->z_stream.avail_in); #endif