Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Dec 1999 14:01:02 +0100 (CET)
From:      cejkar@dcse.fee.vutbr.cz
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/15458: sort(1) doesn't sort correctly in some cases
Message-ID:  <199912131301.OAA28722@kazi.dcse.fee.vutbr.cz>

next in thread | raw e-mail | index | archive | help

>Number:         15458
>Category:       bin
>Synopsis:       sort(1) doesn't sort correctly in some cases
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 13 05:10:02 PST 1999
>Closed-Date:
>Last-Modified:
>Originator:     Rudolf Cejka
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
Brno University of Technology, FEE&CS, Czech Republic
>Environment:

Maybe it is not relevant, but it is 4.0-CURRENT, Dec 10 1999.

>Description:

Sort(1) doesn't work in some cases for some locales. In cs_CZ.ISO_8859-2
(will be shortly commited; maybe similar problem could be seen with es_ES)
there is collation definition:

	(H,h);\
	(CH,Ch,ch);\
	(I,i);\

So sort should sort "h" and "ch" in order "h", "ch". But it sorts
these two words incorrectly as "ch", "h". If I want to sort for
example "ha" and "ch", it will be sorted correctly: "ha", "ch".

The problem is in "optimalizations", where only substrings of two
strings of minimal length of one of them are compared in strcoll()
function. This is not possible to do in this manner for languages,
where collating symbols could be longer than one character.

>How-To-Repeat:
>Fix:

Here is my patch for /usr/src/gnu/usr.bin/sort/sort.c:

--- sort.c.orig	Mon Dec 13 13:21:26 1999
+++ sort.c	Mon Dec 13 13:25:33 1999
@@ -208,6 +208,7 @@
 	return strcoll(s[0], s[1]);
 }
 
+#if 0
 static int
 collcmp(char *a, char *b, int mini)
 {
@@ -223,6 +224,7 @@
 	b[mini] = sb;
 	return r;
 }
+#endif
 #endif /* __FreeBSD__ */
 
 static void
@@ -1153,7 +1155,7 @@
 	  }
       else
 #ifdef __FreeBSD__
-	diff = collcmp (texta, textb, min (lena, lenb));
+	diff = strcoll (texta, textb);
 #else
 	diff = memcmp (texta, textb, min (lena, lenb));
 #endif
@@ -1203,7 +1205,7 @@
 	{
 #endif
 #ifdef __FreeBSD__
-	  diff = collcmp (ap, bp, mini);
+	  diff = strcoll (ap, bp);
 #else
 	  diff = memcmp (ap, bp, mini);
 #endif


>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




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