[coreutils/f20] reverted an old change and constricted it's condition
Ondrej Oprala
ooprala at fedoraproject.org
Fri Jan 3 05:47:04 UTC 2014
commit 8e09f222b701ef1c900060db91f255c13a86ae31
Author: Ondrej Oprala <ooprala at redhat.com>
Date: Fri Jan 3 06:46:34 2014 +0100
reverted an old change and constricted it's condition
coreutils-i18n.patch | 145 ++++++++++++++++++++++++++------------------------
coreutils.spec | 5 ++-
2 files changed, 80 insertions(+), 70 deletions(-)
---
diff --git a/coreutils-i18n.patch b/coreutils-i18n.patch
index 5f3be7c..c68ad94 100644
--- a/coreutils-i18n.patch
+++ b/coreutils-i18n.patch
@@ -2429,8 +2429,8 @@ diff -urNp coreutils-8.21-orig/src/pr.c coreutils-8.21/src/pr.c
looking for more options and printing the next batch of files.
diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
---- coreutils-8.21-orig/src/sort.c 2013-08-14 18:14:06.172216606 +0200
-+++ coreutils-8.21/src/sort.c 2013-08-14 18:13:30.295247905 +0200
+--- coreutils-8.21-orig/src/sort.c 2013-01-31 01:46:24.000000000 +0100
++++ coreutils-8.21/src/sort.c 2014-01-03 06:32:46.599049625 +0100
@@ -29,6 +29,14 @@
#include <sys/wait.h>
#include <signal.h>
@@ -2446,12 +2446,17 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
#include "system.h"
#include "argmatch.h"
#include "error.h"
-@@ -166,12 +174,34 @@ static int thousands_sep;
+@@ -164,14 +172,39 @@ static int decimal_point;
+ /* Thousands separator; if -1, then there isn't one. */
+ static int thousands_sep;
++/* True if -f is specified. */
++static bool folding;
++
/* Nonzero if the corresponding locales are hard. */
static bool hard_LC_COLLATE;
-+#if HAVE_LANGINFO_CODESET
-#if HAVE_NL_LANGINFO
++#if HAVE_LANGINFO_CODESET
static bool hard_LC_TIME;
#endif
@@ -2482,24 +2487,24 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
/* The kind of blanks for '-b' to skip in various options. */
enum blanktype { bl_start, bl_end, bl_both };
-@@ -345,13 +375,11 @@ static bool reverse;
+@@ -345,13 +378,11 @@ static bool reverse;
they were read if all keys compare equal. */
static bool stable;
-+/* Tab character separating fields. If tab_length is 0, then fields are
-/* If TAB has this value, blanks separate fields. */
-enum { TAB_DEFAULT = CHAR_MAX + 1 };
-
-/* Tab character separating fields. If TAB_DEFAULT, then fields are
++/* Tab character separating fields. If tab_length is 0, then fields are
separated by the empty string between a non-blank character and a blank
character. */
+-static int tab = TAB_DEFAULT;
+static char tab[MB_LEN_MAX + 1];
+static size_t tab_length = 0;
--static int tab = TAB_DEFAULT;
/* Flag to remove consecutive duplicate lines from the output.
Only the last of a sequence of equal lines will be output. */
-@@ -783,6 +811,46 @@ reap_all (void)
+@@ -783,6 +814,46 @@ reap_all (void)
reap (-1);
}
@@ -2546,34 +2551,34 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
/* Clean up any remaining temporary files. */
static void
-@@ -1223,7 +1291,7 @@ zaptemp (char const *name)
+@@ -1223,7 +1294,7 @@ zaptemp (char const *name)
free (node);
}
-+#if HAVE_LANGINFO_CODESET
-#if HAVE_NL_LANGINFO
++#if HAVE_LANGINFO_CODESET
static int
struct_month_cmp (void const *m1, void const *m2)
-@@ -1238,7 +1306,7 @@ struct_month_cmp (void const *m1, void c
+@@ -1238,7 +1309,7 @@ struct_month_cmp (void const *m1, void c
/* Initialize the character class tables. */
static void
-+inittables_uni (void)
-inittables (void)
++inittables_uni (void)
{
size_t i;
-@@ -1250,7 +1318,7 @@ inittables_uni (void)
+@@ -1250,7 +1321,7 @@ inittables (void)
fold_toupper[i] = toupper (i);
}
-+#if HAVE_LANGINFO_CODESET
-#if HAVE_NL_LANGINFO
++#if HAVE_LANGINFO_CODESET
/* If we're not in the "C" locale, read different names for months. */
if (hard_LC_TIME)
{
-@@ -1332,6 +1400,84 @@ specify_nmerge (int oi, char c, char con
+@@ -1332,6 +1403,84 @@ specify_nmerge (int oi, char c, char con
xstrtol_fatal (e, oi, c, long_options, s);
}
@@ -2658,29 +2663,29 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
/* Specify the amount of main memory to use when sorting. */
static void
specify_sort_size (int oi, char c, char const *s)
-@@ -1564,7 +1710,7 @@ buffer_linelim (struct buffer const *buf
+@@ -1564,7 +1713,7 @@ buffer_linelim (struct buffer const *buf
by KEY in LINE. */
static char *
-+begfield_uni (const struct line *line, const struct keyfield *key)
-begfield (struct line const *line, struct keyfield const *key)
++begfield_uni (const struct line *line, const struct keyfield *key)
{
char *ptr = line->text, *lim = ptr + line->length - 1;
size_t sword = key->sword;
-@@ -1573,10 +1719,10 @@ begfield_uni (const struct line *line, c
+@@ -1573,10 +1722,10 @@ begfield (struct line const *line, struc
/* The leading field separator itself is included in a field when -t
is absent. */
-+ if (tab_length)
- if (tab != TAB_DEFAULT)
++ if (tab_length)
while (ptr < lim && sword--)
{
-+ while (ptr < lim && *ptr != tab[0])
- while (ptr < lim && *ptr != tab)
++ while (ptr < lim && *ptr != tab[0])
++ptr;
if (ptr < lim)
++ptr;
-@@ -1602,11 +1748,70 @@ begfield_uni (const struct line *line, c
+@@ -1602,11 +1751,70 @@ begfield (struct line const *line, struc
return ptr;
}
@@ -2747,38 +2752,38 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
in LINE specified by KEY. */
static char *
-+limfield_uni (const struct line *line, const struct keyfield *key)
-limfield (struct line const *line, struct keyfield const *key)
++limfield_uni (const struct line *line, const struct keyfield *key)
{
char *ptr = line->text, *lim = ptr + line->length - 1;
size_t eword = key->eword, echar = key->echar;
-@@ -1621,10 +1826,10 @@ limfield_uni (const struct line *line, c
+@@ -1621,10 +1829,10 @@ limfield (struct line const *line, struc
'beginning' is the first character following the delimiting TAB.
Otherwise, leave PTR pointing at the first 'blank' character after
the preceding field. */
-+ if (tab_length)
- if (tab != TAB_DEFAULT)
++ if (tab_length)
while (ptr < lim && eword--)
{
-+ while (ptr < lim && *ptr != tab[0])
- while (ptr < lim && *ptr != tab)
++ while (ptr < lim && *ptr != tab[0])
++ptr;
if (ptr < lim && (eword || echar))
++ptr;
-@@ -1670,10 +1875,10 @@ limfield_uni (const struct line *line, c
+@@ -1670,10 +1878,10 @@ limfield (struct line const *line, struc
*/
/* Make LIM point to the end of (one byte past) the current field. */
-+ if (tab_length)
- if (tab != TAB_DEFAULT)
++ if (tab_length)
{
char *newlim;
-+ newlim = memchr (ptr, tab[0], lim - ptr);
- newlim = memchr (ptr, tab, lim - ptr);
++ newlim = memchr (ptr, tab[0], lim - ptr);
if (newlim)
lim = newlim;
}
-@@ -1704,6 +1909,130 @@ limfield_uni (const struct line *line, c
+@@ -1704,6 +1912,130 @@ limfield (struct line const *line, struc
return ptr;
}
@@ -2909,10 +2914,12 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
/* Fill BUF reading from FP, moving buf->left bytes from the end
of buf->buf to the beginning first. If EOF is reached and the
file wasn't terminated by a newline, supply one. Set up BUF's line
-@@ -1790,8 +2119,22 @@ fillbuf (struct buffer *buf, FILE *fp, c
+@@ -1790,8 +2122,22 @@ fillbuf (struct buffer *buf, FILE *fp, c
else
{
if (key->skipsblanks)
+- while (blanks[to_uchar (*line_start)])
+- line_start++;
+ {
+#if HAVE_MBRTOWC
+ if (MB_CUR_MAX > 1)
@@ -2929,21 +2936,19 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
+ while (blanks[to_uchar (*line_start)])
+ line_start++;
+ }
-- while (blanks[to_uchar (*line_start)])
-- line_start++;
line->keybeg = line_start;
}
}
-@@ -1912,7 +2255,7 @@ human_numcompare (char const *a, char co
+@@ -1912,7 +2258,7 @@ human_numcompare (char const *a, char co
hideously fast. */
static int
-+numcompare_uni (const char *a, const char *b)
-numcompare (char const *a, char const *b)
++numcompare_uni (const char *a, const char *b)
{
while (blanks[to_uchar (*a)])
a++;
-@@ -1922,6 +2265,25 @@ numcompare_uni (const char *a, const cha
+@@ -1922,6 +2268,25 @@ numcompare (char const *a, char const *b
return strnumcmp (a, b, decimal_point, thousands_sep);
}
@@ -2969,43 +2974,43 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
/* Work around a problem whereby the long double value returned by glibc's
strtold ("NaN", ...) contains uninitialized bits: clear all bytes of
A and B before calling strtold. FIXME: remove this function once
-@@ -1972,7 +2334,7 @@ general_numcompare (char const *sa, char
+@@ -1972,7 +2337,7 @@ general_numcompare (char const *sa, char
Return 0 if the name in S is not recognized. */
static int
-+getmonth_uni (char const *month, size_t len, char **ea)
-getmonth (char const *month, char **ea)
++getmonth_uni (char const *month, size_t len, char **ea)
{
size_t lo = 0;
size_t hi = MONTHS_PER_YEAR;
-@@ -2247,15 +2609,14 @@ debug_key (struct line const *line, stru
+@@ -2247,15 +2612,14 @@ debug_key (struct line const *line, stru
char saved = *lim;
*lim = '\0';
-+ skipblanks (&beg, lim);
- while (blanks[to_uchar (*beg)])
- beg++;
++ skipblanks (&beg, lim);
char *tighter_lim = beg;
if (lim < beg)
tighter_lim = lim;
else if (key->month)
-+ getmonth (beg, lim-beg, &tighter_lim);
- getmonth (beg, &tighter_lim);
++ getmonth (beg, lim-beg, &tighter_lim);
else if (key->general_numeric)
ignore_value (strtold (beg, &tighter_lim));
else if (key->numeric || key->human_numeric)
-@@ -2399,7 +2760,7 @@ key_warnings (struct keyfield const *gke
+@@ -2399,7 +2763,7 @@ key_warnings (struct keyfield const *gke
bool maybe_space_aligned = !hard_LC_COLLATE && default_key_compare (key)
&& !(key->schar || key->echar);
bool line_offset = key->eword == 0 && key->echar != 0; /* -k1.x,1.y */
-+ if (!gkey_only && !tab_length && !line_offset
- if (!gkey_only && tab == TAB_DEFAULT && !line_offset
++ if (!gkey_only && !tab_length && !line_offset
&& ((!key->skipsblanks && !(implicit_skip || maybe_space_aligned))
|| (!key->skipsblanks && key->schar)
|| (!key->skipeblanks && key->echar)))
-@@ -2457,11 +2818,87 @@ key_warnings (struct keyfield const *gke
+@@ -2457,11 +2821,87 @@ key_warnings (struct keyfield const *gke
error (0, 0, _("option '-r' only applies to last-resort comparison"));
}
@@ -3089,21 +3094,21 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
are no more keys or a difference is found. */
static int
-+keycompare_uni (const struct line *a, const struct line *b)
-keycompare (struct line const *a, struct line const *b)
++keycompare_uni (const struct line *a, const struct line *b)
{
struct keyfield *key = keylist;
-@@ -2546,7 +2983,7 @@ keycompare_uni (const struct line *a, co
+@@ -2546,7 +2986,7 @@ keycompare (struct line const *a, struct
else if (key->human_numeric)
diff = human_numcompare (ta, tb);
else if (key->month)
-+ diff = getmonth (ta, tlena, NULL) - getmonth (tb, tlenb, NULL);
- diff = getmonth (ta, NULL) - getmonth (tb, NULL);
++ diff = getmonth (ta, tlena, NULL) - getmonth (tb, tlenb, NULL);
else if (key->random)
diff = compare_random (ta, tlena, tb, tlenb);
else if (key->version)
-@@ -2662,6 +3099,191 @@ keycompare_uni (const struct line *a, co
+@@ -2662,6 +3102,191 @@ keycompare (struct line const *a, struct
return key->reverse ? -diff : diff;
}
@@ -3295,31 +3300,33 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
/* Compare two lines A and B, returning negative, zero, or positive
depending on whether A compares less than, equal to, or greater than B. */
-@@ -2689,14 +3311,6 @@ compare (struct line const *a, struct li
+@@ -2689,7 +3314,7 @@ compare (struct line const *a, struct li
diff = - NONZERO (blen);
else if (blen == 0)
diff = 1;
- else if (hard_LC_COLLATE)
-- {
-- /* Note xmemcoll0 is a performance enhancement as
-- it will not unconditionally write '\0' after the
-- passed in buffers, which was seen to give around
-- a 3% increase in performance for short lines. */
-- diff = xmemcoll0 (a->text, alen + 1, b->text, blen + 1);
-- }
- else if (! (diff = memcmp (a->text, b->text, MIN (alen, blen))))
- diff = alen < blen ? -1 : alen != blen;
-
-@@ -4157,7 +4771,7 @@ main (int argc, char **argv)
++ else if (hard_LC_COLLATE && !folding)
+ {
+ /* Note xmemcoll0 is a performance enhancement as
+ it will not unconditionally write '\0' after the
+@@ -4079,6 +4704,7 @@ set_ordering (char const *s, struct keyf
+ key->ignore = nondictionary;
+ break;
+ case 'f':
++ folding = true;
+ key->translate = fold_toupper;
+ break;
+ case 'g':
+@@ -4157,7 +4783,7 @@ main (int argc, char **argv)
initialize_exit_failure (SORT_FAILURE);
hard_LC_COLLATE = hard_locale (LC_COLLATE);
-+#if HAVE_LANGINFO_CODESET
-#if HAVE_NL_LANGINFO
++#if HAVE_LANGINFO_CODESET
hard_LC_TIME = hard_locale (LC_TIME);
#endif
-@@ -4178,6 +4792,29 @@ main (int argc, char **argv)
+@@ -4178,6 +4804,29 @@ main (int argc, char **argv)
thousands_sep = -1;
}
@@ -3349,17 +3356,18 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
have_read_stdin = false;
inittables ();
-@@ -4452,13 +5089,34 @@ main (int argc, char **argv)
+@@ -4452,13 +5101,34 @@ main (int argc, char **argv)
case 't':
{
+- char newtab = optarg[0];
+- if (! newtab)
+ char newtab[MB_LEN_MAX + 1];
+ size_t newtab_length = 1;
+ strncpy (newtab, optarg, MB_LEN_MAX);
+ if (! newtab[0])
-- char newtab = optarg[0];
-- if (! newtab)
error (SORT_FAILURE, 0, _("empty tab"));
+- if (optarg[1])
+#if HAVE_MBRTOWC
+ if (MB_CUR_MAX > 1)
+ {
@@ -3380,26 +3388,25 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
+ }
+#endif
+ if (newtab_length == 1 && optarg[1])
-- if (optarg[1])
{
if (STREQ (optarg, "\\0"))
-+ newtab[0] = '\0';
- newtab = '\0';
++ newtab[0] = '\0';
else
{
/* Provoke with 'sort -txx'. Complain about
-@@ -4469,9 +5127,12 @@ main (int argc, char **argv)
+@@ -4469,9 +5139,12 @@ main (int argc, char **argv)
quote (optarg));
}
}
+- if (tab != TAB_DEFAULT && tab != newtab)
+ if (tab_length
+ && (tab_length != newtab_length
+ || memcmp (tab, newtab, tab_length) != 0))
-- if (tab != TAB_DEFAULT && tab != newtab)
error (SORT_FAILURE, 0, _("incompatible tabs"));
+- tab = newtab;
+ memcpy (tab, newtab, newtab_length);
+ tab_length = newtab_length;
-- tab = newtab;
}
break;
diff --git a/coreutils.spec b/coreutils.spec
index bb9c1ee..26872e0 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.21
-Release: 18%{?dist}
+Release: 19%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/
@@ -375,6 +375,9 @@ fi
%{_sbindir}/chroot
%changelog
+* Fri Jan 03 2014 Ondrej Oprala <ooprala at redhat.com> 8.21-19
+- reverted an old change and constricted it's condition
+
* Thu Aug 15 2013 Ondrej Vasik <ovasik at redhat.com> 8.21-18
- pr -e, with a mix of backspaces and TABs, could corrupt the heap
in multibyte locales (analyzed by J.Koncicky)
More information about the scm-commits
mailing list