[Bug 232405] [patch] join: bug when input does not contain enough columns for the comparison column
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Thu Oct 18 18:35:59 UTC 2018
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=232405
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 at FreeBSD.org
Reporter: cem at 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
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 at openbsd
Index: join.c
===================================================================
--- 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 <= 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]));
}
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list