From steve@mouf.net  Fri Apr 13 00:57:43 2012
Return-Path: <steve@mouf.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 0BBD1106564A
	for <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>; 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 <FreeBSD-gnats-submit@freebsd.org>; 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 <swills@FreeBSD.org>
Reply-To: Steve Wills <swills@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] add partial zipinfo mode support to base unzip
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         166895
>Category:       bin
>Synopsis:       add partial zipinfo mode support to base unzip
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr 13 01:00:26 UTC 2012
>Closed-Date:    Mon Apr 16 01:21:24 UTC 2012
>Last-Modified:  Mon Apr 16 01:30:04 UTC 2012
>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:

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/166895: commit references a PR
Date: Fri, 13 Apr 2012 06:16:02 +0000 (UTC)

 Author: kevlo
 Date: Fri Apr 13 06:15:51 2012
 New Revision: 234206
 URL: http://svn.freebsd.org/changeset/base/234206
 
 Log:
   Partially implement zipinfo (-Z) support.
   This fixes some test failures seen with perl 5.12 and 5.14.
   
   PR:	bin/166895
   Submitted by:	swills
   MFC after:	3 days
 
 Modified:
   head/usr.bin/unzip/unzip.c
 
 Modified: head/usr.bin/unzip/unzip.c
 ==============================================================================
 --- head/usr.bin/unzip/unzip.c	Fri Apr 13 06:13:37 2012	(r234205)
 +++ head/usr.bin/unzip/unzip.c	Fri Apr 13 06:15:51 2012	(r234206)
 @@ -65,6 +65,7 @@ static int		 q_opt;		/* quiet */
  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 @@ static time_t		 now;
  /* debug flag */
  static int		 unzip_debug;
  
 +/* zipinfo mode */
 +static int		 zipinfo_mode;
 +
  /* running on tty? */
  static int		 tty;
  
 @@ -802,17 +806,22 @@ list(struct archive *a, struct archive_e
  	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 @@ unzip(const char *fn)
  	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 @@ unzip(const char *fn)
  		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 @@ static void
  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 @@ getopts(int argc, char *argv[])
  	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 @@ getopts(int argc, char *argv[])
  		case 'x':
  			add_pattern(&exclude, optarg);
  			break;
 +		case 'Z':
 +			zipinfo_mode = 1;
 +			break;
  		default:
  			usage();
  		}
 @@ -1024,6 +1048,15 @@ main(int argc, char *argv[])
  	 */
  	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++];
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/166895: commit references a PR
Date: Mon, 16 Apr 2012 01:15:48 +0000 (UTC)

 Author: kevlo
 Date: Mon Apr 16 01:15:38 2012
 New Revision: 234330
 URL: http://svn.freebsd.org/changeset/base/234330
 
 Log:
   MFC r234206:
   Partially implement zipinfo (-Z) support.
   This fixes some test failures seen with perl 5.12 and 5.14.
   
   PR:	bin/166895
   Submitted by:	swills
 
 Modified:
   stable/9/usr.bin/unzip/unzip.c
 Directory Properties:
   stable/9/usr.bin/   (props changed)
 
 Modified: stable/9/usr.bin/unzip/unzip.c
 ==============================================================================
 --- stable/9/usr.bin/unzip/unzip.c	Sun Apr 15 23:56:03 2012	(r234329)
 +++ stable/9/usr.bin/unzip/unzip.c	Mon Apr 16 01:15:38 2012	(r234330)
 @@ -65,6 +65,7 @@ static int		 q_opt;		/* quiet */
  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 @@ static time_t		 now;
  /* debug flag */
  static int		 unzip_debug;
  
 +/* zipinfo mode */
 +static int		 zipinfo_mode;
 +
  /* running on tty? */
  static int		 tty;
  
 @@ -802,17 +806,22 @@ list(struct archive *a, struct archive_e
  	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 @@ unzip(const char *fn)
  	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 @@ unzip(const char *fn)
  		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 @@ static void
  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 @@ getopts(int argc, char *argv[])
  	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 @@ getopts(int argc, char *argv[])
  		case 'x':
  			add_pattern(&exclude, optarg);
  			break;
 +		case 'Z':
 +			zipinfo_mode = 1;
 +			break;
  		default:
  			usage();
  		}
 @@ -1024,6 +1048,15 @@ main(int argc, char *argv[])
  	 */
  	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++];
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: kevlo 
State-Changed-When: Mon Apr 16 01:20:46 UTC 2012 
State-Changed-Why:  
Committed, thanks. The patch was also MFC'd to stable/8 and stable/9. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=166895 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/166895: commit references a PR
Date: Mon, 16 Apr 2012 01:20:28 +0000 (UTC)

 Author: kevlo
 Date: Mon Apr 16 01:20:17 2012
 New Revision: 234331
 URL: http://svn.freebsd.org/changeset/base/234331
 
 Log:
   MFC r234206:
   Partially implement zipinfo (-Z) support.
   This fixes some test failures seen with perl 5.12 and 5.14.
   
   PR:	bin/166895
   Submitted by:	swills
 
 Modified:
   stable/8/usr.bin/unzip/unzip.c
 Directory Properties:
   stable/8/usr.bin/   (props changed)
   stable/8/usr.bin/unzip/   (props changed)
 
 Modified: stable/8/usr.bin/unzip/unzip.c
 ==============================================================================
 --- stable/8/usr.bin/unzip/unzip.c	Mon Apr 16 01:15:38 2012	(r234330)
 +++ stable/8/usr.bin/unzip/unzip.c	Mon Apr 16 01:20:17 2012	(r234331)
 @@ -65,6 +65,7 @@ static int		 q_opt;		/* quiet */
  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 @@ static time_t		 now;
  /* debug flag */
  static int		 unzip_debug;
  
 +/* zipinfo mode */
 +static int		 zipinfo_mode;
 +
  /* running on tty? */
  static int		 tty;
  
 @@ -802,17 +806,22 @@ list(struct archive *a, struct archive_e
  	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));
  }
 @@ -866,14 +875,16 @@ unzip(const char *fn)
  	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;
 @@ -884,28 +895,35 @@ unzip(const char *fn)
  		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));
 @@ -929,7 +947,7 @@ static void
  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);
  }
  
 @@ -939,8 +957,11 @@ getopts(int argc, char *argv[])
  	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;
 @@ -991,6 +1012,9 @@ getopts(int argc, char *argv[])
  		case 'x':
  			add_pattern(&exclude, optarg);
  			break;
 +		case 'Z':
 +			zipinfo_mode = 1;
 +			break;
  		default:
  			usage();
  		}
 @@ -1020,6 +1044,15 @@ main(int argc, char *argv[])
  	 */
  	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++];
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
