mirror of
https://abf.rosa.ru/djam/coreutils.git
synced 2025-02-24 01:32:50 +00:00
commit
22b550d4d1
18 changed files with 326 additions and 5101 deletions
2
.abf.yml
2
.abf.yml
|
@ -1,3 +1,3 @@
|
|||
sources:
|
||||
coreutils-8.32.tar.xz: b2b12195e276c64c8e850cf40ea2cff9b3aa53f6
|
||||
coreutils-9.3.tar.xz: cd1fd7e27d46fd2497b8f2a670b54785530ef7d2
|
||||
coreutils_man_ru.tar.gz: e39aa20bd84831221d73a758b3ef70bbb50c78f9
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
--- coreutils-5.92/src/date.c.langinfo 2005-09-16 09:06:57.000000000 +0100
|
||||
+++ coreutils-5.92/src/date.c 2005-10-24 18:09:16.000000000 +0100
|
||||
@@ -451,14 +451,7 @@
|
||||
format = DATE_FMT_LANGINFO ();
|
||||
if (! *format)
|
||||
{
|
||||
- /* Do not wrap the following literal format string with _(...).
|
||||
- For example, suppose LC_ALL is unset, LC_TIME=POSIX,
|
||||
- and LANG="ko_KR". In that case, POSIX says that LC_TIME
|
||||
- determines the format and contents of date and time strings
|
||||
- written by date, which means "date" must generate output
|
||||
- using the POSIX locale; but adding _() would cause "date"
|
||||
- to use a Korean translation of the format. */
|
||||
- format = "%a %b %e %H:%M:%S %Z %Y";
|
||||
+ format = dcgettext(NULL, N_("%a %b %e %H:%M:%S %Z %Y"), LC_TIME);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
diff --git a/src/md5sum.c b/src/md5sum.c
|
||||
index 8e21609..a857d62 100644
|
||||
--- a/src/md5sum.c
|
||||
+++ b/src/md5sum.c
|
||||
@@ -265,6 +265,9 @@ Print or check %s (%d-bit) checksums.\n\
|
||||
else
|
||||
fputs (_("\
|
||||
-t, --text read in text mode (default)\n\
|
||||
+"), stdout);
|
||||
+ fputs (_("\
|
||||
+ Note: There is no difference between binary and text mode option on GNU system.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-z, --zero end each output line with NUL, not newline,\n\
|
|
@ -1,40 +0,0 @@
|
|||
diff -Naur coreutils-8.24/src/cp.c coreutils-8.24.tpg/src/cp.c
|
||||
--- coreutils-8.24/src/cp.c 2015-06-26 17:04:19.000000000 +0000
|
||||
+++ coreutils-8.24.tpg/src/cp.c 2015-07-14 20:09:13.652243642 +0000
|
||||
@@ -997,6 +997,7 @@
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
+ x.interactive = I_ALWAYS_YES;
|
||||
x.unlink_dest_after_failed_open = true;
|
||||
break;
|
||||
|
||||
diff -Naur coreutils-8.24/tests/cp/cp-i.sh coreutils-8.24.tpg/tests/cp/cp-i.sh
|
||||
--- coreutils-8.24/tests/cp/cp-i.sh 2015-06-26 17:04:19.000000000 +0000
|
||||
+++ coreutils-8.24.tpg/tests/cp/cp-i.sh 2015-07-14 20:09:52.268330234 +0000
|
||||
@@ -55,9 +55,6 @@
|
||||
echo n | cp -vfn c d 2>/dev/null > out6 || fail=1
|
||||
compare out6 out_empty || fail=1
|
||||
|
||||
-# do not ask, prevent from overwrite
|
||||
-echo n | cp -vnf c d 2>/dev/null > out7 || fail=1
|
||||
-compare out7 out_empty || fail=1
|
||||
|
||||
# options --backup and --no-clobber are mutually exclusive
|
||||
returns_ 1 cp -bn c d 2>/dev/null || fail=1
|
||||
diff -Naur coreutils-8.24/tests/mv/i-2.sh coreutils-8.24.tpg/tests/mv/i-2.sh
|
||||
--- coreutils-8.24/tests/mv/i-2.sh 2015-06-26 17:04:19.000000000 +0000
|
||||
+++ coreutils-8.24.tpg/tests/mv/i-2.sh 2015-07-14 20:10:32.315456259 +0000
|
||||
@@ -34,11 +34,7 @@
|
||||
# Before 4.0s, this would not prompt.
|
||||
cp -if e f < y > out 2>&1 || fail=1
|
||||
|
||||
-# Make sure out contains the prompt.
|
||||
-case "$(cat out)" in
|
||||
- "cp: replace 'f', overriding mode 0000 (---------)?"*) ;;
|
||||
- *) fail=1 ;;
|
||||
-esac
|
||||
+#(peroyvind) this test is bogus, we don't want to be prompted when forcing
|
||||
|
||||
test -f e || fail=1
|
||||
test -f f || fail=1
|
|
@ -1,66 +0,0 @@
|
|||
diff -Naur coreutils-8.32/configure.ac coreutils-8.32.tpg/configure.ac
|
||||
--- coreutils-8.32/configure.ac 2020-02-27 21:45:34.000000000 +0000
|
||||
+++ coreutils-8.32.tpg/configure.ac 2020-03-14 11:50:04.933837427 +0000
|
||||
@@ -334,6 +334,18 @@
|
||||
done
|
||||
fi
|
||||
|
||||
+AC_CACHE_CHECK([for gcc 7-compatible __builtin_mul_overflow_p],
|
||||
+ [utils_cv_builtin_mul_overflow_p],
|
||||
+ [AC_COMPILE_IFELSE(
|
||||
+ [AC_LANG_PROGRAM(
|
||||
+ [[]],
|
||||
+ [[return __builtin_mul_overflow_p(1, 2, 3);]])],
|
||||
+ [utils_cv_builtin_mul_overflow_p=yes],
|
||||
+ [utils_cv_builtin_mul_overflow_p=no])])
|
||||
+if test $utils_cv_builtin_mul_overflow_p = yes; then
|
||||
+ AC_DEFINE([HAVE_BUILTIN_MUL_OVERFLOW_P], [1], [Define if your compiler supports __builtin_mul_overflow_p])
|
||||
+fi
|
||||
+
|
||||
AC_CACHE_CHECK([for 3-argument setpriority function],
|
||||
[utils_cv_func_setpriority],
|
||||
[AC_LINK_IFELSE(
|
||||
diff -Naur coreutils-8.32/lib/fts.c coreutils-8.32.tpg/lib/fts.c
|
||||
--- coreutils-8.32/lib/fts.c 2020-01-01 14:14:23.000000000 +0000
|
||||
+++ coreutils-8.32.tpg/lib/fts.c 2020-03-14 11:52:20.788108201 +0000
|
||||
@@ -200,7 +200,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef FALLTHROUGH
|
||||
-# if __GNUC__ < 7
|
||||
+# if __GNUC__ < 7 || !__has_attribute(__fallthrough__)
|
||||
# define FALLTHROUGH ((void) 0)
|
||||
# else
|
||||
# define FALLTHROUGH __attribute__ ((__fallthrough__))
|
||||
diff -Naur coreutils-8.32/lib/intprops.h coreutils-8.32.tpg/lib/intprops.h
|
||||
--- coreutils-8.32/lib/intprops.h 2020-01-01 14:19:22.000000000 +0000
|
||||
+++ coreutils-8.32.tpg/lib/intprops.h 2020-03-14 11:51:18.088987533 +0000
|
||||
@@ -238,15 +238,11 @@
|
||||
# define _GL_HAS_BUILTIN_MUL_OVERFLOW _GL_HAS_BUILTIN_ADD_OVERFLOW
|
||||
#endif
|
||||
|
||||
-/* True if __builtin_add_overflow_p (A, B, C) works, and similarly for
|
||||
- __builtin_mul_overflow_p and __builtin_mul_overflow_p. */
|
||||
-#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
|
||||
-
|
||||
/* The _GL*_OVERFLOW macros have the same restrictions as the
|
||||
*_RANGE_OVERFLOW macros, except that they do not assume that operands
|
||||
(e.g., A and B) have the same type as MIN and MAX. Instead, they assume
|
||||
that the result (e.g., A + B) has that type. */
|
||||
-#if _GL_HAS_BUILTIN_OVERFLOW_P
|
||||
+#ifdef HAVE_BUILTIN_MUL_OVERFLOW_P
|
||||
# define _GL_ADD_OVERFLOW(a, b, min, max) \
|
||||
__builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
|
||||
# define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
|
||||
diff -Naur coreutils-8.32/lib/xalloc-oversized.h coreutils-8.32.tpg/lib/xalloc-oversized.h
|
||||
--- coreutils-8.32/lib/xalloc-oversized.h 2020-01-01 14:14:24.000000000 +0000
|
||||
+++ coreutils-8.32.tpg/lib/xalloc-oversized.h 2020-03-14 11:52:03.637075864 +0000
|
||||
@@ -41,7 +41,7 @@
|
||||
positive and N must be nonnegative. This is a macro, not a
|
||||
function, so that it works correctly even when SIZE_MAX < N. */
|
||||
|
||||
-#if 7 <= __GNUC__
|
||||
+#ifdef HAVE_BUILTIN_MUL_OVERFLOW_P
|
||||
# define xalloc_oversized(n, s) \
|
||||
__builtin_mul_overflow_p (n, s, (__xalloc_count_type) 1)
|
||||
#elif 5 <= __GNUC__ && !defined __ICC && !__STRICT_ANSI__
|
|
@ -1,364 +0,0 @@
|
|||
From e6df4c3b75bbaf464fc5475a4bdc392ab500670b Mon Sep 17 00:00:00 2001
|
||||
From: Kamil Dudka <kdudka@redhat.com>
|
||||
Date: Thu, 5 Mar 2020 17:37:12 +0100
|
||||
Subject: [PATCH] do not use IF_LINT for initialization of scalar variables
|
||||
|
||||
It triggers false positives in compilers and static analyzers
|
||||
for no real benefit.
|
||||
---
|
||||
src/chcon.c | 2 +-
|
||||
src/chmod.c | 4 ++--
|
||||
src/copy.c | 4 ++--
|
||||
src/cp.c | 2 +-
|
||||
src/cut.c | 2 +-
|
||||
src/df.c | 2 +-
|
||||
src/expand.c | 2 +-
|
||||
src/expr.c | 2 +-
|
||||
src/ls.c | 2 +-
|
||||
src/md5sum.c | 4 ++--
|
||||
src/od.c | 4 ++--
|
||||
src/paste.c | 4 ++--
|
||||
src/pr.c | 2 +-
|
||||
src/shred.c | 4 ++--
|
||||
src/sort.c | 14 +++++++-------
|
||||
src/split.c | 2 +-
|
||||
src/truncate.c | 2 +-
|
||||
src/unexpand.c | 4 ++--
|
||||
src/uniq.c | 4 ++--
|
||||
src/who.c | 2 +-
|
||||
20 files changed, 34 insertions(+), 34 deletions(-)
|
||||
|
||||
diff --git a/src/chcon.c b/src/chcon.c
|
||||
index 724ec9b..c1cf4c4 100644
|
||||
--- a/src/chcon.c
|
||||
+++ b/src/chcon.c
|
||||
@@ -142,7 +142,7 @@ static int
|
||||
change_file_context (int fd, char const *file)
|
||||
{
|
||||
char *file_context = NULL;
|
||||
- context_t context IF_LINT (= 0);
|
||||
+ context_t context = 0;
|
||||
char const * context_string;
|
||||
int errors = 0;
|
||||
|
||||
diff --git a/src/chmod.c b/src/chmod.c
|
||||
index ec91534..a71a43c 100644
|
||||
--- a/src/chmod.c
|
||||
+++ b/src/chmod.c
|
||||
@@ -190,8 +190,8 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
char const *file_full_name = ent->fts_path;
|
||||
char const *file = ent->fts_accpath;
|
||||
const struct stat *file_stats = ent->fts_statp;
|
||||
- mode_t old_mode IF_LINT ( = 0);
|
||||
- mode_t new_mode IF_LINT ( = 0);
|
||||
+ mode_t old_mode = 0;
|
||||
+ mode_t new_mode = 0;
|
||||
bool ok = true;
|
||||
bool chmod_succeeded = false;
|
||||
|
||||
diff --git a/src/copy.c b/src/copy.c
|
||||
index 6e5efc7..bb80038 100644
|
||||
--- a/src/copy.c
|
||||
+++ b/src/copy.c
|
||||
@@ -1889,8 +1889,8 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
{
|
||||
struct stat src_sb;
|
||||
struct stat dst_sb;
|
||||
- mode_t src_mode IF_LINT ( = 0);
|
||||
- mode_t dst_mode IF_LINT ( = 0);
|
||||
+ mode_t src_mode = 0;
|
||||
+ mode_t dst_mode = 0;
|
||||
mode_t dst_mode_bits;
|
||||
mode_t omitted_permissions;
|
||||
bool restore_dst_mode = false;
|
||||
diff --git a/src/cp.c b/src/cp.c
|
||||
index 0193df8..609adcf 100644
|
||||
--- a/src/cp.c
|
||||
+++ b/src/cp.c
|
||||
@@ -403,7 +403,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
|
||||
slash++;
|
||||
while ((slash = strchr (slash, '/')))
|
||||
{
|
||||
- struct dir_attr *new IF_LINT ( = NULL);
|
||||
+ struct dir_attr *new = NULL;
|
||||
bool missing_dir;
|
||||
|
||||
*slash = '\0';
|
||||
diff --git a/src/cut.c b/src/cut.c
|
||||
index 35ab5fc..685ba8d 100644
|
||||
--- a/src/cut.c
|
||||
+++ b/src/cut.c
|
||||
@@ -835,7 +835,7 @@ main (int argc, char **argv)
|
||||
int optc;
|
||||
bool ok;
|
||||
bool delim_specified = false;
|
||||
- char *spec_list_string IF_LINT ( = NULL);
|
||||
+ char *spec_list_string = NULL;
|
||||
char mbdelim[MB_LEN_MAX + 1];
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
diff --git a/src/df.c b/src/df.c
|
||||
index 7e01839..8af1d14 100644
|
||||
--- a/src/df.c
|
||||
+++ b/src/df.c
|
||||
@@ -1588,7 +1588,7 @@ field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent',\n\
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
- struct stat *stats IF_LINT ( = 0);
|
||||
+ struct stat *stats = 0;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
diff --git a/src/expand.c b/src/expand.c
|
||||
index bf61aff..cc9d4cd 100644
|
||||
--- a/src/expand.c
|
||||
+++ b/src/expand.c
|
||||
@@ -190,7 +190,7 @@ expand (void)
|
||||
{
|
||||
/* Column the next input tab stop is on. */
|
||||
uintmax_t next_tab_column;
|
||||
- bool last_tab IF_LINT (=0);
|
||||
+ bool last_tab = 0;
|
||||
|
||||
next_tab_column = get_next_tab_column (column, &tab_index,
|
||||
&last_tab);
|
||||
diff --git a/src/expr.c b/src/expr.c
|
||||
index e134872..a49d37c 100644
|
||||
--- a/src/expr.c
|
||||
+++ b/src/expr.c
|
||||
@@ -690,7 +690,7 @@ trace (fxn)
|
||||
static VALUE *
|
||||
docolon (VALUE *sv, VALUE *pv)
|
||||
{
|
||||
- VALUE *v IF_LINT ( = NULL);
|
||||
+ VALUE *v = NULL;
|
||||
const char *errmsg;
|
||||
struct re_pattern_buffer re_buffer;
|
||||
char fastmap[UCHAR_MAX + 1];
|
||||
diff --git a/src/ls.c b/src/ls.c
|
||||
index 64ecf40..cc61400 100644
|
||||
--- a/src/ls.c
|
||||
+++ b/src/ls.c
|
||||
@@ -4429,7 +4429,7 @@ quote_name_buf (char **inbuf, size_t bufsize, char *name,
|
||||
int needs_general_quoting, size_t *width, bool *pad)
|
||||
{
|
||||
char *buf = *inbuf;
|
||||
- size_t displayed_width IF_LINT ( = 0);
|
||||
+ size_t displayed_width = 0;
|
||||
size_t len = 0;
|
||||
bool quoted;
|
||||
|
||||
diff --git a/src/md5sum.c b/src/md5sum.c
|
||||
index 447a005..91b9a9e 100644
|
||||
--- a/src/md5sum.c
|
||||
+++ b/src/md5sum.c
|
||||
@@ -687,9 +687,9 @@ digest_check (const char *checkfile_name)
|
||||
line_chars_allocated = 0;
|
||||
do
|
||||
{
|
||||
- char *filename IF_LINT ( = NULL);
|
||||
+ char *filename = NULL;
|
||||
int binary;
|
||||
- unsigned char *hex_digest IF_LINT ( = NULL);
|
||||
+ unsigned char *hex_digest = NULL;
|
||||
ssize_t line_length;
|
||||
|
||||
++line_number;
|
||||
diff --git a/src/od.c b/src/od.c
|
||||
index 200bc16..7482bb5 100644
|
||||
--- a/src/od.c
|
||||
+++ b/src/od.c
|
||||
@@ -1570,7 +1570,7 @@ main (int argc, char **argv)
|
||||
int n_files;
|
||||
size_t i;
|
||||
int l_c_m;
|
||||
- size_t desired_width IF_LINT ( = 0);
|
||||
+ size_t desired_width = 0;
|
||||
bool modern = false;
|
||||
bool width_specified = false;
|
||||
bool ok = true;
|
||||
@@ -1579,7 +1579,7 @@ main (int argc, char **argv)
|
||||
|
||||
/* The old-style 'pseudo starting address' to be printed in parentheses
|
||||
after any true address. */
|
||||
- uintmax_t pseudo_start IF_LINT ( = 0);
|
||||
+ uintmax_t pseudo_start = 0;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
diff --git a/src/paste.c b/src/paste.c
|
||||
index 9f401c9..6dd3a4e 100644
|
||||
--- a/src/paste.c
|
||||
+++ b/src/paste.c
|
||||
@@ -234,8 +234,8 @@ paste_parallel (size_t nfiles, char **fnamptr)
|
||||
|
||||
for (size_t i = 0; i < nfiles && files_open; i++)
|
||||
{
|
||||
- int chr IF_LINT ( = 0); /* Input character. */
|
||||
- int err IF_LINT ( = 0); /* Input errno value. */
|
||||
+ int chr = 0; /* Input character. */
|
||||
+ int err = 0; /* Input errno value. */
|
||||
bool sometodo = false; /* Input chars to process. */
|
||||
|
||||
if (fileptr[i])
|
||||
diff --git a/src/pr.c b/src/pr.c
|
||||
index 6374a7f..3ac3c03 100644
|
||||
--- a/src/pr.c
|
||||
+++ b/src/pr.c
|
||||
@@ -2606,7 +2606,7 @@ static bool
|
||||
read_line (COLUMN *p)
|
||||
{
|
||||
int c;
|
||||
- int chars IF_LINT ( = 0);
|
||||
+ int chars = 0;
|
||||
int last_input_position;
|
||||
int j, k;
|
||||
COLUMN *q;
|
||||
diff --git a/src/shred.c b/src/shred.c
|
||||
index fbbeddf..e9a6414 100644
|
||||
--- a/src/shred.c
|
||||
+++ b/src/shred.c
|
||||
@@ -399,7 +399,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
|
||||
{
|
||||
off_t size = *sizep;
|
||||
off_t offset; /* Current file position */
|
||||
- time_t thresh IF_LINT ( = 0); /* Time to maybe print next status update */
|
||||
+ time_t thresh = 0; /* Time to maybe print next status update */
|
||||
time_t now = 0; /* Current time */
|
||||
size_t lim; /* Amount of data to try writing */
|
||||
size_t soff; /* Offset into buffer for next write */
|
||||
@@ -424,7 +424,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
|
||||
|
||||
/* Printable previous offset into the file */
|
||||
char previous_offset_buf[LONGEST_HUMAN_READABLE + 1];
|
||||
- char const *previous_human_offset IF_LINT ( = 0);
|
||||
+ char const *previous_human_offset = 0;
|
||||
|
||||
/* As a performance tweak, avoid direct I/O for small sizes,
|
||||
as it's just a performance rather then security consideration,
|
||||
diff --git a/src/sort.c b/src/sort.c
|
||||
index 8e1533e..cb494f4 100644
|
||||
--- a/src/sort.c
|
||||
+++ b/src/sort.c
|
||||
@@ -1114,7 +1114,7 @@ pipe_fork (int pipefds[2], size_t tries)
|
||||
struct tempnode *saved_temphead;
|
||||
int saved_errno;
|
||||
double wait_retry = 0.25;
|
||||
- pid_t pid IF_LINT ( = -1);
|
||||
+ pid_t pid = -1;
|
||||
struct cs_status cs;
|
||||
|
||||
if (pipe2 (pipefds, O_CLOEXEC) < 0)
|
||||
@@ -2999,9 +2999,9 @@ keycompare_uni (const struct line *a, const struct line *b)
|
||||
size_t tlena;
|
||||
size_t tlenb;
|
||||
|
||||
- char enda IF_LINT (= 0);
|
||||
- char endb IF_LINT (= 0);
|
||||
- void *allocated IF_LINT (= NULL);
|
||||
+ char enda = 0;
|
||||
+ char endb = 0;
|
||||
+ void *allocated = NULL;
|
||||
char stackbuf[4000];
|
||||
|
||||
if (ignore || translate)
|
||||
@@ -3267,8 +3267,8 @@ keycompare_mb (const struct line *a, const struct line *b)
|
||||
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 enda = 0;
|
||||
+ char endb = 0;
|
||||
|
||||
char const *translate = key->translate;
|
||||
bool const *ignore = key->ignore;
|
||||
@@ -4551,7 +4551,7 @@ sort (char *const *files, size_t nfiles, char const *output_file,
|
||||
size_t nthreads)
|
||||
{
|
||||
struct buffer buf;
|
||||
- IF_LINT (buf.buf = NULL);
|
||||
+ buf.buf = NULL;
|
||||
size_t ntemps = 0;
|
||||
bool output_file_created = false;
|
||||
|
||||
diff --git a/src/split.c b/src/split.c
|
||||
index 09e610b..aefa4a7 100644
|
||||
--- a/src/split.c
|
||||
+++ b/src/split.c
|
||||
@@ -1132,7 +1132,7 @@ lines_rr (uintmax_t k, uintmax_t n, char *buf, size_t bufsize)
|
||||
bool wrote = false;
|
||||
bool file_limit;
|
||||
size_t i_file;
|
||||
- of_t *files IF_LINT (= NULL);
|
||||
+ of_t *files = NULL;
|
||||
uintmax_t line_no;
|
||||
|
||||
if (k)
|
||||
diff --git a/src/truncate.c b/src/truncate.c
|
||||
index 91d9674..76e224f 100644
|
||||
--- a/src/truncate.c
|
||||
+++ b/src/truncate.c
|
||||
@@ -203,7 +203,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
bool got_size = false;
|
||||
bool errors = false;
|
||||
- off_t size IF_LINT ( = 0);
|
||||
+ off_t size = 0;
|
||||
off_t rsize = -1;
|
||||
rel_mode_t rel_mode = rm_abs;
|
||||
int c, fd = -1, oflags;
|
||||
diff --git a/src/unexpand.c b/src/unexpand.c
|
||||
index 7d5dd64..b0e0ab3 100644
|
||||
--- a/src/unexpand.c
|
||||
+++ b/src/unexpand.c
|
||||
@@ -225,7 +225,7 @@ unexpand (void)
|
||||
|
||||
if (blank)
|
||||
{
|
||||
- bool last_tab IF_LINT (=0);
|
||||
+ bool last_tab = 0;
|
||||
|
||||
next_tab_column = get_next_tab_column (column, &tab_index,
|
||||
&last_tab);
|
||||
@@ -320,7 +320,7 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
bool have_tabval = false;
|
||||
- uintmax_t tabval IF_LINT ( = 0);
|
||||
+ uintmax_t tabval = 0;
|
||||
int c;
|
||||
|
||||
/* If true, cancel the effect of any -a (explicit or implicit in -t),
|
||||
diff --git a/src/uniq.c b/src/uniq.c
|
||||
index ba3c4ce..fa0fc5c 100644
|
||||
--- a/src/uniq.c
|
||||
+++ b/src/uniq.c
|
||||
@@ -456,8 +456,8 @@ check_file (const char *infile, const char *outfile, char delimiter)
|
||||
*/
|
||||
if (output_unique && output_first_repeated && countmode == count_none)
|
||||
{
|
||||
- char *prevfield IF_LINT ( = NULL);
|
||||
- size_t prevlen IF_LINT ( = 0);
|
||||
+ char *prevfield = NULL;
|
||||
+ size_t prevlen = 0;
|
||||
bool first_group_printed = false;
|
||||
|
||||
while (!feof (stdin))
|
||||
diff --git a/src/who.c b/src/who.c
|
||||
index abf3bc7..401ad0f 100644
|
||||
--- a/src/who.c
|
||||
+++ b/src/who.c
|
||||
@@ -568,7 +568,7 @@ print_heading (void)
|
||||
static void
|
||||
scan_entries (size_t n, const STRUCT_UTMP *utmp_buf)
|
||||
{
|
||||
- char *ttyname_b IF_LINT ( = NULL);
|
||||
+ char *ttyname_b = NULL;
|
||||
time_t boottime = TYPE_MINIMUM (time_t);
|
||||
|
||||
if (include_heading)
|
||||
--
|
||||
2.21.1
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
From 8c022656320592dbad146f5d3a3ae1875f419446 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Date: Thu, 5 Mar 2020 17:25:29 -0800
|
||||
Subject: [PATCH 1/2] ls: restore 8.31 behavior on removed directories
|
||||
|
||||
* NEWS: Mention this.
|
||||
* src/ls.c: Do not include <sys/sycall.h>
|
||||
(print_dir): Don't worry about whether the directory is removed.
|
||||
* tests/ls/removed-directory.sh: Adjust to match new (i.e., old)
|
||||
behavior.
|
||||
|
||||
Upstream-commit: 10fcb97bd728f09d4a027eddf8ad2900f0819b0a
|
||||
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
||||
---
|
||||
src/ls.c | 22 ----------------------
|
||||
tests/ls/removed-directory.sh | 10 ++--------
|
||||
2 files changed, 2 insertions(+), 30 deletions(-)
|
||||
|
||||
diff --git a/src/ls.c b/src/ls.c
|
||||
index 9d25f62..850ecc2 100644
|
||||
--- a/src/ls.c
|
||||
+++ b/src/ls.c
|
||||
@@ -49,10 +49,6 @@
|
||||
# include <sys/ptem.h>
|
||||
#endif
|
||||
|
||||
-#ifdef __linux__
|
||||
-# include <sys/syscall.h>
|
||||
-#endif
|
||||
-
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <setjmp.h>
|
||||
@@ -2896,7 +2892,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
|
||||
struct dirent *next;
|
||||
uintmax_t total_blocks = 0;
|
||||
static bool first = true;
|
||||
- bool found_any_entries = false;
|
||||
|
||||
errno = 0;
|
||||
dirp = opendir (name);
|
||||
@@ -2972,7 +2967,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
|
||||
next = readdir (dirp);
|
||||
if (next)
|
||||
{
|
||||
- found_any_entries = true;
|
||||
if (! file_ignored (next->d_name))
|
||||
{
|
||||
enum filetype type = unknown;
|
||||
@@ -3018,22 +3012,6 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
|
||||
if (errno != EOVERFLOW)
|
||||
break;
|
||||
}
|
||||
-#ifdef __linux__
|
||||
- else if (! found_any_entries)
|
||||
- {
|
||||
- /* If readdir finds no directory entries at all, not even "." or
|
||||
- "..", then double check that the directory exists. */
|
||||
- if (syscall (SYS_getdents, dirfd (dirp), NULL, 0) == -1
|
||||
- && errno != EINVAL)
|
||||
- {
|
||||
- /* We exclude EINVAL as that pertains to buffer handling,
|
||||
- and we've passed NULL as the buffer for simplicity.
|
||||
- ENOENT is returned if appropriate before buffer handling. */
|
||||
- file_failure (command_line_arg, _("reading directory %s"), name);
|
||||
- }
|
||||
- break;
|
||||
- }
|
||||
-#endif
|
||||
else
|
||||
break;
|
||||
|
||||
diff --git a/tests/ls/removed-directory.sh b/tests/ls/removed-directory.sh
|
||||
index e8c835d..fe8f929 100755
|
||||
--- a/tests/ls/removed-directory.sh
|
||||
+++ b/tests/ls/removed-directory.sh
|
||||
@@ -26,20 +26,14 @@ case $host_triplet in
|
||||
*) skip_ 'non linux kernel' ;;
|
||||
esac
|
||||
|
||||
-LS_FAILURE=2
|
||||
-
|
||||
-cat <<\EOF >exp-err || framework_failure_
|
||||
-ls: reading directory '.': No such file or directory
|
||||
-EOF
|
||||
-
|
||||
cwd=$(pwd)
|
||||
mkdir d || framework_failure_
|
||||
cd d || framework_failure_
|
||||
rmdir ../d || framework_failure_
|
||||
|
||||
-returns_ $LS_FAILURE ls >../out 2>../err || fail=1
|
||||
+ls >../out 2>../err || fail=1
|
||||
cd "$cwd" || framework_failure_
|
||||
compare /dev/null out || fail=1
|
||||
-compare exp-err err || fail=1
|
||||
+compare /dev/null err || fail=1
|
||||
|
||||
Exit $fail
|
||||
--
|
||||
2.21.1
|
||||
|
||||
|
||||
From 847324a0debd9d12062c79e7a7a9d3d8ce76390d Mon Sep 17 00:00:00 2001
|
||||
From: Paul Eggert <eggert@cs.ucla.edu>
|
||||
Date: Sat, 7 Mar 2020 10:29:51 -0800
|
||||
Subject: [PATCH 2/2] ls: improve removed-directory test
|
||||
|
||||
* tests/ls/removed-directory.sh: Remove host_triplet test.
|
||||
Skip this test if one cannot remove the working directory.
|
||||
From a suggestion by Bernhard Voelker (Bug#39929).
|
||||
|
||||
Upstream-commit: 672819c73f2e94e61386dc0584bddf9da860cc26
|
||||
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
||||
---
|
||||
tests/ls/removed-directory.sh | 13 ++++---------
|
||||
1 file changed, 4 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/tests/ls/removed-directory.sh b/tests/ls/removed-directory.sh
|
||||
index fe8f929..63b209d 100755
|
||||
--- a/tests/ls/removed-directory.sh
|
||||
+++ b/tests/ls/removed-directory.sh
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
-# If ls is asked to list a removed directory (e.g. the parent process's
|
||||
-# current working directory that has been removed by another process), it
|
||||
-# emits an error message.
|
||||
+# If ls is asked to list a removed directory (e.g., the parent process's
|
||||
+# current working directory has been removed by another process), it
|
||||
+# should not emit an error message merely because the directory is removed.
|
||||
|
||||
# Copyright (C) 2020 Free Software Foundation, Inc.
|
||||
|
||||
@@ -21,15 +21,10 @@
|
||||
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
|
||||
print_ver_ ls
|
||||
|
||||
-case $host_triplet in
|
||||
- *linux*) ;;
|
||||
- *) skip_ 'non linux kernel' ;;
|
||||
-esac
|
||||
-
|
||||
cwd=$(pwd)
|
||||
mkdir d || framework_failure_
|
||||
cd d || framework_failure_
|
||||
-rmdir ../d || framework_failure_
|
||||
+rmdir ../d || skip_ "can't remove working directory on this platform"
|
||||
|
||||
ls >../out 2>../err || fail=1
|
||||
cd "$cwd" || framework_failure_
|
||||
--
|
||||
2.21.1
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
diff -Naur coreutils-8.32/src/dircolors.hin coreutils-8.32.tpg/src/dircolors.hin
|
||||
--- coreutils-8.32/src/dircolors.hin 2020-01-01 14:13:12.000000000 +0000
|
||||
+++ coreutils-8.32.tpg/src/dircolors.hin 2020-03-14 11:39:03.072672120 +0000
|
||||
@@ -8,6 +8,10 @@
|
||||
diff -ruN a/src/dircolors.hin b/src/dircolors.hin
|
||||
--- a/src/dircolors.hin 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/src/dircolors.hin 2023-05-03 17:24:29.513689720 +0300
|
||||
@@ -9,6 +9,10 @@
|
||||
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
|
||||
# slackware version of dircolors) are recognized but ignored.
|
||||
|
||||
|
@ -9,10 +9,10 @@ diff -Naur coreutils-8.32/src/dircolors.hin coreutils-8.32.tpg/src/dircolors.hin
|
|||
+# You can copy this file to .dir_colors in your $HOME directory to override
|
||||
+# the system defaults.
|
||||
+
|
||||
# Below are TERM entries, which can be a glob patterns, to match
|
||||
# against the TERM environment variable to determine if it is colorizable.
|
||||
TERM Eterm
|
||||
@@ -57,8 +61,8 @@
|
||||
# Global config options can be specified before TERM or COLORTERM entries
|
||||
|
||||
# ===================================================================
|
||||
@@ -68,8 +72,8 @@
|
||||
DOOR 01;35 # door
|
||||
BLK 40;33;01 # block device driver
|
||||
CHR 40;33;01 # character device driver
|
||||
|
@ -22,9 +22,9 @@ diff -Naur coreutils-8.32/src/dircolors.hin coreutils-8.32.tpg/src/dircolors.hin
|
|||
+MISSING 01;05;37;41 # ... and the files they point to
|
||||
SETUID 37;41 # file that is setuid (u+s)
|
||||
SETGID 30;43 # file that is setgid (g+s)
|
||||
CAPABILITY 30;41 # file with capability
|
||||
@@ -74,15 +78,15 @@
|
||||
# (and any comments you want to add after a '#')
|
||||
CAPABILITY 00 # file with capability (very expensive to lookup)
|
||||
@@ -91,15 +95,15 @@
|
||||
#
|
||||
|
||||
# If you use DOS-style suffixes, you may want to uncomment the following:
|
||||
-#.cmd 01;32 # executables (bright green)
|
||||
|
@ -37,16 +37,16 @@ diff -Naur coreutils-8.32/src/dircolors.hin coreutils-8.32.tpg/src/dircolors.hin
|
|||
+.com 01;32
|
||||
+.btm 01;32
|
||||
+.bat 01;32
|
||||
# Or if you want to colorize scripts even if they do not have the
|
||||
# Or if you want to color scripts even if they do not have the
|
||||
# executable bit actually set.
|
||||
-#.sh 01;32
|
||||
-#.csh 01;32
|
||||
+.sh 01;32
|
||||
+.csh 01;32
|
||||
|
||||
# archives or compressed (bright red)
|
||||
# archives or compressed (bright red)
|
||||
.tar 01;31
|
||||
@@ -127,6 +131,7 @@
|
||||
@@ -144,6 +148,7 @@
|
||||
.7z 01;31
|
||||
.rz 01;31
|
||||
.cab 01;31
|
||||
|
@ -54,8 +54,8 @@ diff -Naur coreutils-8.32/src/dircolors.hin coreutils-8.32.tpg/src/dircolors.hin
|
|||
.wim 01;31
|
||||
.swm 01;31
|
||||
.dwm 01;31
|
||||
@@ -135,6 +140,8 @@
|
||||
# image formats
|
||||
@@ -153,6 +158,8 @@
|
||||
.avif 01;35
|
||||
.jpg 01;35
|
||||
.jpeg 01;35
|
||||
+.JPG 01;35
|
||||
|
@ -63,7 +63,7 @@ diff -Naur coreutils-8.32/src/dircolors.hin coreutils-8.32.tpg/src/dircolors.hin
|
|||
.mjpg 01;35
|
||||
.mjpeg 01;35
|
||||
.gif 01;35
|
||||
@@ -148,6 +155,7 @@
|
||||
@@ -166,6 +173,7 @@
|
||||
.tif 01;35
|
||||
.tiff 01;35
|
||||
.png 01;35
|
||||
|
@ -71,7 +71,7 @@ diff -Naur coreutils-8.32/src/dircolors.hin coreutils-8.32.tpg/src/dircolors.hin
|
|||
.svg 01;35
|
||||
.svgz 01;35
|
||||
.mng 01;35
|
||||
@@ -160,6 +168,9 @@
|
||||
@@ -178,6 +186,9 @@
|
||||
.webm 01;35
|
||||
.webp 01;35
|
||||
.ogm 01;35
|
||||
|
@ -81,7 +81,7 @@ diff -Naur coreutils-8.32/src/dircolors.hin coreutils-8.32.tpg/src/dircolors.hin
|
|||
.mp4 01;35
|
||||
.m4v 01;35
|
||||
.mp4v 01;35
|
||||
@@ -199,9 +210,78 @@
|
||||
@@ -217,6 +228,12 @@
|
||||
.ogg 00;36
|
||||
.ra 00;36
|
||||
.wav 00;36
|
||||
|
@ -94,10 +94,28 @@ diff -Naur coreutils-8.32/src/dircolors.hin coreutils-8.32.tpg/src/dircolors.hin
|
|||
|
||||
# https://wiki.xiph.org/MIME_Types_and_File_Extensions
|
||||
.oga 00;36
|
||||
.opus 00;36
|
||||
@@ -224,24 +241,80 @@
|
||||
.spx 00;36
|
||||
.xspf 00;36
|
||||
+
|
||||
|
||||
-# backup files
|
||||
-*~ 00;90
|
||||
-*# 00;90
|
||||
-.bak 00;90
|
||||
-.old 00;90
|
||||
-.orig 00;90
|
||||
-.part 00;90
|
||||
-.rej 00;90
|
||||
-.swp 00;90
|
||||
-.tmp 00;90
|
||||
-.dpkg-dist 00;90
|
||||
-.dpkg-old 00;90
|
||||
-.ucf-dist 00;90
|
||||
-.ucf-new 00;90
|
||||
-.ucf-old 00;90
|
||||
-.rpmnew 00;90
|
||||
-.rpmorig 00;90
|
||||
-.rpmsave 00;90
|
||||
+# document and various text(ish) formats
|
||||
+# .txt 01;37;40
|
||||
+# .lyx 01;37;40
|
||||
|
@ -152,6 +170,7 @@ diff -Naur coreutils-8.32/src/dircolors.hin coreutils-8.32.tpg/src/dircolors.hin
|
|||
+
|
||||
+# backup formats
|
||||
+*~ 47;30
|
||||
+*# 47;30
|
||||
+.bak 47;30
|
||||
+.swp 47;30
|
||||
+.bck 47;30
|
||||
|
@ -160,3 +179,17 @@ diff -Naur coreutils-8.32/src/dircolors.hin coreutils-8.32.tpg/src/dircolors.hin
|
|||
+.tmp 47;30
|
||||
+.save 47;30
|
||||
+.rpmsave 47;30
|
||||
+.old 47;30
|
||||
+.orig 47;30
|
||||
+.part 47;30
|
||||
+.rej 47;30
|
||||
+.dpkg-dist 47;30
|
||||
+.dpkg-old 47;30
|
||||
+.ucf-dist 47;30
|
||||
+.ucf-new 47;30
|
||||
+.ucf-old 47;30
|
||||
+.rpmnew 47;30
|
||||
+.rpmorig 47;30
|
||||
|
||||
#
|
||||
# Subsequent TERM or COLORTERM entries, can be used to add / override
|
|
@ -1,8 +1,7 @@
|
|||
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
|
||||
index a507280..400e135 100644
|
||||
--- a/doc/coreutils.texi
|
||||
+++ b/doc/coreutils.texi
|
||||
@@ -11303,6 +11303,13 @@ some systems (notably SunOS), doing this yields more up to date results,
|
||||
diff -ruN a/doc/coreutils.texi b/doc/coreutils.texi
|
||||
--- a/doc/coreutils.texi 2023-05-03 16:46:19.403274895 +0300
|
||||
+++ b/doc/coreutils.texi 2023-05-03 17:36:30.361834665 +0300
|
||||
@@ -12303,6 +12303,13 @@
|
||||
but in general this option makes @command{df} much slower, especially when
|
||||
there are many or very busy file systems.
|
||||
|
||||
|
@ -15,12 +14,11 @@ index a507280..400e135 100644
|
|||
+
|
||||
@item --total
|
||||
@opindex --total
|
||||
@cindex grand total of disk size, usage and available space
|
||||
diff --git a/src/df.c b/src/df.c
|
||||
index 8f760db..a7385fd 100644
|
||||
--- a/src/df.c
|
||||
+++ b/src/df.c
|
||||
@@ -120,6 +120,9 @@ static bool print_type;
|
||||
@cindex grand total of file system size, usage and available space
|
||||
diff -ruN a/src/df.c b/src/df.c
|
||||
--- a/src/df.c 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/src/df.c 2023-05-03 17:36:30.362834685 +0300
|
||||
@@ -125,6 +125,9 @@
|
||||
/* If true, print a grand total at the end. */
|
||||
static bool print_grand_total;
|
||||
|
||||
|
@ -30,7 +28,7 @@ index 8f760db..a7385fd 100644
|
|||
/* Grand total data. */
|
||||
static struct fs_usage grand_fsu;
|
||||
|
||||
@@ -247,13 +250,15 @@ enum
|
||||
@@ -252,13 +255,15 @@
|
||||
NO_SYNC_OPTION = CHAR_MAX + 1,
|
||||
SYNC_OPTION,
|
||||
TOTAL_OPTION,
|
||||
|
@ -47,7 +45,7 @@ index 8f760db..a7385fd 100644
|
|||
{"inodes", no_argument, NULL, 'i'},
|
||||
{"human-readable", no_argument, NULL, 'h'},
|
||||
{"si", no_argument, NULL, 'H'},
|
||||
@@ -509,7 +514,10 @@ get_header (void)
|
||||
@@ -578,7 +583,10 @@
|
||||
for (col = 0; col < ncolumns; col++)
|
||||
{
|
||||
char *cell = NULL;
|
||||
|
@ -59,7 +57,7 @@ index 8f760db..a7385fd 100644
|
|||
|
||||
if (columns[col]->field == SIZE_FIELD
|
||||
&& (header_mode == DEFAULT_MODE
|
||||
@@ -1397,6 +1405,19 @@ get_point (const char *point, const struct stat *statp)
|
||||
@@ -1476,6 +1484,19 @@
|
||||
static void
|
||||
get_entry (char const *name, struct stat const *statp)
|
||||
{
|
||||
|
@ -77,9 +75,9 @@ index 8f760db..a7385fd 100644
|
|||
+ }
|
||||
+
|
||||
if ((S_ISBLK (statp->st_mode) || S_ISCHR (statp->st_mode))
|
||||
&& get_disk (name))
|
||||
&& get_device (name))
|
||||
return;
|
||||
@@ -1467,6 +1488,7 @@ or all file systems by default.\n\
|
||||
@@ -1546,6 +1567,7 @@
|
||||
-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\
|
||||
|
@ -87,7 +85,7 @@ index 8f760db..a7385fd 100644
|
|||
-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);
|
||||
@@ -1557,6 +1579,9 @@ main (int argc, char **argv)
|
||||
@@ -1636,6 +1658,9 @@
|
||||
xstrtol_fatal (e, oi, c, long_options, optarg);
|
||||
}
|
||||
break;
|
||||
|
@ -97,7 +95,7 @@ index 8f760db..a7385fd 100644
|
|||
case 'i':
|
||||
if (header_mode == OUTPUT_MODE)
|
||||
{
|
||||
@@ -1653,6 +1678,13 @@ main (int argc, char **argv)
|
||||
@@ -1732,6 +1757,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,11 +109,9 @@ index 8f760db..a7385fd 100644
|
|||
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
|
||||
diff -ruN a/tests/df/direct.sh b/tests/df/direct.sh
|
||||
--- a/tests/df/direct.sh 1970-01-01 03:00:00.000000000 +0300
|
||||
+++ b/tests/df/direct.sh 2023-05-03 17:36:30.362834685 +0300
|
||||
@@ -0,0 +1,55 @@
|
||||
+#!/bin/sh
|
||||
+# Ensure "df --direct" works as documented
|
131
coreutils-9.3-if-lint.patch
Normal file
131
coreutils-9.3-if-lint.patch
Normal file
|
@ -0,0 +1,131 @@
|
|||
diff -ruN a/src/chcon.c b/src/chcon.c
|
||||
--- a/src/chcon.c 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/src/chcon.c 2023-05-06 12:47:00.876207767 +0300
|
||||
@@ -142,7 +142,7 @@
|
||||
change_file_context (int fd, char const *file)
|
||||
{
|
||||
char *file_context = NULL;
|
||||
- context_t context IF_LINT (= 0);
|
||||
+ context_t context = 0;
|
||||
char const * context_string;
|
||||
int errors = 0;
|
||||
|
||||
diff -ruN a/src/copy.c b/src/copy.c
|
||||
--- a/src/copy.c 2023-04-17 23:43:34.000000000 +0300
|
||||
+++ b/src/copy.c 2023-05-06 12:47:00.877207769 +0300
|
||||
@@ -2206,8 +2206,8 @@
|
||||
{
|
||||
struct stat src_sb;
|
||||
struct stat dst_sb;
|
||||
- mode_t src_mode IF_LINT ( = 0);
|
||||
- mode_t dst_mode IF_LINT ( = 0);
|
||||
+ mode_t src_mode = 0;
|
||||
+ mode_t dst_mode = 0;
|
||||
mode_t dst_mode_bits;
|
||||
mode_t omitted_permissions;
|
||||
bool restore_dst_mode = false;
|
||||
diff -ruN a/src/ls.c b/src/ls.c
|
||||
--- a/src/ls.c 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/src/ls.c 2023-05-06 12:47:00.878207770 +0300
|
||||
@@ -4558,7 +4558,7 @@
|
||||
int needs_general_quoting, size_t *width, bool *pad)
|
||||
{
|
||||
char *buf = *inbuf;
|
||||
- size_t displayed_width IF_LINT ( = 0);
|
||||
+ size_t displayed_width = 0;
|
||||
size_t len = 0;
|
||||
bool quoted;
|
||||
|
||||
diff -ruN a/src/od.c b/src/od.c
|
||||
--- a/src/od.c 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/src/od.c 2023-05-06 12:47:00.879207771 +0300
|
||||
@@ -1573,7 +1573,7 @@
|
||||
int n_files;
|
||||
size_t i;
|
||||
int l_c_m;
|
||||
- size_t desired_width IF_LINT ( = 0);
|
||||
+ size_t desired_width = 0;
|
||||
bool modern = false;
|
||||
bool width_specified = false;
|
||||
bool ok = true;
|
||||
@@ -1582,7 +1582,7 @@
|
||||
|
||||
/* The old-style 'pseudo starting address' to be printed in parentheses
|
||||
after any true address. */
|
||||
- uintmax_t pseudo_start IF_LINT ( = 0);
|
||||
+ uintmax_t pseudo_start = 0;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
diff -ruN a/src/shred.c b/src/shred.c
|
||||
--- a/src/shred.c 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/src/shred.c 2023-05-06 12:47:00.880207773 +0300
|
||||
@@ -400,7 +400,7 @@
|
||||
{
|
||||
off_t size = *sizep;
|
||||
off_t offset; /* Current file position */
|
||||
- time_t thresh IF_LINT ( = 0); /* Time to maybe print next status update */
|
||||
+ time_t thresh = 0; /* Time to maybe print next status update */
|
||||
time_t now = 0; /* Current time */
|
||||
size_t lim; /* Amount of data to try writing */
|
||||
size_t soff; /* Offset into buffer for next write */
|
||||
diff -ruN a/src/split.c b/src/split.c
|
||||
--- a/src/split.c 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/src/split.c 2023-05-06 12:47:08.236217967 +0300
|
||||
@@ -1161,7 +1161,7 @@
|
||||
bool wrote = false;
|
||||
bool file_limit;
|
||||
idx_t i_file;
|
||||
- of_t *files IF_LINT (= NULL);
|
||||
+ of_t *files = NULL;
|
||||
intmax_t line_no;
|
||||
|
||||
if (k)
|
||||
diff -ruN a/src/truncate.c b/src/truncate.c
|
||||
--- a/src/truncate.c 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/src/truncate.c 2023-05-06 12:47:08.236217967 +0300
|
||||
@@ -202,7 +202,7 @@
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
bool got_size = false;
|
||||
- off_t size IF_LINT ( = 0);
|
||||
+ off_t size = 0;
|
||||
off_t rsize = -1;
|
||||
rel_mode_t rel_mode = rm_abs;
|
||||
int c;
|
||||
diff -ruN a/src/tsort.c b/src/tsort.c
|
||||
--- a/src/tsort.c 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/src/tsort.c 2023-05-06 12:47:08.237217968 +0300
|
||||
@@ -355,7 +355,7 @@
|
||||
struct successor *s = *p;
|
||||
s->suc->count--;
|
||||
*p = s->next;
|
||||
- IF_LINT (free (s));
|
||||
+ free (s);
|
||||
break;
|
||||
}
|
||||
|
||||
diff -ruN a/src/unexpand.c b/src/unexpand.c
|
||||
--- a/src/unexpand.c 2023-05-06 12:45:36.443072091 +0300
|
||||
+++ b/src/unexpand.c 2023-05-06 12:47:08.237217968 +0300
|
||||
@@ -319,7 +319,7 @@
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
bool have_tabval = false;
|
||||
- uintmax_t tabval IF_LINT ( = 0);
|
||||
+ uintmax_t tabval = 0;
|
||||
int c;
|
||||
|
||||
/* If true, cancel the effect of any -a (explicit or implicit in -t),
|
||||
diff -ruN a/src/who.c b/src/who.c
|
||||
--- a/src/who.c 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/src/who.c 2023-05-06 12:47:08.237217968 +0300
|
||||
@@ -568,7 +568,7 @@
|
||||
static void
|
||||
scan_entries (size_t n, const STRUCT_UTMP *utmp_buf)
|
||||
{
|
||||
- char *ttyname_b IF_LINT ( = NULL);
|
||||
+ char *ttyname_b = NULL;
|
||||
time_t boottime = TYPE_MINIMUM (time_t);
|
||||
|
||||
if (include_heading)
|
|
@ -1,29 +1,16 @@
|
|||
diff -urNp coreutils-8.2-orig/src/uname.c coreutils-8.2/src/uname.c
|
||||
--- coreutils-8.2-orig/src/uname.c 2009-09-23 10:25:44.000000000 +0200
|
||||
+++ coreutils-8.2/src/uname.c 2009-12-19 09:09:11.663607110 +0100
|
||||
@@ -301,7 +301,7 @@ main (int argc, char **argv)
|
||||
diff -ruN a/src/uname.c b/src/uname.c
|
||||
--- a/src/uname.c 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/src/uname.c 2023-05-03 17:34:26.750298831 +0300
|
||||
@@ -313,7 +313,7 @@
|
||||
|
||||
if (toprint & PRINT_PROCESSOR)
|
||||
{
|
||||
- char const *element = unknown;
|
||||
+ char *element = unknown;
|
||||
#if HAVE_SYSINFO && defined SI_ARCHITECTURE
|
||||
{
|
||||
static char processor[257];
|
||||
@@ -308,6 +308,12 @@ main (int argc, char **argv)
|
||||
if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor))
|
||||
element = processor;
|
||||
}
|
||||
+#else
|
||||
+ {
|
||||
+ struct utsname u;
|
||||
+ uname(&u);
|
||||
+ element = u.machine;
|
||||
+ }
|
||||
#endif
|
||||
#ifdef UNAME_PROCESSOR
|
||||
if (element == unknown)
|
||||
@@ -351,7 +357,7 @@ main (int argc, char **argv)
|
||||
#ifdef __APPLE__
|
||||
# if defined __arm__ || defined __arm64__
|
||||
element = "arm";
|
||||
@@ -347,7 +347,7 @@
|
||||
|
||||
if (toprint & PRINT_HARDWARE_PLATFORM)
|
||||
{
|
||||
|
@ -32,7 +19,7 @@ diff -urNp coreutils-8.2-orig/src/uname.c coreutils-8.2/src/uname.c
|
|||
#if HAVE_SYSINFO && defined SI_PLATFORM
|
||||
{
|
||||
static char hardware_platform[257];
|
||||
@@ -353,6 +359,14 @@ main (int argc, char **argv)
|
||||
@@ -355,6 +355,12 @@
|
||||
hardware_platform, sizeof hardware_platform))
|
||||
element = hardware_platform;
|
||||
}
|
||||
|
@ -41,9 +28,22 @@ diff -urNp coreutils-8.2-orig/src/uname.c coreutils-8.2/src/uname.c
|
|||
+ struct utsname u;
|
||||
+ uname(&u);
|
||||
+ element = u.machine;
|
||||
+ }
|
||||
#endif
|
||||
#ifdef UNAME_HARDWARE_PLATFORM
|
||||
if (element == unknown)
|
||||
@@ -365,6 +371,14 @@
|
||||
if (sysctl (mib, 2, hardware_platform, &s, 0, 0) >= 0)
|
||||
element = hardware_platform;
|
||||
}
|
||||
+#else
|
||||
+ {
|
||||
+ struct utsname u;
|
||||
+ uname(&u);
|
||||
+ element = u.machine;
|
||||
+ if(strlen(element)==4 && element[0]=='i' && element[2]=='8' && element[3]=='6')
|
||||
+ element[1]='3';
|
||||
+ }
|
||||
#endif
|
||||
#ifdef UNAME_HARDWARE_PLATFORM
|
||||
if (element == unknown)
|
||||
if (! (toprint == UINT_MAX && element == unknown))
|
||||
print_element (element);
|
|
@ -1,565 +0,0 @@
|
|||
diff --git a/src/cut.c b/src/cut.c
|
||||
index 7ab6be4..022d0ad 100644
|
||||
--- a/src/cut.c
|
||||
+++ b/src/cut.c
|
||||
@@ -28,6 +28,11 @@
|
||||
#include <assert.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
+
|
||||
+/* Get mbstate_t, mbrtowc(). */
|
||||
+#if HAVE_WCHAR_H
|
||||
+# include <wchar.h>
|
||||
+#endif
|
||||
#include "system.h"
|
||||
|
||||
#include "error.h"
|
||||
@@ -38,6 +43,18 @@
|
||||
|
||||
#include "set-fields.h"
|
||||
|
||||
+/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC
|
||||
+ installation; work around this configuration error. */
|
||||
+#if !defined MB_LEN_MAX || MB_LEN_MAX < 2
|
||||
+# undef MB_LEN_MAX
|
||||
+# define MB_LEN_MAX 16
|
||||
+#endif
|
||||
+
|
||||
+/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */
|
||||
+#if HAVE_MBRTOWC && defined mbstate_t
|
||||
+# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
|
||||
+#endif
|
||||
+
|
||||
/* The official name of this program (e.g., no 'g' prefix). */
|
||||
#define PROGRAM_NAME "cut"
|
||||
|
||||
@@ -54,6 +71,52 @@
|
||||
} \
|
||||
while (0)
|
||||
|
||||
+/* Refill the buffer BUF to get a multibyte character. */
|
||||
+#define REFILL_BUFFER(BUF, BUFPOS, BUFLEN, STREAM) \
|
||||
+ do \
|
||||
+ { \
|
||||
+ if (BUFLEN < MB_LEN_MAX && !feof (STREAM) && !ferror (STREAM)) \
|
||||
+ { \
|
||||
+ memmove (BUF, BUFPOS, BUFLEN); \
|
||||
+ BUFLEN += fread (BUF + BUFLEN, sizeof(char), BUFSIZ, STREAM); \
|
||||
+ BUFPOS = BUF; \
|
||||
+ } \
|
||||
+ } \
|
||||
+ while (0)
|
||||
+
|
||||
+/* Get wide character on BUFPOS. BUFPOS is not included after that.
|
||||
+ If byte sequence is not valid as a character, CONVFAIL is true. Otherwise false. */
|
||||
+#define GET_NEXT_WC_FROM_BUFFER(WC, BUFPOS, BUFLEN, MBLENGTH, STATE, CONVFAIL) \
|
||||
+ do \
|
||||
+ { \
|
||||
+ mbstate_t state_bak; \
|
||||
+ \
|
||||
+ if (BUFLEN < 1) \
|
||||
+ { \
|
||||
+ WC = WEOF; \
|
||||
+ break; \
|
||||
+ } \
|
||||
+ \
|
||||
+ /* Get a wide character. */ \
|
||||
+ CONVFAIL = false; \
|
||||
+ state_bak = STATE; \
|
||||
+ MBLENGTH = mbrtowc ((wchar_t *)&WC, BUFPOS, BUFLEN, &STATE); \
|
||||
+ \
|
||||
+ switch (MBLENGTH) \
|
||||
+ { \
|
||||
+ case (size_t)-1: \
|
||||
+ case (size_t)-2: \
|
||||
+ CONVFAIL = true; \
|
||||
+ STATE = state_bak; \
|
||||
+ /* Fall througn. */ \
|
||||
+ \
|
||||
+ case 0: \
|
||||
+ MBLENGTH = 1; \
|
||||
+ break; \
|
||||
+ } \
|
||||
+ } \
|
||||
+ while (0)
|
||||
+
|
||||
|
||||
/* Pointer inside RP. When checking if a byte or field is selected
|
||||
by a finite range, we check if it is between CURRENT_RP.LO
|
||||
@@ -61,6 +124,9 @@
|
||||
CURRENT_RP.HI then we make CURRENT_RP to point to the next range pair. */
|
||||
static struct field_range_pair *current_rp;
|
||||
|
||||
+/* Length of the delimiter given as argument to -d. */
|
||||
+size_t delimlen;
|
||||
+
|
||||
/* This buffer is used to support the semantics of the -s option
|
||||
(or lack of same) when the specified field list includes (does
|
||||
not include) the first field. In both of those cases, the entire
|
||||
@@ -77,15 +143,25 @@ enum operating_mode
|
||||
{
|
||||
undefined_mode,
|
||||
|
||||
- /* Output characters that are in the given bytes. */
|
||||
+ /* Output bytes that are at the given positions. */
|
||||
byte_mode,
|
||||
|
||||
+ /* Output characters that are at the given positions. */
|
||||
+ character_mode,
|
||||
+
|
||||
/* Output the given delimiter-separated fields. */
|
||||
field_mode
|
||||
};
|
||||
|
||||
static enum operating_mode operating_mode;
|
||||
|
||||
+/* If nonzero, when in byte mode, don't split multibyte characters. */
|
||||
+static int byte_mode_character_aware;
|
||||
+
|
||||
+/* If nonzero, the function for single byte locale is work
|
||||
+ if this program runs on multibyte locale. */
|
||||
+static int force_singlebyte_mode;
|
||||
+
|
||||
/* If true do not output lines containing no delimiter characters.
|
||||
Otherwise, all such lines are printed. This option is valid only
|
||||
with field mode. */
|
||||
@@ -97,6 +173,9 @@ static bool complement;
|
||||
|
||||
/* The delimiter character for field mode. */
|
||||
static unsigned char delim;
|
||||
+#if HAVE_WCHAR_H
|
||||
+static wchar_t wcdelim;
|
||||
+#endif
|
||||
|
||||
/* The delimiter for each line/record. */
|
||||
static unsigned char line_delim = '\n';
|
||||
@@ -164,7 +243,7 @@ Print selected parts of lines from each FILE to standard output.\n\
|
||||
-f, --fields=LIST select only these fields; also print any line\n\
|
||||
that contains no delimiter character, unless\n\
|
||||
the -s option is specified\n\
|
||||
- -n (ignored)\n\
|
||||
+ -n with -b: don't split multibyte characters\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
--complement complement the set of selected bytes, characters\n\
|
||||
@@ -280,6 +359,82 @@ cut_bytes (FILE *stream)
|
||||
}
|
||||
}
|
||||
|
||||
+#if HAVE_MBRTOWC
|
||||
+/* This function is in use for the following case.
|
||||
+
|
||||
+ 1. Read from the stream STREAM, printing to standard output any selected
|
||||
+ characters.
|
||||
+
|
||||
+ 2. Read from stream STREAM, printing to standard output any selected bytes,
|
||||
+ without splitting multibyte characters. */
|
||||
+
|
||||
+static void
|
||||
+cut_characters_or_cut_bytes_no_split (FILE *stream)
|
||||
+{
|
||||
+ size_t idx; /* number of bytes or characters in the line so far. */
|
||||
+ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */
|
||||
+ char *bufpos; /* Next read position of BUF. */
|
||||
+ size_t buflen; /* The length of the byte sequence in buf. */
|
||||
+ wint_t wc; /* A gotten wide character. */
|
||||
+ size_t mblength; /* The byte size of a multibyte character which shows
|
||||
+ as same character as WC. */
|
||||
+ mbstate_t state; /* State of the stream. */
|
||||
+ bool convfail = false; /* true, when conversion failed. Otherwise false. */
|
||||
+ /* Whether to begin printing delimiters between ranges for the current line.
|
||||
+ Set after we've begun printing data corresponding to the first range. */
|
||||
+ bool print_delimiter = false;
|
||||
+
|
||||
+ idx = 0;
|
||||
+ buflen = 0;
|
||||
+ bufpos = buf;
|
||||
+ memset (&state, '\0', sizeof(mbstate_t));
|
||||
+
|
||||
+ current_rp = frp;
|
||||
+
|
||||
+ while (1)
|
||||
+ {
|
||||
+ REFILL_BUFFER (buf, bufpos, buflen, stream);
|
||||
+
|
||||
+ GET_NEXT_WC_FROM_BUFFER (wc, bufpos, buflen, mblength, state, convfail);
|
||||
+ (void) convfail; /* ignore unused */
|
||||
+
|
||||
+ if (wc == WEOF)
|
||||
+ {
|
||||
+ if (idx > 0)
|
||||
+ putchar (line_delim);
|
||||
+ break;
|
||||
+ }
|
||||
+ else if (wc == line_delim)
|
||||
+ {
|
||||
+ putchar (line_delim);
|
||||
+ idx = 0;
|
||||
+ print_delimiter = false;
|
||||
+ current_rp = frp;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ next_item (&idx);
|
||||
+ if (print_kth (idx))
|
||||
+ {
|
||||
+ if (output_delimiter_specified)
|
||||
+ {
|
||||
+ if (print_delimiter && is_range_start_index (idx))
|
||||
+ {
|
||||
+ fwrite (output_delimiter_string, sizeof (char),
|
||||
+ output_delimiter_length, stdout);
|
||||
+ }
|
||||
+ print_delimiter = true;
|
||||
+ }
|
||||
+ fwrite (bufpos, mblength, sizeof(char), stdout);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ buflen -= mblength;
|
||||
+ bufpos += mblength;
|
||||
+ }
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
/* Read from stream STREAM, printing to standard output any selected fields. */
|
||||
|
||||
static void
|
||||
@@ -425,13 +580,211 @@ cut_fields (FILE *stream)
|
||||
}
|
||||
}
|
||||
|
||||
+#if HAVE_MBRTOWC
|
||||
+static void
|
||||
+cut_fields_mb (FILE *stream)
|
||||
+{
|
||||
+ int c;
|
||||
+ size_t field_idx;
|
||||
+ int found_any_selected_field;
|
||||
+ int buffer_first_field;
|
||||
+ int empty_input;
|
||||
+ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */
|
||||
+ char *bufpos; /* Next read position of BUF. */
|
||||
+ size_t buflen; /* The length of the byte sequence in buf. */
|
||||
+ wint_t wc = 0; /* A gotten wide character. */
|
||||
+ size_t mblength; /* The byte size of a multibyte character which shows
|
||||
+ as same character as WC. */
|
||||
+ mbstate_t state; /* State of the stream. */
|
||||
+ bool convfail = false; /* true, when conversion failed. Otherwise false. */
|
||||
+
|
||||
+ current_rp = frp;
|
||||
+
|
||||
+ found_any_selected_field = 0;
|
||||
+ field_idx = 1;
|
||||
+ bufpos = buf;
|
||||
+ buflen = 0;
|
||||
+ memset (&state, '\0', sizeof(mbstate_t));
|
||||
+
|
||||
+ c = getc (stream);
|
||||
+ empty_input = (c == EOF);
|
||||
+ if (c != EOF)
|
||||
+ {
|
||||
+ ungetc (c, stream);
|
||||
+ wc = 0;
|
||||
+ }
|
||||
+ else
|
||||
+ wc = WEOF;
|
||||
+
|
||||
+ /* To support the semantics of the -s flag, we may have to buffer
|
||||
+ all of the first field to determine whether it is `delimited.'
|
||||
+ But that is unnecessary if all non-delimited lines must be printed
|
||||
+ and the first field has been selected, or if non-delimited lines
|
||||
+ must be suppressed and the first field has *not* been selected.
|
||||
+ That is because a non-delimited line has exactly one field. */
|
||||
+ buffer_first_field = (suppress_non_delimited ^ !print_kth (1));
|
||||
+
|
||||
+ while (1)
|
||||
+ {
|
||||
+ if (field_idx == 1 && buffer_first_field)
|
||||
+ {
|
||||
+ int len = 0;
|
||||
+
|
||||
+ while (1)
|
||||
+ {
|
||||
+ REFILL_BUFFER (buf, bufpos, buflen, stream);
|
||||
+
|
||||
+ GET_NEXT_WC_FROM_BUFFER
|
||||
+ (wc, bufpos, buflen, mblength, state, convfail);
|
||||
+
|
||||
+ if (wc == WEOF)
|
||||
+ break;
|
||||
+
|
||||
+ field_1_buffer = xrealloc (field_1_buffer, len + mblength);
|
||||
+ memcpy (field_1_buffer + len, bufpos, mblength);
|
||||
+ len += mblength;
|
||||
+ buflen -= mblength;
|
||||
+ bufpos += mblength;
|
||||
+
|
||||
+ if (!convfail && (wc == line_delim || wc == wcdelim))
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (len <= 0 && wc == WEOF)
|
||||
+ break;
|
||||
+
|
||||
+ /* If the first field extends to the end of line (it is not
|
||||
+ delimited) and we are printing all non-delimited lines,
|
||||
+ print this one. */
|
||||
+ if (convfail || (!convfail && wc != wcdelim))
|
||||
+ {
|
||||
+ if (suppress_non_delimited)
|
||||
+ {
|
||||
+ /* Empty. */
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ fwrite (field_1_buffer, sizeof (char), len, stdout);
|
||||
+ /* Make sure the output line is newline terminated. */
|
||||
+ if (convfail || (!convfail && wc != line_delim))
|
||||
+ putchar (line_delim);
|
||||
+ }
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (print_kth (1))
|
||||
+ {
|
||||
+ /* Print the field, but not the trailing delimiter. */
|
||||
+ fwrite (field_1_buffer, sizeof (char), len - 1, stdout);
|
||||
+ found_any_selected_field = 1;
|
||||
+ }
|
||||
+ next_item (&field_idx);
|
||||
+ }
|
||||
+
|
||||
+ if (wc != WEOF)
|
||||
+ {
|
||||
+ if (print_kth (field_idx))
|
||||
+ {
|
||||
+ if (found_any_selected_field)
|
||||
+ {
|
||||
+ fwrite (output_delimiter_string, sizeof (char),
|
||||
+ output_delimiter_length, stdout);
|
||||
+ }
|
||||
+ found_any_selected_field = 1;
|
||||
+ }
|
||||
+
|
||||
+ while (1)
|
||||
+ {
|
||||
+ REFILL_BUFFER (buf, bufpos, buflen, stream);
|
||||
+
|
||||
+ GET_NEXT_WC_FROM_BUFFER
|
||||
+ (wc, bufpos, buflen, mblength, state, convfail);
|
||||
+
|
||||
+ if (wc == WEOF)
|
||||
+ break;
|
||||
+ else if (!convfail && (wc == wcdelim || wc == line_delim))
|
||||
+ {
|
||||
+ buflen -= mblength;
|
||||
+ bufpos += mblength;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (print_kth (field_idx))
|
||||
+ fwrite (bufpos, mblength, sizeof(char), stdout);
|
||||
+
|
||||
+ buflen -= mblength;
|
||||
+ bufpos += mblength;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if ((!convfail || wc == line_delim) && buflen < 1)
|
||||
+ wc = WEOF;
|
||||
+
|
||||
+ if (!convfail && wc == wcdelim)
|
||||
+ next_item (&field_idx);
|
||||
+ else if (wc == WEOF || (!convfail && wc == line_delim))
|
||||
+ {
|
||||
+ if (found_any_selected_field
|
||||
+ || (!empty_input && !(suppress_non_delimited && field_idx == 1)))
|
||||
+ putchar (line_delim);
|
||||
+ if (wc == WEOF)
|
||||
+ break;
|
||||
+ field_idx = 1;
|
||||
+ current_rp = frp;
|
||||
+ found_any_selected_field = 0;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
static void
|
||||
cut_stream (FILE *stream)
|
||||
{
|
||||
- if (operating_mode == byte_mode)
|
||||
- cut_bytes (stream);
|
||||
+#if HAVE_MBRTOWC
|
||||
+ if (MB_CUR_MAX > 1 && !force_singlebyte_mode)
|
||||
+ {
|
||||
+ switch (operating_mode)
|
||||
+ {
|
||||
+ case byte_mode:
|
||||
+ if (byte_mode_character_aware)
|
||||
+ cut_characters_or_cut_bytes_no_split (stream);
|
||||
+ else
|
||||
+ cut_bytes (stream);
|
||||
+ break;
|
||||
+
|
||||
+ case character_mode:
|
||||
+ cut_characters_or_cut_bytes_no_split (stream);
|
||||
+ break;
|
||||
+
|
||||
+ case field_mode:
|
||||
+ if (delimlen == 1)
|
||||
+ {
|
||||
+ /* Check if we have utf8 multibyte locale, so we can use this
|
||||
+ optimization because of uniqueness of characters, which is
|
||||
+ not true for e.g. SJIS */
|
||||
+ char * loc = setlocale(LC_CTYPE, NULL);
|
||||
+ if (loc && (strstr (loc, "UTF-8") || strstr (loc, "utf-8") ||
|
||||
+ strstr (loc, "UTF8") || strstr (loc, "utf8")))
|
||||
+ {
|
||||
+ cut_fields (stream);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ cut_fields_mb (stream);
|
||||
+ break;
|
||||
+
|
||||
+ default:
|
||||
+ abort ();
|
||||
+ }
|
||||
+ }
|
||||
else
|
||||
- cut_fields (stream);
|
||||
+#endif
|
||||
+ {
|
||||
+ if (operating_mode == field_mode)
|
||||
+ cut_fields (stream);
|
||||
+ else
|
||||
+ cut_bytes (stream);
|
||||
+ }
|
||||
}
|
||||
|
||||
/* Process file FILE to standard output.
|
||||
@@ -483,6 +836,7 @@ main (int argc, char **argv)
|
||||
bool ok;
|
||||
bool delim_specified = false;
|
||||
char *spec_list_string IF_LINT ( = NULL);
|
||||
+ char mbdelim[MB_LEN_MAX + 1];
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -505,7 +859,6 @@ main (int argc, char **argv)
|
||||
switch (optc)
|
||||
{
|
||||
case 'b':
|
||||
- case 'c':
|
||||
/* Build the byte list. */
|
||||
if (operating_mode != undefined_mode)
|
||||
FATAL_ERROR (_("only one type of list may be specified"));
|
||||
@@ -513,6 +866,14 @@ main (int argc, char **argv)
|
||||
spec_list_string = optarg;
|
||||
break;
|
||||
|
||||
+ case 'c':
|
||||
+ /* Build the character list. */
|
||||
+ if (operating_mode != undefined_mode)
|
||||
+ FATAL_ERROR (_("only one type of list may be specified"));
|
||||
+ operating_mode = character_mode;
|
||||
+ spec_list_string = optarg;
|
||||
+ break;
|
||||
+
|
||||
case 'f':
|
||||
/* Build the field list. */
|
||||
if (operating_mode != undefined_mode)
|
||||
@@ -524,10 +885,38 @@ main (int argc, char **argv)
|
||||
case 'd':
|
||||
/* New delimiter. */
|
||||
/* Interpret -d '' to mean 'use the NUL byte as the delimiter.' */
|
||||
- if (optarg[0] != '\0' && optarg[1] != '\0')
|
||||
- FATAL_ERROR (_("the delimiter must be a single character"));
|
||||
- delim = optarg[0];
|
||||
- delim_specified = true;
|
||||
+ {
|
||||
+#if HAVE_MBRTOWC
|
||||
+ if(MB_CUR_MAX > 1)
|
||||
+ {
|
||||
+ mbstate_t state;
|
||||
+
|
||||
+ memset (&state, '\0', sizeof(mbstate_t));
|
||||
+ delimlen = mbrtowc (&wcdelim, optarg, strnlen(optarg, MB_LEN_MAX), &state);
|
||||
+
|
||||
+ if (delimlen == (size_t)-1 || delimlen == (size_t)-2)
|
||||
+ ++force_singlebyte_mode;
|
||||
+ else
|
||||
+ {
|
||||
+ delimlen = (delimlen < 1) ? 1 : delimlen;
|
||||
+ if (wcdelim != L'\0' && *(optarg + delimlen) != '\0')
|
||||
+ FATAL_ERROR (_("the delimiter must be a single character"));
|
||||
+ memcpy (mbdelim, optarg, delimlen);
|
||||
+ mbdelim[delimlen] = '\0';
|
||||
+ if (delimlen == 1)
|
||||
+ delim = *optarg;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (MB_CUR_MAX <= 1 || force_singlebyte_mode)
|
||||
+#endif
|
||||
+ {
|
||||
+ if (optarg[0] != '\0' && optarg[1] != '\0')
|
||||
+ FATAL_ERROR (_("the delimiter must be a single character"));
|
||||
+ delim = (unsigned char) optarg[0];
|
||||
+ }
|
||||
+ delim_specified = true;
|
||||
+ }
|
||||
break;
|
||||
|
||||
case OUTPUT_DELIMITER_OPTION:
|
||||
@@ -540,6 +929,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
+ byte_mode_character_aware = 1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
@@ -579,15 +969,34 @@ main (int argc, char **argv)
|
||||
| (complement ? SETFLD_COMPLEMENT : 0) );
|
||||
|
||||
if (!delim_specified)
|
||||
- delim = '\t';
|
||||
+ {
|
||||
+ delim = '\t';
|
||||
+#ifdef HAVE_MBRTOWC
|
||||
+ wcdelim = L'\t';
|
||||
+ mbdelim[0] = '\t';
|
||||
+ mbdelim[1] = '\0';
|
||||
+ delimlen = 1;
|
||||
+#endif
|
||||
+ }
|
||||
|
||||
if (output_delimiter_string == NULL)
|
||||
{
|
||||
- static char dummy[2];
|
||||
- dummy[0] = delim;
|
||||
- dummy[1] = '\0';
|
||||
- output_delimiter_string = dummy;
|
||||
- output_delimiter_length = 1;
|
||||
+#ifdef HAVE_MBRTOWC
|
||||
+ if (MB_CUR_MAX > 1 && !force_singlebyte_mode)
|
||||
+ {
|
||||
+ output_delimiter_string = xstrdup(mbdelim);
|
||||
+ output_delimiter_length = delimlen;
|
||||
+ }
|
||||
+
|
||||
+ if (MB_CUR_MAX <= 1 || force_singlebyte_mode)
|
||||
+#endif
|
||||
+ {
|
||||
+ static char dummy[2];
|
||||
+ dummy[0] = delim;
|
||||
+ dummy[1] = '\0';
|
||||
+ output_delimiter_string = dummy;
|
||||
+ output_delimiter_length = 1;
|
||||
+ }
|
||||
}
|
||||
|
||||
if (optind == argc)
|
|
@ -1,44 +1,7 @@
|
|||
From e87ab5b991b08092a7e07af82b3ec822a8604151 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Oprala <ooprala@redhat.com>
|
||||
Date: Wed, 5 Aug 2015 09:15:09 +0200
|
||||
Subject: [PATCH] expand,unexpand: add multibyte support
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
* NEWS: Mention the changes.
|
||||
* bootstrap.conf: Add mbfile to the list of modules.
|
||||
* configure.ac: Properly initialize mbfile.
|
||||
* src/expand.c (expand): Iterate over multibyte characters properly.
|
||||
* src/unexpand.c (unexpand): Iterate over multibyte characters
|
||||
properly.
|
||||
* tests/local.mk: Add new tests.
|
||||
* tests/{expand,unexpand}/mb.sh: New tests.
|
||||
|
||||
Co-authored-by: Pádraig Brady <pbrady@redhat.com>
|
||||
---
|
||||
bootstrap.conf | 1 +
|
||||
configure.ac | 2 +
|
||||
lib/mbfile.c | 3 +
|
||||
lib/mbfile.h | 255 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
m4/mbfile.m4 | 14 +++
|
||||
src/expand.c | 43 +++++----
|
||||
src/unexpand.c | 54 +++++++----
|
||||
tests/expand/mb.sh | 98 ++++++++++++++++++++
|
||||
tests/local.mk | 2 +
|
||||
tests/unexpand/mb.sh | 97 ++++++++++++++++++++
|
||||
10 files changed, 535 insertions(+), 34 deletions(-)
|
||||
create mode 100644 lib/mbfile.c
|
||||
create mode 100644 lib/mbfile.h
|
||||
create mode 100644 m4/mbfile.m4
|
||||
create mode 100755 tests/expand/mb.sh
|
||||
create mode 100755 tests/unexpand/mb.sh
|
||||
|
||||
diff --git a/bootstrap.conf b/bootstrap.conf
|
||||
index 8a0ff31..a1c78b2 100644
|
||||
--- a/bootstrap.conf
|
||||
+++ b/bootstrap.conf
|
||||
@@ -152,6 +152,7 @@ gnulib_modules="
|
||||
diff -ruN a/bootstrap.conf b/bootstrap.conf
|
||||
--- a/bootstrap.conf 2023-04-10 13:14:08.000000000 +0300
|
||||
+++ b/bootstrap.conf 2023-05-06 12:08:26.405592732 +0300
|
||||
@@ -165,6 +165,7 @@
|
||||
maintainer-makefile
|
||||
malloc-gnu
|
||||
manywarnings
|
||||
|
@ -46,11 +9,10 @@ index 8a0ff31..a1c78b2 100644
|
|||
mbrlen
|
||||
mbrtowc
|
||||
mbsalign
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 1e74b36..24c9725 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -427,6 +427,8 @@ fi
|
||||
diff -ruN a/configure.ac b/configure.ac
|
||||
--- a/configure.ac 2023-03-20 15:58:05.000000000 +0300
|
||||
+++ b/configure.ac 2023-05-06 12:08:26.405592732 +0300
|
||||
@@ -477,6 +477,8 @@
|
||||
# I'm leaving it here for now. This whole thing needs to be modernized...
|
||||
gl_WINSIZE_IN_PTEM
|
||||
|
||||
|
@ -59,20 +21,16 @@ index 1e74b36..24c9725 100644
|
|||
gl_HEADER_TIOCGWINSZ_IN_TERMIOS_H
|
||||
|
||||
if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \
|
||||
diff --git a/lib/mbfile.c b/lib/mbfile.c
|
||||
new file mode 100644
|
||||
index 0000000..b0a468e
|
||||
--- /dev/null
|
||||
+++ b/lib/mbfile.c
|
||||
diff -ruN a/lib/mbfile.c b/lib/mbfile.c
|
||||
--- a/lib/mbfile.c 1970-01-01 03:00:00.000000000 +0300
|
||||
+++ b/lib/mbfile.c 2023-05-06 12:08:26.405592732 +0300
|
||||
@@ -0,0 +1,3 @@
|
||||
+#include <config.h>
|
||||
+#define MBFILE_INLINE _GL_EXTERN_INLINE
|
||||
+#include "mbfile.h"
|
||||
diff --git a/lib/mbfile.h b/lib/mbfile.h
|
||||
new file mode 100644
|
||||
index 0000000..11f1b12
|
||||
--- /dev/null
|
||||
+++ b/lib/mbfile.h
|
||||
diff -ruN a/lib/mbfile.h b/lib/mbfile.h
|
||||
--- a/lib/mbfile.h 1970-01-01 03:00:00.000000000 +0300
|
||||
+++ b/lib/mbfile.h 2023-05-06 12:08:26.405592732 +0300
|
||||
@@ -0,0 +1,255 @@
|
||||
+/* Multibyte character I/O: macros for multi-byte encodings.
|
||||
+ Copyright (C) 2001, 2005, 2009-2015 Free Software Foundation, Inc.
|
||||
|
@ -329,11 +287,9 @@ index 0000000..11f1b12
|
|||
+_GL_INLINE_HEADER_BEGIN
|
||||
+
|
||||
+#endif /* _MBFILE_H */
|
||||
diff --git a/m4/mbfile.m4 b/m4/mbfile.m4
|
||||
new file mode 100644
|
||||
index 0000000..8589902
|
||||
--- /dev/null
|
||||
+++ b/m4/mbfile.m4
|
||||
diff -ruN a/m4/mbfile.m4 b/m4/mbfile.m4
|
||||
--- a/m4/mbfile.m4 1970-01-01 03:00:00.000000000 +0300
|
||||
+++ b/m4/mbfile.m4 2023-05-06 12:08:26.405592732 +0300
|
||||
@@ -0,0 +1,14 @@
|
||||
+# mbfile.m4 serial 7
|
||||
+dnl Copyright (C) 2005, 2008-2015 Free Software Foundation, Inc.
|
||||
|
@ -349,10 +305,9 @@ index 0000000..8589902
|
|||
+ AC_REQUIRE([AC_TYPE_MBSTATE_T])
|
||||
+ :
|
||||
+])
|
||||
diff --git a/src/expand.c b/src/expand.c
|
||||
index 9fa2e10..380e020 100644
|
||||
--- a/src/expand.c
|
||||
+++ b/src/expand.c
|
||||
diff -ruN a/src/expand.c b/src/expand.c
|
||||
--- a/src/expand.c 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/src/expand.c 2023-05-06 12:08:26.406592722 +0300
|
||||
@@ -37,6 +37,9 @@
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
|
@ -362,8 +317,8 @@ index 9fa2e10..380e020 100644
|
|||
+
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "xstrndup.h"
|
||||
@@ -100,19 +103,19 @@ expand (void)
|
||||
|
||||
@@ -97,19 +100,19 @@
|
||||
{
|
||||
/* Input stream. */
|
||||
FILE *fp = next_file (NULL);
|
||||
|
@ -387,7 +342,7 @@ index 9fa2e10..380e020 100644
|
|||
/* The following variables have valid values only when CONVERT
|
||||
is true: */
|
||||
|
||||
@@ -122,17 +125,23 @@ expand (void)
|
||||
@@ -119,17 +122,23 @@
|
||||
/* Index in TAB_LIST of next tab stop to examine. */
|
||||
size_t tab_index = 0;
|
||||
|
||||
|
@ -415,7 +370,7 @@ index 9fa2e10..380e020 100644
|
|||
{
|
||||
/* Column the next input tab stop is on. */
|
||||
uintmax_t next_tab_column;
|
||||
@@ -151,32 +160,34 @@ expand (void)
|
||||
@@ -148,32 +157,34 @@
|
||||
if (putchar (' ') < 0)
|
||||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
|
||||
|
@ -458,10 +413,9 @@ index 9fa2e10..380e020 100644
|
|||
}
|
||||
}
|
||||
|
||||
diff --git a/src/unexpand.c b/src/unexpand.c
|
||||
index 7801274..569a7ee 100644
|
||||
--- a/src/unexpand.c
|
||||
+++ b/src/unexpand.c
|
||||
diff -ruN a/src/unexpand.c b/src/unexpand.c
|
||||
--- a/src/unexpand.c 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/src/unexpand.c 2023-05-06 12:08:26.406592722 +0300
|
||||
@@ -38,6 +38,9 @@
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
|
@ -471,8 +425,8 @@ index 7801274..569a7ee 100644
|
|||
+
|
||||
#include "system.h"
|
||||
#include "die.h"
|
||||
#include "xstrndup.h"
|
||||
@@ -107,11 +110,12 @@ unexpand (void)
|
||||
|
||||
@@ -106,11 +109,12 @@
|
||||
{
|
||||
/* Input stream. */
|
||||
FILE *fp = next_file (NULL);
|
||||
|
@ -486,7 +440,7 @@ index 7801274..569a7ee 100644
|
|||
|
||||
if (!fp)
|
||||
return;
|
||||
@@ -119,12 +123,14 @@ unexpand (void)
|
||||
@@ -118,12 +122,14 @@
|
||||
/* 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. */
|
||||
|
@ -503,7 +457,7 @@ index 7801274..569a7ee 100644
|
|||
|
||||
/* If true, perform translations. */
|
||||
bool convert = true;
|
||||
@@ -158,12 +164,19 @@ unexpand (void)
|
||||
@@ -157,12 +163,19 @@
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -526,7 +480,7 @@ index 7801274..569a7ee 100644
|
|||
|
||||
if (blank)
|
||||
{
|
||||
@@ -180,16 +193,16 @@ unexpand (void)
|
||||
@@ -179,16 +192,16 @@
|
||||
if (next_tab_column < column)
|
||||
die (EXIT_FAILURE, 0, _("input line is too long"));
|
||||
|
||||
|
@ -546,7 +500,7 @@ index 7801274..569a7ee 100644
|
|||
|
||||
if (! (prev_blank && column == next_tab_column))
|
||||
{
|
||||
@@ -197,13 +210,14 @@ unexpand (void)
|
||||
@@ -196,13 +209,14 @@
|
||||
will be replaced by tabs. */
|
||||
if (column == next_tab_column)
|
||||
one_blank_before_tab_stop = true;
|
||||
|
@ -563,7 +517,7 @@ index 7801274..569a7ee 100644
|
|||
}
|
||||
|
||||
/* Discard pending blanks, unless it was a single
|
||||
@@ -211,7 +225,7 @@ unexpand (void)
|
||||
@@ -210,7 +224,7 @@
|
||||
pending = one_blank_before_tab_stop;
|
||||
}
|
||||
}
|
||||
|
@ -572,7 +526,7 @@ index 7801274..569a7ee 100644
|
|||
{
|
||||
/* Go back one column, and force recalculation of the
|
||||
next tab stop. */
|
||||
@@ -221,7 +235,7 @@ unexpand (void)
|
||||
@@ -220,7 +234,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -581,7 +535,7 @@ index 7801274..569a7ee 100644
|
|||
if (!column)
|
||||
die (EXIT_FAILURE, 0, _("input line is too long"));
|
||||
}
|
||||
@@ -229,8 +243,11 @@ unexpand (void)
|
||||
@@ -228,8 +242,11 @@
|
||||
if (pending)
|
||||
{
|
||||
if (pending > 1 && one_blank_before_tab_stop)
|
||||
|
@ -595,7 +549,7 @@ index 7801274..569a7ee 100644
|
|||
die (EXIT_FAILURE, errno, _("write error"));
|
||||
pending = 0;
|
||||
one_blank_before_tab_stop = false;
|
||||
@@ -240,16 +257,17 @@ unexpand (void)
|
||||
@@ -239,16 +256,17 @@
|
||||
convert &= convert_entire_line || blank;
|
||||
}
|
||||
|
||||
|
@ -616,11 +570,9 @@ index 7801274..569a7ee 100644
|
|||
}
|
||||
}
|
||||
|
||||
diff --git a/tests/expand/mb.sh b/tests/expand/mb.sh
|
||||
new file mode 100755
|
||||
index 0000000..7971e18
|
||||
--- /dev/null
|
||||
+++ b/tests/expand/mb.sh
|
||||
diff -ruN a/tests/expand/mb.sh b/tests/expand/mb.sh
|
||||
--- a/tests/expand/mb.sh 1970-01-01 03:00:00.000000000 +0300
|
||||
+++ b/tests/expand/mb.sh 2023-05-06 12:08:26.406592722 +0300
|
||||
@@ -0,0 +1,98 @@
|
||||
+#!/bin/sh
|
||||
+
|
||||
|
@ -720,11 +672,10 @@ index 0000000..7971e18
|
|||
+compare exp out > /dev/null 2>&1 || fail=1
|
||||
+
|
||||
+exit $fail
|
||||
diff --git a/tests/local.mk b/tests/local.mk
|
||||
index 192f776..8053397 100644
|
||||
--- a/tests/local.mk
|
||||
+++ b/tests/local.mk
|
||||
@@ -544,6 +544,7 @@ all_tests = \
|
||||
diff -ruN a/tests/local.mk b/tests/local.mk
|
||||
--- a/tests/local.mk 2023-05-06 12:06:47.524701773 +0300
|
||||
+++ b/tests/local.mk 2023-05-06 12:08:26.407592711 +0300
|
||||
@@ -586,6 +586,7 @@
|
||||
tests/du/threshold.sh \
|
||||
tests/du/trailing-slash.sh \
|
||||
tests/du/two-args.sh \
|
||||
|
@ -732,7 +683,7 @@ index 192f776..8053397 100644
|
|||
tests/id/gnu-zero-uids.sh \
|
||||
tests/id/no-context.sh \
|
||||
tests/id/context.sh \
|
||||
@@ -684,6 +685,7 @@ all_tests = \
|
||||
@@ -738,6 +739,7 @@
|
||||
tests/touch/read-only.sh \
|
||||
tests/touch/relative.sh \
|
||||
tests/touch/trailing-slash.sh \
|
||||
|
@ -740,11 +691,9 @@ index 192f776..8053397 100644
|
|||
$(all_root_tests)
|
||||
|
||||
# See tests/factor/create-test.sh.
|
||||
diff --git a/tests/unexpand/mb.sh b/tests/unexpand/mb.sh
|
||||
new file mode 100755
|
||||
index 0000000..60d4c1a
|
||||
--- /dev/null
|
||||
+++ b/tests/unexpand/mb.sh
|
||||
diff -ruN a/tests/unexpand/mb.sh b/tests/unexpand/mb.sh
|
||||
--- a/tests/unexpand/mb.sh 1970-01-01 03:00:00.000000000 +0300
|
||||
+++ b/tests/unexpand/mb.sh 2023-05-06 12:08:26.407592711 +0300
|
||||
@@ -0,0 +1,97 @@
|
||||
+#!/bin/sh
|
||||
+
|
||||
|
@ -843,6 +792,3 @@ index 0000000..60d4c1a
|
|||
+
|
||||
+unexpand -a < in > out || fail=1
|
||||
+compare exp out > /dev/null 2>&1 || fail=1
|
||||
--
|
||||
2.7.4
|
||||
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
From ff424639fe863cbd6963add1a79b97290c1606c6 Mon Sep 17 00:00:00 2001
|
||||
From: rpm-build <rpm-build>
|
||||
Date: Fri, 3 Feb 2017 12:26:53 +0100
|
||||
Subject: [PATCH] fold.c: preserve new-lines in mutlibyte text
|
||||
|
||||
---
|
||||
src/fold.c | 49 ++++++++++++++++++++++++-------------------------
|
||||
1 file changed, 24 insertions(+), 25 deletions(-)
|
||||
|
||||
diff --git a/src/fold.c b/src/fold.c
|
||||
index d23edd5..8c232a7 100644
|
||||
--- a/src/fold.c
|
||||
+++ b/src/fold.c
|
||||
@@ -342,39 +342,38 @@ fold_multibyte_text (FILE *istream, size_t width, int *saved_errno)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.7.4
|
||||
|
|
@ -1,22 +1,9 @@
|
|||
From 3976ef5a20369d8b490907ab2cba2d617305a5e0 Mon Sep 17 00:00:00 2001
|
||||
From: Kamil Dudka <kdudka@redhat.com>
|
||||
Date: Mon, 30 May 2016 16:19:20 +0200
|
||||
Subject: [PATCH] sort: do not use static array 'blanks' in human_numcompare()
|
||||
|
||||
... because the array is not initialized with MB locales. Note this is
|
||||
rather a conservative fix. I plan to do more cleanup of the i18n patch
|
||||
in Fedora to prevent mistakes like this in future updates of coreutils.
|
||||
---
|
||||
src/sort.c | 8 +++-----
|
||||
1 file changed, 3 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/src/sort.c b/src/sort.c
|
||||
index 9e07ad8..e47b039 100644
|
||||
--- a/src/sort.c
|
||||
+++ b/src/sort.c
|
||||
@@ -2304,12 +2304,10 @@ find_unit_order (char const *number)
|
||||
<none/unknown> < K/k < M < G < T < P < E < Z < Y */
|
||||
diff -ruN a/src/sort.c b/src/sort.c
|
||||
--- a/src/sort.c 2023-05-06 12:33:29.838320728 +0300
|
||||
+++ b/src/sort.c 2023-05-06 12:34:13.727760166 +0300
|
||||
@@ -2324,12 +2324,10 @@
|
||||
|
||||
ATTRIBUTE_PURE
|
||||
static int
|
||||
-human_numcompare (char const *a, char const *b)
|
||||
+human_numcompare (char *a, char *b)
|
||||
|
@ -30,6 +17,3 @@ index 9e07ad8..e47b039 100644
|
|||
|
||||
int diff = find_unit_order (a) - find_unit_order (b);
|
||||
return (diff ? diff : strnumcmp (a, b, decimal_point, thousands_sep));
|
||||
--
|
||||
2.5.5
|
||||
|
||||
|
|
3536
coreutils-i18n.patch
3536
coreutils-i18n.patch
File diff suppressed because it is too large
Load diff
|
@ -1,17 +1,30 @@
|
|||
diff --git a/man/chcon.x b/man/chcon.x
|
||||
index 8c1ff6f..c84fb96 100644
|
||||
--- a/man/chcon.x
|
||||
+++ b/man/chcon.x
|
||||
diff -ruN a/doc/coreutils.texi b/doc/coreutils.texi
|
||||
--- a/doc/coreutils.texi 2023-04-10 13:14:08.000000000 +0300
|
||||
+++ b/doc/coreutils.texi 2023-05-03 16:46:19.403274895 +0300
|
||||
@@ -8899,6 +8899,11 @@
|
||||
exit $fail
|
||||
@end example
|
||||
|
||||
+@item -c
|
||||
+@cindex SELinux security context information, preserving
|
||||
+Preserve SELinux security context of the original files if possible.
|
||||
+Some file systems don't support storing of SELinux security context.
|
||||
+
|
||||
@item --copy-contents
|
||||
@cindex directories, copying recursively
|
||||
@cindex copying directories recursively
|
||||
diff -ruN a/man/chcon.x b/man/chcon.x
|
||||
--- a/man/chcon.x 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/man/chcon.x 2023-05-03 16:46:19.398274915 +0300
|
||||
@@ -1,4 +1,4 @@
|
||||
[NAME]
|
||||
-chcon \- change file security context
|
||||
+chcon \- change file SELinux security context
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
diff --git a/man/runcon.x b/man/runcon.x
|
||||
index d2df13e..5c5f5d8 100644
|
||||
--- a/man/runcon.x
|
||||
+++ b/man/runcon.x
|
||||
diff -ruN a/man/runcon.x b/man/runcon.x
|
||||
--- a/man/runcon.x 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/man/runcon.x 2023-05-03 16:46:19.399274911 +0300
|
||||
@@ -1,5 +1,5 @@
|
||||
[NAME]
|
||||
-runcon \- run command with specified security context
|
||||
|
@ -19,12 +32,11 @@ index d2df13e..5c5f5d8 100644
|
|||
[DESCRIPTION]
|
||||
Run COMMAND with completely-specified CONTEXT, or with current or
|
||||
transitioned security context modified by one or more of LEVEL,
|
||||
diff --git a/src/cp.c b/src/cp.c
|
||||
index 1b528c6..25dbb88 100644
|
||||
--- a/src/cp.c
|
||||
+++ b/src/cp.c
|
||||
@@ -203,6 +203,9 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
|
||||
all\n\
|
||||
diff -ruN a/src/cp.c b/src/cp.c
|
||||
--- a/src/cp.c 2023-04-10 13:14:08.000000000 +0300
|
||||
+++ b/src/cp.c 2023-05-03 16:46:19.399274911 +0300
|
||||
@@ -203,6 +203,9 @@
|
||||
--preserve[=ATTR_LIST] preserve the specified attributes\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
+ -c deprecated, same as --preserve=context\n\
|
||||
|
@ -33,7 +45,7 @@ index 1b528c6..25dbb88 100644
|
|||
--no-preserve=ATTR_LIST don't preserve the specified attributes\n\
|
||||
--parents use full source file name under DIRECTORY\n\
|
||||
"), stdout);
|
||||
@@ -929,7 +932,7 @@ main (int argc, char **argv)
|
||||
@@ -978,7 +981,7 @@
|
||||
selinux_enabled = (0 < is_selinux_enabled ());
|
||||
cp_option_init (&x);
|
||||
|
||||
|
@ -42,7 +54,7 @@ index 1b528c6..25dbb88 100644
|
|||
long_opts, NULL))
|
||||
!= -1)
|
||||
{
|
||||
@@ -977,6 +980,17 @@ main (int argc, char **argv)
|
||||
@@ -1030,6 +1033,17 @@
|
||||
copy_contents = true;
|
||||
break;
|
||||
|
||||
|
@ -60,28 +72,11 @@ index 1b528c6..25dbb88 100644
|
|||
case 'd':
|
||||
x.preserve_links = true;
|
||||
x.dereference = DEREF_NEVER;
|
||||
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
|
||||
index 47e4480..cff2ead 100644
|
||||
--- a/doc/coreutils.texi
|
||||
+++ b/doc/coreutils.texi
|
||||
@@ -8083,6 +8083,11 @@ done
|
||||
exit $fail
|
||||
@end example
|
||||
|
||||
+@item -c
|
||||
+@cindex SELinux security context information, preserving
|
||||
+Preserve SELinux security context of the original files if possible.
|
||||
+Some file systems don't support storing of SELinux security context.
|
||||
+
|
||||
@item --copy-contents
|
||||
@cindex directories, copying recursively
|
||||
@cindex copying directories recursively
|
||||
diff --git a/src/install.c b/src/install.c
|
||||
index d79d597..437889a 100644
|
||||
--- a/src/install.c
|
||||
+++ b/src/install.c
|
||||
@@ -673,7 +673,7 @@ In the 4th form, create all components of the given DIRECTORY(ies).\n\
|
||||
-v, --verbose print the name of each directory as it is created\n\
|
||||
diff -ruN a/src/install.c b/src/install.c
|
||||
--- a/src/install.c 2023-03-13 21:08:10.000000000 +0300
|
||||
+++ b/src/install.c 2023-05-03 16:46:19.404274891 +0300
|
||||
@@ -627,7 +627,7 @@
|
||||
-v, --verbose print the name of each created file or directory\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
- --preserve-context preserve SELinux security context\n\
|
||||
|
@ -89,7 +84,7 @@ index d79d597..437889a 100644
|
|||
-Z set SELinux security context of destination\n\
|
||||
file and each created directory to default type\n\
|
||||
--context[=CTX] like -Z, or if CTX is specified then set the\n\
|
||||
@@ -824,7 +824,7 @@ main (int argc, char **argv)
|
||||
@@ -803,7 +803,7 @@
|
||||
dir_arg = false;
|
||||
umask (0);
|
||||
|
||||
|
@ -98,7 +93,7 @@ index d79d597..437889a 100644
|
|||
NULL)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
@@ -885,6 +885,8 @@ main (int argc, char **argv)
|
||||
@@ -867,6 +867,8 @@
|
||||
no_target_directory = true;
|
||||
break;
|
||||
|
||||
|
@ -107,7 +102,7 @@ index d79d597..437889a 100644
|
|||
case PRESERVE_CONTEXT_OPTION:
|
||||
if (! selinux_enabled)
|
||||
{
|
||||
@@ -892,6 +894,10 @@ main (int argc, char **argv)
|
||||
@@ -874,6 +876,10 @@
|
||||
"this kernel is not SELinux-enabled"));
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
Summary: The GNU core utilities: a set of tools commonly used in shell scripts
|
||||
Name: coreutils
|
||||
Version: 8.32
|
||||
Release: 4
|
||||
Version: 9.3
|
||||
Release: 1
|
||||
License: GPLv3+
|
||||
Group: System/Base
|
||||
Url: http://www.gnu.org/software/coreutils/
|
||||
|
@ -27,69 +27,46 @@ Patch105: coreutils-8.26-selinuxenable.patch
|
|||
Patch950: coreutils-selinux.patch
|
||||
|
||||
# fileutils
|
||||
Patch1155: coreutils-8.24-force-option--override--interactive-option.patch
|
||||
Patch118: fileutils-4.1-ls_h.patch
|
||||
Patch500: coreutils-8.3-mem.patch
|
||||
|
||||
#add info about TZ envvar to date manpage
|
||||
Patch703: coreutils-8.21-dateman.patch
|
||||
Patch713: coreutils-4.5.3-langinfo.patch
|
||||
|
||||
# (sb) lin18nux/lsb compliance - normally from here:
|
||||
# http://www.openi18n.org/subgroups/utildev/patch/
|
||||
# this one is actually a merger of 5.2 and 5.3, as join segfaults
|
||||
# compiled with gcc4 and the 5.1/5.2 patch
|
||||
# fwang: we often get this patch from fedora
|
||||
Patch800: coreutils-i18n.patch
|
||||
|
||||
Patch909: coreutils-5.1.0-64bit-fixes.patch
|
||||
|
||||
# https://qa.mandriva.com/show_bug.cgi?id=38577
|
||||
Patch911: coreutils-8.3-groupfix.patch
|
||||
|
||||
Patch1011: coreutils-8.26-DIR_COLORS-mdkconf.patch
|
||||
Patch1011: coreutils-9.3-DIR_COLORS-mdkconf.patch
|
||||
#(peroyvind): fix a test that fails to compile with -Werror=format-security
|
||||
Patch1014: coreutils-8.22-check-string-format.patch
|
||||
#(peroyvind): add missing header includes
|
||||
Patch1015: coreutils-8.24-include-missing-headers.patch
|
||||
# https://github.com/coreutils/coreutils/issues/11
|
||||
Patch1016: coreutils-8.28-check-for-__builtin_mul_overflow_p.patch
|
||||
Patch1017: coreutils-8.28-inline.patch
|
||||
|
||||
# fedora patches
|
||||
#add note about no difference between binary/text mode on Linux - md5sum manpage
|
||||
Patch2101: coreutils-6.10-manpages.patch
|
||||
#do display processor type for uname -p/-i based on uname(2) syscall
|
||||
Patch2103: coreutils-8.2-uname-processortype.patch
|
||||
Patch2103: coreutils-9.3-uname-processortype.patch
|
||||
#df --direct
|
||||
Patch2104: coreutils-8.24-df-direct.patch
|
||||
Patch2104: coreutils-9.3-df-direct.patch
|
||||
#add note about mkdir --mode behaviour into info documentation(#610559)
|
||||
Patch2107: coreutils-8.4-mkdir-modenote.patch
|
||||
# (sb) lin18nux/lsb compliance - expand/unexpand
|
||||
Patch2108: coreutils-i18n-expand-unexpand.patch
|
||||
# i18n patch for cut - old version - used
|
||||
Patch2109: coreutils-i18n-cut-old.patch
|
||||
# The unexpand patch above is not correct. Sent to the patch authors
|
||||
Patch2110: coreutils-i18n-fix-unexpand.patch
|
||||
#(un)expand - allow multiple files on input - broken by patch 801
|
||||
Patch2111: coreutils-i18n-fix2-expand-unexpand.patch
|
||||
#(un)expand - test BOM headers
|
||||
Patch2112: coreutils-i18n-un-expand-BOM.patch
|
||||
# make 'sort -h' work for arbitrary column even when using UTF-8 locales
|
||||
Patch2113: coreutils-i18n-sort-human.patch
|
||||
# fold: preserve new-lines in mutlibyte text (#1418505)
|
||||
Patch2114: coreutils-i18n-fold-newline.patch
|
||||
|
||||
# do not use IF_LINT for initialization of scalar variables
|
||||
Patch2115: https://src.fedoraproject.org/rpms/coreutils/raw/master/f/coreutils-8.32-if-lint.patch
|
||||
# ls: restore 8.31 behavior on removed directories
|
||||
Patch2116: https://src.fedoraproject.org/rpms/coreutils/raw/master/f/coreutils-8.32-ls-removed-dir.patch
|
||||
# https://src.fedoraproject.org/rpms/coreutils/raw/master/f/coreutils-8.32-if-lint.patch
|
||||
Patch2115: coreutils-9.3-if-lint.patch
|
||||
|
||||
#getgrouplist() patch from Ulrich Drepper.
|
||||
Patch2908: coreutils-8.14-getgrouplist.patch
|
||||
%if %{with crosscompile}
|
||||
Patch3001: dummy_help2man.patch
|
||||
%endif
|
||||
|
||||
#BuildRequires: locales-fr
|
||||
#BuildRequires: locales-ja
|
||||
|
@ -142,7 +119,6 @@ This package contains coreutils documentation in GNU info format.
|
|||
%prep
|
||||
%autosetup -p1
|
||||
|
||||
chmod a+x tests/misc/sort-mb-tests.sh tests/df/direct.sh tests/cp/no-ctx.sh
|
||||
chmod +w ./src/dircolors.h
|
||||
./src/dcgen ./src/dircolors.hin > ./src/dircolors.h
|
||||
|
||||
|
@ -198,7 +174,7 @@ make mandir=%{buildroot}%{_mandir} install-man
|
|||
|
||||
# let be compatible with old fileutils, sh-utils and textutils packages :
|
||||
mkdir -p %{buildroot}{/bin,%{_bindir},%{_sbindir}}
|
||||
for f in basename arch cat chgrp chmod chown coreutils cp cut date dd df echo env expr false id link ln ls mkdir mknod mktemp mv nice pwd rm rmdir sleep sort stat stty sync touch true uname unlink tac
|
||||
for f in basename arch cat chgrp chmod chown coreutils cp cut date dd df echo env expr false id link ln ls md5sum mkdir mknod mktemp mv nice pwd rm rmdir sleep sort stat stty sync touch true uname unlink tac
|
||||
do
|
||||
mv %{buildroot}{%{_bindir},/bin}/$f || :
|
||||
done
|
||||
|
|
Loading…
Add table
Reference in a new issue