From 85ca01a1d93f5918b4daecb52be590599fc00dc7 Mon Sep 17 00:00:00 2001 From: Ondrej Vasik Date: Mar 02 2009 13:51:18 +0000 Subject: fix sort bugs (including #485715) for multibyte locales --- diff --git a/coreutils-6.12-sort-endoffields.patch b/coreutils-6.12-sort-endoffields.patch index 997feef..1f841af 100644 --- a/coreutils-6.12-sort-endoffields.patch +++ b/coreutils-6.12-sort-endoffields.patch @@ -79,7 +79,18 @@ diff -urNp coreutils-6.12-orig/src/sort.c coreutils-6.12/src/sort.c diff -urNp coreutils-6.12-orig/tests/misc/sort coreutils-6.12/tests/misc/sort --- coreutils-6.12-orig/tests/misc/sort 2008-05-17 08:41:12.000000000 +0200 +++ coreutils-6.12/tests/misc/sort 2009-02-26 16:25:39.000000000 +0100 -@@ -108,6 +108,8 @@ my @Tests = +@@ -24,6 +24,10 @@ my $prog = 'sort'; + # Turn off localization of executable's output. + @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; + ++my $mb_locale = $ENV{LOCALE_FR_UTF8}; ++! defined $mb_locale || $mb_locale eq 'none' ++ and $mb_locale = 'C'; ++ + # Since each test is run with a file name and with redirected stdin, + # the name in the diagnostic is either the file name or "-". + # Normalize each diagnostic to use '-'. +@@ -108,6 +114,8 @@ my @Tests = ["07b", '-k 2,3', {IN=>"a a b\nz a a\n"}, {OUT=>"z a a\na a b\n"}], ["07c", '-k 2,3', {IN=>"y k b\nz k a\n"}, {OUT=>"z k a\ny k b\n"}], ["07d", '+1 -3', {IN=>"y k b\nz k a\n"}, {OUT=>"z k a\ny k b\n"}], @@ -88,7 +99,7 @@ diff -urNp coreutils-6.12-orig/tests/misc/sort coreutils-6.12/tests/misc/sort # # report an error for `.' without following char spec ["08a", '-k 2.,3', {EXIT=>2}, -@@ -208,6 +210,10 @@ my @Tests = +@@ -208,6 +216,15 @@ my @Tests = # key start and key end. ["18e", '-nb -k1.1,1.2', {IN=>" 901\n100\n"}, {OUT=>"100\n 901\n"}], @@ -96,6 +107,11 @@ diff -urNp coreutils-6.12-orig/tests/misc/sort coreutils-6.12/tests/misc/sort +# next field are not included in the sort. I.E. order should not change here. +["18f", '-k1,1b', {IN=>"a y\na z\n"}, {OUT=>"a y\na z\n"}], + ++# When ignoring leading blanks for start position, ensure blanks from ++# next field are not included in the sort. I.E. order should not change here. ++# This was noticed as an issue on fedora 8 (only in multibyte locales). ++["18g", '-k1b,1', {IN=>"a y\na z\n"}, {OUT=>"a y\na z\n"}, ++ {ENV => "LC_ALL=$mb_locale"}], # This looks odd, but works properly -- 2nd keyspec is never # used because all lines are different. ["19a", '+0 +1nr', {IN=>"b 2\nb 1\nb 3\n"}, {OUT=>"b 1\nb 2\nb 3\n"}], diff --git a/coreutils-i18n.patch b/coreutils-i18n.patch index 2f48694..c70aa2a 100644 --- a/coreutils-i18n.patch +++ b/coreutils-i18n.patch @@ -1919,7 +1919,7 @@ diff -urNp coreutils-6.11-orig/src/join.c coreutils-6.11/src/join.c if (newlim) lim = newlim; } -@@ -1384,6 +1570,107 @@ +@@ -1384,6 +1570,113 @@ return ptr; } @@ -1931,7 +1931,10 @@ diff -urNp coreutils-6.11-orig/src/join.c coreutils-6.11/src/join.c + size_t eword = key->eword, echar = key->echar; + int i; + size_t mblength; ++ + mbstate_t state; ++ if (echar == 0) ++ eword++; /* skip all of end field. */ + + memset (&state, '\0', sizeof(mbstate_t)); + @@ -2001,24 +2004,27 @@ diff -urNp coreutils-6.11-orig/src/join.c coreutils-6.11/src/join.c + } +# endif + -+ /* If we're skipping leading blanks, don't start counting characters -+ * until after skipping past any leading blanks. */ -+ if (key->skipsblanks) -+ while (ptr < lim && ismbblank (ptr, lim - ptr, &mblength)) -+ ptr += mblength; ++ if (echar != 0) ++ { ++ /* If we're skipping leading blanks, don't start counting characters ++ * until after skipping past any leading blanks. */ ++ if (key->skipsblanks) ++ while (ptr < lim && ismbblank (ptr, lim - ptr, &mblength)) ++ ptr += mblength; + -+ memset (&state, '\0', sizeof(mbstate_t)); ++ memset (&state, '\0', sizeof(mbstate_t)); + -+ /* Advance PTR by ECHAR (if possible), but no further than LIM. */ -+ for (i = 0; i < echar; i++) -+ { -+ GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state); ++ /* Advance PTR by ECHAR (if possible), but no further than LIM. */ ++ for (i = 0; i < echar; i++) ++ { ++ GET_BYTELEN_OF_CHAR (lim, ptr, mblength, state); + -+ if (ptr + mblength > lim) -+ break; -+ else -+ ptr += mblength; -+ } ++ if (ptr + mblength > lim) ++ break; ++ else ++ ptr += mblength; ++ } ++ } + + return ptr; +} diff --git a/coreutils.spec b/coreutils.spec index 96902f8..5976065 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: The GNU core utilities: a set of tools commonly used in shell scripts Name: coreutils Version: 6.12 -Release: 19%{?dist} +Release: 20%{?dist} License: GPLv3+ Group: System Environment/Base Url: http://www.gnu.org/software/coreutils/ @@ -342,6 +342,10 @@ fi /sbin/runuser %changelog +* Mon Mar 02 2009 Ondrej Vasik - 6.12-20 +- fix sort bugs (including #485715) for multibyte locales + as well + * Thu Feb 26 2009 Ondrej Vasik - 6.12-19 - fix showing ACL's for ls -Z (#487374), fix automatic column width for it as well