Discussion:
bug#32903: [PATCH] Display uncompressed size when testing
Stephen Kitt
2018-10-02 06:49:29 UTC
Permalink
Alongside the OK message, print the real size in bytes; this provides
a way to view the stored file's size when it's larger than 4GiB.

Signed-off-by: Stephen Kitt <***@sk2.org>
---
gzip.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gzip.c b/gzip.c
index e6a7761..4104472 100644
--- a/gzip.c
+++ b/gzip.c
@@ -62,6 +62,7 @@ static char const *const license_msg[] = {
#include <stddef.h>
#include <sys/stat.h>
#include <errno.h>
+#include <inttypes.h>

#include "tailor.h"
#include "gzip.h"
@@ -807,7 +808,7 @@ local void treat_stdin()

if (verbose) {
if (test) {
- fprintf(stderr, " OK\n");
+ fprintf(stderr, " OK (%jd bytes)\n", (intmax_t) bytes_out);

} else if (!decompress) {
display_ratio(bytes_in-(bytes_out-header_bytes), bytes_in, stderr);
@@ -1060,7 +1061,7 @@ local void treat_file(iname)
/* Display statistics */
if(verbose) {
if (test) {
- fprintf(stderr, " OK");
+ fprintf(stderr, " OK (%jd bytes)", (int_max_t) bytes_out);
} else if (decompress) {
display_ratio(bytes_out-(bytes_in-header_bytes), bytes_out,stderr);
} else {
--
2.11.0
Sergey Ponomarev
2018-11-04 12:49:50 UTC
Permalink
Post by Stephen Kitt
Alongside the OK message, print the real size in bytes; this provides
a way to view the stored file's size when it's larger than 4GiB.

You can get a real size by `gzip --list` command. Why to show the size in
`gzip --test` output? Almost all other compressors (lzop, xz, bzip2, etc0
just shows the same message:
filename: OK

Even more, archive manages and other tools may try to parse the test
command output and the change may have some impact.
Post by Stephen Kitt
this provides a way to view the stored file's size when it's larger than
4GiB.
I didn't get it. Can you please elaborate on this: `gzip --list` can't show
uncompressed size more than 4GiB?

Regards, Sergey
Stephen Kitt
2018-11-04 19:39:34 UTC
Permalink
Hi Sergey,
Post by Stephen Kitt
Post by Stephen Kitt
Alongside the OK message, print the real size in bytes; this provides
a way to view the stored file's size when it's larger than 4GiB.
You can get a real size by `gzip --list` command. Why to show the size in
`gzip --test` output? Almost all other compressors (lzop, xz, bzip2, etc0
filename: OK
"gzip --list" only reports sizes correctly up to 4GiB; see the BUGS section in
the manpage:

The gzip format represents the input size modulo 2^32, so the --list
option reports incorrect uncompressed sizes and compression ratios
for uncompressed files 4 GB and larger.
Post by Stephen Kitt
Even more, archive manages and other tools may try to parse the test
command output and the change may have some impact.
True, I haven’t checked the impact much — although I’ve been running gzip
with this patch for a while without adverse effects (but that’s anecdotal).
Post by Stephen Kitt
Post by Stephen Kitt
this provides a way to view the stored file's size when it's larger than
4GiB.
I didn't get it. Can you please elaborate on this: `gzip --list` can't show
uncompressed size more than 4GiB?
See above.

Regards,

Stephen
Sergey Ponomarev
2018-11-04 19:54:59 UTC
Permalink
Thanks for explanation,

From user point of view it would be better not to enclose the size
into brackets: it will be easier to parse the output by other tools.
Post by Stephen Kitt
Hi Sergey,
Post by Stephen Kitt
Post by Stephen Kitt
Alongside the OK message, print the real size in bytes; this provides
a way to view the stored file's size when it's larger than 4GiB.
You can get a real size by `gzip --list` command. Why to show the size in
`gzip --test` output? Almost all other compressors (lzop, xz, bzip2, etc0
filename: OK
"gzip --list" only reports sizes correctly up to 4GiB; see the BUGS section in
The gzip format represents the input size modulo 2^32, so the --list
option reports incorrect uncompressed sizes and compression ratios
for uncompressed files 4 GB and larger.
Post by Stephen Kitt
Even more, archive manages and other tools may try to parse the test
command output and the change may have some impact.
True, I haven’t checked the impact much — although I’ve been running gzip
with this patch for a while without adverse effects (but that’s anecdotal).
Post by Stephen Kitt
Post by Stephen Kitt
this provides a way to view the stored file's size when it's larger
than
Post by Stephen Kitt
4GiB.
I didn't get it. Can you please elaborate on this: `gzip --list` can't
show
Post by Stephen Kitt
uncompressed size more than 4GiB?
See above.
Regards,
Stephen
--
Sergey Ponomarev <https://linkedin.com/in/stokito>, skype:stokito
Loading...