Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/gnu/usr.bin/gzip use off_t instead of long to store sizes wh...
details: https://anonhg.NetBSD.org/src/rev/299b875ee4a3
branches: trunk
changeset: 512219:299b875ee4a3
user: lukem <lukem%NetBSD.org@localhost>
date: Sat Jul 07 21:57:41 2001 +0000
description:
use off_t instead of long to store sizes which will be displayed with "--list".
fixes wacky display problems for files > 2GB in size. tested ok on i386 and
alpha (no change for the latter).
diffstat:
gnu/usr.bin/gzip/deflate.c | 4 ++--
gnu/usr.bin/gzip/gzip.1 | 3 +--
gnu/usr.bin/gzip/gzip.c | 40 ++++++++++++++++++++--------------------
gnu/usr.bin/gzip/gzip.h | 8 ++++----
gnu/usr.bin/gzip/trees.c | 4 ++--
gnu/usr.bin/gzip/unpack.c | 4 ++--
gnu/usr.bin/gzip/util.c | 8 ++++----
gnu/usr.bin/gzip/zip.c | 9 +++++----
8 files changed, 40 insertions(+), 40 deletions(-)
diffs (284 lines):
diff -r d09a131c8a61 -r 299b875ee4a3 gnu/usr.bin/gzip/deflate.c
--- a/gnu/usr.bin/gzip/deflate.c Sat Jul 07 21:35:27 2001 +0000
+++ b/gnu/usr.bin/gzip/deflate.c Sat Jul 07 21:57:41 2001 +0000
@@ -68,7 +68,7 @@
#include "lzw.h" /* just for consistency checking */
#ifdef RCSID
-static char rcsid[] = "$Id: deflate.c,v 1.2 1993/10/15 23:05:30 jtc Exp $";
+static char rcsid[] = "$Id: deflate.c,v 1.3 2001/07/07 21:57:41 lukem Exp $";
#endif
/* ===========================================================================
@@ -666,7 +666,7 @@
int match_available = 0; /* set if previous match exists */
register unsigned match_length = MIN_MATCH-1; /* length of best match */
#ifdef DEBUG
- extern long isize; /* byte length of input file, for debug only */
+ extern off_t isize; /* byte length of input file, for debug only */
#endif
if (compr_level <= 3) return deflate_fast(); /* optimized for speed */
diff -r d09a131c8a61 -r 299b875ee4a3 gnu/usr.bin/gzip/gzip.1
--- a/gnu/usr.bin/gzip/gzip.1 Sat Jul 07 21:35:27 2001 +0000
+++ b/gnu/usr.bin/gzip/gzip.1 Sat Jul 07 21:57:41 2001 +0000
@@ -1,4 +1,4 @@
-.\" $Id: gzip.1,v 1.5 1999/07/25 07:06:06 simonb Exp $
+.\" $Id: gzip.1,v 1.6 2001/07/07 21:57:41 lukem Exp $
.PU
.TH GZIP 1
.SH NAME
@@ -468,7 +468,6 @@
for reading and writing compressed data on tapes. (This example
assumes you are using the GNU version of tar.)
.SH BUGS
-The --list option reports incorrect sizes if they exceed 2 gigabytes.
The --list option reports sizes as -1 and crc as ffffffff if the
compressed file is on a non seekable media.
diff -r d09a131c8a61 -r 299b875ee4a3 gnu/usr.bin/gzip/gzip.c
--- a/gnu/usr.bin/gzip/gzip.c Sat Jul 07 21:35:27 2001 +0000
+++ b/gnu/usr.bin/gzip/gzip.c Sat Jul 07 21:57:41 2001 +0000
@@ -45,7 +45,7 @@
*/
#ifdef RCSID
-static char rcsid[] = "$Id: gzip.c,v 1.7 2000/11/17 01:31:26 simonb Exp $";
+static char rcsid[] = "$Id: gzip.c,v 1.8 2001/07/07 21:57:41 lukem Exp $";
#endif
#include <ctype.h>
@@ -220,16 +220,16 @@
int last_member; /* set for .zip and .Z files */
int part_nb; /* number of parts in .gz file */
long time_stamp; /* original time stamp (modification time) */
-long ifile_size; /* input file size, -1 for devices (debug only) */
+off_t ifile_size; /* input file size, -1 for devices (debug only) */
char *env; /* contents of GZIP env variable */
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 */
@@ -652,7 +652,7 @@
time_stamp = istat.st_mtime;
#endif /* NO_STDIN_FSTAT */
}
- ifile_size = -1L; /* convention for unknown size */
+ ifile_size = -1; /* convention for unknown size */
clear_bufs(); /* clear input and output buffers */
to_stdout = 1;
@@ -1346,15 +1346,15 @@
printf("method crc date time ");
}
if (!quiet) {
- printf("compressed uncompr. ratio uncompressed_name\n");
+ printf(" compressed uncompressed ratio uncompressed_name\n");
}
} else if (method < 0) {
if (total_in <= 0 || total_out <= 0) return;
if (verbose) {
- printf(" %9lu %9lu ",
- total_in, total_out);
+ printf(" %12llu %12llu ",
+ (long long)total_in, (long long)total_out);
} else if (!quiet) {
- printf("%9ld %9ld ", total_in, total_out);
+ printf("%12lld %12lld ", (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
@@ -1364,7 +1364,7 @@
return;
}
crc = (ulg)~0; /* unknown */
- bytes_out = -1L;
+ bytes_out = -1;
bytes_in = ifile_size;
#if RECORD_IO == 0
@@ -1375,10 +1375,10 @@
* 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);
- if (bytes_in != -1L) {
+ bytes_in = lseek(ifd, (off_t)(-8), SEEK_END);
+ if (bytes_in != -1) {
uch buf[8];
- bytes_in += 8L;
+ bytes_in += 8;
if (read(ifd, (char*)buf, sizeof(buf)) != sizeof(buf)) {
read_error();
}
@@ -1392,15 +1392,15 @@
if (verbose) {
printf("%5s %08lx %11s ", methods[method], crc, date);
}
- printf("%9ld %9ld ", bytes_in, bytes_out);
- if (bytes_in == -1L) {
- total_in = -1L;
+ printf("%12lld %12lld ", (long long)bytes_in, (long long)bytes_out);
+ if (bytes_in == -1) {
+ total_in = -1;
bytes_in = bytes_out = header_bytes = 0;
} else if (total_in >= 0) {
total_in += bytes_in;
}
- if (bytes_out == -1L) {
- total_out = -1L;
+ if (bytes_out == -1) {
+ total_out = -1;
bytes_in = bytes_out = header_bytes = 0;
} else if (total_out >= 0) {
total_out += bytes_out;
diff -r d09a131c8a61 -r 299b875ee4a3 gnu/usr.bin/gzip/gzip.h
--- a/gnu/usr.bin/gzip/gzip.h Sat Jul 07 21:35:27 2001 +0000
+++ b/gnu/usr.bin/gzip/gzip.h Sat Jul 07 21:57:41 2001 +0000
@@ -133,8 +133,8 @@
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
@@ -147,7 +147,7 @@
extern char *progname; /* program name */
extern long time_stamp; /* original time stamp (modification time) */
-extern long ifile_size; /* input file size, -1 for devices (debug only) */
+extern off_t ifile_size; /* input file size, -1 for devices (debug only) */
typedef int file_t; /* Do not use stdio */
#define NO_FILE (-1) /* in memory compression */
@@ -313,7 +313,7 @@
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 -r d09a131c8a61 -r 299b875ee4a3 gnu/usr.bin/gzip/trees.c
--- a/gnu/usr.bin/gzip/trees.c Sat Jul 07 21:35:27 2001 +0000
+++ b/gnu/usr.bin/gzip/trees.c Sat Jul 07 21:57:41 2001 +0000
@@ -59,7 +59,7 @@
#include "gzip.h"
#ifdef RCSID
-static char rcsid[] = "$Id: trees.c,v 1.2 1993/10/15 23:05:50 jtc Exp $";
+static char rcsid[] = "$Id: trees.c,v 1.3 2001/07/07 21:57:42 lukem Exp $";
#endif
/* ===========================================================================
@@ -281,7 +281,7 @@
#ifdef DEBUG
extern ulg bits_sent; /* bit length of the compressed data */
-extern long isize; /* byte length of input file */
+extern off_t isize; /* byte length of input file */
#endif
extern long block_start; /* window offset of current block */
diff -r d09a131c8a61 -r 299b875ee4a3 gnu/usr.bin/gzip/unpack.c
--- a/gnu/usr.bin/gzip/unpack.c Sat Jul 07 21:35:27 2001 +0000
+++ b/gnu/usr.bin/gzip/unpack.c Sat Jul 07 21:57:41 2001 +0000
@@ -5,7 +5,7 @@
*/
#ifdef RCSID
-static char rcsid[] = "$Id: unpack.c,v 1.2 1993/10/15 23:05:54 jtc Exp $";
+static char rcsid[] = "$Id: unpack.c,v 1.3 2001/07/07 21:57:42 lukem Exp $";
#endif
#include "tailor.h"
@@ -231,7 +231,7 @@
} /* for (;;) */
flush_window();
- Trace((stderr, "bytes_out %ld\n", bytes_out));
+ Trace((stderr, "bytes_out %lld\n", (long long)bytes_out));
if (orig_len != (ulg)bytes_out) {
error("invalid compressed data--length error");
}
diff -r d09a131c8a61 -r 299b875ee4a3 gnu/usr.bin/gzip/util.c
--- a/gnu/usr.bin/gzip/util.c Sat Jul 07 21:35:27 2001 +0000
+++ b/gnu/usr.bin/gzip/util.c Sat Jul 07 21:57:41 2001 +0000
@@ -5,7 +5,7 @@
*/
#ifdef RCSID
-static char rcsid[] = "$Id: util.c,v 1.2 1993/10/15 23:05:56 jtc Exp $";
+static char rcsid[] = "$Id: util.c,v 1.3 2001/07/07 21:57:42 lukem Exp $";
#endif
#include <ctype.h>
@@ -84,7 +84,7 @@
{
outcnt = 0;
insize = inptr = 0;
- bytes_in = bytes_out = 0L;
+ bytes_in = bytes_out = 0;
}
/* ===========================================================================
@@ -368,8 +368,8 @@
* Display compression ratio on the given stream on 6 characters.
*/
void display_ratio(num, den, file)
- long num;
- long den;
+ off_t num;
+ off_t den;
FILE *file;
{
long ratio; /* 1000 times the compression ratio */
diff -r d09a131c8a61 -r 299b875ee4a3 gnu/usr.bin/gzip/zip.c
--- a/gnu/usr.bin/gzip/zip.c Sat Jul 07 21:35:27 2001 +0000
+++ b/gnu/usr.bin/gzip/zip.c Sat Jul 07 21:57:41 2001 +0000
@@ -5,7 +5,7 @@
*/
#ifdef RCSID
-static char rcsid[] = "$Id: zip.c,v 1.2 1993/10/15 23:06:01 jtc Exp $";
+static char rcsid[] = "$Id: zip.c,v 1.3 2001/07/07 21:57:42 lukem Exp $";
#endif
#include <ctype.h>
@@ -78,8 +78,9 @@
/* Check input size (but not in VMS -- variable record lengths mess it up)
* and not on MSDOS -- diet in TSR mode reports an incorrect file size)
*/
- if (ifile_size != -1L && isize != (ulg)ifile_size) {
- Trace((stderr, " actual=%ld, read=%ld ", ifile_size, isize));
+ if (ifile_size != -1 && isize != ifile_size) {
+ Trace((stderr, " actual=%lld, read=%lld ",
+ (long long)ifile_size, (long long)isize));
fprintf(stderr, "%s: %s: file size changed while zipping\n",
progname, ifname);
}
@@ -87,7 +88,7 @@
/* Write the crc and uncompressed size */
put_long(crc);
- put_long(isize);
+ put_long((ulg)isize);
header_bytes += 2*sizeof(long);
flush_outbuf();
Home |
Main Index |
Thread Index |
Old Index