CVS commit: src/distrib/utils/zcat

2021-04-23 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Apr 24 04:50:47 UTC 2021

Modified Files:
src/distrib/utils/zcat: Makefile

Log Message:
use GCC_NO_IMPLICIT_FALLTHRU


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/distrib/utils/zcat/Makefile

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

Modified files:

Index: src/distrib/utils/zcat/Makefile
diff -u src/distrib/utils/zcat/Makefile:1.19 src/distrib/utils/zcat/Makefile:1.20
--- src/distrib/utils/zcat/Makefile:1.19	Sun Sep 29 23:44:58 2019
+++ src/distrib/utils/zcat/Makefile	Sat Apr 24 04:50:47 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.19 2019/09/29 23:44:58 mrg Exp $
+# $NetBSD: Makefile,v 1.20 2021/04/24 04:50:47 mrg Exp $
 # Small zcat (i.e. for install media)
 #
 
@@ -26,9 +26,7 @@ CPPFLAGS+=	-I${LIBC}/include
 CPPFLAGS+=	-Dsnprintf=snprintf_ss -Dsprintf=sprintf_ss
 CPPFLAGS+=	-Dstrerror=strerror_ss
 
-.if defined(HAVE_GCC) && ${HAVE_GCC} >= 7 && ${ACTIVE_CC} == "gcc"
-COPTS.inflate.c+=	-Wno-error=implicit-fallthrough
-.endif
+COPTS.inflate.c+=	${GCC_NO_IMPLICIT_FALLTHRU}
 
 .include 
 



CVS commit: src/distrib/utils/zcat

2019-02-06 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed Feb  6 09:17:18 UTC 2019

Modified Files:
src/distrib/utils/zcat: Makefile

Log Message:
pply zlib hack for gcc 7 here too (4th occurance!)


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/distrib/utils/zcat/Makefile

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

Modified files:

Index: src/distrib/utils/zcat/Makefile
diff -u src/distrib/utils/zcat/Makefile:1.17 src/distrib/utils/zcat/Makefile:1.18
--- src/distrib/utils/zcat/Makefile:1.17	Thu Jan 12 01:58:03 2017
+++ src/distrib/utils/zcat/Makefile	Wed Feb  6 09:17:18 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.17 2017/01/12 01:58:03 christos Exp $
+# $NetBSD: Makefile,v 1.18 2019/02/06 09:17:18 mrg Exp $
 # Small zcat (i.e. for install media)
 #
 
@@ -26,6 +26,10 @@ CPPFLAGS+=	-I${LIBC}/include
 CPPFLAGS+=	-Dsnprintf=snprintf_ss -Dsprintf=sprintf_ss
 CPPFLAGS+=	-Dstrerror=strerror_ss
 
+.if defined(HAVE_GCC) && ${HAVE_GCC} == 7 && ${ACTIVE_CC} == "gcc"
+COPTS.inflate.c+=	-Wno-error=implicit-fallthrough
+.endif
+
 .include 
 
 test: zcat



CVS commit: src/distrib/utils/zcat

2017-01-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan 12 01:58:03 UTC 2017

Modified Files:
src/distrib/utils/zcat: Makefile zcat.c
Added Files:
src/distrib/utils/zcat: misc.c

Log Message:
This is an example how to make a small program using libc. Original size
300K; final size 75K.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/distrib/utils/zcat/Makefile
cvs rdiff -u -r0 -r1.1 src/distrib/utils/zcat/misc.c
cvs rdiff -u -r1.4 -r1.5 src/distrib/utils/zcat/zcat.c

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

Modified files:

Index: src/distrib/utils/zcat/Makefile
diff -u src/distrib/utils/zcat/Makefile:1.16 src/distrib/utils/zcat/Makefile:1.17
--- src/distrib/utils/zcat/Makefile:1.16	Tue Jan 10 23:04:12 2017
+++ src/distrib/utils/zcat/Makefile	Wed Jan 11 20:58:03 2017
@@ -1,26 +1,32 @@
-# $NetBSD: Makefile,v 1.16 2017/01/11 04:04:12 christos Exp $
+# $NetBSD: Makefile,v 1.17 2017/01/12 01:58:03 christos Exp $
 # Small zcat (i.e. for install media)
 #
-# Note: gzio.c is compiled here so that crunchgen will assume
-# the same symbol space for zcat.c and gzio.c which is required
-# so that the fake deflate functions in zcat.c will satisfy the
-# references to those functions in gzio.c (yes, it's a hack).
+
+NOSSP=yes
+NOMAN=
+.include 
 
 SRCDIR=		${.CURDIR}/../../../common/dist/zlib
+LIBC=		${NETBSDSRCDIR}/lib/libc
+
+.PATH:		${SRCDIR} ${LIBC}/stdlib
 
 WARNS?=		4
 PROG=		zcat
-NOMAN=		# defined
-
-SRCS=		zcat.c gzread.c gzclose.c gzlib.c
 
+# Just what we need from libz
+SRCS=		zcat.c gzread.c gzclose.c gzlib.c inflate.c 
+SRCS+=		adler32.c crc32.c zutil.c inffast.c inftrees.c
 CPPFLAGS+=	-I${SRCDIR} -DNO_GZCOMPRESS
-DPADD+=		${LIBZ}
-LDADD+=		-lz
 
-.include 
+# This avoids including stdio, threads, locale, etc.
+SRCS+=		misc.c
+SRCS+=		malloc.c	# small
+CPPFLAGS+=	-I${LIBC}/include
+CPPFLAGS+=	-Dsnprintf=snprintf_ss -Dsprintf=sprintf_ss
+CPPFLAGS+=	-Dstrerror=strerror_ss
 
