From owner-svn-src-head@freebsd.org Tue May 8 10:58:15 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB63FFB1993; Tue, 8 May 2018 10:58:15 +0000 (UTC) (envelope-from danfe@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [96.47.72.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 716326C70A; Tue, 8 May 2018 10:58:15 +0000 (UTC) (envelope-from danfe@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1033) id 65FDBDCC2; Tue, 8 May 2018 10:58:15 +0000 (UTC) Date: Tue, 8 May 2018 10:58:15 +0000 From: Alexey Dokuchaev To: Kyle Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r333351 - head/usr.bin/grep Message-ID: <20180508105815.GB7299@FreeBSD.org> References: <201805080353.w483rlde033542@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201805080353.w483rlde033542@repo.freebsd.org> User-Agent: Mutt/1.9.2 (2017-12-15) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 May 2018 10:58:15 -0000 On Tue, May 08, 2018 at 03:53:47AM +0000, Kyle Evans wrote: > New Revision: 333351 > URL: https://svnweb.freebsd.org/changeset/base/333351 > > Log: > bsdgrep: Allow "-" to be passed to -f to mean "standard input" > > A version of this patch was originally sent to me by se@, matching behavior > from newer versions of GNU grep. > > - if ((f = fopen(fn, "r")) == NULL) > + if (strcmp(fn, "-") == 0) > + f = stdin; This makes sense: when `fn' is "-", `f' is stdin. > - fclose(f); > + if (strcmp(fn, "-") != 0) > + fclose(f); But not this one: why are you checking `fn' again? Shouldn't you fclose(f) if it's not stdin? if (f != stdin) fclose(f); ./danfe