From owner-freebsd-bugs@FreeBSD.ORG Fri Apr 13 01:00:27 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 949391065674 for ; Fri, 13 Apr 2012 01:00:27 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 682838FC18 for ; Fri, 13 Apr 2012 01:00:27 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q3D10Rub076415 for ; Fri, 13 Apr 2012 01:00:27 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q3D10Rje076410; Fri, 13 Apr 2012 01:00:27 GMT (envelope-from gnats) Resent-Date: Fri, 13 Apr 2012 01:00:27 GMT Resent-Message-Id: <201204130100.q3D10Rje076410@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Steve Wills Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0BBD1106564A for ; Fri, 13 Apr 2012 00:57:43 +0000 (UTC) (envelope-from steve@mouf.net) Received: from mouf.net (mouf.net [IPv6:2607:fc50:0:4400:216:3eff:fe69:33b2]) by mx1.freebsd.org (Postfix) with ESMTP id A83BD8FC14 for ; Fri, 13 Apr 2012 00:57:42 +0000 (UTC) Received: from meatwad.mouf.net (cpe-024-162-230-236.nc.res.rr.com [24.162.230.236]) by mouf.net (8.14.4/8.14.4) with ESMTP id q3D0vbO2064360 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 12 Apr 2012 20:57:38 -0400 (EDT) (envelope-from steve@meatwad.mouf.net) Received: (from steve@localhost) by meatwad.mouf.net (8.14.5/8.14.5/Submit) id q3D0vb80033086; Thu, 12 Apr 2012 20:57:37 -0400 (EDT) (envelope-from steve) Message-Id: <201204130057.q3D0vb80033086@meatwad.mouf.net> Date: Thu, 12 Apr 2012 20:57:37 -0400 (EDT) From: Steve Wills To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/166895: add partial zipinfo mode support to base unzip X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Steve Wills List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Apr 2012 01:00:27 -0000 >Number: 166895 >Category: bin >Synopsis: add partial zipinfo mode support to base unzip >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Apr 13 01:00:26 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Steve Wills >Release: FreeBSD 10.0-CURRENT amd64 >Organization: >Environment: System: FreeBSD meatwad.mouf.net 10.0-CURRENT FreeBSD 10.0-CURRENT #17 r233932: Thu Apr 5 22:13:25 EDT 2012 root@meatwad.mouf.net:/usr/obj/usr/src/sys/MEATWAD amd64 >Description: here's a patch I wrote to partiall implement zipinfo (-Z) support for the base unzip. This fixes some test failures seen with perl 5.12 and 5.14. >How-To-Repeat: install perl 5.12 or 5.14 on 9.x or 10.x and run "make test". Some tests related to Archive::Extract will fail due to trying to call unzip -Z -1 filename. This patch makes that work. >Fix: Index: unzip.c =================================================================== --- unzip.c (revision 234193) +++ unzip.c (working copy) @@ -65,6 +65,7 @@ static int t_opt; /* test */ static int u_opt; /* update */ static int v_opt; /* verbose/list */ +static int Z1_opt; /* zipinfo mode list files only */ /* time when unzip started */ static time_t now; @@ -72,6 +73,9 @@ /* debug flag */ static int unzip_debug; +/* zipinfo mode */ +static int zipinfo_mode; + /* running on tty? */ static int tty; @@ -802,17 +806,22 @@ mtime = archive_entry_mtime(e); strftime(buf, sizeof(buf), "%m-%d-%g %R", localtime(&mtime)); - if (v_opt == 1) { - printf(" %8ju %s %s\n", - (uintmax_t)archive_entry_size(e), - buf, archive_entry_pathname(e)); - } else if (v_opt == 2) { - printf("%8ju Stored %7ju 0%% %s %08x %s\n", - (uintmax_t)archive_entry_size(e), - (uintmax_t)archive_entry_size(e), - buf, - 0U, - archive_entry_pathname(e)); + if (!zipinfo_mode) { + if (v_opt == 1) { + printf(" %8ju %s %s\n", + (uintmax_t)archive_entry_size(e), + buf, archive_entry_pathname(e)); + } else if (v_opt == 2) { + printf("%8ju Stored %7ju 0%% %s %08x %s\n", + (uintmax_t)archive_entry_size(e), + (uintmax_t)archive_entry_size(e), + buf, + 0U, + archive_entry_pathname(e)); + } + } else { + if (Z1_opt) + printf("%s\n",archive_entry_pathname(e)); } ac(archive_read_data_skip(a)); } @@ -870,14 +879,16 @@ ac(archive_read_support_format_zip(a)); ac(archive_read_open_fd(a, fd, 8192)); - if (!p_opt && !q_opt) - printf("Archive: %s\n", fn); - if (v_opt == 1) { - printf(" Length Date Time Name\n"); - printf(" -------- ---- ---- ----\n"); - } else if (v_opt == 2) { - printf(" Length Method Size Ratio Date Time CRC-32 Name\n"); - printf("-------- ------ ------- ----- ---- ---- ------ ----\n"); + if (!zipinfo_mode) { + if (!p_opt && !q_opt) + printf("Archive: %s\n", fn); + if (v_opt == 1) { + printf(" Length Date Time Name\n"); + printf(" -------- ---- ---- ----\n"); + } else if (v_opt == 2) { + printf(" Length Method Size Ratio Date Time CRC-32 Name\n"); + printf("-------- ------ ------- ----- ---- ---- ------ ----\n"); + } } total_size = 0; @@ -888,28 +899,35 @@ if (ret == ARCHIVE_EOF) break; ac(ret); - if (t_opt) - error_count += test(a, e); - else if (v_opt) - list(a, e); - else if (p_opt || c_opt) - extract_stdout(a, e); - else - extract(a, e); + if (!zipinfo_mode) { + if (t_opt) + error_count += test(a, e); + else if (v_opt) + list(a, e); + else if (p_opt || c_opt) + extract_stdout(a, e); + else + extract(a, e); + } else { + if (Z1_opt) + list(a, e); + } total_size += archive_entry_size(e); ++file_count; } - if (v_opt == 1) { - printf(" -------- -------\n"); - printf(" %8ju %ju file%s\n", - total_size, 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, - file_count != 1 ? "s" : ""); + if (zipinfo_mode) { + if (v_opt == 1) { + printf(" -------- -------\n"); + printf(" %8ju %ju file%s\n", + total_size, 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, + file_count != 1 ? "s" : ""); + } } ac(archive_read_close(a)); @@ -933,7 +951,7 @@ usage(void) { - fprintf(stderr, "usage: unzip [-aCcfjLlnopqtuv] [-d dir] [-x pattern] zipfile\n"); + fprintf(stderr, "usage: unzip [-aCcfjLlnopqtuvZ1] [-d dir] [-x pattern] zipfile\n"); exit(1); } @@ -943,8 +961,11 @@ int opt; optreset = optind = 1; - while ((opt = getopt(argc, argv, "aCcd:fjLlnopqtuvx:")) != -1) + while ((opt = getopt(argc, argv, "aCcd:fjLlnopqtuvx:Z1")) != -1) switch (opt) { + case '1': + Z1_opt = 1; + break; case 'a': a_opt = 1; break; @@ -995,6 +1016,9 @@ case 'x': add_pattern(&exclude, optarg); break; + case 'Z': + zipinfo_mode = 1; + break; default: usage(); } @@ -1024,6 +1048,15 @@ */ nopts = getopts(argc, argv); + /* + * When more of the zipinfo mode options are implemented, this + * will need to change. + */ + if (zipinfo_mode && !Z1_opt) { + printf("Zipinfo mode needs additional options\n"); + exit(1); + } + if (argc <= nopts) usage(); zipfile = argv[nopts++]; >Release-Note: >Audit-Trail: >Unformatted: