diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..d87f5613ec4234f82f8eaeebc563711f587fdf88 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.xz filter=lfs diff=lfs merge=lfs -text diff --git a/.lfsconfig b/.lfsconfig new file mode 100644 index 0000000000000000000000000000000000000000..3fdd4bd555d97c9354bc9b72f461e9236370f6d9 --- /dev/null +++ b/.lfsconfig @@ -0,0 +1,2 @@ +[lfs] + url = https://artlfs.openeuler.openatom.cn/src-openEuler/coreutils diff --git a/backport-cat-don-t-trust-st_size-on-proc-files.patch b/backport-cat-don-t-trust-st_size-on-proc-files.patch deleted file mode 100644 index 2324d7a2834bebb578de52de3d988be339fd19fb..0000000000000000000000000000000000000000 --- a/backport-cat-don-t-trust-st_size-on-proc-files.patch +++ /dev/null @@ -1,105 +0,0 @@ -From 225cb8d7473eadb481a4884e929bf23589d4bd82 Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Sat, 6 Apr 2024 15:13:23 -0700 -Subject: [PATCH] =?UTF-8?q?cat:=20don=E2=80=99t=20trust=20st=5Fsize=20on?= - =?UTF-8?q?=20/proc=20files?= -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -* src/cat.c (main): -Improve test for when copying will exhaust the output device. -Do not rely on st_size, which is unreliable in /proc. -Use lseek instead; this is good enough here. -* tests/cat/cat-self.sh: Test the relaxation of the heuristic -for self-copying. ---- - src/cat.c | 31 +++++++++++++++++++++---------- - tests/cat/cat-self.sh | 20 ++++++++++++++++++++ - 2 files changed, 41 insertions(+), 10 deletions(-) - -diff --git a/src/cat.c b/src/cat.c -index 4ed404363..b33faeb35 100644 ---- a/src/cat.c -+++ b/src/cat.c -@@ -645,9 +645,10 @@ main (int argc, char **argv) - /* Optimal size of i/o operations of output. */ - idx_t outsize = io_blksize (&stat_buf); - -- /* Device and I-node number of the output. */ -+ /* Device, I-node number and lazily-acquired flags of the output. */ - dev_t out_dev = stat_buf.st_dev; - ino_t out_ino = stat_buf.st_ino; -+ int out_flags = -2; - - /* True if the output is a regular file. */ - bool out_isreg = S_ISREG (stat_buf.st_mode) != 0; -@@ -701,17 +702,27 @@ main (int argc, char **argv) - - fdadvise (input_desc, 0, 0, FADVISE_SEQUENTIAL); - -- /* Don't copy a nonempty regular file to itself, as that would -- merely exhaust the output device. It's better to catch this -- error earlier rather than later. */ -+ /* Don't copy a file to itself if that would merely exhaust the -+ output device. It's better to catch this error earlier -+ rather than later. */ - -- if (out_isreg -- && stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino -- && lseek (input_desc, 0, SEEK_CUR) < stat_buf.st_size) -+ if (stat_buf.st_dev == out_dev && stat_buf.st_ino == out_ino) - { -- error (0, 0, _("%s: input file is output file"), quotef (infile)); -- ok = false; -- goto contin; -+ if (out_flags < -1) -+ out_flags = fcntl (STDOUT_FILENO, F_GETFL); -+ bool exhausting = 0 <= out_flags && out_flags & O_APPEND; -+ if (!exhausting) -+ { -+ off_t in_pos = lseek (input_desc, 0, SEEK_CUR); -+ if (0 <= in_pos) -+ exhausting = in_pos < lseek (STDOUT_FILENO, 0, SEEK_CUR); -+ } -+ if (exhausting) -+ { -+ error (0, 0, _("%s: input file is output file"), quotef (infile)); -+ ok = false; -+ goto contin; -+ } - } - - /* Pointer to the input buffer. */ -diff --git a/tests/cat/cat-self.sh b/tests/cat/cat-self.sh -index e0f6455c0..854825def 100755 ---- a/tests/cat/cat-self.sh -+++ b/tests/cat/cat-self.sh -@@ -30,4 +30,24 @@ echo y >doc.end || framework_failure_ - cat doc doc.end >doc || fail=1 - compare doc doc.end || fail=1 - -+# This terminates even though it copies a file to itself. -+# Coreutils 9.5 and earlier rejected this. -+echo x >fx || framework_failure_ -+echo y >fy || framework_failure_ -+cat fx fy >fxy || fail=1 -+for i in 1 2; do -+ cat fx >fxy$i || fail=1 -+done -+for i in 3 4 5 6; do -+ cat fx >fx$i || fail=1 -+done -+cat - fy fxy1 || fail=1 -+compare fxy fxy1 || fail=1 -+cat fxy2 fy 1<>fxy2 || fail=1 -+compare fxy fxy2 || fail=1 -+returns_ 1 cat fx fx3 1<>fx3 || fail=1 -+returns_ 1 cat - fx4 fx4 || fail=1 -+returns_ 1 cat fx5 >>fx5 || fail=1 -+returns_ 1 cat >fx6 || fail=1 -+ - Exit $fail --- -2.43.0 - diff --git a/backport-chroot-whoami-use-uintmax_t-for-printing-uids.patch b/backport-chroot-whoami-use-uintmax_t-for-printing-uids.patch deleted file mode 100644 index e07aa6d7eadc4f33fefebc7e3f8c2640e2c20054..0000000000000000000000000000000000000000 --- a/backport-chroot-whoami-use-uintmax_t-for-printing-uids.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 8083944484f2cdf6c9b737642567bcdb54db784d Mon Sep 17 00:00:00 2001 -From: Collin Funk -Date: Sun, 6 Oct 2024 22:19:51 -0700 -Subject: [PATCH] chroot,whoami: use uintmax_t for printing uids - -Reference:https://github.com/coreutils/coreutils/commit/8083944484f2cdf6c9b737642567bcdb54db784d -* src/chroot.c (main): Cast the uid to uintmax_t instead of int. -* src/whoami.c (main): Cast the uid to uintmax_t instead of unsigned -long int. ---- - src/chroot.c | 3 ++- - src/whoami.c | 4 ++-- - 2 files changed, 4 insertions(+), 3 deletions(-) - -diff --git a/src/chroot.c b/src/chroot.c -index e12454c..dd1ec62 100644 ---- a/src/chroot.c -+++ b/src/chroot.c -@@ -375,7 +375,8 @@ main (int argc, char **argv) - else if (gid_unset (gid)) - { - error (EXIT_CANCELED, errno, -- _("no group specified for unknown uid: %d"), (int) uid); -+ _("no group specified for unknown uid: %ju"), -+ (uintmax_t) uid); - } - } - -diff --git a/src/whoami.c b/src/whoami.c -index f64171d..834ca9f 100644 ---- a/src/whoami.c -+++ b/src/whoami.c -@@ -81,8 +81,8 @@ main (int argc, char **argv) - uid = geteuid (); - pw = uid == NO_UID && errno ? nullptr : getpwuid (uid); - if (!pw) -- error (EXIT_FAILURE, errno, _("cannot find name for user ID %lu"), -- (unsigned long int) uid); -+ error (EXIT_FAILURE, errno, _("cannot find name for user ID %ju"), -+ (uintmax_t) uid); - puts (pw->pw_name); - return EXIT_SUCCESS; - } --- -2.27.0 - diff --git a/backport-coreutils-df-direct.patch b/backport-coreutils-df-direct.patch deleted file mode 100644 index 9e3434aeabec5735c3d3c048ff44a41584046c83..0000000000000000000000000000000000000000 --- a/backport-coreutils-df-direct.patch +++ /dev/null @@ -1,187 +0,0 @@ -From 6e36198f10a2f63b89c89ebb5d5c185b20fb3a63 Mon Sep 17 00:00:00 2001 -From: Kamil Dudka -Date: Mon, 29 Mar 2010 17:20:34 +0000 -Subject: [PATCH] coreutils-df-direct.patch - ---- - doc/coreutils.texi | 7 ++++++ - src/df.c | 34 ++++++++++++++++++++++++++-- - tests/df/direct.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 94 insertions(+), 2 deletions(-) - create mode 100755 tests/df/direct.sh - -diff --git a/doc/coreutils.texi b/doc/coreutils.texi -index 5b9a597..6810c15 100644 ---- a/doc/coreutils.texi -+++ b/doc/coreutils.texi -@@ -12074,6 +12074,13 @@ some systems (notably Solaris), doing this yields more up to date results, - but in general this option makes @command{df} much slower, especially when - there are many or very busy file systems. - -+@item --direct -+@opindex --direct -+@cindex direct statfs for a file -+Do not resolve mount point and show statistics directly for a file. It can be -+especially useful for NFS mount points if there is a boundary between two -+storage policies behind the mount point. -+ - @item --total - @opindex --total - @cindex grand total of file system size, usage and available space -diff --git a/src/df.c b/src/df.c -index 48025b9..c8efa5b 100644 ---- a/src/df.c -+++ b/src/df.c -@@ -125,6 +125,9 @@ static bool print_type; - /* If true, print a grand total at the end. */ - static bool print_grand_total; - -+/* If true, show statistics for a file instead of mount point. */ -+static bool direct_statfs; -+ - /* Grand total data. */ - static struct fs_usage grand_fsu; - -@@ -252,13 +255,15 @@ enum - NO_SYNC_OPTION = CHAR_MAX + 1, - SYNC_OPTION, - TOTAL_OPTION, -- OUTPUT_OPTION -+ OUTPUT_OPTION, -+ DIRECT_OPTION - }; - - static struct option const long_options[] = - { - {"all", no_argument, nullptr, 'a'}, - {"block-size", required_argument, nullptr, 'B'}, -+ {"direct", no_argument, nullptr, DIRECT_OPTION}, - {"inodes", no_argument, nullptr, 'i'}, - {"human-readable", no_argument, nullptr, 'h'}, - {"si", no_argument, nullptr, 'H'}, -@@ -583,7 +588,10 @@ get_header (void) - for (col = 0; col < ncolumns; col++) - { - char *cell = nullptr; -- char const *header = _(columns[col]->caption); -+ char const *header = (columns[col]->field == TARGET_FIELD -+ && direct_statfs)? -+ _("File") : -+ _(columns[col]->caption); - - if (columns[col]->field == SIZE_FIELD - && (header_mode == DEFAULT_MODE -@@ -1486,6 +1494,17 @@ get_point (char const *point, const struct stat *statp) - static void - get_entry (char const *name, struct stat const *statp) - { -+ if (direct_statfs) -+ { -+ char *resolved = canonicalize_file_name (name); -+ if (resolved) -+ { -+ get_dev (NULL, resolved, name, NULL, NULL, false, false, NULL, false); -+ free (resolved); -+ return; -+ } -+ } -+ - if ((S_ISBLK (statp->st_mode) || S_ISCHR (statp->st_mode)) - && get_device (name)) - return; -@@ -1556,6 +1575,7 @@ or all file systems by default.\n\ - -B, --block-size=SIZE scale sizes by SIZE before printing them; e.g.,\n\ - '-BM' prints sizes in units of 1,048,576 bytes;\n\ - see SIZE format below\n\ -+ --direct show statistics for a file instead of mount point\n\ - -h, --human-readable print sizes in powers of 1024 (e.g., 1023M)\n\ - -H, --si print sizes in powers of 1000 (e.g., 1.1G)\n\ - "), stdout); -@@ -1646,6 +1666,9 @@ main (int argc, char **argv) - xstrtol_fatal (e, oi, c, long_options, optarg); - } - break; -+ case DIRECT_OPTION: -+ direct_statfs = true; -+ break; - case 'i': - if (header_mode == OUTPUT_MODE) - { -@@ -1742,6 +1765,13 @@ main (int argc, char **argv) - } - } - -+ if (direct_statfs && show_local_fs) -+ { -+ error (0, 0, _("options --direct and --local (-l) are mutually " -+ "exclusive")); -+ usage (EXIT_FAILURE); -+ } -+ - if (human_output_opts == -1) - { - if (posix_format) -diff --git a/tests/df/direct.sh b/tests/df/direct.sh -new file mode 100755 -index 0000000..8e4cfb8 ---- /dev/null -+++ b/tests/df/direct.sh -@@ -0,0 +1,55 @@ -+#!/bin/sh -+# Ensure "df --direct" works as documented -+ -+# Copyright (C) 2010 Free Software Foundation, Inc. -+ -+# This program is free software: you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation, either version 3 of the License, or -+# (at your option) any later version. -+ -+# This program is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+ -+# You should have received a copy of the GNU General Public License -+# along with this program. If not, see . -+ -+. "${srcdir=.}/init.sh"; path_prepend_ ../src -+print_ver_ df -+ -+df || skip_ "df fails" -+ -+DIR=`pwd` || framework_failure -+FILE="$DIR/file" -+touch "$FILE" || framework_failure -+echo "$FILE" > file_exp || framework_failure -+echo "Mounted on" > header_mounted_exp || framework_failure -+echo "File" > header_file_exp || framework_failure -+ -+fail=0 -+ -+df --portability "$FILE" > df_out || fail=1 -+df --portability --direct "$FILE" > df_direct_out || fail=1 -+df --portability --direct --local "$FILE" > /dev/null 2>&1 && fail=1 -+ -+# check df header -+$AWK '{ if (NR==1) print $6 " " $7; }' df_out > header_mounted_out \ -+ || framework_failure -+$AWK '{ if (NR==1) print $6; }' df_direct_out > header_file_out \ -+ || framework_failure -+compare header_mounted_out header_mounted_exp || fail=1 -+compare header_file_out header_file_exp || fail=1 -+ -+# check df output (without --direct) -+$AWK '{ if (NR==2) print $6; }' df_out > file_out \ -+ || framework_failure -+compare file_out file_exp && fail=1 -+ -+# check df output (with --direct) -+$AWK '{ if (NR==2) print $6; }' df_direct_out > file_out \ -+ || framework_failure -+compare file_out file_exp || fail=1 -+ -+Exit $fail --- -2.31.1 - diff --git a/backport-dd-don-t-trust-st_size-on-proc-files.patch b/backport-dd-don-t-trust-st_size-on-proc-files.patch deleted file mode 100644 index d28a5de700b37a767910d8463992f44144e7b301..0000000000000000000000000000000000000000 --- a/backport-dd-don-t-trust-st_size-on-proc-files.patch +++ /dev/null @@ -1,30 +0,0 @@ -From ac6b8d8224de140f5a6f2ca66e6ce279604a37e6 Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Sat, 6 Apr 2024 15:15:04 -0700 -Subject: [PATCH] =?UTF-8?q?dd:=20don=E2=80=99t=20trust=20st=5Fsize=20on=20?= - =?UTF-8?q?/proc/files?= -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -* src/dd.c (skip): Don’t trust st_size == 0 ---- - src/dd.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/dd.c b/src/dd.c -index b50b841..a582111 100644 ---- a/src/dd.c -+++ b/src/dd.c -@@ -1813,7 +1813,7 @@ skip (int fdesc, char const *file, intmax_t records, idx_t blocksize, - struct stat st; - if (ifstat (STDIN_FILENO, &st) != 0) - error (EXIT_FAILURE, errno, _("cannot fstat %s"), quoteaf (file)); -- if (usable_st_size (&st) && 0 <= input_offset -+ if (usable_st_size (&st) && 0 < st.st_size && 0 <= input_offset - && st.st_size - input_offset < offset) - { - /* When skipping past EOF, return the number of _full_ blocks --- -2.27.0 - diff --git a/backport-head-fix-overflows-in-elide_tail_bytes_pipe.patch b/backport-head-fix-overflows-in-elide_tail_bytes_pipe.patch deleted file mode 100644 index 0a4d9a718b71c36686a442ac4d0ec9c47247ca90..0000000000000000000000000000000000000000 --- a/backport-head-fix-overflows-in-elide_tail_bytes_pipe.patch +++ /dev/null @@ -1,252 +0,0 @@ -From 8fe800a06e50be3c905ab1694a2d1bfd6e70be42 Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Sat, 10 Aug 2024 22:19:17 -0700 -Subject: [PATCH] head: fix overflows in elide_tail_bytes_pipe -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Not clear that the overflows could be exploited, -but they made the code confusing. -* src/head.c (elide_tail_bytes_pipe): Don’t convert uintmax_t -to size_t first thing; wait until it’s known the value will fit, -and then use idx_t rather than size_t to prefer signed types. -Prefer idx_t in nearby code, too. -Rename locals n_elide_0 to n_elide (for consistency elsewhere) -and n_elide to in_elide. -Remove bogus (SIZE_MAX < n_elide + READ_BUFSIZE) test; -in the typical case where n_elide’s type was the same as -that of SIZE_MAX, the test never succeeded, and in the -less-common case where n_elide was wider than size_t, -the addition could silently overflow, causing the test -to fail when it should succeed. The test is not needed anyway now. -Add static asserts to document code assumptions. -Redo the ! (n_elide <= HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD) case -so that it works with enormous values of n_elide even on -32-bit platforms; for example, n_bufs is now uintmax_t not size_t. -Simplify by using xpalloc instead of by-hand code. -Remove bogus ‘if (rem)’ test, as rem is always nonzero. ---- - src/head.c | 129 ++++++++++++++++++++++++----------------------------- - 1 file changed, 58 insertions(+), 71 deletions(-) - -diff --git a/src/head.c b/src/head.c -index a9155c24c..9715b7b73 100644 ---- a/src/head.c -+++ b/src/head.c -@@ -237,17 +237,16 @@ elseek (int fd, off_t offset, int whence, char const *filename) - } - - /* For an input file with name FILENAME and descriptor FD, -- output all but the last N_ELIDE_0 bytes. -+ output all but the last N_ELIDE bytes. - If CURRENT_POS is nonnegative, assume that the input file is - positioned at CURRENT_POS and that it should be repositioned to - just before the elided bytes before returning. - Return true upon success. - Give a diagnostic and return false upon error. */ - static bool --elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0, -+elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide, - off_t current_pos) - { -- size_t n_elide = n_elide_0; - uintmax_t desired_pos = current_pos; - bool ok = true; - -@@ -265,16 +264,9 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0, - #endif - - #if HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD < 2 * READ_BUFSIZE -- "HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD must be at least 2 * READ_BUFSIZE" -+# error "HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD must be at least 2 * READ_BUFSIZE" - #endif - -- if (SIZE_MAX < n_elide_0 + READ_BUFSIZE) -- { -- char umax_buf[INT_BUFSIZE_BOUND (n_elide_0)]; -- error (EXIT_FAILURE, 0, _("%s: number of bytes is too large"), -- umaxtostr (n_elide_0, umax_buf)); -- } -- - /* Two cases to consider... - 1) n_elide is small enough that we can afford to double-buffer: - allocate 2 * (READ_BUFSIZE + n_elide) bytes -@@ -286,11 +278,14 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0, - CAUTION: do not fail (out of memory) when asked to elide - a ridiculous amount, but when given only a small input. */ - -+ static_assert (READ_BUFSIZE <= IDX_MAX); -+ static_assert (HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD <= IDX_MAX - READ_BUFSIZE); - if (n_elide <= HEAD_TAIL_PIPE_BYTECOUNT_THRESHOLD) - { -+ idx_t in_elide = n_elide; - bool first = true; - bool eof = false; -- size_t n_to_read = READ_BUFSIZE + n_elide; -+ size_t n_to_read = READ_BUFSIZE + in_elide; - bool i; - char *b[2]; - b[0] = xnmalloc (2, n_to_read); -@@ -310,7 +305,7 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0, - } - - /* reached EOF */ -- if (n_read <= n_elide) -+ if (n_read <= in_elide) - { - if (first) - { -@@ -320,7 +315,7 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0, - } - else - { -- delta = n_elide - n_read; -+ delta = in_elide - n_read; - } - } - eof = true; -@@ -330,15 +325,15 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0, - the previous round. */ - if (! first) - { -- desired_pos += n_elide - delta; -- xwrite_stdout (b[!i] + READ_BUFSIZE, n_elide - delta); -+ desired_pos += in_elide - delta; -+ xwrite_stdout (b[!i] + READ_BUFSIZE, in_elide - delta); - } - first = false; - -- if (n_elide < n_read) -+ if (in_elide < n_read) - { -- desired_pos += n_read - n_elide; -- xwrite_stdout (b[i], n_read - n_elide); -+ desired_pos += n_read - in_elide; -+ xwrite_stdout (b[i], n_read - in_elide); - } - } - -@@ -350,31 +345,24 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0, - bytes. Then, for each new buffer we read, also write an old one. */ - - bool eof = false; -- size_t n_read; -- bool buffered_enough; -- size_t i, i_next; -+ idx_t n_read; - char **b = nullptr; -- /* Round n_elide up to a multiple of READ_BUFSIZE. */ -- size_t rem = READ_BUFSIZE - (n_elide % READ_BUFSIZE); -- size_t n_elide_round = n_elide + rem; -- size_t n_bufs = n_elide_round / READ_BUFSIZE + 1; -- size_t n_alloc = 0; -- size_t n_array_alloc = 0; -- -- buffered_enough = false; -+ -+ idx_t remainder = n_elide % READ_BUFSIZE; -+ /* The number of buffers needed to hold n_elide bytes plus one -+ extra buffer. They are allocated lazily, so don't report -+ overflow now simply because the number does not fit into idx_t. */ -+ uintmax_t n_bufs = n_elide / READ_BUFSIZE + (remainder != 0) + 1; -+ idx_t n_alloc = 0; -+ idx_t n_array_alloc = 0; -+ -+ bool buffered_enough = false; -+ idx_t i, i_next; - for (i = 0, i_next = 1; !eof; i = i_next, i_next = (i_next + 1) % n_bufs) - { - if (n_array_alloc == i) -- { -- /* reallocate between 16 and n_bufs entries. */ -- if (n_array_alloc == 0) -- n_array_alloc = MIN (n_bufs, 16); -- else if (n_array_alloc <= n_bufs / 2) -- n_array_alloc *= 2; -- else -- n_array_alloc = n_bufs; -- b = xnrealloc (b, n_array_alloc, sizeof *b); -- } -+ b = xpalloc (b, &n_array_alloc, 1, MIN (n_bufs, PTRDIFF_MAX), -+ sizeof *b); - - if (! buffered_enough) - { -@@ -403,43 +391,42 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0, - } - } - -- /* Output any remainder: rem bytes from b[i] + n_read. */ -- if (rem) -+ /* Output the remainder: rem bytes from b[i] + n_read. */ -+ idx_t rem = READ_BUFSIZE - remainder; -+ if (buffered_enough) - { -- if (buffered_enough) -+ idx_t n_bytes_left_in_b_i = READ_BUFSIZE - n_read; -+ desired_pos += rem; -+ if (rem < n_bytes_left_in_b_i) - { -- size_t n_bytes_left_in_b_i = READ_BUFSIZE - n_read; -- desired_pos += rem; -- if (rem < n_bytes_left_in_b_i) -- { -- xwrite_stdout (b[i] + n_read, rem); -- } -- else -- { -- xwrite_stdout (b[i] + n_read, n_bytes_left_in_b_i); -- xwrite_stdout (b[i_next], rem - n_bytes_left_in_b_i); -- } -+ xwrite_stdout (b[i] + n_read, rem); - } -- else if (i + 1 == n_bufs) -+ else - { -- /* This happens when n_elide < file_size < n_elide_round. -- -- |READ_BUF.| -- | | rem | -- |---------!---------!---------!---------| -- |---- n_elide ---------| -- | | x | -- | |y | -- |---- file size -----------| -- | |n_read| -- |---- n_elide_round ----------| -- */ -- size_t y = READ_BUFSIZE - rem; -- size_t x = n_read - y; -- desired_pos += x; -- xwrite_stdout (b[i_next], x); -+ xwrite_stdout (b[i] + n_read, n_bytes_left_in_b_i); -+ xwrite_stdout (b[i_next], rem - n_bytes_left_in_b_i); - } - } -+ else if (i + 1 == n_bufs) -+ { -+ /* This happens when -+ n_elide < file_size < (n_bufs - 1) * READ_BUFSIZE. -+ -+ |READ_BUF.| -+ | | rem | -+ |---------!---------!---------!---------| -+ |---- n_elide----------| -+ | | x | -+ | |y | -+ |---- file size -----------| -+ | |n_read| -+ |(n_bufs - 1) * READ_BUFSIZE--| -+ */ -+ idx_t y = READ_BUFSIZE - rem; -+ idx_t x = n_read - y; -+ desired_pos += x; -+ xwrite_stdout (b[i_next], x); -+ } - - free_mem: - for (i = 0; i < n_alloc; i++) --- -2.33.0 - diff --git a/backport-head-off_t-not-uintmax_t-for-file-offset.patch b/backport-head-off_t-not-uintmax_t-for-file-offset.patch deleted file mode 100644 index 421a129d559c3e57bbf64118013f10b67db7f7da..0000000000000000000000000000000000000000 --- a/backport-head-off_t-not-uintmax_t-for-file-offset.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0f9e2719e0dd2366f0381daa832f9415f3162af2 Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Sat, 10 Aug 2024 18:55:09 -0700 -Subject: [PATCH] head: off_t not uintmax_t for file offset - -* src/head.c (elide_tail_lines_pipe): -Use off_t, not uintmax_t, for a local var that is -a file offset. ---- - src/head.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/head.c b/src/head.c -index 2795ae486..a9155c24c 100644 ---- a/src/head.c -+++ b/src/head.c -@@ -504,7 +504,7 @@ elide_tail_lines_pipe (char const *filename, int fd, uintmax_t n_elide, - size_t nlines; - struct linebuffer *next; - }; -- uintmax_t desired_pos = current_pos; -+ off_t desired_pos = current_pos; - typedef struct linebuffer LBUFFER; - LBUFFER *first, *last, *tmp; - size_t total_lines = 0; /* Total number of newlines in all buffers. */ --- -2.43.0 - diff --git a/backport-ls-fix-crash-with-context.patch b/backport-ls-fix-crash-with-context.patch new file mode 100644 index 0000000000000000000000000000000000000000..bab7a9b5386325e837b52916564def9911e1cd07 --- /dev/null +++ b/backport-ls-fix-crash-with-context.patch @@ -0,0 +1,80 @@ +From 915004f403cb25fadb207ddfdbe6a2f43bd44fac Mon Sep 17 00:00:00 2001 +From: =?utf8?q?P=C3=A1draig=20Brady?= +Date: Fri, 17 Jan 2025 17:29:34 +0000 +Subject: [PATCH] ls: fix crash with --context + +* src/ls.c (main): Flag that we need to stat() +if we're going to get security context (call file_has_aclinfo_cache). +(file_has_aclinfo_cache): Be defensive and only lookup the device +for the file if the stat has been performed. +(has_capability_cache): Likewise. +* tests/ls/selinux-segfault.sh: Add a test case. +Reported by Bruno Haible. +--- + src/ls.c | 10 +++++----- + tests/ls/selinux-segfault.sh | 3 +++ + 2 files changed, 13 insertions(+), 5 deletions(-) + +diff --git a/src/ls.c b/src/ls.c +index 321536021..f67167f16 100644 +--- a/src/ls.c ++++ b/src/ls.c +@@ -1768,7 +1768,7 @@ main (int argc, char **argv) + + format_needs_stat = ((sort_type == sort_time) | (sort_type == sort_size) + | (format == long_format) +- | print_block_size | print_hyperlink); ++ | print_block_size | print_hyperlink | print_scontext); + format_needs_type = ((! format_needs_stat) + & (recursive | print_with_color | print_scontext + | directories_first +@@ -3309,7 +3309,7 @@ file_has_aclinfo_cache (char const *file, struct fileinfo *f, + static int unsupported_scontext_err; + static dev_t unsupported_device; + +- if (f->stat.st_dev == unsupported_device) ++ if (f->stat_ok && f->stat.st_dev == unsupported_device) + { + ai->buf = ai->u.__gl_acl_ch; + ai->size = 0; +@@ -3322,7 +3322,7 @@ file_has_aclinfo_cache (char const *file, struct fileinfo *f, + errno = 0; + int n = file_has_aclinfo (file, ai, flags); + int err = errno; +- if (n <= 0 && !acl_errno_valid (err)) ++ if (f->stat_ok && n <= 0 && !acl_errno_valid (err)) + { + unsupported_return = n; + unsupported_scontext = ai->scontext; +@@ -3342,14 +3342,14 @@ has_capability_cache (char const *file, struct fileinfo *f) + found that has_capability fails indicating lack of support. */ + static dev_t unsupported_device; + +- if (f->stat.st_dev == unsupported_device) ++ if (f->stat_ok && f->stat.st_dev == unsupported_device) + { + errno = ENOTSUP; + return 0; + } + + bool b = has_capability (file); +- if ( !b && !acl_errno_valid (errno)) ++ if (f->stat_ok && !b && !acl_errno_valid (errno)) + unsupported_device = f->stat.st_dev; + return b; + } +diff --git a/tests/ls/selinux-segfault.sh b/tests/ls/selinux-segfault.sh +index 11623acb3..1cac2b5fc 100755 +--- a/tests/ls/selinux-segfault.sh ++++ b/tests/ls/selinux-segfault.sh +@@ -30,4 +30,7 @@ mkdir sedir || framework_failure_ + ln -sf missing sedir/broken || framework_failure_ + returns_ 1 ls -L -R -Z -m sedir > out || fail=1 + ++# ls 9.6 would segfault with the following ++ls -Z . > out || fail=1 ++ + Exit $fail +-- +2.34.1 + diff --git a/backport-putenv-Don-t-crash-upon-out-of-memory.patch b/backport-putenv-Don-t-crash-upon-out-of-memory.patch deleted file mode 100644 index 13d132ea41b1d1a1e7f3606aafcdf87ad48f9c14..0000000000000000000000000000000000000000 --- a/backport-putenv-Don-t-crash-upon-out-of-memory.patch +++ /dev/null @@ -1,30 +0,0 @@ -From adb76c754290c328a88438af89e491ece7e6a9c5 Mon Sep 17 00:00:00 2001 -From: Bruno Haible -Date: Thu, 6 Jun 2024 02:24:44 +0200 -Subject: [PATCH] putenv: Don't crash upon out-of-memory. - -* lib/putenv.c (_unsetenv): Handle malloc failure. - -Reference:https://github.com/coreutils/gnulib/commit/adb76c754290c328a88438af89e491ece7e6a9c5 -Conflict:delete ChangeLog - ---- - lib/putenv.c | 2 ++ - 1 files changed, 2 insertions(+) - -diff --git a/lib/putenv.c b/lib/putenv.c -index 525d12ae..1d70717e 100644 ---- a/lib/putenv.c -+++ b/lib/putenv.c -@@ -92,6 +92,8 @@ _unsetenv (const char *name) - { - int putenv_result; - char *name_ = malloc (len + 2); -+ if (name_ == NULL) -+ return -1; - memcpy (name_, name, len); - name_[len] = '='; - name_[len + 1] = 0; --- -2.43.0 - diff --git a/backport-shuf-avoid-integer-overflow-on-huge-inputs.patch b/backport-shuf-avoid-integer-overflow-on-huge-inputs.patch deleted file mode 100644 index 7d02db5a9697788261c43def876cac5817a4e880..0000000000000000000000000000000000000000 --- a/backport-shuf-avoid-integer-overflow-on-huge-inputs.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 1ea7255f8b0661cdfabbd13f8f443f81665a07e0 Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Sat, 3 Aug 2024 22:59:12 -0700 -Subject: [PATCH] shuf: avoid integer overflow on huge inputs - -* gl/lib/randperm.c: Include . -(randperm_bound): Return SIZE_MAX if the multiplication overflows. -Do not overflow when converting bit count to byte count. - -Reference:https://github.com/coreutils/coreutils/commit/1ea7255f8b0661cdfabbd13f8f443f81665a07e0 -Conflict:change gl/lib/randperm.c to lib/randperm.c; Adaptation to floor_lg() - ---- - gl/lib/randperm.c | 11 +++++++---- - 1 file changed, 7 insertions(+), 4 deletions(-) - -diff --git a/lib/randperm.c b/lib/randperm.c -index 50328cd9a..14a304524 100644 ---- a/lib/randperm.c -+++ b/lib/randperm.c -@@ -23,6 +23,7 @@ - - #include - #include -+#include - #include - - #include "attribute.h" - -@@ -39,13 +40,15 @@ randperm_bound (size_t h, size_t n) - { - /* Upper bound on number of bits needed to generate the first number - of the permutation. */ -- uintmax_t lg_n = floor_lg (n) + 1; -+ unsigned int lg_n = floor_lg (n) + 1; - -- /* Upper bound on number of bits needed to generated the first H elements. */ -- uintmax_t ar = lg_n * h; -+ /* Upper bound on number of bits needed to generate the first H elements. */ -+ uintmax_t ar; -+ if (ckd_mul (&ar, lg_n, h)) -+ return SIZE_MAX; - - /* Convert the bit count to a byte count. */ -- size_t bound = (ar + CHAR_BIT - 1) / CHAR_BIT; -+ size_t bound = ar / CHAR_BIT + (ar % CHAR_BIT != 0); - - return bound; - } --- -2.43.0 - diff --git a/backport-shuf-fix-randomness-bug.patch b/backport-shuf-fix-randomness-bug.patch deleted file mode 100644 index 565666ba7b0852fa89b692605be6d6b2e978e22c..0000000000000000000000000000000000000000 --- a/backport-shuf-fix-randomness-bug.patch +++ /dev/null @@ -1,40 +0,0 @@ -From bfbb3ec7f798b179d7fa7b42673e068b18048899 Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Sat, 3 Aug 2024 22:31:20 -0700 -Subject: [PATCH] shuf: fix randomness bug - -Problem reported by Daniel Carpenter . -* gl/lib/randread.c (randread_new): Fill the ISAAC buffer -instead of storing at most BYTES_BOUND bytes into it. ---- - gl/lib/randread.c | 12 +++++++++++- - 1 files changed, 12 insertions(+), 1 deletion(-) - -diff --git a/lib/randread.c b/lib/randread.c -index cbee224bb..43c0cf09f 100644 ---- a/lib/randread.c -+++ b/lib/randread.c -@@ -189,9 +189,19 @@ randread_new (char const *name, size_t bytes_bound) - setvbuf (source, s->buf.c, _IOFBF, MIN (sizeof s->buf.c, bytes_bound)); - else - { -+ /* Fill the ISAAC buffer. Although it is tempting to read at -+ most BYTES_BOUND bytes, this is incorrect for two reasons. -+ First, BYTES_BOUND is just an estimate. -+ Second, even if the estimate is correct -+ ISAAC64 poorly randomizes when BYTES_BOUND is small -+ and just the first few bytes of s->buf.isaac.state.m -+ are random while the other bytes are all zero. See: -+ Aumasson J-P. On the pseudo-random generator ISAAC. -+ Cryptology ePrint Archive. 2006;438. -+ . */ - s->buf.isaac.buffered = 0; - if (! get_nonce (s->buf.isaac.state.m, -- MIN (sizeof s->buf.isaac.state.m, bytes_bound))) -+ sizeof s->buf.isaac.state.m)) - { - int e = errno; - randread_free_body (s); --- -2.43.0 - diff --git a/backport-sort-don-t-trust-st_size-on-proc-files.patch b/backport-sort-don-t-trust-st_size-on-proc-files.patch deleted file mode 100644 index 210774e28df5f49becc7006e141419193fe56020..0000000000000000000000000000000000000000 --- a/backport-sort-don-t-trust-st_size-on-proc-files.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 8ff3903281e03d36dd1aa2a202a56f38af726d91 Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Sat, 6 Apr 2024 15:17:14 -0700 -Subject: [PATCH] =?UTF-8?q?sort:=20don=E2=80=99t=20trust=20st=5Fsize=20on?= - =?UTF-8?q?=20/proc=20files?= -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Problem and fix reported by Takashi Kusumi in: -https://bugs.gnu.org/70231 -* src/sort.c (sort_buffer_size): Don’t trust st_size == 0. ---- - src/sort.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/sort.c b/src/sort.c -index e779845..b983ca2 100644 ---- a/src/sort.c -+++ b/src/sort.c -@@ -1538,7 +1538,7 @@ sort_buffer_size (FILE *const *fps, size_t nfps, - != 0) - sort_die (_("stat failed"), files[i]); - -- if (S_ISREG (st.st_mode)) -+ if (usable_st_size (&st) && 0 < st.st_size) - file_size = st.st_size; - else - { --- -2.27.0 - diff --git a/backport-split-don-t-trust-st_size-on-proc-files.patch b/backport-split-don-t-trust-st_size-on-proc-files.patch deleted file mode 100644 index dc051b97b1e274308af9967e486221d3e74b79a9..0000000000000000000000000000000000000000 --- a/backport-split-don-t-trust-st_size-on-proc-files.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 11163675818ab877f20d3740a7c3e59d565b8e9c Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Sat, 6 Apr 2024 15:18:04 -0700 -Subject: [PATCH] =?UTF-8?q?split:=20don=E2=80=99t=20trust=20st=5Fsize=20on?= - =?UTF-8?q?=20/proc=20files?= -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -* src/split.c (create): Don’t trust st_size == 0. ---- - src/split.c | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -diff --git a/src/split.c b/src/split.c -index 037960a59..f82a7f74b 100644 ---- a/src/split.c -+++ b/src/split.c -@@ -489,10 +489,8 @@ create (char const *name) - if (psame_inode (&in_stat_buf, &out_stat_buf)) - error (EXIT_FAILURE, 0, _("%s would overwrite input; aborting"), - quoteaf (name)); -- bool regularish -- = S_ISREG (out_stat_buf.st_mode) || S_TYPEISSHM (&out_stat_buf); -- if (! (regularish && out_stat_buf.st_size == 0) -- && ftruncate (fd, 0) < 0 && regularish) -+ if (ftruncate (fd, 0) < 0 -+ && (S_ISREG (out_stat_buf.st_mode) || S_TYPEISSHM (&out_stat_buf))) - error (EXIT_FAILURE, errno, _("%s: error truncating"), quotef (name)); - - return fd; --- -2.43.0 - diff --git a/backport-tail-avoid-infloop-with-c-on-dev-zero.patch b/backport-tail-avoid-infloop-with-c-on-dev-zero.patch deleted file mode 100644 index 6e8f62be1681019af614381cc45ed043cf0b0fe9..0000000000000000000000000000000000000000 --- a/backport-tail-avoid-infloop-with-c-on-dev-zero.patch +++ /dev/null @@ -1,84 +0,0 @@ -From fb543b6b82c1f3a20ff88f44cc3ed367bfe811b6 Mon Sep 17 00:00:00 2001 -From: Paul Eggert -Date: Fri, 19 Apr 2024 21:44:32 -0700 -Subject: [PATCH] tail: avoid infloop with -c on /dev/zero - -Problem reported by Ionut Nicula in: -https://bugs.gnu.org/70477 -* src/tail.c (tail_bytes): Do not loop forever on commands -like 'tail -c 4096 /dev/zero'. -* tests/tail/tail-c.sh: Test this fix. ---- - src/tail.c | 24 +++++++++++++++++++----- - tests/tail/tail-c.sh | 10 ++++++++++ - 2 files changed, 29 insertions(+), 5 deletions(-) - -diff --git a/src/tail.c b/src/tail.c -index 52c0810..a3b46ca 100644 ---- a/src/tail.c -+++ b/src/tail.c -@@ -760,7 +760,8 @@ free_lbuffers: - return ok; - } - --/* Print the last N_BYTES characters from the end of pipe FD. -+/* Print the last N_BYTES characters from the end of FD. -+ Work even if the input is a pipe. - This is a stripped down version of pipe_lines. - Return true if successful. */ - -@@ -1875,15 +1876,28 @@ tail_bytes (char const *pretty_filename, int fd, uintmax_t n_bytes, - { - off_t end_pos = -1; - off_t current_pos = -1; -+ bool copy_from_current_pos = false; - - if (! presume_input_pipe && n_bytes <= OFF_T_MAX) - { - if (usable_st_size (&stats)) -- end_pos = stats.st_size; -- else if ((current_pos = lseek (fd, -n_bytes, SEEK_END)) != -1) -- end_pos = current_pos + n_bytes; -+ { -+ /* Use st_size only if it's so large that this is -+ probably not a /proc or similar file, where st_size -+ is notional. */ -+ end_pos = stats.st_size; -+ off_t smallish_size = STP_BLKSIZE (&stats); -+ copy_from_current_pos = smallish_size < end_pos; -+ } -+ else -+ { -+ current_pos = lseek (fd, -n_bytes, SEEK_END); -+ copy_from_current_pos = current_pos != -1; -+ if (copy_from_current_pos) -+ end_pos = current_pos + n_bytes; -+ } - } -- if (end_pos <= (off_t) STP_BLKSIZE (&stats)) -+ if (! copy_from_current_pos) - return pipe_bytes (pretty_filename, fd, n_bytes, read_pos); - if (current_pos == -1) - current_pos = xlseek (fd, 0, SEEK_CUR, pretty_filename); -diff --git a/tests/tail/tail-c.sh b/tests/tail/tail-c.sh -index f518e5b..a9f2bc2 100755 ---- a/tests/tail/tail-c.sh -+++ b/tests/tail/tail-c.sh -@@ -35,4 +35,14 @@ printf '123456' | tail -c3 > out || fail=1 - printf '456' > exp || framework_failure_ - compare exp out || fail=1 - -+# Any part of /dev/zero should be valid for tail -c. -+head -c 4096 /dev/zero >exp || fail=1 -+tail -c 4096 /dev/zero >out || fail=1 -+compare exp out || fail=1 -+ -+# Any part of /dev/urandom, if it exists, should be valid for tail -c. -+if test -r /dev/urandom; then -+ timeout --verbose 1 tail -c 4096 /dev/urandom >/dev/null || fail=1 -+fi -+ - Exit $fail --- -2.43.0 - diff --git a/coreutils-9.5-gcc14-gnulib-lto.patch b/coreutils-9.5-gcc14-gnulib-lto.patch deleted file mode 100644 index cc4d60564e2bfd54252fa55d7ea4083d252f7691..0000000000000000000000000000000000000000 --- a/coreutils-9.5-gcc14-gnulib-lto.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 4602765093f04e597f87d78cf29d21eea03b6fa4 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?P=C3=A1draig=20Brady?= -Date: Wed, 28 Aug 2024 12:10:43 +0100 -Subject: avoid GCC -Wmaybe-uninitialized false positives with LTO - -Avoids false warnings with GCC 14.2.1 with -flto - -* lib/canonicalize.c: Initialize END_IDX. -* lib/getndelim2.c: Initialize C. ---- - ChangeLog | 8 ++++++++ - lib/canonicalize.c | 9 ++++++++- - lib/getndelim2.c | 8 +++++--- - 3 files changed, 21 insertions(+), 4 deletions(-) - ---- a/lib/canonicalize.c -+++ b/lib/canonicalize.c -@@ -34,6 +34,13 @@ - #include "hash-triple.h" - #include "xalloc.h" - -+/* Suppress bogus GCC -Wmaybe-uninitialized warnings. */ -+#if defined GCC_LINT || defined lint -+# define IF_LINT(Code) Code -+#else -+# define IF_LINT(Code) /* empty */ -+#endif -+ - #ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT - # define DOUBLE_SLASH_IS_DISTINCT_ROOT false - #endif -@@ -367,7 +374,7 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode, - buf[n] = '\0'; - - char *extra_buf = bufs->extra.data; -- idx_t end_idx; -+ idx_t end_idx IF_LINT (= 0); - if (end_in_extra_buffer) - end_idx = end - extra_buf; - size_t len = strlen (end); -diff --git a/lib/getndelim2.c b/lib/getndelim2.c -index 89989ae..db61e2a 100644 ---- a/lib/getndelim2.c -+++ b/lib/getndelim2.c -@@ -47,8 +47,10 @@ - #include "memchr2.h" - - /* Avoid false GCC warning "'c' may be used uninitialized". */ --#if __GNUC__ + (__GNUC_MINOR__ >= 7) > 4 --# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" -+#if defined GCC_LINT || defined lint -+# define IF_LINT(Code) Code -+#else -+# define IF_LINT(Code) /* empty */ - #endif - - /* The maximum value that getndelim2 can return without suffering from -@@ -102,7 +104,7 @@ getndelim2 { - /* Here always ptr + size == read_pos + nbytes_avail. - Also nbytes_avail > 0 || size < nmax. */ - -- int c; -+ int c IF_LINT (= EOF); - const char *buffer; - size_t buffer_len; diff --git a/coreutils-9.5.tar.xz b/coreutils-9.5.tar.xz deleted file mode 100644 index 3a6c9dba57057be00225ffa49c7840d166699801..0000000000000000000000000000000000000000 Binary files a/coreutils-9.5.tar.xz and /dev/null differ diff --git a/coreutils-9.5-sw.patch b/coreutils-9.6-sw.patch similarity index 84% rename from coreutils-9.5-sw.patch rename to coreutils-9.6-sw.patch index a43c1cda5cc2eb1aa1323c817414c32298f5cae3..9db13dfec66dd19979b7c80d80dee3252e09bc7b 100755 --- a/coreutils-9.5-sw.patch +++ b/coreutils-9.6-sw.patch @@ -1,6 +1,6 @@ -diff -ur coreutils-9.5.orig/build-aux/config.guess coreutils-9.5/build-aux/config.guess ---- coreutils-9.5.orig/build-aux/config.guess 2024-09-02 09:08:54.651545374 +0800 -+++ coreutils-9.5/build-aux/config.guess 2024-09-02 09:10:13.785486378 +0800 +diff -ur coreutils-9.6.orig/build-aux/config.guess coreutils-9.6/build-aux/config.guess +--- coreutils-9.6.orig/build-aux/config.guess 2024-09-02 09:08:54.651545374 +0800 ++++ coreutils-9.6/build-aux/config.guess 2024-09-02 09:10:13.785486378 +0800 @@ -1008,6 +1008,14 @@ UNAME_MACHINE=aarch64_be GUESS=$UNAME_MACHINE-unknown-linux-$LIBC @@ -16,20 +16,20 @@ diff -ur coreutils-9.5.orig/build-aux/config.guess coreutils-9.5/build-aux/confi alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; -diff -ur coreutils-9.5.orig/build-aux/config.sub coreutils-9.5/build-aux/config.sub ---- coreutils-9.5.orig/build-aux/config.sub 2024-09-02 09:08:54.652545386 +0800 -+++ coreutils-9.5/build-aux/config.sub 2024-09-02 09:10:31.238693918 +0800 -@@ -1183,6 +1183,7 @@ - | a29k \ - | aarch64 | aarch64_be | aarch64c | arm64ec \ +diff -ur coreutils-9.6.orig/build-aux/config.sub coreutils-9.6/build-aux/config.sub +--- coreutils-9.6.orig/build-aux/config.sub 2024-09-02 09:08:54.652545386 +0800 ++++ coreutils-9.6/build-aux/config.sub 2024-09-02 09:10:31.238693918 +0800 +@@ -1254,6 +1254,7 @@ + | aarch64_be \ + | aarch64c \ | abacus \ + | sw_64 \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ - | alphapca5[67] | alpha64pca5[67] \ -diff -ur coreutils-9.5.orig/configure coreutils-9.5/configure ---- coreutils-9.5.orig/configure 2024-09-02 09:08:53.994537562 +0800 -+++ coreutils-9.5/configure 2024-09-02 09:12:45.750293437 +0800 + | alpha \ + | alpha64 \ + | alpha64ev56 \ +diff -ur coreutils-9.6.orig/configure coreutils-9.6/configure +--- coreutils-9.6.orig/configure 2024-09-02 09:08:53.994537562 +0800 ++++ coreutils-9.6/configure 2024-09-02 09:12:45.750293437 +0800 @@ -8769,6 +8769,12 @@ # (according to the test results of Bruno Haible's ieeefp/fenv_default.m4 # and the GCC 4.1.2 manual). @@ -61,9 +61,9 @@ diff -ur coreutils-9.5.orig/configure coreutils-9.5/configure gl_cv_host_cpu_c_abi_32bit=no ;; *) gl_cv_host_cpu_c_abi_32bit=unknown ;; -diff -ur coreutils-9.5.orig/lib/uname.c coreutils-9.5/lib/uname.c ---- coreutils-9.5.orig/lib/uname.c 2024-09-02 09:08:54.765546730 +0800 -+++ coreutils-9.5/lib/uname.c 2024-09-02 09:13:34.891877792 +0800 +diff -ur coreutils-9.6.orig/lib/uname.c coreutils-9.6/lib/uname.c +--- coreutils-9.6.orig/lib/uname.c 2024-09-02 09:08:54.765546730 +0800 ++++ coreutils-9.6/lib/uname.c 2024-09-02 09:13:34.891877792 +0800 @@ -228,6 +228,10 @@ case PROCESSOR_ARCHITECTURE_MIPS: strcpy (buf->machine, "mips"); @@ -75,9 +75,9 @@ diff -ur coreutils-9.5.orig/lib/uname.c coreutils-9.5/lib/uname.c case PROCESSOR_ARCHITECTURE_ALPHA: case PROCESSOR_ARCHITECTURE_ALPHA64: strcpy (buf->machine, "alpha"); -diff -ur coreutils-9.5.orig/m4/fpieee.m4 coreutils-9.5/m4/fpieee.m4 ---- coreutils-9.5.orig/m4/fpieee.m4 2024-09-02 09:08:54.055538287 +0800 -+++ coreutils-9.5/m4/fpieee.m4 2024-09-02 09:14:22.824447773 +0800 +diff -ur coreutils-9.6.orig/m4/fpieee.m4 coreutils-9.6/m4/fpieee.m4 +--- coreutils-9.6.orig/m4/fpieee.m4 2024-09-02 09:08:54.055538287 +0800 ++++ coreutils-9.6/m4/fpieee.m4 2024-09-02 09:14:22.824447773 +0800 @@ -30,6 +30,12 @@ # (according to the test results of Bruno Haible's ieeefp/fenv_default.m4 # and the GCC 4.1.2 manual). @@ -91,9 +91,9 @@ diff -ur coreutils-9.5.orig/m4/fpieee.m4 coreutils-9.5/m4/fpieee.m4 alpha*) # On Alpha systems, a compiler option provides the behaviour. # See the ieee(3) manual page, also available at -diff -ur coreutils-9.5.orig/m4/host-cpu-c-abi.m4 coreutils-9.5/m4/host-cpu-c-abi.m4 ---- coreutils-9.5.orig/m4/host-cpu-c-abi.m4 2024-09-02 09:08:54.075538525 +0800 -+++ coreutils-9.5/m4/host-cpu-c-abi.m4 2024-09-02 09:16:15.858791895 +0800 +diff -ur coreutils-9.6.orig/m4/host-cpu-c-abi.m4 coreutils-9.6/m4/host-cpu-c-abi.m4 +--- coreutils-9.6.orig/m4/host-cpu-c-abi.m4 2024-09-02 09:08:54.075538525 +0800 ++++ coreutils-9.6/m4/host-cpu-c-abi.m4 2024-09-02 09:16:15.858791895 +0800 @@ -91,6 +91,12 @@ ;; @@ -135,9 +135,9 @@ diff -ur coreutils-9.5.orig/m4/host-cpu-c-abi.m4 coreutils-9.5/m4/host-cpu-c-abi gl_cv_host_cpu_c_abi_32bit=no ;; *) gl_cv_host_cpu_c_abi_32bit=unknown ;; -diff -ur coreutils-9.5.orig/src/longlong.h coreutils-9.5/src/longlong.h ---- coreutils-9.5.orig/src/longlong.h 2024-09-02 09:08:53.933536836 +0800 -+++ coreutils-9.5/src/longlong.h 2024-09-02 09:17:29.550668195 +0800 +diff -ur coreutils-9.6.orig/src/longlong.h coreutils-9.6/src/longlong.h +--- coreutils-9.6.orig/src/longlong.h 2024-09-02 09:08:53.933536836 +0800 ++++ coreutils-9.6/src/longlong.h 2024-09-02 09:17:29.550668195 +0800 @@ -170,6 +170,92 @@ don't need to be under !NO_ASM */ #if ! defined (NO_ASM) diff --git a/coreutils-9.6.tar.xz b/coreutils-9.6.tar.xz new file mode 100644 index 0000000000000000000000000000000000000000..0d191eaa9bf9ed0ae9b1bf723eea51da4b4beb52 --- /dev/null +++ b/coreutils-9.6.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a0124327b398fd9eb1a6abde583389821422c744ffa10734b24f557610d3283 +size 6134764 diff --git a/backport-coreutils-i18n.patch b/coreutils-i18n.patch similarity index 95% rename from backport-coreutils-i18n.patch rename to coreutils-i18n.patch index aa21a355250ee1bed44ef282ff0edb3d642852c6..e7699c1438fe6cb1bce6ba4c416cf0d3b94634c6 100644 --- a/backport-coreutils-i18n.patch +++ b/coreutils-i18n.patch @@ -1,4 +1,4 @@ -From 94cf02dfcb1be23dedf8a39af295f28ee2de6013 Mon Sep 17 00:00:00 2001 +From a153c65067f6c09cf2cf38dc7c149aa1521c615a Mon Sep 17 00:00:00 2001 From: rpm-build Date: Wed, 30 Aug 2023 17:19:58 +0200 Subject: [PATCH] coreutils-i18n.patch @@ -17,24 +17,24 @@ Subject: [PATCH] coreutils-i18n.patch src/expand-common.c | 114 ++++++ src/expand-common.h | 12 + src/expand.c | 90 +++- - src/fold.c | 312 ++++++++++++-- + src/fold.c | 311 ++++++++++++-- src/local.mk | 4 +- src/pr.c | 443 ++++++++++++++++++-- src/sort.c | 792 +++++++++++++++++++++++++++++++++--- - src/unexpand.c | 102 ++++- + src/unexpand.c | 101 ++++- tests/Coreutils.pm | 3 + tests/expand/mb.sh | 183 +++++++++ tests/i18n/sort.sh | 29 ++ tests/local.mk | 4 + tests/misc/expand.pl | 42 ++ - tests/misc/fold.pl | 50 ++- + tests/misc/fold.pl | 51 ++- tests/misc/sort-mb-tests.sh | 45 ++ tests/misc/unexpand.pl | 39 ++ tests/pr/pr-tests.pl | 49 +++ tests/sort/sort-merge.pl | 42 ++ tests/sort/sort.pl | 40 +- tests/unexpand/mb.sh | 172 ++++++++ - 30 files changed, 3605 insertions(+), 196 deletions(-) + 30 files changed, 3603 insertions(+), 197 deletions(-) create mode 100644 lib/mbchar.c create mode 100644 lib/mbchar.h create mode 100644 lib/mbfile.c @@ -47,10 +47,10 @@ Subject: [PATCH] coreutils-i18n.patch create mode 100644 tests/unexpand/mb.sh diff --git a/bootstrap.conf b/bootstrap.conf -index 126e1e8..b4ccebf 100644 +index 380fa11..ca80e6f 100644 --- a/bootstrap.conf +++ b/bootstrap.conf -@@ -163,6 +163,8 @@ gnulib_modules=" +@@ -165,6 +165,8 @@ gnulib_modules=" maintainer-makefile malloc-gnu manywarnings @@ -60,10 +60,10 @@ index 126e1e8..b4ccebf 100644 mbrtoc32 mbrtowc diff --git a/configure.ac b/configure.ac -index 9cb6ee1..1131ce3 100644 +index bf6da2a..321016d 100644 --- a/configure.ac +++ b/configure.ac -@@ -504,6 +504,12 @@ fi +@@ -505,6 +505,12 @@ fi # I'm leaving it here for now. This whole thing needs to be modernized... gl_WINSIZE_IN_PTEM @@ -77,12 +77,12 @@ index 9cb6ee1..1131ce3 100644 if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \ diff --git a/lib/linebuffer.h b/lib/linebuffer.h -index ae0d55d..5bf5350 100644 +index ca56f80..509b7e6 100644 --- a/lib/linebuffer.h +++ b/lib/linebuffer.h -@@ -22,6 +22,11 @@ - # include "idx.h" - # include +@@ -27,6 +27,11 @@ extern "C" { + #endif + +/* Get mbstate_t. */ +# if HAVE_WCHAR_H @@ -92,7 +92,7 @@ index ae0d55d..5bf5350 100644 /* A 'struct linebuffer' holds a line of text. */ struct linebuffer -@@ -29,6 +34,9 @@ struct linebuffer +@@ -34,6 +39,9 @@ struct linebuffer idx_t size; /* Allocated. */ idx_t length; /* Used. */ char *buffer; @@ -849,7 +849,7 @@ index 0000000..83068a9 + : +]) diff --git a/src/cut.c b/src/cut.c -index 061e09c..6d10425 100644 +index b424997..c9f181c 100644 --- a/src/cut.c +++ b/src/cut.c @@ -27,6 +27,11 @@ @@ -1509,7 +1509,7 @@ index 061e09c..6d10425 100644 if (have_read_stdin && fclose (stdin) == EOF) diff --git a/src/expand-common.c b/src/expand-common.c -index c95998d..d4386fe 100644 +index 2dbbbe4..91a90a3 100644 --- a/src/expand-common.c +++ b/src/expand-common.c @@ -19,6 +19,7 @@ @@ -1518,9 +1518,9 @@ index c95998d..d4386fe 100644 #include +#include #include "system.h" + #include "c-ctype.h" #include "fadvise.h" - #include "quote.h" -@@ -123,6 +124,119 @@ set_increment_size (uintmax_t tabval) +@@ -123,6 +124,119 @@ set_increment_size (colno tabval) return ok; } @@ -1641,10 +1641,10 @@ index c95998d..d4386fe 100644 to the list of tab stops. */ extern void diff --git a/src/expand-common.h b/src/expand-common.h -index 1a57108..6025652 100644 +index fe6c8ed..80a1280 100644 --- a/src/expand-common.h +++ b/src/expand-common.h -@@ -25,6 +25,18 @@ extern size_t max_column_width; +@@ -29,6 +29,18 @@ extern idx_t max_column_width; /* The desired exit status. */ extern int exit_status; @@ -1662,9 +1662,9 @@ index 1a57108..6025652 100644 + /* Add tab stop TABVAL to the end of 'tab_list'. */ extern void - add_tab_stop (uintmax_t tabval); + add_tab_stop (colno tabval); diff --git a/src/expand.c b/src/expand.c -index a6176a9..60b1b8e 100644 +index 5ec7ce9..65ac315 100644 --- a/src/expand.c +++ b/src/expand.c @@ -38,6 +38,9 @@ @@ -1725,7 +1725,7 @@ index a6176a9..60b1b8e 100644 @@ -118,17 +143,48 @@ expand (void) /* Index in TAB_LIST of next tab stop to examine. */ - size_t tab_index = 0; + idx_t tab_index = 0; - /* Convert a line of text. */ @@ -1775,8 +1775,8 @@ index a6176a9..60b1b8e 100644 + if (mb_iseq (c, '\t')) { /* Column the next input tab stop is on. */ - uintmax_t next_tab_column; -@@ -147,32 +203,34 @@ expand (void) + bool last_tab; +@@ -139,31 +195,33 @@ expand (void) if (putchar (' ') < 0) write_error (); @@ -1795,14 +1795,13 @@ index a6176a9..60b1b8e 100644 + /* A leading control character could make us trip over. */ + else if (!mb_iscntrl (c)) { -- column++; -+ column += mb_width (c); - if (!column) +- if (ckd_add (&column, column, 1)) ++ if (ckd_add (&column, column, mb_width (c))) error (EXIT_FAILURE, 0, _("input line is too long")); } - convert &= convert_entire_line || !! isblank (c); -+ convert &= convert_entire_line || mb_isblank (c); ++ convert &= convert_entire_line || !! mb_isblank (c); } - if (c < 0) @@ -1820,7 +1819,7 @@ index a6176a9..60b1b8e 100644 } diff --git a/src/fold.c b/src/fold.c -index 941ad11..cf1e747 100644 +index b64aad4..a156337 100644 --- a/src/fold.c +++ b/src/fold.c @@ -23,10 +23,32 @@ @@ -1931,9 +1930,9 @@ index 941ad11..cf1e747 100644 - FILE *istream; int c; size_t column = 0; /* Screen column where next char will go. */ - size_t offset_out = 0; /* Index in 'line_out' for next char. */ + idx_t offset_out = 0; /* Index in 'line_out' for next char. */ static char *line_out = nullptr; - static size_t allocated_out = 0; + static idx_t allocated_out = 0; - int saved_errno; - - if (STREQ (filename, "-")) @@ -1954,7 +1953,7 @@ index 941ad11..cf1e747 100644 @@ -168,6 +196,15 @@ fold_file (char const *filename, size_t width) bool found_blank = false; - size_t logical_end = offset_out; + idx_t logical_end = offset_out; + /* If LINE_OUT has no wide character, + put a new wide character in LINE_OUT @@ -1968,7 +1967,7 @@ index 941ad11..cf1e747 100644 /* Look for the last blank. */ while (logical_end) { -@@ -214,13 +251,225 @@ fold_file (char const *filename, size_t width) +@@ -212,13 +249,224 @@ fold_file (char const *filename, size_t width) line_out[offset_out++] = c; } @@ -1979,7 +1978,7 @@ index 941ad11..cf1e747 100644 + *saved_errno = 0; if (offset_out) - fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); + fwrite (line_out, sizeof (char), offset_out, stdout); +} + @@ -1997,8 +1996,8 @@ index 941ad11..cf1e747 100644 + int convfail = 0; /* 1, when conversion is failed. Otherwise 0. */ + + static char *line_out = NULL; -+ size_t offset_out = 0; /* Index in `line_out' for next char. */ -+ static size_t allocated_out = 0; ++ idx_t offset_out = 0; /* Index in `line_out' for next char. */ ++ static idx_t allocated_out = 0; + + int increment; + size_t column = 0; @@ -2066,39 +2065,38 @@ index 941ad11..cf1e747 100644 + } + +rescan: -+ if (operating_mode == byte_mode) /* byte mode */ ++ if (convfail) ++ increment = 1; ++ else if (wc == L'\n') ++ { ++ /* preserve newline */ ++ fwrite (line_out, sizeof(char), offset_out, stdout); ++ START_NEW_LINE; ++ continue; ++ } ++ else if (operating_mode == byte_mode) /* byte mode */ + increment = mblength; + else if (operating_mode == character_mode) /* character mode */ + increment = 1; -+ else /* column mode */ ++ else /* column mode */ + { -+ if (convfail) -+ increment = 1; -+ else ++ switch (wc) + { -+ switch (wc) -+ { -+ case L'\n': -+ fwrite (line_out, sizeof(char), offset_out, stdout); -+ START_NEW_LINE; -+ continue; -+ -+ case L'\b': -+ increment = (column > 0) ? -1 : 0; -+ break; ++ case L'\b': ++ increment = (column > 0) ? -1 : 0; ++ break; + -+ case L'\r': -+ increment = -1 * column; -+ break; ++ case L'\r': ++ increment = -1 * column; ++ break; + -+ case L'\t': -+ increment = 8 - column % 8; -+ break; ++ case L'\t': ++ increment = 8 - column % 8; ++ break; + -+ default: -+ increment = wcwidth (wc); -+ increment = (increment < 0) ? 0 : increment; -+ } ++ default: ++ increment = wcwidth (wc); ++ increment = (increment < 0) ? 0 : increment; + } + } + @@ -2122,9 +2120,9 @@ index 941ad11..cf1e747 100644 + goto rescan; + } + -+ if (allocated_out < offset_out + mblength) ++ if (allocated_out - offset_out <= mblength) + { -+ line_out = X2REALLOC (line_out, &allocated_out); ++ line_out = xpalloc (line_out, &allocated_out, 1, -1, sizeof *line_out); + } + + memcpy (line_out + offset_out, bufpos, mblength); @@ -2156,14 +2154,14 @@ index 941ad11..cf1e747 100644 + *saved_errno = 0; + + if (offset_out) -+ fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); ++ fwrite (line_out, sizeof (char), offset_out, stdout); + +} +#endif + +/* Fold file FILENAME, or standard input if FILENAME is "-", + to stdout, with maximum line length WIDTH. -+ Return 0 if successful, 1 if an error occurs. */ ++ Return true if successful. */ + +static bool +fold_file (char const *filename, size_t width) @@ -2174,15 +2172,15 @@ index 941ad11..cf1e747 100644 + if (STREQ (filename, "-")) + { + istream = stdin; -+ have_read_stdin = 1; ++ have_read_stdin = true; + } + else + istream = fopen (filename, "r"); + -+ if (istream == NULL) ++ if (istream == nullptr) + { + error (0, errno, "%s", filename); -+ return 1; ++ return false; + } + + /* Define how ISTREAM is being folded. */ @@ -2196,7 +2194,7 @@ index 941ad11..cf1e747 100644 if (STREQ (filename, "-")) clearerr (istream); else if (fclose (istream) != 0 && !saved_errno) -@@ -251,7 +500,8 @@ main (int argc, char **argv) +@@ -249,7 +497,8 @@ main (int argc, char **argv) atexit (close_stdout); @@ -2206,7 +2204,7 @@ index 941ad11..cf1e747 100644 while ((optc = getopt_long (argc, argv, shortopts, longopts, nullptr)) != -1) { -@@ -260,7 +510,15 @@ main (int argc, char **argv) +@@ -258,7 +507,15 @@ main (int argc, char **argv) switch (optc) { case 'b': /* Count bytes rather than columns. */ @@ -2224,10 +2222,10 @@ index 941ad11..cf1e747 100644 case 's': /* Break at word boundaries. */ diff --git a/src/local.mk b/src/local.mk -index 96ee941..8fdb8fc 100644 +index fd9dc81..5133cc0 100644 --- a/src/local.mk +++ b/src/local.mk -@@ -450,8 +450,8 @@ src_base32_CPPFLAGS = -DBASE_TYPE=32 $(AM_CPPFLAGS) +@@ -476,8 +476,8 @@ src_base32_CPPFLAGS = -DBASE_TYPE=32 $(AM_CPPFLAGS) src_basenc_SOURCES = src/basenc.c src_basenc_CPPFLAGS = -DBASE_TYPE=42 $(AM_CPPFLAGS) @@ -2239,7 +2237,7 @@ index 96ee941..8fdb8fc 100644 src_wc_SOURCES = src/wc.c if USE_AVX2_WC_LINECOUNT diff --git a/src/pr.c b/src/pr.c -index 09c6fa8..7552b62 100644 +index e7081a0..19e0268 100644 --- a/src/pr.c +++ b/src/pr.c @@ -312,6 +312,24 @@ @@ -2265,9 +2263,9 @@ index 09c6fa8..7552b62 100644 +#endif + #include "system.h" + #include "c-ctype.h" #include "fadvise.h" - #include "hard-locale.h" -@@ -324,6 +342,18 @@ +@@ -325,6 +343,18 @@ #include "xstrtol-error.h" #include "xdectoint.h" @@ -2286,7 +2284,7 @@ index 09c6fa8..7552b62 100644 /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "pr" -@@ -416,7 +446,20 @@ struct COLUMN +@@ -417,7 +447,20 @@ struct COLUMN typedef struct COLUMN COLUMN; @@ -2308,9 +2306,9 @@ index 09c6fa8..7552b62 100644 static bool read_line (COLUMN *p); static bool print_page (void); static bool print_stored (COLUMN *p); -@@ -428,6 +471,7 @@ static void add_line_number (COLUMN *p); - static void getoptnum (char const *n_str, int min, int *num, - char const *errfmt); +@@ -428,6 +471,7 @@ static void pad_across_to (int position); + static void add_line_number (COLUMN *p); + static int getoptnum (char const *n_str, int min, char const *errfmt); static void getoptarg (char *arg, char switch_char, char *character, + int *character_length, int *character_width, int *number); @@ -2443,7 +2441,7 @@ index 09c6fa8..7552b62 100644 /* Could check tab width > 0. */ tabify_output = true; break; -@@ -985,8 +1068,8 @@ main (int argc, char **argv) +@@ -986,8 +1069,8 @@ main (int argc, char **argv) case 'n': numbered_lines = true; if (optarg) @@ -2454,7 +2452,7 @@ index 09c6fa8..7552b62 100644 break; case 'N': skip_count = false; -@@ -1011,6 +1094,7 @@ main (int argc, char **argv) +@@ -1013,6 +1096,7 @@ main (int argc, char **argv) /* Reset an additional input of -s, -S dominates -s */ col_sep_string = ""; col_sep_length = 0; @@ -2462,7 +2460,7 @@ index 09c6fa8..7552b62 100644 use_col_separator = true; if (optarg) separator_string (optarg); -@@ -1165,7 +1249,8 @@ getoptnum (char const *n_str, int min, int *num, char const *err) +@@ -1168,7 +1252,8 @@ getoptnum (char const *n_str, int min, char const *err) a number. */ static void @@ -2472,10 +2470,10 @@ index 09c6fa8..7552b62 100644 { if (!*arg) { -@@ -1174,7 +1259,41 @@ getoptarg (char *arg, char switch_char, char *character, int *number) +@@ -1177,7 +1262,41 @@ getoptarg (char *arg, char switch_char, char *character, int *number) } - if (!ISDIGIT (*arg)) + if (!c_isdigit (*arg)) - *character = *arg++; + { +#ifdef HAVE_MBRTOWC @@ -2515,7 +2513,7 @@ index 09c6fa8..7552b62 100644 if (*arg) { long int tmp_long; -@@ -1203,6 +1322,11 @@ static void +@@ -1206,6 +1325,11 @@ static void init_parameters (int number_of_files) { int chars_used_by_number = 0; @@ -2527,7 +2525,7 @@ index 09c6fa8..7552b62 100644 lines_per_body = lines_per_page - lines_per_header - lines_per_footer; if (lines_per_body <= 0) -@@ -1240,7 +1364,7 @@ init_parameters (int number_of_files) +@@ -1243,7 +1367,7 @@ init_parameters (int number_of_files) else col_sep_string = column_separator; @@ -2536,7 +2534,7 @@ index 09c6fa8..7552b62 100644 use_col_separator = true; } /* It's rather pointless to define a TAB separator with column -@@ -1272,11 +1396,11 @@ init_parameters (int number_of_files) +@@ -1275,11 +1399,11 @@ init_parameters (int number_of_files) + TAB_WIDTH (chars_per_input_tab, chars_per_number); */ /* Estimate chars_per_text without any margin and keep it constant. */ @@ -2550,7 +2548,7 @@ index 09c6fa8..7552b62 100644 /* The number is part of the column width unless we are printing files in parallel. */ -@@ -1285,7 +1409,7 @@ init_parameters (int number_of_files) +@@ -1288,7 +1412,7 @@ init_parameters (int number_of_files) } int sep_chars, useful_chars; @@ -2559,7 +2557,7 @@ index 09c6fa8..7552b62 100644 sep_chars = INT_MAX; if (ckd_sub (&useful_chars, chars_per_line - chars_used_by_number, sep_chars)) -@@ -1308,7 +1432,7 @@ init_parameters (int number_of_files) +@@ -1311,7 +1435,7 @@ init_parameters (int number_of_files) We've to use 8 as the lower limit, if we use chars_per_default_tab = 8 to expand a tab which is not an input_tab-char. */ free (clump_buff); @@ -2568,7 +2566,7 @@ index 09c6fa8..7552b62 100644 } /* Open the necessary files, -@@ -1414,7 +1538,7 @@ init_funcs (void) +@@ -1417,7 +1541,7 @@ init_funcs (void) /* Enlarge p->start_position of first column to use the same form of padding_not_printed with all columns. */ @@ -2577,7 +2575,7 @@ index 09c6fa8..7552b62 100644 /* This loop takes care of all but the rightmost column. */ -@@ -1448,7 +1572,7 @@ init_funcs (void) +@@ -1451,7 +1575,7 @@ init_funcs (void) } else { @@ -2586,7 +2584,7 @@ index 09c6fa8..7552b62 100644 h_next = h + chars_per_column; } } -@@ -1745,9 +1869,9 @@ static void +@@ -1748,9 +1872,9 @@ static void align_column (COLUMN *p) { padding_not_printed = p->start_position; @@ -2598,9 +2596,9 @@ index 09c6fa8..7552b62 100644 padding_not_printed = ANYWHERE; } -@@ -2021,13 +2145,13 @@ store_char (char c) +@@ -2024,13 +2148,13 @@ store_char (char c) /* May be too generous. */ - buff = X2REALLOC (buff, &buff_allocated); + buff = xpalloc (buff, &buff_allocated, 1, -1, sizeof *buff); } - buff[buff_current++] = c; + buff[buff_current++] = (unsigned char) c; @@ -2614,7 +2612,7 @@ index 09c6fa8..7552b62 100644 char *s; int num_width; -@@ -2044,22 +2168,24 @@ add_line_number (COLUMN *p) +@@ -2047,22 +2171,24 @@ add_line_number (COLUMN *p) /* Tabification is assumed for multiple columns, also for n-separators, but 'default n-separator = TAB' hasn't been given priority over equal column_width also specified by POSIX. */ @@ -2643,7 +2641,7 @@ index 09c6fa8..7552b62 100644 output_position = POS_AFTER_TAB (chars_per_output_tab, output_position); } -@@ -2218,7 +2344,7 @@ print_white_space (void) +@@ -2221,7 +2347,7 @@ print_white_space (void) while (goal - h_old > 1 && (h_new = POS_AFTER_TAB (chars_per_output_tab, h_old)) <= goal) { @@ -2652,7 +2650,7 @@ index 09c6fa8..7552b62 100644 h_old = h_new; } while (++h_old <= goal) -@@ -2238,6 +2364,7 @@ print_sep_string (void) +@@ -2241,6 +2367,7 @@ print_sep_string (void) { char const *s = col_sep_string; int l = col_sep_length; @@ -2660,7 +2658,7 @@ index 09c6fa8..7552b62 100644 if (separators_not_printed <= 0) { -@@ -2249,6 +2376,7 @@ print_sep_string (void) +@@ -2252,6 +2379,7 @@ print_sep_string (void) { for (; separators_not_printed > 0; --separators_not_printed) { @@ -2668,7 +2666,7 @@ index 09c6fa8..7552b62 100644 while (l-- > 0) { /* 3 types of sep_strings: spaces only, spaces and chars, -@@ -2262,12 +2390,15 @@ print_sep_string (void) +@@ -2265,12 +2393,15 @@ print_sep_string (void) } else { @@ -2685,7 +2683,7 @@ index 09c6fa8..7552b62 100644 /* sep_string ends with some spaces */ if (spaces_not_printed > 0) print_white_space (); -@@ -2295,7 +2426,7 @@ print_clump (COLUMN *p, int n, char *clump) +@@ -2298,7 +2429,7 @@ print_clump (COLUMN *p, int n, char *clump) required number of tabs and spaces. */ static void @@ -2694,7 +2692,7 @@ index 09c6fa8..7552b62 100644 { if (tabify_output) { -@@ -2319,6 +2450,74 @@ print_char (char c) +@@ -2322,6 +2453,74 @@ print_char (char c) putchar (c); } @@ -2769,7 +2767,7 @@ index 09c6fa8..7552b62 100644 /* Skip to page PAGE before printing. PAGE may be larger than total number of pages. */ -@@ -2495,9 +2694,9 @@ read_line (COLUMN *p) +@@ -2498,9 +2697,9 @@ read_line (COLUMN *p) align_empty_cols = false; } @@ -2781,7 +2779,7 @@ index 09c6fa8..7552b62 100644 padding_not_printed = ANYWHERE; } -@@ -2566,7 +2765,7 @@ print_stored (COLUMN *p) +@@ -2569,7 +2768,7 @@ print_stored (COLUMN *p) COLUMN *q; int line = p->current_line++; @@ -2790,7 +2788,7 @@ index 09c6fa8..7552b62 100644 /* FIXME UMR: Uninitialized memory read: * This is occurring while in: -@@ -2578,7 +2777,7 @@ print_stored (COLUMN *p) +@@ -2581,7 +2780,7 @@ print_stored (COLUMN *p) xmalloc [xmalloc.c:94] init_store_cols [pr.c:1648] */ @@ -2799,7 +2797,7 @@ index 09c6fa8..7552b62 100644 pad_vertically = true; -@@ -2598,9 +2797,9 @@ print_stored (COLUMN *p) +@@ -2601,9 +2800,9 @@ print_stored (COLUMN *p) } } @@ -2811,7 +2809,7 @@ index 09c6fa8..7552b62 100644 padding_not_printed = ANYWHERE; } -@@ -2613,8 +2812,8 @@ print_stored (COLUMN *p) +@@ -2616,8 +2815,8 @@ print_stored (COLUMN *p) if (spaces_not_printed == 0) { output_position = p->start_position + end_vector[line]; @@ -2822,7 +2820,7 @@ index 09c6fa8..7552b62 100644 } return true; -@@ -2633,7 +2832,7 @@ print_stored (COLUMN *p) +@@ -2636,7 +2835,7 @@ print_stored (COLUMN *p) number of characters is 1.) */ static int @@ -2831,7 +2829,7 @@ index 09c6fa8..7552b62 100644 { unsigned char uc = c; char *s = clump_buff; -@@ -2643,10 +2842,10 @@ char_to_clump (char c) +@@ -2646,10 +2845,10 @@ char_to_clump (char c) int chars; int chars_per_c = 8; @@ -2844,7 +2842,7 @@ index 09c6fa8..7552b62 100644 { width = TAB_WIDTH (chars_per_c, input_position); -@@ -2727,6 +2926,164 @@ char_to_clump (char c) +@@ -2730,6 +2929,164 @@ char_to_clump (char c) return chars; } @@ -3010,7 +3008,7 @@ index 09c6fa8..7552b62 100644 looking for more options and printing the next batch of files. diff --git a/src/sort.c b/src/sort.c -index 2d8324c..46331b8 100644 +index 0928fd5..8c43fd4 100644 --- a/src/sort.c +++ b/src/sort.c @@ -29,6 +29,14 @@ @@ -3028,7 +3026,7 @@ index 2d8324c..46331b8 100644 #include "system.h" #include "argmatch.h" #include "assure.h" -@@ -157,14 +165,39 @@ static int thousands_sep; +@@ -158,14 +166,39 @@ static int thousands_sep; /* We currently ignore multi-byte grouping chars. */ static bool thousands_sep_ignored; @@ -3069,7 +3067,7 @@ index 2d8324c..46331b8 100644 /* The kind of blanks for '-b' to skip in various options. */ enum blanktype { bl_start, bl_end, bl_both }; -@@ -341,13 +374,11 @@ static bool stable; +@@ -342,13 +375,11 @@ static bool stable; /* An int value outside char range. */ enum { NON_CHAR = CHAR_MAX + 1 }; @@ -3086,7 +3084,7 @@ index 2d8324c..46331b8 100644 /* Flag to remove consecutive duplicate lines from the output. Only the last of a sequence of equal lines will be output. */ -@@ -804,6 +835,46 @@ reap_all (void) +@@ -807,6 +838,46 @@ reap_all (void) reap (-1); } @@ -3133,7 +3131,7 @@ index 2d8324c..46331b8 100644 /* Clean up any remaining temporary files. */ static void -@@ -1271,7 +1342,7 @@ zaptemp (char const *name) +@@ -1274,7 +1345,7 @@ zaptemp (char const *name) free (node); } @@ -3142,7 +3140,7 @@ index 2d8324c..46331b8 100644 static int struct_month_cmp (void const *m1, void const *m2) -@@ -1286,7 +1357,7 @@ struct_month_cmp (void const *m1, void const *m2) +@@ -1289,7 +1360,7 @@ struct_month_cmp (void const *m1, void const *m2) /* Initialize the character class tables. */ static void @@ -3151,7 +3149,7 @@ index 2d8324c..46331b8 100644 { size_t i; -@@ -1298,7 +1369,7 @@ inittables (void) +@@ -1301,7 +1372,7 @@ inittables (void) fold_toupper[i] = toupper (i); } @@ -3160,7 +3158,7 @@ index 2d8324c..46331b8 100644 /* If we're not in the "C" locale, read different names for months. */ if (hard_LC_TIME) { -@@ -1380,6 +1451,84 @@ specify_nmerge (int oi, char c, char const *s) +@@ -1381,6 +1452,84 @@ specify_nmerge (int oi, char c, char const *s) xstrtol_fatal (e, oi, c, long_options, s); } @@ -3245,7 +3243,7 @@ index 2d8324c..46331b8 100644 /* Specify the amount of main memory to use when sorting. */ static void specify_sort_size (int oi, char c, char const *s) -@@ -1611,7 +1760,7 @@ buffer_linelim (struct buffer const *buf) +@@ -1612,7 +1761,7 @@ buffer_linelim (struct buffer const *buf) by KEY in LINE. */ static char * @@ -3254,7 +3252,7 @@ index 2d8324c..46331b8 100644 { char *ptr = line->text, *lim = ptr + line->length - 1; size_t sword = key->sword; -@@ -1620,10 +1769,10 @@ begfield (struct line const *line, struct keyfield const *key) +@@ -1621,10 +1770,10 @@ begfield (struct line const *line, struct keyfield const *key) /* The leading field separator itself is included in a field when -t is absent. */ @@ -3267,7 +3265,7 @@ index 2d8324c..46331b8 100644 ++ptr; if (ptr < lim) ++ptr; -@@ -1649,12 +1798,71 @@ begfield (struct line const *line, struct keyfield const *key) +@@ -1650,12 +1799,71 @@ begfield (struct line const *line, struct keyfield const *key) return ptr; } @@ -3340,7 +3338,7 @@ index 2d8324c..46331b8 100644 { char *ptr = line->text, *lim = ptr + line->length - 1; size_t eword = key->eword, echar = key->echar; -@@ -1669,10 +1877,10 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1670,10 +1878,10 @@ limfield (struct line const *line, struct keyfield const *key) 'beginning' is the first character following the delimiting TAB. Otherwise, leave PTR pointing at the first 'blank' character after the preceding field. */ @@ -3353,7 +3351,7 @@ index 2d8324c..46331b8 100644 ++ptr; if (ptr < lim && (eword || echar)) ++ptr; -@@ -1718,10 +1926,10 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1719,10 +1927,10 @@ limfield (struct line const *line, struct keyfield const *key) */ /* Make LIM point to the end of (one byte past) the current field. */ @@ -3366,7 +3364,7 @@ index 2d8324c..46331b8 100644 if (newlim) lim = newlim; } -@@ -1752,6 +1960,130 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1753,6 +1961,130 @@ limfield (struct line const *line, struct keyfield const *key) return ptr; } @@ -3497,7 +3495,7 @@ index 2d8324c..46331b8 100644 /* 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 -@@ -1838,8 +2170,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) +@@ -1839,8 +2171,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) else { if (key->skipsblanks) @@ -3522,7 +3520,7 @@ index 2d8324c..46331b8 100644 line->keybeg = line_start; } } -@@ -1977,12 +2323,10 @@ find_unit_order (char const *number) +@@ -1978,12 +2324,10 @@ find_unit_order (char const *number) ATTRIBUTE_PURE static int @@ -3538,7 +3536,7 @@ index 2d8324c..46331b8 100644 int diff = find_unit_order (a) - find_unit_order (b); return (diff ? diff : strnumcmp (a, b, decimal_point, thousands_sep)); -@@ -1994,7 +2338,7 @@ human_numcompare (char const *a, char const *b) +@@ -1995,7 +2339,7 @@ human_numcompare (char const *a, char const *b) ATTRIBUTE_PURE static int @@ -3547,7 +3545,7 @@ index 2d8324c..46331b8 100644 { while (blanks[to_uchar (*a)]) a++; -@@ -2004,6 +2348,25 @@ numcompare (char const *a, char const *b) +@@ -2005,6 +2349,25 @@ numcompare (char const *a, char const *b) return strnumcmp (a, b, decimal_point, thousands_sep); } @@ -3573,7 +3571,7 @@ index 2d8324c..46331b8 100644 static int nan_compare (long double a, long double b) { -@@ -2045,7 +2408,7 @@ general_numcompare (char const *sa, char const *sb) +@@ -2046,7 +2409,7 @@ general_numcompare (char const *sa, char const *sb) Return 0 if the name in S is not recognized. */ static int @@ -3582,7 +3580,7 @@ index 2d8324c..46331b8 100644 { size_t lo = 0; size_t hi = MONTHS_PER_YEAR; -@@ -2372,15 +2735,14 @@ debug_key (struct line const *line, struct keyfield const *key) +@@ -2385,15 +2748,14 @@ debug_key (struct line const *line, struct keyfield const *key) char saved = *lim; *lim = '\0'; @@ -3600,7 +3598,7 @@ index 2d8324c..46331b8 100644 else if (key->general_numeric) ignore_value (strtold (beg, &tighter_lim)); else if (key->numeric || key->human_numeric) -@@ -2526,7 +2888,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2539,7 +2901,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) /* Warn about significant leading blanks. */ bool implicit_skip = key_numeric (key) || key->month; bool line_offset = key->eword == 0 && key->echar != 0; /* -k1.x,1.y */ @@ -3609,7 +3607,7 @@ index 2d8324c..46331b8 100644 && ((!key->skipsblanks && !implicit_skip) || (!key->skipsblanks && key->schar) || (!key->skipeblanks && key->echar))) -@@ -2574,9 +2936,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2587,9 +2949,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) bool number_locale_warned = false; if (basic_numeric_field_span) { @@ -3622,7 +3620,7 @@ index 2d8324c..46331b8 100644 { error (0, 0, _("field separator %s is treated as a " -@@ -2587,9 +2949,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2600,9 +2962,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) } if (basic_numeric_field_span || general_numeric_field_span) { @@ -3635,7 +3633,7 @@ index 2d8324c..46331b8 100644 { error (0, 0, _("field separator %s is treated as a " -@@ -2597,19 +2959,19 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2610,19 +2972,19 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) quote (((char []) {decimal_point, 0}))); number_locale_warned = true; } @@ -3659,7 +3657,7 @@ index 2d8324c..46331b8 100644 } } -@@ -2620,7 +2982,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2633,7 +2995,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) { error (0, 0, _("%snumbers use %s as a decimal point in this locale"), @@ -3668,7 +3666,7 @@ index 2d8324c..46331b8 100644 quote (((char []) {decimal_point, 0}))); } -@@ -2662,11 +3024,87 @@ diff_reversed (int diff, bool reversed) +@@ -2675,11 +3037,87 @@ diff_reversed (int diff, bool reversed) return reversed ? (diff < 0) - (diff > 0) : diff; } @@ -3757,7 +3755,7 @@ index 2d8324c..46331b8 100644 { struct keyfield *key = keylist; -@@ -2747,7 +3185,7 @@ keycompare (struct line const *a, struct line const *b) +@@ -2760,7 +3198,7 @@ keycompare (struct line const *a, struct line const *b) else if (key->human_numeric) diff = human_numcompare (ta, tb); else if (key->month) @@ -3766,7 +3764,7 @@ index 2d8324c..46331b8 100644 else if (key->random) diff = compare_random (ta, tlena, tb, tlenb); else if (key->version) -@@ -2857,6 +3295,211 @@ keycompare (struct line const *a, struct line const *b) +@@ -2870,6 +3308,211 @@ keycompare (struct line const *a, struct line const *b) return diff_reversed (diff, key->reverse); } @@ -3978,7 +3976,7 @@ index 2d8324c..46331b8 100644 /* Compare two lines A and B, returning negative, zero, or positive depending on whether A compares less than, equal to, or greater than B. */ -@@ -2884,7 +3527,7 @@ compare (struct line const *a, struct line const *b) +@@ -2897,7 +3540,7 @@ compare (struct line const *a, struct line const *b) diff = - NONZERO (blen); else if (blen == 0) diff = 1; @@ -3987,7 +3985,7 @@ index 2d8324c..46331b8 100644 { /* xmemcoll0 is a performance enhancement as it will not unconditionally write '\0' after the -@@ -4272,6 +4915,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) +@@ -4285,6 +4928,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) break; case 'f': key->translate = fold_toupper; @@ -3995,7 +3993,7 @@ index 2d8324c..46331b8 100644 break; case 'g': key->general_numeric = true; -@@ -4351,7 +4995,7 @@ main (int argc, char **argv) +@@ -4364,7 +5008,7 @@ main (int argc, char **argv) initialize_exit_failure (SORT_FAILURE); hard_LC_COLLATE = hard_locale (LC_COLLATE); @@ -4004,7 +4002,7 @@ index 2d8324c..46331b8 100644 hard_LC_TIME = hard_locale (LC_TIME); #endif -@@ -4374,6 +5018,29 @@ main (int argc, char **argv) +@@ -4387,6 +5031,29 @@ main (int argc, char **argv) thousands_sep = NON_CHAR; } @@ -4034,7 +4032,7 @@ index 2d8324c..46331b8 100644 have_read_stdin = false; inittables (); -@@ -4644,13 +5311,34 @@ main (int argc, char **argv) +@@ -4657,13 +5324,34 @@ main (int argc, char **argv) case 't': { @@ -4073,7 +4071,7 @@ index 2d8324c..46331b8 100644 else { /* Provoke with 'sort -txx'. Complain about -@@ -4661,9 +5349,11 @@ main (int argc, char **argv) +@@ -4674,9 +5362,11 @@ main (int argc, char **argv) quote (optarg)); } } @@ -4088,7 +4086,7 @@ index 2d8324c..46331b8 100644 break; diff --git a/src/unexpand.c b/src/unexpand.c -index aca67dd..f79c808 100644 +index ff234d7..7c36ef6 100644 --- a/src/unexpand.c +++ b/src/unexpand.c @@ -39,6 +39,9 @@ @@ -4101,7 +4099,7 @@ index aca67dd..f79c808 100644 #include "system.h" #include "expand-common.h" -@@ -105,24 +108,47 @@ unexpand (void) +@@ -105,24 +108,46 @@ unexpand (void) { /* Input stream. */ FILE *fp = next_file (nullptr); @@ -4121,28 +4119,27 @@ index aca67dd..f79c808 100644 if (!fp) return; + + mbf_init (mbf, fp); + found_bom=check_bom(fp,&mbf); + + if (using_utf_locale == false && found_bom == true) -+ { -+ /*try using some predefined locale */ - -+ if (set_utf_locale () != 0) + { -+ error (EXIT_FAILURE, errno, _("cannot set UTF-8 locale")); ++ /* Try using some predefined locale */ ++ if (set_utf_locale () != 0) ++ { ++ error (EXIT_FAILURE, errno, _("cannot set UTF-8 locale")); ++ } + } -+ } ++ /* The worst case is a non-blank character, then one blank, then a tab stop, then MAX_COLUMN_WIDTH - 1 blanks, then a non-blank; so allocate MAX_COLUMN_WIDTH bytes to store the blanks. */ -- pending_blank = xmalloc (max_column_width); -+ pending_blank = xmalloc (max_column_width * sizeof (mbf_char_t)); +- pending_blank = ximalloc (max_column_width); ++ pending_blank = ximalloc (max_column_width * sizeof (mbf_char_t)); + + if (found_bom == true) -+ { + print_bom(); -+ } while (true) { @@ -4152,7 +4149,7 @@ index aca67dd..f79c808 100644 /* If true, perform translations. */ bool convert = true; -@@ -156,12 +182,44 @@ unexpand (void) +@@ -156,12 +181,44 @@ unexpand (void) do { @@ -4200,10 +4197,10 @@ index aca67dd..f79c808 100644 if (blank) { -@@ -178,16 +236,16 @@ unexpand (void) - if (next_tab_column < column) - error (EXIT_FAILURE, 0, _("input line is too long")); +@@ -175,16 +232,16 @@ unexpand (void) + if (convert) + { - if (c == '\t') + if (mb_iseq (c, '\t')) { @@ -4220,7 +4217,7 @@ index aca67dd..f79c808 100644 if (! (prev_blank && column == next_tab_column)) { -@@ -195,13 +253,14 @@ unexpand (void) +@@ -192,13 +249,14 @@ unexpand (void) will be replaced by tabs. */ if (column == next_tab_column) one_blank_before_tab_stop = true; @@ -4237,7 +4234,7 @@ index aca67dd..f79c808 100644 } /* Discard pending blanks, unless it was a single -@@ -209,7 +268,7 @@ unexpand (void) +@@ -206,7 +264,7 @@ unexpand (void) pending = one_blank_before_tab_stop; } } @@ -4246,7 +4243,7 @@ index aca67dd..f79c808 100644 { /* Go back one column, and force recalculation of the next tab stop. */ -@@ -219,16 +278,20 @@ unexpand (void) +@@ -216,16 +274,20 @@ unexpand (void) } else { @@ -4271,7 +4268,7 @@ index aca67dd..f79c808 100644 write_error (); pending = 0; one_blank_before_tab_stop = false; -@@ -238,16 +301,17 @@ unexpand (void) +@@ -235,16 +297,17 @@ unexpand (void) convert &= convert_entire_line || blank; } @@ -4293,7 +4290,7 @@ index aca67dd..f79c808 100644 } diff --git a/tests/Coreutils.pm b/tests/Coreutils.pm -index 18e7bea..24a141b 100644 +index b55fb9d..ac80f49 100644 --- a/tests/Coreutils.pm +++ b/tests/Coreutils.pm @@ -269,6 +269,9 @@ sub run_tests ($$$$$) @@ -4531,10 +4528,10 @@ index 0000000..26c95de + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk -index fdbf369..a6ce49c 100644 +index 12e30b4..1529db6 100644 --- a/tests/local.mk +++ b/tests/local.mk -@@ -387,6 +387,8 @@ all_tests = \ +@@ -390,6 +390,8 @@ all_tests = \ tests/sort/sort-discrim.sh \ tests/sort/sort-files0-from.pl \ tests/sort/sort-float.sh \ @@ -4543,7 +4540,7 @@ index fdbf369..a6ce49c 100644 tests/sort/sort-h-thousands-sep.sh \ tests/sort/sort-merge.pl \ tests/sort/sort-merge-fdlimit.sh \ -@@ -590,6 +592,7 @@ all_tests = \ +@@ -593,6 +595,7 @@ all_tests = \ tests/du/threshold.sh \ tests/du/trailing-slash.sh \ tests/du/two-args.sh \ @@ -4551,7 +4548,7 @@ index fdbf369..a6ce49c 100644 tests/id/gnu-zero-uids.sh \ tests/id/no-context.sh \ tests/id/context.sh \ -@@ -746,6 +749,7 @@ all_tests = \ +@@ -749,6 +752,7 @@ all_tests = \ tests/touch/read-only.sh \ tests/touch/relative.sh \ tests/touch/trailing-slash.sh \ @@ -4560,7 +4557,7 @@ index fdbf369..a6ce49c 100644 # See tests/factor/create-test.sh. diff --git a/tests/misc/expand.pl b/tests/misc/expand.pl -index 11f3fc4..d609a2c 100755 +index 4b07210..68b9ea1 100755 --- a/tests/misc/expand.pl +++ b/tests/misc/expand.pl @@ -27,6 +27,15 @@ my $prog = 'expand'; @@ -4627,10 +4624,10 @@ index 11f3fc4..d609a2c 100755 my $verbose = $ENV{VERBOSE}; diff --git a/tests/misc/fold.pl b/tests/misc/fold.pl -index 00b4362..7d51bea 100755 +index 0981ec9..ba889c8 100755 --- a/tests/misc/fold.pl +++ b/tests/misc/fold.pl -@@ -20,9 +20,18 @@ use strict; +@@ -20,9 +20,17 @@ use strict; (my $program_name = $0) =~ s|.*/||; @@ -4640,17 +4637,17 @@ index 00b4362..7d51bea 100755 + # Turn off localization of executable's output. @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; - +-my $prog = 'fold'; ++ +# uncommented to enable multibyte paths +my $mb_locale = $ENV{LOCALE_FR_UTF8}; +! defined $mb_locale || $mb_locale eq 'none' + and $mb_locale = 'C'; -+ + my @Tests = ( - ['s1', '-w2 -s', {IN=>"a\t"}, {OUT=>"a\n\t"}], -@@ -31,9 +40,48 @@ my @Tests = - ['s4', '-w4 -s', {IN=>"abc ef\n"}, {OUT=>"abc \nef\n"}], +@@ -44,9 +52,48 @@ my @Tests = + {OUT=>"123456\n7890\nabcdef\nghij\n123456\n7890"}], ); +# Add _POSIX2_VERSION=199209 to the environment of each test @@ -4751,7 +4748,7 @@ index 0000000..11836ba + +Exit $fail diff --git a/tests/misc/unexpand.pl b/tests/misc/unexpand.pl -index 76bcbd4..59eb819 100755 +index 27d9c17..4976335 100755 --- a/tests/misc/unexpand.pl +++ b/tests/misc/unexpand.pl @@ -27,6 +27,14 @@ my $limits = getlimits (); @@ -4808,7 +4805,7 @@ index 76bcbd4..59eb819 100755 my $verbose = $ENV{VERBOSE}; diff --git a/tests/pr/pr-tests.pl b/tests/pr/pr-tests.pl -index 6b34e0b..34b4aeb 100755 +index 60e6106..3c64a08 100755 --- a/tests/pr/pr-tests.pl +++ b/tests/pr/pr-tests.pl @@ -24,6 +24,15 @@ use strict; @@ -4877,7 +4874,7 @@ index 6b34e0b..34b4aeb 100755 my $verbose = $ENV{VERBOSE}; diff --git a/tests/sort/sort-merge.pl b/tests/sort/sort-merge.pl -index 89eed0c..b855d73 100755 +index a3204d3..40942a5 100755 --- a/tests/sort/sort-merge.pl +++ b/tests/sort/sort-merge.pl @@ -26,6 +26,15 @@ my $prog = 'sort'; @@ -4937,7 +4934,7 @@ index 89eed0c..b855d73 100755 my $verbose = $ENV{VERBOSE}; diff --git a/tests/sort/sort.pl b/tests/sort/sort.pl -index d49f65f..ebba925 100755 +index 2ee92c4..96c7965 100755 --- a/tests/sort/sort.pl +++ b/tests/sort/sort.pl @@ -24,10 +24,15 @@ my $prog = 'sort'; @@ -5183,5 +5180,5 @@ index 0000000..8a82d74 +LC_ALL=C unexpand in in > out || fail=1 +compare exp out > /dev/null 2>&1 || fail=1 -- -2.44.0 +2.48.1 diff --git a/coreutils.spec b/coreutils.spec index e792c2d369177d0379053146baebfbc9054d0f64..1bd5a52ce8d887020f8f63dafccd94c9c741a066 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Name: coreutils -Version: 9.5 -Release: 7 -License: GPLv3+ +Version: 9.6 +Release: 1 +License: GPL-3.0-or-later Summary: A set of basic GNU tools commonly used in shell scripts Url: https://www.gnu.org/software/coreutils/ Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz @@ -17,23 +17,13 @@ Patch2: bugfix-remove-usr-local-lib-from-m4.patch Patch3: bugfix-dummy_help2man.patch Patch4: skip-the-tests-that-require-selinux-if-selinux-is-di.patch Patch5: backport-config-color-alias-for-ls.patch -Patch6: backport-coreutils-df-direct.patch -Patch7: backport-coreutils-i18n.patch +Patch7: coreutils-i18n.patch Patch8: test-skip-overlay-filesystem-because-of-no-inotify_add_watch.patch -Patch9: coreutils-9.5-gcc14-gnulib-lto.patch -patch10: backport-sort-don-t-trust-st_size-on-proc-files.patch -patch11: backport-cat-don-t-trust-st_size-on-proc-files.patch -patch12: backport-dd-don-t-trust-st_size-on-proc-files.patch -patch13: backport-split-don-t-trust-st_size-on-proc-files.patch -patch14: backport-putenv-Don-t-crash-upon-out-of-memory.patch -patch15: backport-head-off_t-not-uintmax_t-for-file-offset.patch -patch16: backport-shuf-avoid-integer-overflow-on-huge-inputs.patch -patch17: backport-shuf-fix-randomness-bug.patch -patch18: backport-chroot-whoami-use-uintmax_t-for-printing-uids.patch -patch19: backport-tail-avoid-infloop-with-c-on-dev-zero.patch -patch20: backport-head-fix-overflows-in-elide_tail_bytes_pipe.patch - -Patch9001: coreutils-9.5-sw.patch + +# Upstream patches +Patch6001: backport-ls-fix-crash-with-context.patch + +Patch9001: coreutils-9.6-sw.patch Conflicts: filesystem < 3 @@ -52,8 +42,6 @@ BuildRequires: gettext-devel, gmp-devel, libacl-devel, libattr-devel BuildRequires: libcap-devel, libselinux-devel, libselinux-utils, openssl-devel tcl Requires: ncurses, gmp -Requires(preun): /sbin/install-info -Requires(post): /sbin/install-info Provides: coreutils-full = %{version}-%{release} Provides: fileutils = %{version}-%{release} @@ -83,9 +71,13 @@ tee DIR_COLORS{,.256color,.lightbgcolor} /dev/null find tests -name '*.sh' -perm 0644 -print -exec chmod 0755 '{}' '+' (echo "<<< done") 2>/dev/null -autoreconf -fiv +# FIXME: Force a newer gettext version to workaround `autoreconf -i` errors +# with coreutils 9.6 and bundled gettext 0.19.2 from gettext-common-devel. +sed -i 's/0.19.2/0.22.5/' bootstrap.conf configure.ac %build +autoreconf -fi + if [ %user = root ]; then export FORCE_UNSAFE_CONFIGURE=1 fi @@ -151,7 +143,6 @@ popd %{_libexecdir}/coreutils/*.so %doc ABOUT-NLS NEWS README THANKS TODO %license COPYING -%exclude %{_infodir}/dir %config(noreplace) %{_sysconfdir}/profile.d/* %config(noreplace) %{_sysconfdir}/DIR_COLORS* @@ -161,6 +152,9 @@ popd %{_mandir}/man*/* %changelog +* Sat Jan 18 2025 Funda Wang - 9.6-1 +- update to 9.6 + * Thu Nov 28 2024 huyubiao - 9.5-7 - sync patches from community - add backport-head-fix-overflows-in-elide_tail_bytes_pipe.patch