Subject: Re: CVS commit: src/distrib/news68k/floppies/ramdisk
To: None <mrg@eterna.com.au>
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
List: source-changes
Date: 03/27/2004 20:19:26
In article <20198.1080375229@splode.eterna.com.au>
mrg@eterna.com.au wrote:

> x_gzip is basically an old version of usr.bin/gzip.  ideally the latter
> can be updated to remove more features with -DSMALL and x_gzip has no
> sources in it... things i can see off hand:

I tried a quick patch which disables bzip2 and compress support by
-DNO_BZIP2_SUPPORT and -DNO_COMPRESS_SUPPORT:
---
% ls -lS gzip*
-rwxr-xr-x  1 100  100  218791 Mar 27 19:55 gzip-static
-rwxr-xr-x  1 100  100  214652 Mar 27 19:55 gzip-static_without_compress
-rwxr-xr-x  1 100  100  168745 Mar 27 19:55 gzip-static_without_bzip2
-rwxr-xr-x  1 100  100  164478 Mar 27 19:56 gzip-static_without_bzip2_compress
---
Current distrib/utils/x_gzip is:
---
-rwxr-xr-x  1 100  100  145758 Mar 27 20:08 x_gzip-static
---
Is this difference worth? Now distrib/utils/x_gzip should only have
Makefile with some CPPFLAGS which disables unneeded features?
---
Izumi Tsutsui
tsutsui@ceres.dti.ne.jp

Index: gzip.c
===================================================================
RCS file: /cvsroot/src/usr.bin/gzip/gzip.c,v
retrieving revision 1.22
diff -u -r1.22 gzip.c
--- gzip.c	18 Feb 2004 08:19:48 -0000	1.22
+++ gzip.c	27 Mar 2004 10:53:54 -0000
@@ -67,20 +67,28 @@
 /* what type of file are we dealing with */
 enum filetype {
 	FT_GZIP,
+#ifndef NO_BZIP2_SUPPORT
 	FT_BZIP2,
+#endif
+#ifndef NO_COMPRESS_SUPPORT
 	FT_Z,
+#endif
 	FT_LAST,
 	FT_UNKNOWN
 };
 
+#ifndef NO_BZIP2_SUPPORT
 #define BZ_NO_STDIO
 #include <bzlib.h>
 
-#define Z_SUFFIX	".Z"
-#define Z_MAGIC		"\037\235"
-
 #define BZ2_SUFFIX	".bz2"
 #define BZIP2_MAGIC	"\102\132\150"
+#endif
+
+#ifndef NO_COMPRESS_SUPPORT
+#define Z_SUFFIX	".Z"
+#define Z_MAGIC		"\037\235"
+#endif
 
 #define GZ_SUFFIX	".gz"
 
@@ -138,9 +146,13 @@
 static	void	print_list(int fd, off_t, const char *, time_t);
 static	void	usage(void);
 static	void	display_version(void);
+#ifndef NO_BZIP2_SUPPORT
 static	off_t	unbzip2(int, int);
+#endif
+#ifndef NO_COMPRESS_SUPPORT
 static	FILE 	*zopen(const char *);
 static	off_t	zuncompress(FILE *, FILE *);
+#endif
 
 int main(int, char *p[]);
 
@@ -614,16 +626,22 @@
 	if (header1[0] == GZIP_MAGIC0 &&
 	    (header1[1] == GZIP_MAGIC1 || header1[1] == GZIP_OMAGIC1))
 		method = FT_GZIP;
-	else if (memcmp(header1, BZIP2_MAGIC, 3) == 0 &&
+	else
+#ifndef NO_BZIP2_SUPPORT
+	if (memcmp(header1, BZIP2_MAGIC, 3) == 0 &&
 	    header1[3] >= '0' && header1[3] <= '9') {
 		if (Sflag == NULL)
 			suffix = BZ2_SUFFIX;
 		method = FT_BZIP2;
-	} else if (memcmp(header1, Z_MAGIC, 2) == 0) {
+	} else
+#endif
+#ifndef NO_COMPRESS_SUPPORT
+	if (memcmp(header1, Z_MAGIC, 2) == 0) {
 		if (Sflag == NULL)
 			suffix = Z_SUFFIX;
 		method = FT_Z;
 	} else
+#endif
 		method = FT_UNKNOWN;
 
 	if (fflag == 0 && method == FT_UNKNOWN)
@@ -680,6 +698,7 @@
 			goto lose;
 	}
 
+#ifndef NO_BZIP2_SUPPORT
 	if (method == FT_BZIP2) {
 		int in, out;
 
@@ -696,7 +715,10 @@
 			unlink(outfile);
 			goto lose;
 		}
-	} else if (method == FT_Z) {
+	} else
+#endif
+#ifndef NO_COMPRESS_SUPPORT
+	if (method == FT_Z) {
 		FILE *in, *out;
 		int fd;
 
@@ -729,7 +751,9 @@
 			maybe_err(1, "failed outfile close");
 		}
 
-	} else {
+	} else
+#endif
+	{
 		if (lflag) {
 			int fd;
 
@@ -1089,5 +1113,9 @@
 	exit(0);
 }
 
+#ifndef NO_BZIP2_SUPPORT
 #include "unbzip2.c"
+#endif
+#ifndef NO_COMPRESS_SUPPORT
 #include "zuncompress.c"
+#endif