From 6cf6cd48dd1577f0f69816c3afcd4775b0d281bb Mon Sep 17 00:00:00 2001 From: Kamil Dudka Date: Jul 14 2016 14:50:51 +0000 Subject: make 'sort -h' work for arbitrary column ... even when using UTF-8 locales --- diff --git a/coreutils-i18n-sort-human.patch b/coreutils-i18n-sort-human.patch new file mode 100644 index 0000000..2469189 --- /dev/null +++ b/coreutils-i18n-sort-human.patch @@ -0,0 +1,35 @@ +From 3976ef5a20369d8b490907ab2cba2d617305a5e0 Mon Sep 17 00:00:00 2001 +From: Kamil Dudka +Date: Mon, 30 May 2016 16:19:20 +0200 +Subject: [PATCH] sort: do not use static array 'blanks' in human_numcompare() + +... because the array is not initialized with MB locales. Note this is +rather a conservative fix. I plan to do more cleanup of the i18n patch +in Fedora to prevent mistakes like this in future updates of coreutils. +--- + src/sort.c | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +diff --git a/src/sort.c b/src/sort.c +index 9e07ad8..e47b039 100644 +--- a/src/sort.c ++++ b/src/sort.c +@@ -2274,12 +2274,10 @@ find_unit_order (char const *number) + < K/k < M < G < T < P < E < Z < Y */ + + static int +-human_numcompare (char const *a, char const *b) ++human_numcompare (char *a, char *b) + { +- while (blanks[to_uchar (*a)]) +- a++; +- while (blanks[to_uchar (*b)]) +- b++; ++ skipblanks(&a, a + strlen(a)); ++ skipblanks(&b, b + strlen(b)); + + int diff = find_unit_order (a) - find_unit_order (b); + return (diff ? diff : strnumcmp (a, b, decimal_point, thousands_sep)); +-- +2.5.5 + diff --git a/coreutils.spec b/coreutils.spec index e48bca6..010fe77 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 8.25 -Release: 12%{?dist} +Release: 13%{?dist} License: GPLv3+ Group: System Environment/Base Url: http://www.gnu.org/software/coreutils/ @@ -53,6 +53,8 @@ Patch803: coreutils-i18n-fix-unexpand.patch Patch805: coreutils-i18n-fix2-expand-unexpand.patch #(un)expand - test BOM headers Patch806: coreutils-i18n-un-expand-BOM.patch +# make 'sort -h' work for arbitrary column even when using UTF-8 locales +Patch807: coreutils-i18n-sort-human.patch #getgrouplist() patch from Ulrich Drepper. Patch908: coreutils-getgrouplist.patch @@ -195,6 +197,7 @@ tee DIR_COLORS{,.256color,.lightbgcolor} /dev/null %patch804 -p1 -b .i18n-cutold %patch805 -p1 -b .i18n-fix2-expand-unexpand %patch806 -p1 -b .i18n-BOM-expand-unexpand +%patch807 -p1 # Coreutils %patch908 -p1 -b .getgrouplist @@ -349,6 +352,9 @@ fi %license COPYING %changelog +* Thu Jul 14 2016 Kamil Dudka - 8.25-13 +- make 'sort -h' work for arbitrary column even when using UTF-8 locales + * Mon Jul 11 2016 Kamil Dudka - 8.25-12 - install -Z now sets default SELinux context for created directories (#1339135) - drop the %%pre scriptlet, which is no longer needed (#1354078)