Compare commits

...

12 Commits
rawhide ... f20

Author SHA1 Message Date
Kamil Dudka 48f014bf39 fix occasional assertion failure of gnulib tests
... that check ctime
2015-05-14 18:27:02 +02:00
Ondrej Oprala a2e0798d1e sort - fix buffer overflow in some case conversions
- patch by Pádraig Brady
2015-05-14 16:59:43 +02:00
Pádraig Brady 7f8c3ba1de sync/adjust LS_COLORS
* coreutils-DIR_COLORS: sync with upstream
(remove old Xiph formats, add m4a audio format).
* coreutils-DIR_COLORS.256color: Likewise.
Also sync with 8 color mode above, by removing
the specific MULTIHARDLINK coloring, and
giving MISSING symlink targets a red background.
Also lighten the DIR and EXEC color a little
(as discussed in bug 1196642)
* coreutils-DIR_COLORS.lightbgcolor: Sync terminal
types with other 2 databases above.
2015-05-14 16:24:54 +02:00
Peter Robinson 413639da53 drop ChangeLog (covered in enough detail in news for averge users), drop ancient docs 2015-05-14 16:22:50 +02:00
Ondřej Vašík 52eebeada4 have the LC_TIME subdirs with lang macro (#1169027) 2015-05-14 16:20:09 +02:00
Ondřej Vašík d74d45106d handle situation with ro /tmp in colorls scripts (#1149761) 2015-05-14 16:18:24 +02:00
Ondřej Vašík a3ce470478 fix the sorting in multibyte locales (NUL-terminate sort keys) - patch by Andreas Schwab (#1146185) 2015-05-14 16:14:54 +02:00
Jakub Čajka 930932b82e Fixed gnulib tests on ppc64(le) 2015-05-14 16:05:18 +02:00
Ondřej Vašík 505bcfb22f fix the date crash or infloop in TZ= parsing (#1069657), colorls - unset unnecessary envvars and fix issue with noclobber set 2014-03-05 13:39:16 +01:00
Ondřej Vašík e606f563b8 ln: --relative: fix updating of existing symlinks (#1072103, from upstream) 2014-03-05 13:28:42 +01:00
Ondrej Oprala 46a2c86062 Fix sorting by non-first field (#1003544) 2014-01-06 11:52:48 +01:00
Ondrej Oprala 8e09f222b7 reverted an old change and constricted it's condition 2014-01-03 06:46:34 +01:00
11 changed files with 954 additions and 117 deletions

View File

@ -0,0 +1,183 @@
From 60a155ed296dbeb5fad69a9611e7f5959f99902b Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Thu, 14 May 2015 18:22:34 +0200
Subject: [PATCH] gnulib-tests/nap.h: update from coreutils-8.22
---
gnulib-tests/nap.h | 137 +++++++++++++++++++++++++++++++----------------------
1 file changed, 81 insertions(+), 56 deletions(-)
diff --git a/gnulib-tests/nap.h b/gnulib-tests/nap.h
index 342a70c..229e4d3 100644
--- a/gnulib-tests/nap.h
+++ b/gnulib-tests/nap.h
@@ -19,19 +19,37 @@
#ifndef GLTEST_NAP_H
# define GLTEST_NAP_H
+# include <limits.h>
+# include <stdbool.h>
+
+/* File descriptor used for the witness file. */
+static int nap_fd = -1;
+
+/* Return A - B, in ns.
+ Return 0 if the true result would be negative.
+ Return INT_MAX if the true result would be greater than INT_MAX. */
static int
-lt_mtime (struct stat const *a, struct stat const *b)
+diff_timespec (struct timespec a, struct timespec b)
{
- time_t as = a->st_mtime;
- time_t bs = b->st_mtime;
- int ans = get_stat_mtime_ns (a);
- int bns = get_stat_mtime_ns (b);
+ time_t as = a.tv_sec;
+ time_t bs = b.tv_sec;
+ int ans = a.tv_nsec;
+ int bns = b.tv_nsec;
- return as < bs || (as == bs && ans < bns);
+ if (! (bs < as || (bs == as && bns < ans)))
+ return 0;
+ if (as - bs <= INT_MAX / 1000000000)
+ {
+ int sdiff = (as - bs) * 1000000000;
+ int usdiff = ans - bns;
+ if (usdiff < INT_MAX - sdiff)
+ return sdiff + usdiff;
+ }
+ return INT_MAX;
}
static void
-get_mtime (int fd, struct stat *st, int do_write)
+get_stat (int fd, struct stat *st, int do_write)
{
if (do_write)
ASSERT (write (fd, "\n", 1) == 1);
@@ -39,65 +57,72 @@ get_mtime (int fd, struct stat *st, int do_write)
}
/* Given a file whose descriptor is FD, see whether delaying by DELAY
- microseconds causes a change in a file's time stamp. If the time
- stamps differ, repeat the test one more time, in case we crossed a
- quantization boundary on a file system with lower resolution. *ST
- is the file's status, recently gotten. Update *ST to reflect the
- latest status gotten. */
-static int
-nap_works (int fd, int delay, struct stat *st)
+ nanoseconds causes a change in a file's ctime and mtime.
+ OLD_ST is the file's status, recently gotten. */
+static bool
+nap_works (int fd, int delay, struct stat old_st)
{
- struct stat old_st;
- old_st = *st;
- usleep (delay);
- get_mtime (fd, st, 1);
- if (! lt_mtime (&old_st, st))
- return 0;
- old_st = *st;
- usleep (delay);
- get_mtime (fd, st, 1);
- return lt_mtime (&old_st, st);
+ struct stat st;
+ struct timespec delay_spec;
+ delay_spec.tv_sec = delay / 1000000000;
+ delay_spec.tv_nsec = delay % 1000000000;
+ ASSERT (nanosleep (&delay_spec, 0) == 0);
+ get_stat (fd, &st, 1);
+
+ if ( diff_timespec (get_stat_ctime (&st), get_stat_ctime (&old_st))
+ && diff_timespec (get_stat_mtime (&st), get_stat_mtime (&old_st)))
+ return true;
+
+ return false;
}
-static int
-guess_delay (void)
+#define TEMPFILE BASE "nap.tmp"
+
+static void
+clear_temp_file (void)
{
- /* Try a 1-microsecond sleep first, for speed. If that doesn't
- work, try a 1 ms sleep; that should work with ext. If it doesn't
- work, try a 20 ms sleep. xfs has a quantization of about 10
- milliseconds, even though it has a granularity of 1 nanosecond,
- and NTFS has a default quantization of 15.25 milliseconds, even
- though it has a granularity of 100 nanoseconds, so 20 ms is a
- good quantization to try. If that doesn't work, try 1 second.
- The worst case is 2 seconds, needed for FAT. */
- static int const delaytab[] = {1, 1000, 20000, 1000000 };
- int fd = creat (BASE "tmp", 0600);
- int i;
- int delay = 2000000;
- struct stat st;
- ASSERT (0 <= fd);
- get_mtime (fd, &st, 0);
- for (i = 0; i < sizeof delaytab / sizeof delaytab[0]; i++)
- if (nap_works (fd, delaytab[i], &st))
- {
- delay = delaytab[i];
- break;
- }
- ASSERT (close (fd) == 0);
- ASSERT (unlink (BASE "tmp") == 0);
- return delay;
+ if (0 <= nap_fd)
+ {
+ ASSERT (close (nap_fd) != -1);
+ ASSERT (unlink (TEMPFILE) != -1);
+ }
}
/* Sleep long enough to notice a timestamp difference on the file
- system in the current directory. Assumes that BASE is defined,
- and requires that the test module depends on usleep. */
+ system in the current directory. Use an adaptive approach, trying
+ to find the smallest delay which works on the current file system
+ to make the timestamp difference appear. Assert a maximum delay of
+ ~2 seconds, more precisely sum(2^n) from 0 to 30 = 2^31 - 1 = 2.1s.
+ Assumes that BASE is defined, and requires that the test module
+ depends on nanosleep. */
static void
nap (void)
{
- static int delay;
- if (!delay)
- delay = guess_delay ();
- usleep (delay);
+ struct stat old_st;
+ static int delay = 1;
+
+ if (-1 == nap_fd)
+ {
+ atexit (clear_temp_file);
+ ASSERT ((nap_fd = creat (TEMPFILE, 0600)) != -1);
+ get_stat (nap_fd, &old_st, 0);
+ }
+ else
+ {
+ ASSERT (0 <= nap_fd);
+ get_stat (nap_fd, &old_st, 1);
+ }
+
+ if (1 < delay)
+ delay = delay / 2; /* Try half of the previous delay. */
+ ASSERT (0 < delay);
+
+ for ( ; delay <= 2147483647; delay = delay * 2)
+ if (nap_works (nap_fd, delay, old_st))
+ return;
+
+ /* Bummer: even the highest nap delay didn't work. */
+ ASSERT (0);
}
#endif /* GLTEST_NAP_H */
--
2.4.0

View File

@ -0,0 +1,71 @@
From e52293aa7fcf283758f97bc9bcc945707ccbce0a Mon Sep 17 00:00:00 2001
From: =?utf8?q?R=C3=A9my=20Lefevre?= <lefevreremy@gmail.com>
Date: Tue, 2 Apr 2013 02:48:28 +0100
Subject: [PATCH 1/1] ln: --relative: fix updating of existing symlinks
Don't dereference an existing symlink being replaced.
I.E. generate the symlink relative to the symlink's containing dir,
rather than to some arbitrary place it points to.
* src/ln.c (convert_abs_rel): Don't consider the final component
of the symlink name when canonicalizing, as we want to avoid
dereferencing the final component.
* tests/ln/relative.sh: Add a test case.
Resolves http://bugs.gnu.org/14116
---
src/ln.c | 14 ++++++++------
tests/ln/relative.sh | 5 +++++
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/ln.c b/src/ln.c
index 1aa1473..2489b9a 100644
--- a/src/ln.c
+++ b/src/ln.c
@@ -132,22 +132,24 @@ target_directory_operand (char const *file)
static char *
convert_abs_rel (const char *from, const char *target)
{
- char *realtarget = canonicalize_filename_mode (target, CAN_MISSING);
+ /* Get dirname to generate paths relative to. We don't resolve
+ the full TARGET as the last component could be an existing symlink. */
+ char *targetdir = dir_name (target);
+
+ char *realdest = canonicalize_filename_mode (targetdir, CAN_MISSING);
char *realfrom = canonicalize_filename_mode (from, CAN_MISSING);
/* Write to a PATH_MAX buffer. */
char *relative_from = xmalloc (PATH_MAX);
- /* Get dirname to generate paths relative to. */
- realtarget[dir_len (realtarget)] = '\0';
-
- if (!relpath (realfrom, realtarget, relative_from, PATH_MAX))
+ if (!relpath (realfrom, realdest, relative_from, PATH_MAX))
{
free (relative_from);
relative_from = NULL;
}
- free (realtarget);
+ free (targetdir);
+ free (realdest);
free (realfrom);
return relative_from ? relative_from : xstrdup (from);
diff --git a/tests/ln/relative.sh b/tests/ln/relative.sh
index 0418b8a..818da83 100755
--- a/tests/ln/relative.sh
+++ b/tests/ln/relative.sh
@@ -29,4 +29,9 @@ test $(readlink usr/bin/foo) = '../lib/foo/foo' || fail=1
ln -sr usr/bin/foo usr/lib/foo/link-to-foo
test $(readlink usr/lib/foo/link-to-foo) = 'foo' || fail=1
+# Correctly update an existing link, which was broken in <= 8.21
+ln -s dir1/dir2/f existing_link
+ln -srf here existing_link
+test $(readlink existing_link) = 'here' || fail=1
+
Exit $fail
--
1.7.2.5

View File

@ -0,0 +1,67 @@
diff -urNp coreutils-8.22-orig/gnulib-tests/test-parse-datetime.c coreutils-8.22/gnulib-tests/test-parse-datetime.c
--- coreutils-8.22-orig/gnulib-tests/test-parse-datetime.c 2013-12-04 15:53:33.000000000 +0100
+++ coreutils-8.22/gnulib-tests/test-parse-datetime.c 2014-03-02 20:33:25.691688592 +0100
@@ -419,5 +419,21 @@ main (int argc _GL_UNUSED, char **argv)
starting with a high-bit-set byte would be treated like "0". */
ASSERT ( ! parse_datetime (&result, "\xb0", &now));
+ /* Exercise TZ="" parsing code. */
+ /* These two would infloop or segfault before Feb 2014. */
+ ASSERT ( ! parse_datetime (&result, "TZ=\"\"\"", &now));
+ ASSERT ( ! parse_datetime (&result, "TZ=\"\" \"", &now));
+ /* Exercise invalid patterns. */
+ ASSERT ( ! parse_datetime (&result, "TZ=\"", &now));
+ ASSERT ( ! parse_datetime (&result, "TZ=\"\\\"", &now));
+ ASSERT ( ! parse_datetime (&result, "TZ=\"\\n", &now));
+ ASSERT ( ! parse_datetime (&result, "TZ=\"\\n\"", &now));
+ /* Exercise valid patterns. */
+ ASSERT ( parse_datetime (&result, "TZ=\"\"", &now));
+ ASSERT ( parse_datetime (&result, "TZ=\"\" ", &now));
+ ASSERT ( parse_datetime (&result, " TZ=\"\"", &now));
+ ASSERT ( parse_datetime (&result, "TZ=\"\\\\\"", &now));
+ ASSERT ( parse_datetime (&result, "TZ=\"\\\"\"", &now));
+
return 0;
}
diff -urNp coreutils-8.22-orig/lib/parse-datetime.y coreutils-8.22/lib/parse-datetime.y
--- coreutils-8.22-orig/lib/parse-datetime.y 2013-12-04 15:53:33.000000000 +0100
+++ coreutils-8.22/lib/parse-datetime.y 2014-03-02 20:32:23.246124920 +0100
@@ -1303,8 +1303,6 @@ parse_datetime (struct timespec *result,
char tz1buf[TZBUFSIZE];
bool large_tz = TZBUFSIZE < tzsize;
bool setenv_ok;
- /* Free tz0, in case this is the 2nd or subsequent time through. */
- free (tz0);
tz0 = get_tz (tz0buf);
z = tz1 = large_tz ? xmalloc (tzsize) : tz1buf;
for (s = tzbase; *s != '"'; s++)
@@ -1316,7 +1314,12 @@ parse_datetime (struct timespec *result,
if (!setenv_ok)
goto fail;
tz_was_altered = true;
+
p = s + 1;
+ while (c = *p, c_isspace (c))
+ p++;
+
+ break;
}
}
diff -urNp coreutils-8.22-orig/tests/misc/date.pl coreutils-8.22/tests/misc/date.pl
--- coreutils-8.22-orig/tests/misc/date.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/misc/date.pl 2014-03-02 20:30:43.200328295 +0100
@@ -287,6 +287,13 @@ my @Tests =
{ERR => "date: invalid date '\\260'\n"},
{EXIT => 1},
],
+
+ # From coreutils-5.3.0 to 8.22 inclusive
+ # this would either infinite loop or crash
+ ['invalid-TZ-crash', "-d 'TZ=\"\"\"'",
+ {ERR => "date: invalid date 'TZ=\"\"\"'\n"},
+ {EXIT => 1},
+ ],
);
# Repeat the cross-dst test, using Jan 1, 2005 and every interval from 1..364.

View File

@ -80,11 +80,11 @@ EIGHTBIT 1
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
#NORMAL 00 # no color code at all
#FILE 00 # normal file, use no color at all
RESET 0 # reset to "normal" color
RESET 0 # reset to "normal" color
DIR 01;34 # directory
LINK 01;36 # symbolic link (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointed to.)
MULTIHARDLINK 00 # regular file with more than one link
MULTIHARDLINK 00 # regular file with more than one link
FIFO 40;33 # pipe
SOCK 01;35 # socket
DOOR 01;35 # door
@ -203,8 +203,6 @@ EXEC 01;32
.emf 01;35
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
.axv 01;35
.anx 01;35
.ogv 01;35
.ogx 01;35
@ -212,6 +210,7 @@ EXEC 01;32
.aac 01;36
.au 01;36
.flac 01;36
.m4a 01;36
.mid 01;36
.midi 01;36
.mka 01;36
@ -222,8 +221,8 @@ EXEC 01;32
.wav 01;36
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
.axa 01;36
.oga 01;36
.opus 01;36
.spx 01;36
.xspf 01;36

View File

@ -54,17 +54,17 @@ EIGHTBIT 1
#NORMAL 00 # global default, no color code at all
#FILE 00 # normal file, use no color at all
RESET 0 # reset to "normal" color
DIR 38;5;27 # directory
DIR 38;5;33 # directory
LINK 38;5;51 # symbolic link (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointed to.)
MULTIHARDLINK 44;38;5;15 # regular file with more than one link
MULTIHARDLINK 00 # regular file with more than one link
FIFO 40;38;5;11 # pipe
SOCK 38;5;13 # socket
DOOR 38;5;5 # door
BLK 48;5;232;38;5;11 # block device driver
CHR 48;5;232;38;5;3 # character device driver
ORPHAN 48;5;232;38;5;9 # symlink to nonexistent file, or non-stat'able file
MISSING 05;48;5;232;38;5;15 # ... and the files they point to
MISSING 01;05;37;41 # ... and the files they point to
SETUID 48;5;196;38;5;15 # file that is setuid (u+s)
SETGID 48;5;11;38;5;16 # file that is setgid (g+s)
CAPABILITY 48;5;196;38;5;226 # file with capability
@ -73,7 +73,7 @@ OTHER_WRITABLE 48;5;10;38;5;21 # dir that is other-writable (o+w) and not sticky
STICKY 48;5;21;38;5;15 # dir with the sticky bit set (+t) and not other-writable
# This is for files with execute permission:
EXEC 38;5;34
EXEC 38;5;40
# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
@ -176,8 +176,6 @@ EXEC 38;5;34
.emf 38;5;13
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
.axv 38;5;13
.anx 38;5;13
.ogv 38;5;13
.ogx 38;5;13
@ -185,6 +183,7 @@ EXEC 38;5;34
.aac 38;5;45
.au 38;5;45
.flac 38;5;45
.m4a 38;5;45
.mid 38;5;45
.midi 38;5;45
.mka 38;5;45
@ -195,8 +194,8 @@ EXEC 38;5;34
.wav 38;5;45
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
.axa 38;5;45
.oga 38;5;45
.opus 38;5;45
.spx 38;5;45
.xspf 38;5;45

View File

@ -1,4 +1,4 @@
# Configuration file for the color ls utility - modified for gray backgrounds
# Configuration file for the color ls utility - modified for lighter backgrounds
# Synchronized with coreutils 8.5 dircolors
# This file goes in the /etc directory, and must be world readable.
# You can copy this file to .dir_colors in your $HOME directory to override
@ -16,8 +16,9 @@ COLOR tty
OPTIONS -F -T 0
# Below, there should be one TERM entry for each termtype that is colorizable
TERM linux
TERM console
TERM Eterm
TERM ansi
TERM color-xterm
TERM con132x25
TERM con132x30
TERM con132x43
@ -29,20 +30,46 @@ TERM con80x43
TERM con80x50
TERM con80x60
TERM cons25
TERM xterm
TERM xterm-16color
TERM xterm-88color
TERM xterm-256color
TERM console
TERM cygwin
TERM dtterm
TERM eterm-color
TERM gnome
TERM gnome-256color
TERM jfbterm
TERM konsole
TERM kterm
TERM linux
TERM linux-c
TERM mach-color
TERM mlterm
TERM putty
TERM putty-256color
TERM rxvt
TERM rxvt-256color
TERM rxvt-cygwin
TERM rxvt-cygwin-native
TERM rxvt-unicode
TERM rxvt-unicode-256color
TERM rxvt-unicode256
TERM xterm-color
TERM color-xterm
TERM screen
TERM screen-256color
TERM screen-256color-bce
TERM screen-bce
TERM screen-w
TERM screen.Eterm
TERM screen.rxvt
TERM screen.linux
TERM st
TERM st-256color
TERM terminator
TERM vt100
TERM dtterm
TERM color_xterm
TERM xterm
TERM xterm-16color
TERM xterm-256color
TERM xterm-88color
TERM xterm-color
TERM xterm-debian
# EIGHTBIT, followed by '1' for on, '0' for off. (8-bit output)
EIGHTBIT 1
@ -57,7 +84,7 @@ EIGHTBIT 1
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
#NORMAL 00 # no color code at all
#FILE 00 # normal file, use no color at all
RESET 0
RESET 0 # reset to "normal" color
DIR 00;34 # directory
LINK 00;36 # symbolic link (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointed to.)
@ -76,7 +103,6 @@ STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
# This is for files with execute permission:
EXEC 00;32
@ -180,8 +206,6 @@ EXEC 00;32
.emf 00;35
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
.axv 00;35
.anx 00;35
.ogv 00;35
.ogx 00;35
@ -189,6 +213,7 @@ EXEC 00;32
.aac 00;36
.au 00;36
.flac 00;36
.m4a 00;36
.mid 00;36
.midi 00;36
.mka 00;36
@ -199,8 +224,8 @@ EXEC 00;32
.wav 00;36
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
.axa 00;36
.oga 00;36
.opus 00;36
.spx 00;36
.xspf 00;36

View File

@ -31,9 +31,16 @@ set INCLUDE="`cat "$COLORS" | grep '^INCLUDE' | cut -d ' ' -f2-`"
if ( ! -e "$COLORS" ) exit
set _tmp="`mktemp .colorlsXXX --tmpdir=/tmp`"
set _tmp="`mktemp .colorlsXXX -q --tmpdir=/tmp`"
#if mktemp fails, exit when include was active, otherwise use $COLORS file
if ( "$_tmp" == '' ) then
if ( "$INCLUDE" == '' ) then
eval "`dircolors -c $COLORS`"
endif
goto cleanup
endif
if ( "$INCLUDE" != '' ) cat "$INCLUDE" > $_tmp
if ( "$INCLUDE" != '' ) cat "$INCLUDE" >> $_tmp
grep -v '^INCLUDE' "$COLORS" >> $_tmp
eval "`dircolors -c $_tmp`"
@ -41,6 +48,7 @@ eval "`dircolors -c $_tmp`"
rm -f $_tmp
if ( "$LS_COLORS" == '' ) exit
cleanup:
set color_none=`sed -n '/^COLOR.*none/Ip' < $COLORS`
if ( "$color_none" != '' ) then
unset color_none
@ -48,6 +56,8 @@ if ( "$color_none" != '' ) then
endif
unset color_none
unset _tmp
unset INCLUDE
unset COLORS
finish:
alias ll 'ls -l --color=auto'

View File

@ -33,19 +33,26 @@ if [ -z "$USER_LS_COLORS" ]; then
# Existence of $COLORS already checked above.
[ -n "$COLORS" ] || return
TMP="`mktemp .colorlsXXX --tmpdir=/tmp`"
if [ -e "$INCLUDE" ];
then
TMP="`mktemp .colorlsXXX -q --tmpdir=/tmp`"
[ -z "$TMP" ] && return
[ -e "$INCLUDE" ] && cat "$INCLUDE" > $TMP
grep -v '^INCLUDE' "$COLORS" >> $TMP
cat "$INCLUDE" >> $TMP
grep -v '^INCLUDE' "$COLORS" >> $TMP
eval "`dircolors --sh $TMP 2>/dev/null`"
rm -f $TMP
eval "`dircolors --sh $TMP 2>/dev/null`"
rm -f $TMP
else
eval "`dircolors --sh $COLORS 2>/dev/null`"
fi
[ -z "$LS_COLORS" ] && return
grep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null && return
fi
unset TMP COLORS INCLUDE
alias ll='ls -l --color=auto' 2>/dev/null
alias l.='ls -d .* --color=auto' 2>/dev/null
alias ls='ls --color=auto' 2>/dev/null

View File

@ -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"));
}
@ -3075,7 +3080,7 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
+ ? monthtab[lo].val : 0);
+
+ if (ea && result)
+ *ea = s + strlen (monthtab[lo].name);
+ *ea = (char*) s + strlen (monthtab[lo].name);
+
+ free (month);
+ free (tmp);
@ -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,209 @@ keycompare (struct line const *a, struct
return key->reverse ? -diff : diff;
}
@ -3208,13 +3213,16 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
+ size_t lena = lima <= texta ? 0 : lima - texta;
+ size_t lenb = limb <= textb ? 0 : limb - textb;
+
+ char enda IF_LINT (= 0);
+ char endb IF_LINT (= 0);
+
+ char const *translate = key->translate;
+ bool const *ignore = key->ignore;
+
+ if (ignore || translate)
+ {
+ char *copy_a = (char *) xmalloc (lena + 1 + lenb + 1);
+ char *copy_b = copy_a + lena + 1;
+ char *copy_a = (char *) xmalloc ((lena + lenb) * MB_CUR_MAX + 2);
+ char *copy_b = copy_a + lena * MB_CUR_MAX + 1;
+ size_t new_len_a, new_len_b;
+ size_t i, j;
+
@ -3225,6 +3233,12 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
+ texta = copy_a; textb = copy_b;
+ lena = new_len_a; lenb = new_len_b;
+ }
+ else
+ {
+ /* Use the keys in-place, temporarily null-terminated. */
+ enda = texta[lena]; texta[lena] = '\0';
+ endb = textb[lenb]; textb[lenb] = '\0';
+ }
+
+ if (key->random)
+ diff = compare_random (texta, lena, textb, lenb);
@ -3246,15 +3260,24 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
+ diff = - NONZERO (lenb);
+ else if (lenb == 0)
+ diff = 1;
+ else if (hard_LC_COLLATE && !folding)
+ {
+ diff = xmemcoll0 (texta, lena + 1, textb, lenb + 1);
+ }
+ else
+ {
+ diff = memcmp (texta, textb, MIN (lena,lenb));
+ if (!diff)
+ diff = xmemcoll (texta, lena, textb, lenb);
+ }
+ {
+ diff = memcmp (texta, textb, MIN (lena, lenb));
+ if (diff == 0)
+ diff = lena < lenb ? -1 : lena != lenb;
+ }
+
+ if (ignore || translate)
+ free (texta);
+ else
+ {
+ texta[lena] = enda;
+ textb[lenb] = endb;
+ }
+
+ if (diff)
+ goto not_equal;
@ -3295,31 +3318,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 +3332,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
@@ -4080,6 +4723,7 @@ set_ordering (char const *s, struct keyf
break;
case 'f':
key->translate = fold_toupper;
+ folding = true;
break;
case 'g':
key->general_numeric = true;
@@ -4157,7 +4801,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 +4822,29 @@ main (int argc, char **argv)
thousands_sep = -1;
}
@ -3349,17 +3374,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 +5119,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 +3406,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 +5157,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;
@ -4037,14 +4062,50 @@ diff -urNp coreutils-8.21-orig/src/uniq.c coreutils-8.21/src/uniq.c
skip_chars = 0;
skip_fields = 0;
check_chars = SIZE_MAX;
diff --git a/tests/i18n/sort.sh b/tests/i18n/sort.sh
new file mode 100644
index 0000000..26c95de
--- /dev/null
+++ b/tests/i18n/sort.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+# Verify sort's multi-byte support.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ sort
+
+export LC_ALL=en_US.UTF-8
+locale -k LC_CTYPE | grep -q "charmap.*UTF-8" \
+ || skip_ "No UTF-8 locale available"
+
+# Enable heap consistency checkng on older systems
+export MALLOC_CHECK_=2
+
+
+# check buffer overflow issue due to
+# expanding multi-byte representation due to case conversion
+# https://bugzilla.suse.com/show_bug.cgi?id=928749
+cat <<EOF > exp
+.
+ɑ
+EOF
+cat <<EOF | sort -f > out || fail=1
+.
+ɑ
+EOF
+compare exp out || { fail=1; cat out; }
+
+
+Exit $fail
diff -urNp coreutils-8.21-orig/tests/local.mk coreutils-8.21/tests/local.mk
--- coreutils-8.21-orig/tests/local.mk 2013-02-15 14:24:32.645654553 +0100
+++ coreutils-8.21/tests/local.mk 2013-02-15 14:25:07.873467648 +0100
@@ -325,6 +325,7 @@ all_tests = \
@@ -325,6 +325,8 @@ all_tests = \
tests/misc/sort-discrim.sh \
tests/misc/sort-files0-from.pl \
tests/misc/sort-float.sh \
+ tests/misc/sort-mb-tests.sh \
+ tests/i18n/sort.sh \
tests/misc/sort-merge.pl \
tests/misc/sort-merge-fdlimit.sh \
tests/misc/sort-month.sh \
@ -4203,3 +4264,339 @@ diff -urNp coreutils-8.21-orig/tests/misc/sort-mb-tests.sh coreutils-8.21/tests/
+compare exp out || { fail=1; cat out; }
+
+Exit $fail
diff -urNp coreutils-8.22-orig/tests/misc/sort-merge.pl coreutils-8.22/tests/misc/sort-merge.pl
--- coreutils-8.22-orig/tests/misc/sort-merge.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/misc/sort-merge.pl 2014-01-08 13:55:56.139375141 +0100
@@ -26,6 +26,15 @@ my $prog = 'sort';
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+my $mb_locale;
+# uncommented according to upstream commit enabling multibyte paths
+$mb_locale = $ENV{LOCALE_FR_UTF8};
+! defined $mb_locale || $mb_locale eq 'none'
+ and $mb_locale = 'C';
+
+my $try = "Try \`$prog --help' for more information.\n";
+my $inval = "$prog: invalid byte, character or field list\n$try";
+
# three empty files and one that says 'foo'
my @inputs = (+(map{{IN=> {"empty$_"=> ''}}}1..3), {IN=> {foo=> "foo\n"}});
@@ -77,6 +86,39 @@ my @Tests =
{OUT=>$big_input}],
);
+# Add _POSIX2_VERSION=199209 to the environment of each test
+# that uses an old-style option like +1.
+if ($mb_locale ne 'C')
+ {
+ # Duplicate each test vector, appending "-mb" to the test name and
+ # inserting {ENV => "LC_ALL=$mb_locale"} in the copy, so that we
+ # provide coverage for the distro-added multi-byte code paths.
+ my @new;
+ foreach my $t (@Tests)
+ {
+ my @new_t = @$t;
+ my $test_name = shift @new_t;
+
+ # Depending on whether sort is multi-byte-patched,
+ # it emits different diagnostics:
+ # non-MB: invalid byte or field list
+ # MB: invalid byte, character or field list
+ # Adjust the expected error output accordingly.
+ if (grep {ref $_ eq 'HASH' && exists $_->{ERR} && $_->{ERR} eq $inval}
+ (@new_t))
+ {
+ my $sub = {ERR_SUBST => 's/, character//'};
+ push @new_t, $sub;
+ push @$t, $sub;
+ }
+ next if ($test_name =~ "nmerge-.");
+ push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}];
+ }
+ push @Tests, @new;
+ }
+
+@Tests = triple_test \@Tests;
+
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
diff -urNp coreutils-8.22-orig/tests/misc/sort.pl coreutils-8.22/tests/misc/sort.pl
--- coreutils-8.22-orig/tests/misc/sort.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/misc/sort.pl 2014-01-08 13:55:56.140375131 +0100
@@ -24,10 +24,15 @@ 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};
+my $mb_locale;
+#Comment out next line to disable multibyte tests
+$mb_locale = $ENV{LOCALE_FR_UTF8};
! defined $mb_locale || $mb_locale eq 'none'
and $mb_locale = 'C';
+my $try = "Try \`$prog --help' for more information.\n";
+my $inval = "$prog: invalid byte, character or field list\n$try";
+
# 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 '-'.
@@ -317,6 +322,10 @@ my @Tests =
["22a", '-k 2,2fd -k 1,1r', {IN=>"3 b\n4 B\n"}, {OUT=>"4 B\n3 b\n"}],
["22b", '-k 2,2d -k 1,1r', {IN=>"3 b\n4 b\n"}, {OUT=>"4 b\n3 b\n"}],
+# This fails in Fedora 20, per Göran Uddeborg in: http://bugs.gnu.org/18540
+["23", '-s -k1,1 -t/', {IN=>"a b/x\na-b-c/x\n"}, {OUT=>"a b/x\na-b-c/x\n"},
+ {ENV => "LC_ALL=$mb_locale"}],
+
["no-file1", 'no-file', {EXIT=>2}, {ERR=>$no_file}],
# This test failed until 1.22f. Sort didn't give an error.
# From Will Edgington.
@@ -415,6 +420,38 @@ foreach my $t (@Tests)
}
}
+if ($mb_locale ne 'C')
+ {
+ # Duplicate each test vector, appending "-mb" to the test name and
+ # inserting {ENV => "LC_ALL=$mb_locale"} in the copy, so that we
+ # provide coverage for the distro-added multi-byte code paths.
+ my @new;
+ foreach my $t (@Tests)
+ {
+ my @new_t = @$t;
+ my $test_name = shift @new_t;
+
+ # Depending on whether sort is multi-byte-patched,
+ # it emits different diagnostics:
+ # non-MB: invalid byte or field list
+ # MB: invalid byte, character or field list
+ # Adjust the expected error output accordingly.
+ if (grep {ref $_ eq 'HASH' && exists $_->{ERR} && $_->{ERR} eq $inval}
+ (@new_t))
+ {
+ my $sub = {ERR_SUBST => 's/, character//'};
+ push @new_t, $sub;
+ push @$t, $sub;
+ }
+ #disable several failing tests until investigation, disable all tests with envvars set
+ next if (grep {ref $_ eq 'HASH' && exists $_->{ENV}} (@new_t));
+ next if ($test_name =~ "18g" or $test_name =~ "sort-numeric" or $test_name =~ "08[ab]" or $test_name =~ "03[def]" or $test_name =~ "h4" or $test_name =~ "n1" or $test_name =~ "2[01]a");
+ next if ($test_name =~ "11[ab]"); # avoid FP: expected result differs to MB result due to collation rules.
+ push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}];
+ }
+ push @Tests, @new;
+ }
+
@Tests = triple_test \@Tests;
# Remember that triple_test creates from each test with exactly one "IN"
@@ -424,6 +460,7 @@ foreach my $t (@Tests)
# Remove the IN_PIPE version of the "output-is-input" test above.
# The others aren't susceptible because they have three inputs each.
@Tests = grep {$_->[0] ne 'output-is-input.p'} @Tests;
+@Tests = grep {$_->[0] ne 'output-is-input-mb.p'} @Tests;
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
diff -urNp coreutils-8.22-orig/tests/misc/unexpand.pl coreutils-8.22/tests/misc/unexpand.pl
--- coreutils-8.22-orig/tests/misc/unexpand.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/misc/unexpand.pl 2014-01-08 13:55:56.140375131 +0100
@@ -27,6 +27,14 @@ my $limits = getlimits ();
my $prog = 'unexpand';
+# comment out next line to disable multibyte tests
+my $mb_locale = $ENV{LOCALE_FR_UTF8};
+! defined $mb_locale || $mb_locale eq 'none'
+ and $mb_locale = 'C';
+
+my $try = "Try \`$prog --help' for more information.\n";
+my $inval = "$prog: invalid byte, character or field list\n$try";
+
my @Tests =
(
['a1', {IN=> ' 'x 1 ."y\n"}, {OUT=> ' 'x 1 ."y\n"}],
@@ -92,6 +100,37 @@ my @Tests =
{EXIT => 1}, {ERR => "$prog: tab stop value is too large\n"}],
);
+if ($mb_locale ne 'C')
+ {
+ # Duplicate each test vector, appending "-mb" to the test name and
+ # inserting {ENV => "LC_ALL=$mb_locale"} in the copy, so that we
+ # provide coverage for the distro-added multi-byte code paths.
+ my @new;
+ foreach my $t (@Tests)
+ {
+ my @new_t = @$t;
+ my $test_name = shift @new_t;
+
+ # Depending on whether unexpand is multi-byte-patched,
+ # it emits different diagnostics:
+ # non-MB: invalid byte or field list
+ # MB: invalid byte, character or field list
+ # Adjust the expected error output accordingly.
+ if (grep {ref $_ eq 'HASH' && exists $_->{ERR} && $_->{ERR} eq $inval}
+ (@new_t))
+ {
+ my $sub = {ERR_SUBST => 's/, character//'};
+ push @new_t, $sub;
+ push @$t, $sub;
+ }
+ next if ($test_name =~ 'b-1');
+ push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}];
+ }
+ push @Tests, @new;
+ }
+
+@Tests = triple_test \@Tests;
+
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
diff -urNp coreutils-8.22-orig/tests/misc/uniq.pl coreutils-8.22/tests/misc/uniq.pl
--- coreutils-8.22-orig/tests/misc/uniq.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/misc/uniq.pl 2014-01-08 13:55:56.141375121 +0100
@@ -23,9 +23,17 @@ my $limits = getlimits ();
my $prog = 'uniq';
my $try = "Try '$prog --help' for more information.\n";
+my $inval = "$prog: invalid byte, character or field list\n$try";
+
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+my $mb_locale;
+#Comment out next line to disable multibyte tests
+$mb_locale = $ENV{LOCALE_FR_UTF8};
+! defined $mb_locale || $mb_locale eq 'none'
+ and $mb_locale = 'C';
+
# When possible, create a "-z"-testing variant of each test.
sub add_z_variants($)
{
@@ -261,6 +269,53 @@ foreach my $t (@Tests)
and push @$t, {ENV=>'_POSIX2_VERSION=199209'};
}
+if ($mb_locale ne 'C')
+ {
+ # Duplicate each test vector, appending "-mb" to the test name and
+ # inserting {ENV => "LC_ALL=$mb_locale"} in the copy, so that we
+ # provide coverage for the distro-added multi-byte code paths.
+ my @new;
+ foreach my $t (@Tests)
+ {
+ my @new_t = @$t;
+ my $test_name = shift @new_t;
+
+ # Depending on whether uniq is multi-byte-patched,
+ # it emits different diagnostics:
+ # non-MB: invalid byte or field list
+ # MB: invalid byte, character or field list
+ # Adjust the expected error output accordingly.
+ if (grep {ref $_ eq 'HASH' && exists $_->{ERR} && $_->{ERR} eq $inval}
+ (@new_t))
+ {
+ my $sub = {ERR_SUBST => 's/, character//'};
+ push @new_t, $sub;
+ push @$t, $sub;
+ }
+ # In test #145, replace the each ... by '...'.
+ if ($test_name =~ "145")
+ {
+ my $sub = { ERR_SUBST => "s/([^]+)/'\$1'/g"};
+ push @new_t, $sub;
+ push @$t, $sub;
+ }
+ next if ( $test_name =~ "schar"
+ or $test_name =~ "^obs-plus"
+ or $test_name =~ "119");
+ push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}];
+ }
+ push @Tests, @new;
+ }
+
+# Remember that triple_test creates from each test with exactly one "IN"
+# file two more tests (.p and .r suffix on name) corresponding to reading
+# input from a file and from a pipe. The pipe-reading test would fail
+# due to a race condition about 1 in 20 times.
+# Remove the IN_PIPE version of the "output-is-input" test above.
+# The others aren't susceptible because they have three inputs each.
+
+@Tests = grep {$_->[0] ne 'output-is-input.p'} @Tests;
+
@Tests = add_z_variants \@Tests;
@Tests = triple_test \@Tests;
diff -urNp coreutils-8.22-orig/tests/pr/pr-tests.pl coreutils-8.22/tests/pr/pr-tests.pl
--- coreutils-8.22-orig/tests/pr/pr-tests.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/pr/pr-tests.pl 2014-01-08 13:55:56.144375092 +0100
@@ -23,6 +23,15 @@ use strict;
my $prog = 'pr';
+my $mb_locale;
+#Uncomment the following line to enable multibyte tests
+$mb_locale = $ENV{LOCALE_FR_UTF8};
+! defined $mb_locale || $mb_locale eq 'none'
+ and $mb_locale = 'C';
+
+my $try = "Try \`$prog --help' for more information.\n";
+my $inval = "$prog: invalid byte, character or field list\n$try";
+
my @tv = (
# -b option is no longer an official option. But it's still working to
@@ -466,8 +475,48 @@ push @Tests,
{IN=>{3=>"x\ty\tz\n"}},
{OUT=>join("\t", qw(a b c m n o x y z)) . "\n"} ];
+# Add _POSIX2_VERSION=199209 to the environment of each test
+# that uses an old-style option like +1.
+if ($mb_locale ne 'C')
+ {
+ # Duplicate each test vector, appending "-mb" to the test name and
+ # inserting {ENV => "LC_ALL=$mb_locale"} in the copy, so that we
+ # provide coverage for the distro-added multi-byte code paths.
+ my @new;
+ foreach my $t (@Tests)
+ {
+ my @new_t = @$t;
+ my $test_name = shift @new_t;
+
+ # Depending on whether pr is multi-byte-patched,
+ # it emits different diagnostics:
+ # non-MB: invalid byte or field list
+ # MB: invalid byte, character or field list
+ # Adjust the expected error output accordingly.
+ if (grep {ref $_ eq 'HASH' && exists $_->{ERR} && $_->{ERR} eq $inval}
+ (@new_t))
+ {
+ my $sub = {ERR_SUBST => 's/, character//'};
+ push @new_t, $sub;
+ push @$t, $sub;
+ }
+ #temporarily skip some failing tests
+ next if ($test_name =~ "col-0" or $test_name =~ "col-inval");
+ push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}];
+ }
+ push @Tests, @new;
+ }
+
@Tests = triple_test \@Tests;
+# Remember that triple_test creates from each test with exactly one "IN"
+# file two more tests (.p and .r suffix on name) corresponding to reading
+# input from a file and from a pipe. The pipe-reading test would fail
+# due to a race condition about 1 in 20 times.
+# Remove the IN_PIPE version of the "output-is-input" test above.
+# The others aren't susceptible because they have three inputs each.
+@Tests = grep {$_->[0] ne 'output-is-input.p'} @Tests;
+
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};

