From owner-svn-src-all@FreeBSD.ORG Thu May 23 20:57:21 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 6B2C247E; Thu, 23 May 2013 20:57:21 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 5DE9985; Thu, 23 May 2013 20:57:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4NKvLGx077331; Thu, 23 May 2013 20:57:21 GMT (envelope-from se@svn.freebsd.org) Received: (from se@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4NKvLtB077330; Thu, 23 May 2013 20:57:21 GMT (envelope-from se@svn.freebsd.org) Message-Id: <201305232057.r4NKvLtB077330@svn.freebsd.org> From: Stefan Esser Date: Thu, 23 May 2013 20:57:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r250943 - head/usr.bin/patch X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 May 2013 20:57:21 -0000 Author: se Date: Thu May 23 20:57:20 2013 New Revision: 250943 URL: http://svnweb.freebsd.org/changeset/base/250943 Log: Fix target selection logic, which did not comply with the man page. Instead of using the file with the least order of path name components, shortest filename and finally the shortest basename (with the search stopping as soon as one of these conditions is true), the first filename checked was used as the reference, and another filename was only selected if all of the above comparisons are in favour of the latter file. This was wrong, because filenames with path less components were only considered, if both of the other conditions were true as well. In fact, the first filename to be checked had good chances to be selected in the end, since it only needed to be better with regard to any one of the three criteria ... Reviewed by: delphij@freebsd.org Modified: head/usr.bin/patch/pch.c Modified: head/usr.bin/patch/pch.c ============================================================================== --- head/usr.bin/patch/pch.c Thu May 23 20:52:30 2013 (r250942) +++ head/usr.bin/patch/pch.c Thu May 23 20:57:20 2013 (r250943) @@ -1537,10 +1537,16 @@ best_name(const struct file_name *names, continue; if ((tmp = num_components(names[i].path)) > min_components) continue; - min_components = tmp; + if (tmp < min_components) { + min_components = tmp; + best = names[i].path; + } if ((tmp = strlen(basename(names[i].path))) > min_baselen) continue; - min_baselen = tmp; + if (tmp < min_baselen) { + min_baselen = tmp; + best = names[i].path; + } if ((tmp = strlen(names[i].path)) > min_len) continue; min_len = tmp;