Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Jan 2024 08:54:49 GMT
From:      Tijl Coosemans <tijl@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: aaefd6898a73 - stable/14 - join(1): Fix ordering in case of missing fields
Message-ID:  <202401310854.40V8snKx087194@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by tijl:

URL: https://cgit.FreeBSD.org/src/commit/?id=aaefd6898a73528d3888331a51983cbcc9f06125

commit aaefd6898a73528d3888331a51983cbcc9f06125
Author:     Tijl Coosemans <tijl@FreeBSD.org>
AuthorDate: 2024-01-22 10:35:31 +0000
Commit:     Tijl Coosemans <tijl@FreeBSD.org>
CommitDate: 2024-01-31 08:53:11 +0000

    join(1): Fix ordering in case of missing fields
    
    The comparison function had the ordering reversed causing join(1) to
    miss some matching lines.
    
    PR:             232405
    Submitted by:   Martijn van Duren <martijn@openbsd.org>
    
    (cherry picked from commit 95bf75895ddcf17402b1f69dce26cb821c922476)
---
 usr.bin/join/join.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/usr.bin/join/join.c b/usr.bin/join/join.c
index b9e708dd98cd..eab0dbcac900 100644
--- a/usr.bin/join/join.c
+++ b/usr.bin/join/join.c
@@ -392,9 +392,9 @@ static int
 cmp(LINE *lp1, u_long fieldno1, LINE *lp2, u_long fieldno2)
 {
 	if (lp1->fieldcnt <= fieldno1)
-		return (lp2->fieldcnt <= fieldno2 ? 0 : 1);
+		return (lp2->fieldcnt <= fieldno2 ? 0 : -1);
 	if (lp2->fieldcnt <= fieldno2)
-		return (-1);
+		return (1);
 	return (mbscoll(lp1->fields[fieldno1], lp2->fields[fieldno2]));
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401310854.40V8snKx087194>