From owner-freebsd-bugs@FreeBSD.ORG Thu Oct 25 11:50:00 2007 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EE63116A41B for ; Thu, 25 Oct 2007 11:50:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id DBE8613C4A8 for ; Thu, 25 Oct 2007 11:50:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id l9PBo0dD032322 for ; Thu, 25 Oct 2007 11:50:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l9PBo0xO032321; Thu, 25 Oct 2007 11:50:00 GMT (envelope-from gnats) Resent-Date: Thu, 25 Oct 2007 11:50:00 GMT Resent-Message-Id: <200710251150.l9PBo0xO032321@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jasper Jongmans Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0EA2216A419 for ; Thu, 25 Oct 2007 11:49:41 +0000 (UTC) (envelope-from aprogas@aprogas.student.utwente.nl) Received: from aprogas.student.utwente.nl (aprogas.student.utwente.nl [130.89.160.179]) by mx1.freebsd.org (Postfix) with ESMTP id D7EF613C49D for ; Thu, 25 Oct 2007 11:49:40 +0000 (UTC) (envelope-from aprogas@aprogas.student.utwente.nl) Received: by harry.aprogas.local (Postfix, from userid 1000) id 5631A6B; Thu, 25 Oct 2007 13:17:50 +0200 (CEST) Message-Id: <20071025111750.5631A6B@harry.aprogas.local> Date: Thu, 25 Oct 2007 13:17:50 +0200 (CEST) From: Jasper Jongmans To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Jasper Jongmans Subject: gnu/117481: sort(1) incorrect numeric sort in very specific cases X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jasper Jongmans List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Oct 2007 11:50:01 -0000 >Number: 117481 >Category: gnu >Synopsis: sort(1) incorrect numeric sort in very specific cases >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Oct 25 11:50:00 UTC 2007 >Closed-Date: >Last-Modified: >Originator: Jasper Jongmans >Release: FreeBSD 6.2-RELEASE-p1 i386 >Organization: Church of Harkmannetjes >Environment: System: FreeBSD harry.aprogas.local 6.2-RELEASE-p1 FreeBSD 6.2-RELEASE-p1 #6: Thu Feb 22 12:38:44 CET 2007 root@harry.aprogas.net:/usr/obj/usr/src/sys/HARRY i386 sort (GNU coreutils) 5.3.0-20040812-FreeBSD Problem could not be reproduced on: FreeBSD 4.11-RELEASE-p11 i386 sort - GNU textutils 1.14 Debian GNU/Linux (exact version unknown) sort from coreutils 5.94 >Description: When sorting a file with comma seperated numeric values that are intended as individual integers rather than numbers with a decimal point, in specific cases sort(1) produces incorrect results. So far I've been able to narrow down the problem to the following: - the comma is used as field seperator - a numeric sort is attempted either using -k1n +0n or just -n - the field specified as sorting key is followed by another field containing numerics - this second field contains more digits than the same field on other lines - the sorting key and the numeric field following it do not have to be the only fields on the line, e.g. "foo,bar,2,14,bla" with -k3n will behave the same as "2,14" with -k1n - does not occur on all locales Let me reiterate that I am not trying to sort decimal fractions, but rather individual integers that happen to be seperated by commas. >How-To-Repeat: % cat sort.txt 2,14 3,5 1,321 8,12 1,9 % env LANG=en_US.UTF-8 sort -t, -k1n sort.txt 1,9 3,5 2,14 8,12 1,321 % env LANG=nl_NL.UTF-8 sort -t, -k1n sort.txt 1,321 1,9 2,14 3,5 8,12 % env LANG=C sort -t, -k1n sort.txt 1,321 1,9 2,14 3,5 8,12 >Fix: Workaround: set LANG=C or LC_ALL=C as recommended in the sort(1) manpage >Release-Note: >Audit-Trail: >Unformatted: