[Midnightbsd-cvs] src [7265] trunk/usr.bin/unzip: cleanup code
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Tue Aug 18 19:08:22 EDT 2015
Revision: 7265
http://svnweb.midnightbsd.org/src/?rev=7265
Author: laffer1
Date: 2015-08-18 19:08:22 -0400 (Tue, 18 Aug 2015)
Log Message:
-----------
cleanup code
Modified Paths:
--------------
trunk/usr.bin/unzip/unzip.1
trunk/usr.bin/unzip/unzip.c
Modified: trunk/usr.bin/unzip/unzip.1
===================================================================
--- trunk/usr.bin/unzip/unzip.1 2015-08-18 21:02:40 UTC (rev 7264)
+++ trunk/usr.bin/unzip/unzip.1 2015-08-18 23:08:22 UTC (rev 7265)
@@ -50,7 +50,7 @@
When extracting files from the zipfile, they are written to stdout.
This is similar to
.Fl p ,
-but doesn't suppress normal output.
+but does not suppress normal output.
.It Fl d Ar dir
Extract files into the specified directory rather than the current
directory.
Modified: trunk/usr.bin/unzip/unzip.c
===================================================================
--- trunk/usr.bin/unzip/unzip.c 2015-08-18 21:02:40 UTC (rev 7264)
+++ trunk/usr.bin/unzip/unzip.c 2015-08-18 23:08:22 UTC (rev 7265)
@@ -865,19 +865,14 @@
{
struct archive *a;
struct archive_entry *e;
- int fd, ret;
+ int ret;
uintmax_t total_size, file_count, error_count;
- if (strcmp(fn, "-") == 0)
- fd = STDIN_FILENO;
- else if ((fd = open(fn, O_RDONLY)) < 0)
- error("%s", fn);
-
if ((a = archive_read_new()) == NULL)
error("archive_read_new failed");
ac(archive_read_support_format_zip(a));
- ac(archive_read_open_fd(a, fd, 8192));
+ ac(archive_read_open_filename(a, fn, 8192));
if (!zipinfo_mode) {
if (!p_opt && !q_opt)
@@ -931,11 +926,8 @@
}
ac(archive_read_close(a));
- (void)archive_read_finish(a);
+ (void)archive_read_free(a);
- if (fd != STDIN_FILENO && close(fd) != 0)
- error("%s", fn);
-
if (t_opt) {
if (error_count > 0) {
errorx("%d checksum error(s) found.", error_count);
@@ -1061,6 +1053,9 @@
usage();
zipfile = argv[nopts++];
+ if (strcmp(zipfile, "-") == 0)
+ zipfile = NULL; /* STDIN */
+
while (nopts < argc && *argv[nopts] != '-')
add_pattern(&include, argv[nopts++]);
More information about the Midnightbsd-cvs
mailing list