Module Name: src Committed By: christos Date: Thu Aug 18 11:29:27 UTC 2011
Modified Files: src/usr.bin/unzip: Makefile unzip.1 unzip.c Log Message: revert 4 digit year printing and add -y option to print 4 digit years. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/unzip/Makefile cvs rdiff -u -r1.7 -r1.8 src/usr.bin/unzip/unzip.1 cvs rdiff -u -r1.16 -r1.17 src/usr.bin/unzip/unzip.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/unzip/Makefile diff -u src/usr.bin/unzip/Makefile:1.1 src/usr.bin/unzip/Makefile:1.2 --- src/usr.bin/unzip/Makefile:1.1 Thu Jun 25 16:27:05 2009 +++ src/usr.bin/unzip/Makefile Thu Aug 18 07:29:27 2011 @@ -1,8 +1,10 @@ -# $NetBSD: Makefile,v 1.1 2009/06/25 20:27:05 joerg Exp $ +# $NetBSD: Makefile,v 1.2 2011/08/18 11:29:27 christos Exp $ PROG= unzip DPADD+= ${LIBARCHIVE} ${LIBZ} ${LIBBZ2} LDADD+= -larchive -lz -lbz2 +COPTS.unzip.c += -Wno-format-y2k + .include <bsd.prog.mk> Index: src/usr.bin/unzip/unzip.1 diff -u src/usr.bin/unzip/unzip.1:1.7 src/usr.bin/unzip/unzip.1:1.8 --- src/usr.bin/unzip/unzip.1:1.7 Sun Sep 6 16:19:59 2009 +++ src/usr.bin/unzip/unzip.1 Thu Aug 18 07:29:27 2011 @@ -25,9 +25,9 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD: revision 180125$ -.\" $NetBSD: unzip.1,v 1.7 2009/09/06 20:19:59 wiz Exp $ +.\" $NetBSD: unzip.1,v 1.8 2011/08/18 11:29:27 christos Exp $ .\" -.Dd September 6, 2009 +.Dd August 18, 2011 .Dt UNZIP 1 .Os .Sh NAME @@ -35,7 +35,7 @@ .Nd extract files from a ZIP archive .Sh SYNOPSIS .Nm -.Op Fl aCcfjLlnopqtuv +.Op Fl aCcfjLlnopqtuvy .Op Fl d Ar dir .Op Fl x Ar pattern .Ar zipfile @@ -104,6 +104,8 @@ .It Fl x Ar pattern Exclude files matching the pattern .Ar pattern . +.It Fl y +Print four digit years in listings instead of two. .El .Pp Note that only one of Index: src/usr.bin/unzip/unzip.c diff -u src/usr.bin/unzip/unzip.c:1.16 src/usr.bin/unzip/unzip.c:1.17 --- src/usr.bin/unzip/unzip.c:1.16 Wed Aug 17 09:37:39 2011 +++ src/usr.bin/unzip/unzip.c Thu Aug 18 07:29:27 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: unzip.c,v 1.16 2011/08/17 13:37:39 christos Exp $ */ +/* $NetBSD: unzip.c,v 1.17 2011/08/18 11:29:27 christos Exp $ */ /*- * Copyright (c) 2009, 2010 Joerg Sonnenberger <jo...@netbsd.org> @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: unzip.c,v 1.16 2011/08/17 13:37:39 christos Exp $"); +__RCSID("$NetBSD: unzip.c,v 1.17 2011/08/18 11:29:27 christos Exp $"); #include <sys/queue.h> #include <sys/stat.h> @@ -70,6 +70,7 @@ static int t_opt; /* test */ static int u_opt; /* update */ static int v_opt; /* verbose/list */ +static const char * y_str = ""; /* 4 digit year */ /* time when unzip started */ static time_t now; @@ -821,9 +822,14 @@ { char buf[20]; time_t mtime; + struct tm *tm; mtime = archive_entry_mtime(e); - strftime(buf, sizeof(buf), "%m-%d-%G %R", localtime(&mtime)); + tm = localtime(&mtime); + if (*y_str) + strftime(buf, sizeof(buf), "%m-%d-%G %R", tm); + else + strftime(buf, sizeof(buf), "%m-%d-%g %R", tm); if (v_opt == 1) { printf(" %8ju %s %s\n", @@ -893,11 +899,11 @@ printf("Archive: %s\n", fn); if (v_opt == 1) { - printf(" Length Date Time Name\n"); - printf(" -------- ---- ---- ----\n"); + printf(" Length %sDate Time Name\n", y_str); + printf(" -------- %s---- ---- ----\n", y_str); } else if (v_opt == 2) { - printf(" Length Method Size Ratio Date Time CRC-32 Name\n"); - printf("-------- ------ ------- ----- ---- ---- ------ ----\n"); + printf(" Length Method Size Ratio %sDate Time CRC-32 Name\n", y_str); + printf("-------- ------ ------- ----- %s---- ---- ------ ----\n", y_str); } total_size = 0; @@ -922,13 +928,13 @@ } if (v_opt == 1) { - printf(" -------- -------\n"); - printf(" %8ju %ju file%s\n", - total_size, file_count, file_count != 1 ? "s" : ""); + printf(" -------- %s-------\n", y_str); + printf(" %8ju %s%ju file%s\n", + total_size, y_str, file_count, file_count != 1 ? "s" : ""); } else if (v_opt == 2) { - printf("-------- ------- --- -------\n"); - printf("%8ju %7ju 0%% %ju file%s\n", - total_size, total_size, file_count, + printf("-------- ------- --- %s-------\n", y_str); + printf("%8ju %7ju 0%% %s%ju file%s\n", + total_size, total_size, y_str, file_count, file_count != 1 ? "s" : ""); } @@ -949,11 +955,12 @@ } } -static void +static void __dead usage(void) { - fprintf(stderr, "usage: unzip [-aCcfjLlnopqtuv] [-d dir] [-x pattern] zipfile\n"); + fprintf(stderr, "Usage: %s [-aCcfjLlnopqtuvy] [-d dir] [-x pattern] " + "zipfile\n", getprogname()); exit(1); } @@ -963,7 +970,7 @@ int opt; optreset = optind = 1; - while ((opt = getopt(argc, argv, "aCcd:fjLlnopqtuvx:")) != -1) + while ((opt = getopt(argc, argv, "aCcd:fjLlnopqtuvyx:")) != -1) switch (opt) { case 'a': a_opt = 1; @@ -1015,6 +1022,9 @@ case 'x': add_pattern(&exclude, optarg); break; + case 'y': + y_str = " "; + break; default: usage(); }