View File

@ -0,0 +1,39 @@
diff -up coreutils-8.22/gnulib-tests/test-isnanl.h.ppc coreutils-8.22/gnulib-tests/test-isnanl.h
--- coreutils-8.22/gnulib-tests/test-isnanl.h.ppc 2014-06-23 14:01:05.925541920 +0200
+++ coreutils-8.22/gnulib-tests/test-isnanl.h 2014-06-23 14:01:39.437617584 +0200
@@ -51,6 +51,15 @@ main ()
/* A bit pattern that is different from a Quiet NaN. With a bit of luck,
it's a Signalling NaN. */
{
+#if defined __powerpc__ && LDBL_MANT_DIG == 106
+ /* This is PowerPC "double double", a pair of two doubles. Inf and Nan are
+ represented as the corresponding 64-bit IEEE values in the first double;
+ the second is ignored. Manipulate only the first double. */
+ #undef NWORDS
+ #define NWORDS \
+ ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
+#endif
+
memory_long_double m;
m.value = NaNl ();
# if LDBL_EXPBIT0_BIT > 0
diff -up coreutils-8.22/gnulib-tests/test-signbit.c.ppc coreutils-8.22/gnulib-tests/test-signbit.c
--- coreutils-8.22/gnulib-tests/test-signbit.c.ppc 2013-12-04 15:53:33.000000000 +0100
+++ coreutils-8.22/gnulib-tests/test-signbit.c 2014-06-23 13:59:20.378307385 +0200
@@ -151,6 +151,16 @@ test_signbitl ()
#define NWORDS \
((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
typedef union { long double value; unsigned int word[NWORDS]; } memory_long_double;
+
+#if defined __powerpc__ && LDBL_MANT_DIG == 106
+ /* This is PowerPC "double double", a pair of two doubles. Inf and Nan are
+ represented as the corresponding 64-bit IEEE values in the first double;
+ the second is ignored. Manipulate only the first double. */
+ #undef NWORDS
+ #define NWORDS \
+ ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
+#endif
+
memory_long_double m;
m.value = zerol / zerol;
# if LDBL_EXPBIT0_BIT > 0

View File

@ -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: 22%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/
@ -15,6 +15,12 @@ Source106: coreutils-colorls.csh
# From upstream
Patch1: coreutils-8.21-install-strip.patch
Patch2: coreutils-aarch64-longlong.patch
Patch3: coreutils-8.21-ln-updateexisting.patch
Patch4: coreutils-8.22-datetzcrash.patch
#backport of patch from gnulib fixing tests on powerPC
Patch5: coreutils-ppc-gnulib-tests.patch
#fix occasional assertion failure of gnulib tests that check ctime
Patch6: coreutils-8.21-gnulib-tests-ctime.patch
# Our patches
#general patch to workaround koji build system issues
@ -129,6 +135,10 @@ the old GNU fileutils, sh-utils, and textutils packages.
# From upstream
%patch1 -p1 -b .strip
%patch2 -p1 -b .aarch64
%patch3 -p1 -b .exist
%patch4 -p1 -b .tzcrash
%patch5 -p1 -b .ppc
%patch6 -p1 -b .ctime
# Our patches
%patch100 -p1 -b .configure
@ -161,6 +171,10 @@ find ./po/ -name "*.p*" | xargs \
sed -i \
-e 's/-dpR/-cdpR/'
# make gnulib tests compatible with [-Werror=format-security]
sed -e 's/xasprintf (empty)/xasprintf ("%s", empty)/' \
-i gnulib-tests/test-xvasprintf.c
%build
export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing -fpic"
%{expand:%%global optflags %{optflags} -D_GNU_SOURCE=1}
@ -233,6 +247,8 @@ find %{buildroot}%{_datadir}/locale -type l | \
done)
%find_lang %name
#Add the %lang(xyz) ownership for the LC_TIME dirs as well...
grep LC_TIME %name.lang | cut -d'/' -f1-6 | sed -e 's/) /) %%dir /g' >>%name.lang
# (sb) Deal with Installed (but unpackaged) file(s) found
rm -f $RPM_BUILD_ROOT%{_infodir}/dir
@ -264,10 +280,9 @@ fi
%files -f %{name}.lang
%defattr(-,root,root,-)
%dir %{_datadir}/locale/*/LC_TIME
%config(noreplace) %{_sysconfdir}/DIR_COLORS*
%config(noreplace) %{_sysconfdir}/profile.d/*
%doc COPYING ABOUT-NLS ChangeLog.bz2 NEWS README THANKS TODO old/*
%doc COPYING ABOUT-NLS NEWS README THANKS TODO
%{_bindir}/arch
%{_bindir}/basename
%{_bindir}/cat
@ -375,6 +390,31 @@ fi
%{_sbindir}/chroot
%changelog
* Thu May 14 2015 Kamil Dudka <kdudka@redhat.com> 8.21-22
- fix occasional assertion failure of gnulib tests that check ctime
- sort - fix buffer overflow in some case conversions
- patch by Pádraig Brady
- Adjust LS_COLORS in 256 color mode; brighten some, remove hardlink colors (#1196642)
- Drop large ancient docs
- have the LC_TIME subdirs with lang macro (#1169027)
- handle situation with ro /tmp in colorls scripts (#1149761)
- fix the sorting in multibyte locales (NUL-terminate sort keys)
- patch by Andreas Schwab (#1146185)
- fix failed tests on ppc(backport from gnulib upstream)
* Wed Mar 05 2014 Ondrej Vasik <ovasik@redhat.com> 8.21-21
- ln: --relative: fix updating of existing symlinks (#1072103)
- fix possible colorls.csh script errors for tcsh with
noclobber set and entered include file (#1027279)
- unset the unnecessary envvars after colorls scripts(#1051703)
- fix the date crash or infloop in TZ="" parsing (#1069657)
* Mon Jan 06 2014 Ondrej Oprala <ooprala@redhat.com> 8.21-20
- fix sorting by non-first field (#1003544)
* Fri Jan 03 2014 Ondrej Oprala <ooprala@redhat.com> 8.21-19
- reverted an old change and constricted it's condition
* Thu Aug 15 2013 Ondrej Vasik <ovasik@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)