From owner-svn-src-stable@freebsd.org Mon Mar 19 03:22:44 2018 Return-Path: Delivered-To: svn-src-stable@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 8BDC5F424A7; Mon, 19 Mar 2018 03:22:44 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3997375F5F; Mon, 19 Mar 2018 03:22:44 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 349341415; Mon, 19 Mar 2018 03:22:44 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2J3Min5094902; Mon, 19 Mar 2018 03:22:44 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2J3Migo094901; Mon, 19 Mar 2018 03:22:44 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201803190322.w2J3Migo094901@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Mon, 19 Mar 2018 03:22:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r331164 - stable/11/usr.bin/join X-SVN-Group: stable-11 X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: stable/11/usr.bin/join X-SVN-Commit-Revision: 331164 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 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, 19 Mar 2018 03:22:44 -0000 Author: eadler Date: Mon Mar 19 03:22:43 2018 New Revision: 331164 URL: https://svnweb.freebsd.org/changeset/base/331164 Log: MFC r320210: join(1): Fix field ordering for -v output Per POSIX, join(1) (in modes other than -o) is a concatenation of selected character fields. The joined field is first, followed by fields in the order they occurred in the input files. Our join(1) utility previously handled this correctly for lines with a match in the other file. But it failed to order output fields correctly for unmatched lines, printed in -a and -v modes. A simple test case is: $ touch a $ echo "2 1" > b $ join -v2 -2 2 a b 1 2 PR: 217711 Modified: stable/11/usr.bin/join/join.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/join/join.c ============================================================================== --- stable/11/usr.bin/join/join.c Mon Mar 19 03:20:35 2018 (r331163) +++ stable/11/usr.bin/join/join.c Mon Mar 19 03:22:43 2018 (r331164) @@ -469,9 +469,15 @@ outoneline(INPUT *F, LINE *lp) else outfield(lp, 0, 1); } - else + else { + /* + * Output the join field, then the remaining fields. + */ + outfield(lp, F->joinf, 0); for (cnt = 0; cnt < lp->fieldcnt; ++cnt) - outfield(lp, cnt, 0); + if (F->joinf != cnt) + outfield(lp, cnt, 0); + } (void)printf("\n"); if (ferror(stdout)) err(1, "stdout");