From owner-svn-src-stable@FreeBSD.ORG Mon May 28 21:25:20 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5465D1065670; Mon, 28 May 2012 21:25:20 +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 25AA68FC12; Mon, 28 May 2012 21:25:20 +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 q4SLPKdi034341; Mon, 28 May 2012 21:25:20 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4SLPJmN034337; Mon, 28 May 2012 21:25:19 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201205282125.q4SLPJmN034337@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Mon, 28 May 2012 21:25:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236201 - stable/8/usr.bin/unzip X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 May 2012 21:25:20 -0000 Author: des Date: Mon May 28 21:25:19 2012 New Revision: 236201 URL: http://svn.freebsd.org/changeset/base/236201 Log: MFH r208957: check return value from archive_read_new() MFH r214137, r214140, r214174, r224584: support reading from stdin MFH r230044, r233456: style and markup nits MFH r234311: correct name in copyright statement Modified: stable/8/usr.bin/unzip/unzip.1 stable/8/usr.bin/unzip/unzip.c Directory Properties: stable/8/usr.bin/unzip/ (props changed) Modified: stable/8/usr.bin/unzip/unzip.1 ============================================================================== --- stable/8/usr.bin/unzip/unzip.1 Mon May 28 21:19:33 2012 (r236200) +++ stable/8/usr.bin/unzip/unzip.1 Mon May 28 21:25:19 2012 (r236201) @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 2007-2008 Dag-Erling Coïdan Smørgrav +.\" Copyright (c) 2007-2008 Dag-Erling Smørgrav .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -38,7 +38,6 @@ .Ar zipfile .Sh DESCRIPTION .\" ... -.Pp The following options are available: .Bl -tag -width Fl .It Fl a @@ -121,6 +120,10 @@ Note that only one of and .Fl u may be specified. +If specified filename is +.Qq - , +then data is read from +.Va stdin . .Sh ENVIRONMENT If the .Ev UNZIP_DEBUG Modified: stable/8/usr.bin/unzip/unzip.c ============================================================================== --- stable/8/usr.bin/unzip/unzip.c Mon May 28 21:19:33 2012 (r236200) +++ stable/8/usr.bin/unzip/unzip.c Mon May 28 21:25:19 2012 (r236201) @@ -1,6 +1,6 @@ /*- * Copyright (c) 2009 Joerg Sonnenberger - * Copyright (c) 2007-2008 Dag-Erling Coïdan Smørgrav + * Copyright (c) 2007-2008 Dag-Erling Smørgrav * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -426,7 +426,7 @@ handle_existing_file(char **path) fprintf(stderr, "replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", *path); - if (fgets(buf, sizeof(buf), stdin) == 0) { + if (fgets(buf, sizeof(buf), stdin) == NULL) { clearerr(stdin); printf("NULL\n(EOF or read error, " "treating as \"[N]one\"...)\n"); @@ -868,10 +868,14 @@ unzip(const char *fn) int fd, ret; uintmax_t total_size, file_count, error_count; - if ((fd = open(fn, O_RDONLY)) < 0) + if (strcmp(fn, "-") == 0) + fd = STDIN_FILENO; + else if ((fd = open(fn, O_RDONLY)) < 0) error("%s", fn); - a = archive_read_new(); + 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)); @@ -929,7 +933,7 @@ unzip(const char *fn) ac(archive_read_close(a)); (void)archive_read_finish(a); - if (close(fd) != 0) + if (fd != STDIN_FILENO && close(fd) != 0) error("%s", fn); if (t_opt) {