Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/unzip revert 4 digit year printing and add -y option...



details:   https://anonhg.NetBSD.org/src/rev/79e1413dc36e
branches:  trunk
changeset: 768525:79e1413dc36e
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Aug 18 11:29:27 2011 +0000

description:
revert 4 digit year printing and add -y option to print 4 digit years.

diffstat:

 usr.bin/unzip/Makefile |   4 +++-
 usr.bin/unzip/unzip.1  |   8 +++++---
 usr.bin/unzip/unzip.c  |  42 ++++++++++++++++++++++++++----------------
 3 files changed, 34 insertions(+), 20 deletions(-)

diffs (160 lines):

diff -r 2f02b4e7defe -r 79e1413dc36e usr.bin/unzip/Makefile
--- a/usr.bin/unzip/Makefile    Thu Aug 18 09:03:28 2011 +0000
+++ b/usr.bin/unzip/Makefile    Thu Aug 18 11:29:27 2011 +0000
@@ -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>
diff -r 2f02b4e7defe -r 79e1413dc36e usr.bin/unzip/unzip.1
--- a/usr.bin/unzip/unzip.1     Thu Aug 18 09:03:28 2011 +0000
+++ b/usr.bin/unzip/unzip.1     Thu Aug 18 11:29:27 2011 +0000
@@ -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
diff -r 2f02b4e7defe -r 79e1413dc36e usr.bin/unzip/unzip.c
--- a/usr.bin/unzip/unzip.c     Thu Aug 18 09:03:28 2011 +0000
+++ b/usr.bin/unzip/unzip.c     Thu Aug 18 11:29:27 2011 +0000
@@ -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 <joerg%NetBSD.org@localhost>
@@ -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();
                }



Home | Main Index | Thread Index | Old Index