diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2002-11-05 16:16:15 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2002-11-05 16:16:15 +0000 |
commit | a1a477af2071432c6e11842748e15d3c836154cd (patch) | |
tree | d07c9b0710fdeb2badf6d1547468d773df68e3b3 /gnu/usr.bin | |
parent | 1b67e3ff818680995aea5210f2e7dd1a60de26da (diff) |
-bytes_in/_out and total_in/_out are off_t, not long. fixes a few displaying
problems with files > 2GB.
-print bytes in/out to stderr in verbose mode
ok millert@ fgsch@
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r-- | gnu/usr.bin/gzip/gzip.c | 26 | ||||
-rw-r--r-- | gnu/usr.bin/gzip/gzip.h | 6 | ||||
-rw-r--r-- | gnu/usr.bin/gzip/util.c | 8 |
3 files changed, 23 insertions, 17 deletions
diff --git a/gnu/usr.bin/gzip/gzip.c b/gnu/usr.bin/gzip/gzip.c index 5eb0b243309..12b133cb0fa 100644 --- a/gnu/usr.bin/gzip/gzip.c +++ b/gnu/usr.bin/gzip/gzip.c @@ -45,7 +45,7 @@ static char *license_msg[] = { */ #ifdef RCSID -static char rcsid[] = "$Id: gzip.c,v 1.5 2002/03/13 18:14:18 millert Exp $"; +static char rcsid[] = "$Id: gzip.c,v 1.6 2002/11/05 16:16:14 henning Exp $"; #endif #include <ctype.h> @@ -226,10 +226,10 @@ char **args = NULL; /* argv pointer if GZIP env variable defined */ char z_suffix[MAX_SUFFIX+1]; /* default suffix (can be set with --suffix) */ int z_len; /* strlen(z_suffix) */ -long bytes_in; /* number of input bytes */ -long bytes_out; /* number of output bytes */ -long total_in = 0; /* input bytes for all files */ -long total_out = 0; /* output bytes for all files */ +off_t bytes_in; /* number of input bytes */ +off_t bytes_out; /* number of output bytes */ +off_t total_in = 0; /* input bytes for all files */ +off_t total_out = 0; /* output bytes for all files */ char ifname[MAX_PATH_LEN]; /* input file name */ char ofname[MAX_PATH_LEN]; /* output file name */ int remove_ofname = 0; /* remove output file on error */ @@ -701,6 +701,9 @@ local void treat_stdin() fprintf(stderr, "\n"); #endif } + if (!test) + fprintf(stderr, "%lld bytes in, %lld bytes out\n", + (long long)bytes_in, (long long)bytes_out); } } @@ -850,6 +853,9 @@ local void treat_file(iname) fprintf(stderr, " -- replaced with %s", ofname); } fprintf(stderr, "\n"); + if (!test) + fprintf(stderr, "%lld bytes in, %lld bytes out\n", + (long long)bytes_in, (long long)bytes_out); } /* Copy modes, times, ownership, and remove the input file */ if (!to_stdout) { @@ -1357,10 +1363,10 @@ local void do_list(ifd, method) } else if (method < 0) { if (total_in <= 0 || total_out <= 0) return; if (verbose) { - printf(" %9lu %9lu ", - total_in, total_out); + printf(" %9lld %9lld ", + (long long)total_in, (long long)total_out); } else if (!quiet) { - printf("%9ld %9ld ", total_in, total_out); + printf("%9lld %9lld ", (long long)total_in, (long long)total_out); } display_ratio(total_out-(total_in-header_bytes), total_out, stdout); /* header_bytes is not meaningful but used to ensure the same @@ -1381,7 +1387,7 @@ local void do_list(ifd, method) * Use "gunzip < foo.gz | wc -c" to get the uncompressed size if * you are not concerned about speed. */ - bytes_in = (long)lseek(ifd, (off_t)(-8), SEEK_END); + bytes_in = lseek(ifd, (off_t)(-8), SEEK_END); if (bytes_in != -1L) { uch buf[8]; bytes_in += 8L; @@ -1398,7 +1404,7 @@ local void do_list(ifd, method) if (verbose) { printf("%5s %08lx %11s ", methods[method], crc, date); } - printf("%9ld %9ld ", bytes_in, bytes_out); + printf("%9lld %9lld ", (long long)bytes_in, (long long)bytes_out); if (bytes_in == -1L) { total_in = -1L; bytes_in = bytes_out = header_bytes = 0; diff --git a/gnu/usr.bin/gzip/gzip.h b/gnu/usr.bin/gzip/gzip.h index 88b07101707..9c3e022802e 100644 --- a/gnu/usr.bin/gzip/gzip.h +++ b/gnu/usr.bin/gzip/gzip.h @@ -132,8 +132,8 @@ extern unsigned insize; /* valid bytes in inbuf */ extern unsigned inptr; /* index of next byte to be processed in inbuf */ extern unsigned outcnt; /* bytes in output buffer */ -extern long bytes_in; /* number of input bytes */ -extern long bytes_out; /* number of output bytes */ +extern off_t bytes_in; /* number of input bytes */ +extern off_t bytes_out; /* number of output bytes */ extern long header_bytes;/* number of bytes in gzip header */ #define isize bytes_in @@ -308,7 +308,7 @@ extern void error OF((char *m)); extern void warn OF((char *a, char *b)); extern void read_error OF((void)); extern void write_error OF((void)); -extern void display_ratio OF((long num, long den, FILE *file)); +extern void display_ratio OF((off_t num, off_t den, FILE *file)); extern voidp xmalloc OF((unsigned int size)); /* in inflate.c */ diff --git a/gnu/usr.bin/gzip/util.c b/gnu/usr.bin/gzip/util.c index c0aad140ae0..710e6c238bb 100644 --- a/gnu/usr.bin/gzip/util.c +++ b/gnu/usr.bin/gzip/util.c @@ -5,7 +5,7 @@ */ #ifdef RCSID -static char rcsid[] = "$Id: util.c,v 1.1 1995/10/18 08:40:54 deraadt Exp $"; +static char rcsid[] = "$Id: util.c,v 1.2 2002/11/05 16:16:14 henning Exp $"; #endif #include <ctype.h> @@ -368,9 +368,9 @@ void write_error() * Display compression ratio on the given stream on 6 characters. */ void display_ratio(num, den, file) - long num; - long den; - FILE *file; + off_t num; + off_t den; + FILE *file; { long ratio; /* 1000 times the compression ratio */ |