Subject: bin/25572: 'sort -k1.2,1.0' incorrectly says fields out of order
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <Ross.Patterson@CatchFS.Com>
List: netbsd-bugs
Date: 05/14/2004 19:54:41
>Number: 25572
>Category: bin
>Synopsis: 'sort -k1.2,1.0' incorrectly says fields out of order
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri May 14 19:55:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: Ross Patterson
>Release: 1.6
>Organization:
CatchFIRE Systems, Inc
>Environment:
NetBSD BUBBA 1.6 NetBSD 1.6 (BUBBA) #788: Wed May 5 12:35:47 EDT 2004 rap@devo.rap.catchfs.com:/home/rap/usr/src/sys/arch/i386/compile/BUBBA i386
Architecture: i386
>Description:
The /usr/bin/sort command tests to see if the start and end positions of a keyfield are out of order, but the test doesn't handle the special meaning of "x.0" as "the last character of field x", not the 0th character.
>How-To-Repeat:
# sort -k1.2,1.0
sort: fields out of order
>Fix:
diff -u -r1.1.1.1 init.c
--- usr/src/usr.bin/sort/init.c 14 Mar 2003 16:26:44 -0000 1.1.1.1
+++ usr/src/usr.bin/sort/init.c 14 May 2004 19:43:36 -0000
@@ -203,6 +203,7 @@
if (cur_fld->tcol.num && !(!(cur_fld->flags & BI)
&& cur_fld->flags & BT) && (cur_fld->tcol.num <= cur_fld->icol.num
+ && !cur_fld->tcol.indent
&& cur_fld->tcol.indent < cur_fld->icol.indent))
errx(2, "fields out of order");
insertcol(cur_fld);
>Release-Note:
>Audit-Trail:
>Unformatted: