Bug 249315 - sort -R is not random in a non-C locale
Summary: sort -R is not random in a non-C locale
Alias: None
Product: Fedora
Classification: Fedora
Component: coreutils   
(Show other bugs)
Version: rawhide
Hardware: All Linux
Target Milestone: ---
Assignee: Ondrej Vasik
QA Contact: Fedora Extras Quality Assurance
: 249421 (view as bug list)
Depends On:
Blocks: F8Target
TreeView+ depends on / blocked
Reported: 2007-07-23 17:39 UTC by Jim Meyering
Modified: 2013-03-13 20:40 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-10-29 17:34:34 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description Jim Meyering 2007-07-23 17:39:33 UTC
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                                                           

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:
Actual results:

Expected results:

Additional info:

Comment 1 Pádraig Brady 2007-07-25 08:41:44 UTC
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 22:36:35 UTC
*** Bug 249421 has been marked as a duplicate of this bug. ***

Comment 3 Ondrej Vasik 2007-10-29 17:34:34 UTC
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 18:30:49 UTC
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 09:44:27 UTC
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.

Note You need to log in before you can comment on or make changes to this bug.