Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Oct 2018 18:35:57 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 232405] [patch] join: bug when input does not contain enough columns for the comparison column
Message-ID:  <bug-232405-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D232405

            Bug ID: 232405
           Summary: [patch] join: bug when input does not contain enough
                    columns for the comparison column
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: cem@freebsd.org

Martijn van Duren of OpenBSD shares both this bug and a patch.

A similar bug was reported in http://gnats.netbsd.org/1356.

The problem is the following:
$ cat /tmp/z1=20=20
a b
c d
$ cat /tmp/z2
a
e d
$ ./join -j 2 /tmp/z1 /tmp/z2
$ ./join.patch -j 2 /tmp/z1 /tmp/z2
d c e

The problem is that when the first line is compared the second file
is being slurped instead of the first file.

Sincerely,

Martijn van Duren
martijn@openbsd


Index: join.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- join.c      (revision 331931)
+++ join.c      (working copy)
@@ -394,9 +394,9 @@
 cmp(LINE *lp1, u_long fieldno1, LINE *lp2, u_long fieldno2)
 {
        if (lp1->fieldcnt <=3D fieldno1)
-               return (lp2->fieldcnt <=3D fieldno2 ? 0 : 1);
+               return (lp2->fieldcnt <=3D fieldno2 ? 0 : -1);
        if (lp2->fieldcnt <=3D fieldno2)
-               return (-1);
+               return (1);
        return (mbscoll(lp1->fields[fieldno1], lp2->fields[fieldno2]));
 }

--=20
You are receiving this mail because:
You are the assignee for the bug.=



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