Subject: BSD licensed compress/gzip for NetBSD
To: None <current-users@netbsd.org>
From: Bruce J.A. Nourish <netbsd@bjan.freeshell.org>
List: current-users
Date: 02/24/2004 00:12:45
Hey everyone,

I've made the small changes neccesary to make OpenBSD's BSD licensed
compress/gzip compile on NetBSD-current. Most of them were howlers
that would have been caught by more strict compiler flags.

To give this a whirl, grab a copy of OpenBSD's src/usr.bin/compress
directory: http://bjan.freeshell.org/obsd-compress-20040221.tar.gz).
Remove /usr/src/usr.bin/compress and replace it with the OpenBSD
version, then apply the patch at the end. Build as usual.

The new programs should build fine, and they passed some cursory sanity
checks I performed. I haven't tried to install them yet. I'll send-pr
on this later, once I've done some more tests, but right now I have
a linear algebra class that just won't wait :-(.

Look for a similar treatment of [bd]c in the coming days.

--- /usr/home/bjan/Hacking/obsd/compress/Makefile	2003-09-05 18:11:00.000000000 -0700
+++ Makefile	2004-02-23 15:16:07.000000000 -0700
@@ -10,6 +10,8 @@
 	${BINDIR}/compress ${BINDIR}/gzcat \
 	${BINDIR}/zdiff ${BINDIR}/zcmp
 
+SCRIPTS=zmore zdiff zforce gzexe znew
+
 MLINKS= compress.1 uncompress.1 \
 	compress.1 zcat.1 \
 	compress.1 gzip.1 \
@@ -20,10 +22,4 @@
 LDADD=-lz
 DPADD=${LIBZ}
 
-afterinstall:
-	install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
-	    ${.CURDIR}/zmore ${.CURDIR}/zdiff \
-	    ${.CURDIR}/zforce ${.CURDIR}/gzexe ${.CURDIR}/znew \
-	    ${DESTDIR}${BINDIR}
-
 .include <bsd.prog.mk>
--- /usr/home/bjan/Hacking/obsd/compress/gzopen.c	2003-12-16 19:45:00.000000000 -0700
+++ gzopen.c	2004-02-23 16:03:39.000000000 -0700
@@ -201,7 +201,7 @@
 			err = deflateEnd(&s->z_stream);
 #else
 			err = -1;
-#endif;
+#endif
 		else if (s->z_mode == 'r')
 			err = inflateEnd(&s->z_stream);
 	}
--- /usr/home/bjan/Hacking/obsd/compress/main.c	2004-01-22 19:31:00.000000000 -0700
+++ main.c	2004-02-23 15:57:08.000000000 -0700
@@ -449,7 +449,7 @@
 }
 
 int
-docompress(const char *in, char *out, const struct compressor *method,
+docompress(const char *_in, char *out, const struct compressor *method,
     int bits, struct stat *sb)
 {
 	u_char buf[Z_BUFSIZE];
@@ -459,6 +459,7 @@
 	ssize_t nr;
 	u_int32_t mtime;
 	struct z_info info;
+	char *in;
 
 	mtime = 0;
 	flags = 0;
@@ -466,6 +467,8 @@
 	name = NULL;
 	cookie  = NULL;
 
+	in = strdup(_in);
+
 	if ((ifd = open(in, O_RDONLY)) < 0) {
 		if (verbose >= 0)
 			warn("%s", out);
@@ -799,7 +802,7 @@
 		if (strcmp(name, "/dev/stdout") == 0)
 			name += 5;
 		if (verbose > 0) {
-			timestr = ctime(&info->mtime) + 4;
+			timestr = ctime((const time_t *)&info->mtime) + 4;
 			timestr[12] = '\0';
 			if (timestr[4] == ' ')
 				timestr[4] = '0';
-- 
Bruce J.A. Nourish <bjan@bjan.freeshell.org> http://bjan.freeshell.org
SDF Public Access UNIX System - http://sdf.lonestar.org