Module Name:    src
Committed By:   mrg
Date:           Sat Nov  6 21:42:32 UTC 2010

Modified Files:
        src/usr.bin/gzip: gzip.c unpack.c zuncompress.c

Log Message:
pull across a few changes from the freebsd folks:

http://svn.freebsd.org/changeset/base/213044
        - fixes gunzip issues
http://svn.freebsd.org/changeset/base/213927
        - fixes various typos and comments

and also an older change to add support for bzip2's "-k" option:
        don't delete the input file

thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/gzip/gzip.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/gzip/unpack.c
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/gzip/zuncompress.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/gzip/gzip.c
diff -u src/usr.bin/gzip/gzip.c:1.97 src/usr.bin/gzip/gzip.c:1.98
--- src/usr.bin/gzip/gzip.c:1.97	Sun Oct 11 09:17:21 2009
+++ src/usr.bin/gzip/gzip.c	Sat Nov  6 21:42:32 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: gzip.c,v 1.97 2009/10/11 09:17:21 mrg Exp $	*/
+/*	$NetBSD: gzip.c,v 1.98 2010/11/06 21:42:32 mrg Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998, 2003, 2004, 2006 Matthew R. Green
@@ -30,7 +30,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1997, 1998, 2003, 2004, 2006\
  Matthew R. Green.  All rights reserved.");
-__RCSID("$NetBSD: gzip.c,v 1.97 2009/10/11 09:17:21 mrg Exp $");
+__RCSID("$NetBSD: gzip.c,v 1.98 2010/11/06 21:42:32 mrg Exp $");
 #endif /* not lint */
 
 /*
@@ -148,7 +148,7 @@
 #define NUM_SUFFIXES (sizeof suffixes / sizeof suffixes[0])
 #define SUFFIX_MAXLEN	30
 
-static	const char	gzip_version[] = "NetBSD gzip 20091011";
+static	const char	gzip_version[] = "NetBSD gzip 20101018";
 
 static	int	cflag;			/* stdout mode */
 static	int	dflag;			/* decompress mode */
@@ -157,6 +157,7 @@
 
 #ifndef SMALL
 static	int	fflag;			/* force mode */
+static	int	kflag;			/* don't delete input files */
 static	int	nflag;			/* don't save name/timestamp */
 static	int	Nflag;			/* don't restore name/timestamp */
 static	int	qflag;			/* quiet mode */
@@ -238,6 +239,7 @@
 	{ "uncompress",		no_argument,		0,	'd' },
 	{ "force",		no_argument,		0,	'f' },
 	{ "help",		no_argument,		0,	'h' },
+	{ "keep",		no_argument,		0,	'k' },
 	{ "list",		no_argument,		0,	'l' },
 	{ "no-name",		no_argument,		0,	'n' },
 	{ "name",		no_argument,		0,	'N' },
@@ -291,7 +293,7 @@
 #ifdef SMALL
 #define OPT_LIST "123456789cdhltV"
 #else