-.PATH:		${SRCDIR}
+.include 
 
 test: zcat
 	echo 'hello, hello!' | gzip | ./zcat

Index: src/distrib/utils/zcat/zcat.c
diff -u src/distrib/utils/zcat/zcat.c:1.4 src/distrib/utils/zcat/zcat.c:1.5
--- src/distrib/utils/zcat/zcat.c:1.4	Thu May 19 18:23:12 2011
+++ src/distrib/utils/zcat/zcat.c	Wed Jan 11 20:58:03 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: zcat.c,v 1.4 2011/05/19 22:23:12 tsutsui Exp $	*/
+/*	$NetBSD: zcat.c,v 1.5 2017/01/12 01:58:03 christos Exp $	*/
 
 /* mini zcat.c -- a minimal zcat using the zlib compression library
  * Copyright (C) 1995-1996 Jean-loup Gailly.
@@ -13,8 +13,11 @@
  */
 
 #include 
+#include 
+#include 
 #include 
 #include 
+#include 
 
 #include "zlib.h"
 
@@ -22,24 +25,33 @@
 
 char *prog;
 
-void error(const char *msg);
-void gz_uncompress(gzFile in, FILE   *out);
-int  main(int argc, char *argv[]);
+static void error(const char *, ...) __printflike(1, 2);
+static void gz_uncompress(gzFile, int);
 
 /* ===
  * Display error message and exit
  */
-void error(const char *msg)
+static void
+error(const char *fmt, ...)
 {
-
-	fprintf(stderr, "%s: %s\n", prog, msg);
-	exit(EXIT_SUCCESS);
+	char buf[1024];
+	va_list ap;
+	int l;
+
+	l = snprintf_ss(buf, sizeof(buf), "%s: ", prog);
+	write(STDERR_FILENO, buf, l);
+	va_start(ap, fmt);
+	l = vsnprintf_ss(buf, sizeof(buf), fmt, ap);
+	va_end(ap);
+	write(STDERR_FILENO, buf, l);
+	_exit(EXIT_SUCCESS);
 }
 
 /* ===
  * Uncompress input to output then close both files.
  */
-void gz_uncompress(gzFile in, FILE *out)
+static void
+gz_uncompress(gzFile in, int out)
 {
 	char buf[BUFLEN];
 	int len;
@@ -48,15 +60,15 @@ void gz_uncompress(gzFile in, FILE *out)
 	for (;;) {
 		len = gzread(in, buf, sizeof(buf));
 		if (len < 0)
-			error (gzerror(in, ));
+			error ("%s", gzerror(in, ));
 		if (len == 0)
 			break;
 
-		if ((int)fwrite(buf, 1, (unsigned)len, out) != len) {
+		if ((int)write(out, buf, (size_t)len) != len) {
 			error("failed fwrite");
 		}
 	}
-	if (fclose(out))
+	if (close(out))
 		error("failed fclose");
 
 	if (gzclose(in) != Z_OK)
@@ -68,7 +80,8 @@ void gz_uncompress(gzFile in, FILE *out)
  * Usage:  zcat [files...]
  */
 
-int main(int argc, char *argv[])
+int
+main(int argc, char *argv[])
 {
 	gzFile zfp;
 
@@ -82,10 +95,10 @@ int main(int argc, char *argv[])
 	}
 
 	if (argc == 0) {
-		zfp = gzdopen(fileno(stdin), "rb");
+		zfp = gzdopen(STDIN_FILENO, "rb");
 		if (zfp == NULL)
 			error("can't gzdopen stdin");
-		gz_uncompress(zfp, stdout);
+		gz_uncompress(zfp, STDOUT_FILENO);
 		return 0;
 	}
 
@@ -93,10 +106,10 @@ int main(int argc, char *argv[])
 		/* file_uncompress(*argv); */
 		zfp = gzopen(*argv, "rb");
 		if (zfp == NULL) {
-			fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv);
-			exit(EXIT_FAILURE);
+			error("can't gzopen `%s'", *argv);
+			_exit(EXIT_FAILURE);
 		}
-		

CVS commit: src/distrib/utils/zcat

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 11 04:04:12 UTC 2017

Modified Files:
src/distrib/utils/zcat: Makefile

Log Message:
adjust to new zlib


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/distrib/utils/zcat/Makefile

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

Modified files:

Index: src/distrib/utils/zcat/Makefile
diff -u src/distrib/utils/zcat/Makefile:1.15 src/distrib/utils/zcat/Makefile:1.16
--- src/distrib/utils/zcat/Makefile:1.15	Thu May 19 18:23:12 2011
+++ src/distrib/utils/zcat/Makefile	Tue Jan 10 23:04:12 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.15 2011/05/19 22:23:12 tsutsui Exp $
+# $NetBSD: Makefile,v 1.16 2017/01/11 04:04:12 christos Exp $
 # Small zcat (i.e. for install media)
 #
 # Note: gzio.c is compiled here so that crunchgen will assume
@@ -12,7 +12,7 @@ WARNS?=		4
 PROG=		zcat
 NOMAN=		# defined
 
-SRCS=		zcat.c gzio.c
+SRCS=		zcat.c gzread.c gzclose.c gzlib.c
 
 CPPFLAGS+=	-I${SRCDIR} -DNO_GZCOMPRESS
 DPADD+=		${LIBZ}