From owner-svn-src-stable-9@FreeBSD.ORG Fri Aug 24 10:09:35 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3266B106566B; Fri, 24 Aug 2012 10:09:35 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1C3BC8FC12; Fri, 24 Aug 2012 10:09:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q7OA9YCc017318; Fri, 24 Aug 2012 10:09:34 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q7OA9YO1017316; Fri, 24 Aug 2012 10:09:34 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201208241009.q7OA9YO1017316@svn.freebsd.org> From: Dag-Erling Smørgrav Date: Fri, 24 Aug 2012 10:09:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r239646 - stable/9/usr.bin/unzip X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Aug 2012 10:09:35 -0000 Author: des Date: Fri Aug 24 10:09:34 2012 New Revision: 239646 URL: http://svn.freebsd.org/changeset/base/239646 Log: MFH (r236226): pass filename to libarchive rather than descriptor Modified: stable/9/usr.bin/unzip/unzip.c Directory Properties: stable/9/usr.bin/unzip/ (props changed) Modified: stable/9/usr.bin/unzip/unzip.c ============================================================================== --- stable/9/usr.bin/unzip/unzip.c Fri Aug 24 09:58:14 2012 (r239645) +++ stable/9/usr.bin/unzip/unzip.c Fri Aug 24 10:09:34 2012 (r239646) @@ -865,19 +865,14 @@ unzip(const char *fn) { 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) @@ -933,9 +928,6 @@ unzip(const char *fn) ac(archive_read_close(a)); (void)archive_read_finish(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 @@ main(int argc, char *argv[]) usage(); zipfile = argv[nopts++]; + if (strcmp(zipfile, "-") == 0) + zipfile = NULL; /* STDIN */ + while (nopts < argc && *argv[nopts] != '-') add_pattern(&include, argv[nopts++]);