-#define OPT_LIST "123456789cdfhlNnqrS:tVv"
+#define OPT_LIST "123456789cdfhklNnqrS:tVv"
 #endif
 
 	while ((ch = getopt_long(argc, argv, OPT_LIST, longopts, NULL)) != -1) {
@@ -318,6 +320,9 @@
 		case 'f':
 			fflag = 1;
 			break;
+		case 'k':
+			kflag = 1;
+			break;
 		case 'N':
 			nflag = 0;
 			Nflag = 1;
@@ -886,6 +891,9 @@
 			switch (error) {
 			/* Z_BUF_ERROR goes with Z_FINISH... */
 			case Z_BUF_ERROR:
+				if (z.avail_out > 0 && !done_reading)
+					continue;
+
 			case Z_STREAM_END:
 			case Z_OK:
 				break;
@@ -1127,8 +1135,10 @@
 {
 	struct stat nsb;
 
+	if (kflag)
+		return;
 	if (stat(file, &nsb) != 0)
-		/* Must be gone alrady */
+		/* Must be gone already */
 		return;
 	if (nsb.st_dev != sb->st_dev || nsb.st_ino != sb->st_ino)
 		/* Definitely a different file */
@@ -1991,6 +2001,7 @@
     "    --uncompress\n"
     " -f --force           force overwriting & compress links\n"
     " -h --help            display this help\n"
+    " -k --keep            don't delete input files during operation\n"
     " -l --list            list compressed file contents\n"
     " -N --name            save or restore original file name and time stamp\n"
     " -n --no-name         don't save original file name or time stamp\n"

Index: src/usr.bin/gzip/unpack.c
diff -u src/usr.bin/gzip/unpack.c:1.1 src/usr.bin/gzip/unpack.c:1.2
--- src/usr.bin/gzip/unpack.c:1.1	Sun Oct 11 07:07:54 2009
+++ src/usr.bin/gzip/unpack.c	Sat Nov  6 21:42:32 2010
@@ -1,5 +1,5 @@
 /*	$FreeBSD: head/usr.bin/gzip/unpack.c 194579 2009-06-21 09:39:43Z delphij $	*/
-/*	$NetBSD: unpack.c,v 1.1 2009/10/11 07:07:54 mrg Exp $	*/
+/*	$NetBSD: unpack.c,v 1.2 2010/11/06 21:42:32 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2009 Xin LI <[email protected]>
@@ -41,7 +41,7 @@
  * tree levels, each level would consume 1 byte (See [1]).
  *
  * After the symbol count table, there is the symbol table, storing
- * symbols represented by coresponding leaf node.  EOB is not being
+ * symbols represented by corresponding leaf node.  EOB is not being
  * explicitly transmitted (not necessary anyway) in the symbol table.
  *
  * Compressed data goes after the symbol table.
@@ -62,7 +62,7 @@
 /*
  * unpack descriptor
  *
- * Represent the huffman tree in a similiar way that pack(1) would
+ * Represent the huffman tree in a similar way that pack(1) would
  * store in a packed file.  We store all symbols in a linear table,
  * and store pointers to each level's first symbol.  In addition to
  * that, maintain two counts for each level: inner nodes count and
@@ -93,7 +93,7 @@
  * Caller is responsible to make sure that all of these pointers are
  * initialized (in our case, they all point to valid memory block).
  * We don't zero out pointers here because nobody else would ever
- * reference the memory block without scrubing them.
+ * reference the memory block without scrubbing them.
  */
 static void
 unpack_descriptor_fini(unpack_descriptor_t *unpackd)
@@ -118,7 +118,7 @@
 	/*
 	 * The internal nodes would be 1/2 of total internal nodes and
 	 * leaf nodes in the next level.  For the last level there
-	 * would be no internal node by defination.
+	 * would be no internal node by definition.
 	 */
 	if (level < unpackd->treelevels) {
 		unpackd_fill_inodesin(unpackd, level + 1);
@@ -141,7 +141,7 @@
 
 /*
  * Read file header and construct the tree.  Also, prepare the buffered I/O
- * for decode rountine.
+ * for decode routine.
  *
  * Return value is uncompressed size.
  */
@@ -196,7 +196,7 @@
 	/* We count from 0 so adjust to match array upper bound */
 	unpackd->treelevels--;
 
-	/* Read the levels symbol count table and caculate total */
+	/* Read the levels symbol count table and calculate total */
 	unpackd->symbol_size = 1;		/* EOB */
 	for (i = 0; i <= unpackd->treelevels; i++) {
 		if ((thisbyte = fgetc(unpackd->fpIn)) == EOF)
@@ -238,7 +238,7 @@
 
 	/*
 	 * The symbolsin table has been constructed now.
-	 * Caculate the internal nodes count table based on it.
+	 * Calculate the internal nodes count table based on it.
 	 */
 	unpackd_fill_inodesin(unpackd, 0);
 }

Index: src/usr.bin/gzip/zuncompress.c
diff -u src/usr.bin/gzip/zuncompress.c:1.7 src/usr.bin/gzip/zuncompress.c:1.8
--- src/usr.bin/gzip/zuncompress.c:1.7	Sun Apr 12 10:31:14 2009
+++ src/usr.bin/gzip/zuncompress.c	Sat Nov  6 21:42:32 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: zuncompress.c,v 1.7 2009/04/12 10:31:14 lukem Exp $ */
+/*	$NetBSD: zuncompress.c,v 1.8 2010/11/06 21:42:32 mrg Exp $ */
 
 /*-
  * Copyright (c) 1985, 1986, 1992, 1993
@@ -114,7 +114,7 @@
 			code_int zs_ent;
 			code_int zs_hsize_reg;
 			int zs_hshift;
-		} w;			/* Write paramenters */
+		} w;			/* Write parameters */
 		struct {
 			char_type *zs_stackp;
 			int zs_finchar;

Reply via email to