Bug 249315

Summary: sort -R is not random in a non-C locale
Product: [Fedora] Fedora Reporter: Jim Meyering <meyering>
Component: coreutilsAssignee: Ondrej Vasik <ovasik>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhideCC: bakers, p
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-10-29 13:34:34 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Bug Depends On:    
Bug Blocks: 235704    

Description Jim Meyering 2007-07-23 13:39:33 EDT
Description of problem:
sort -R does not randomize its input in a non-C locale

Version-Release number of selected component (if applicable):

  $ rpm -q coreutils                                                           
      
  coreutils-6.9-4.fc8

How reproducible:
For example, the following should print differences, but does not:
It produces no output.

  (export PATH=/bin:$PATH LC_ALL=fr_FR.utf8; \
    diff <(seq 99|sort -R) <(seq 99|sort -R))

This example works fine with straight upstream code, so the problem is probably
in the multibyte patch for sort.c.


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:
Comment 1 Pádraig Brady 2007-07-25 04:41:44 EDT
Possible fix from Andreas Schwab...

If they use the same i18n patch, then this should work (will appear soon
in openSUSE Factory):

--- src/sort.c
+++ src/sort.c
@@ -2341,7 +2341,10 @@ keycompare_mb (const struct line *a, con
       size_t lenb = limb <= textb ? 0 : limb - textb;
 
       /* Actually compare the fields. */
-      if (key->numeric | key->general_numeric)
+
+      if (key->random)
+	diff = compare_random (texta, lena, textb, lenb);
+      else if (key->numeric | key->general_numeric)
 	{
 	  char savea = *lima, saveb = *limb;
Comment 2 Tim Waugh 2007-07-25 18:36:35 EDT
*** Bug 249421 has been marked as a duplicate of this bug. ***
Comment 3 Ondrej Vasik 2007-10-29 13:34:34 EDT
Change for i18n patch applied. Seems to be working correctly. Built as  
coreutils-6.9-10.fc9, closing RAWHIDE
Comment 4 Pádraig Brady 2007-10-29 14:30:49 EDT
3 months for an important bug with provided simple fix. Not great :(
I hope this fix will be in F8 at least.
Comment 5 Ondrej Vasik 2007-10-30 05:44:27 EDT
Sorry, I got coreutils from Pete Graner 10 days ago, so I'm trying to get it
into shape asap, but it will take some time... It will get to F8, but I don't
know if it will happen before the official release - I want to have more
troubles finished in one F8 commit/build and I don't know if I will finish it
before release date.