diff --git a/0001-coreutils-8.31-i18n.patch b/0001-coreutils-8.31-i18n.patch index 6c376d29fa01afd807b3be81a68861260ee494d2..4a78178351f6c3712aecb09eb17c6087008a0314 100644 --- a/0001-coreutils-8.31-i18n.patch +++ b/0001-coreutils-8.31-i18n.patch @@ -1,6 +1,6 @@ -From 4135d348d731717473baca6fed127123ce142eb5 Mon Sep 17 00:00:00 2001 +From 3bc69048f43a78571269bc570ff0b229b13c012d Mon Sep 17 00:00:00 2001 From: openEuler Buildteam -Date: Fri, 10 Jan 2020 13:52:36 +0800 +Date: Wed, 29 Jul 2020 11:35:56 +0800 Subject: [PATCH] coreutils 8.31 i18n --- @@ -8,42 +8,43 @@ Subject: [PATCH] coreutils 8.31 i18n configure.ac | 2 + lib/linebuffer.h | 8 + lib/mbfile.c | 3 + - lib/mbfile.h | 255 +++++++++++++++ + lib/mbfile.h | 255 ++++++++++++ m4/mbfile.m4 | 14 + - src/cut.c | 441 ++++++++++++++++++++++++- - src/expand-common.c | 114 +++++++ + src/cut.c | 441 +++++++++++++++++++- + src/expand-common.c | 114 ++++++ src/expand-common.h | 12 + - src/expand.c | 90 +++++- - src/fold.c | 307 ++++++++++++++++-- - src/join.c | 359 +++++++++++++++++--- - src/pr.c | 443 ++++++++++++++++++++++--- - src/sort.c | 772 +++++++++++++++++++++++++++++++++++++++++--- - src/unexpand.c | 101 ++++-- - src/uniq.c | 265 ++++++++++++++- - tests/expand/mb.sh | 183 +++++++++++ + src/expand.c | 90 ++++- + src/fold.c | 307 ++++++++++++-- + src/join.c | 359 ++++++++++++++--- + src/local.mk | 4 +- + src/pr.c | 443 +++++++++++++++++++-- + src/sort.c | 772 ++++++++++++++++++++++++++++++++++-- + src/unexpand.c | 101 ++++- + src/uniq.c | 119 +++++- + tests/expand/mb.sh | 183 +++++++++ tests/i18n/sort.sh | 29 ++ tests/local.mk | 4 + - tests/misc/expand.pl | 42 +++ + tests/misc/expand.pl | 42 ++ tests/misc/fold.pl | 50 ++- tests/misc/join.pl | 50 +++ tests/misc/sort-mb-tests.sh | 45 +++ - tests/misc/sort-merge.pl | 42 +++ - tests/misc/sort.pl | 40 ++- - tests/misc/unexpand.pl | 39 +++ - tests/misc/uniq.pl | 55 ++++ + tests/misc/sort-merge.pl | 42 ++ + tests/misc/sort.pl | 40 +- + tests/misc/unexpand.pl | 39 ++ + tests/misc/uniq.pl | 55 +++ tests/pr/pr-tests.pl | 49 +++ - tests/unexpand/mb.sh | 172 ++++++++++ - 29 files changed, 3771 insertions(+), 216 deletions(-) + tests/unexpand/mb.sh | 172 ++++++++ + 30 files changed, 3633 insertions(+), 212 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 100644 tests/i18n/sort.sh - create mode 100644 tests/misc/sort-mb-tests.sh + create mode 100755 tests/i18n/sort.sh + create mode 100755 tests/misc/sort-mb-tests.sh create mode 100755 tests/unexpand/mb.sh diff --git a/bootstrap.conf b/bootstrap.conf -index 4926152..00c51e4 100644 +index db49c97..2a342c1 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -154,6 +154,7 @@ gnulib_modules=" @@ -55,10 +56,10 @@ index 4926152..00c51e4 100644 mbrtowc mbsalign diff --git a/configure.ac b/configure.ac -index 0ee01b2..f842d7a 100644 +index c2ad08c..f5da816 100644 --- a/configure.ac +++ b/configure.ac -@@ -438,6 +438,8 @@ fi +@@ -446,6 +446,8 @@ fi # I'm leaving it here for now. This whole thing needs to be modernized... gl_WINSIZE_IN_PTEM @@ -68,7 +69,7 @@ index 0ee01b2..f842d7a 100644 if test $gl_cv_sys_tiocgwinsz_needs_termios_h = no && \ diff --git a/lib/linebuffer.h b/lib/linebuffer.h -index 397ad13..5cbc2a2 100644 +index b19fea7..1f0a1a2 100644 --- a/lib/linebuffer.h +++ b/lib/linebuffer.h @@ -21,6 +21,11 @@ @@ -384,7 +385,7 @@ index 0000000..8589902 + : +]) diff --git a/src/cut.c b/src/cut.c -index bb2e641..f2f32c1 100644 +index 0f6ba60..35ab5fc 100644 --- a/src/cut.c +++ b/src/cut.c @@ -28,6 +28,11 @@ @@ -949,7 +950,7 @@ index bb2e641..f2f32c1 100644 if (optind == argc) diff --git a/src/expand-common.c b/src/expand-common.c -index 4502c0c..b70bf70 100644 +index e4209a0..76be4d8 100644 --- a/src/expand-common.c +++ b/src/expand-common.c @@ -19,6 +19,7 @@ @@ -1081,7 +1082,7 @@ index 4502c0c..b70bf70 100644 to the list of tab stops. */ extern void diff --git a/src/expand-common.h b/src/expand-common.h -index 3f3bfbc..adefb47 100644 +index f304fbb..eaa2f15 100644 --- a/src/expand-common.h +++ b/src/expand-common.h @@ -34,6 +34,18 @@ extern size_t max_column_width; @@ -1104,7 +1105,7 @@ index 3f3bfbc..adefb47 100644 extern void add_tab_stop (uintmax_t tabval); diff --git a/src/expand.c b/src/expand.c -index 6aa0711..03a46ee 100644 +index 3412d7b..bf61aff 100644 --- a/src/expand.c +++ b/src/expand.c @@ -37,6 +37,9 @@ @@ -1260,7 +1261,7 @@ index 6aa0711..03a46ee 100644 } diff --git a/src/fold.c b/src/fold.c -index 1d637de..f1e5ba3 100644 +index 2221f72..917c652 100644 --- a/src/fold.c +++ b/src/fold.c @@ -22,12 +22,34 @@ @@ -1660,7 +1661,7 @@ index 1d637de..f1e5ba3 100644 case 's': /* Break at word boundaries. */ diff --git a/src/join.c b/src/join.c -index dd0ce42..d0f28d9 100644 +index 1accfd4..e27243f 100644 --- a/src/join.c +++ b/src/join.c @@ -22,19 +22,33 @@ @@ -2099,7 +2100,7 @@ index dd0ce42..d0f28d9 100644 } putchar (eolchar); } -@@ -1099,20 +1345,43 @@ main (int argc, char **argv) +@@ -1098,20 +1344,43 @@ main (int argc, char **argv) case 't': { @@ -2152,8 +2153,23 @@ index dd0ce42..d0f28d9 100644 } break; +diff --git a/src/local.mk b/src/local.mk +index 72db9c7..ef3bfa4 100644 +--- a/src/local.mk ++++ b/src/local.mk +@@ -415,8 +415,8 @@ src_basenc_CPPFLAGS = -DBASE_TYPE=42 $(AM_CPPFLAGS) + + src_ginstall_CPPFLAGS = -DENABLE_MATCHPATHCON=1 $(AM_CPPFLAGS) + +-src_expand_SOURCES = src/expand.c src/expand-common.c +-src_unexpand_SOURCES = src/unexpand.c src/expand-common.c ++src_expand_SOURCES = src/expand.c src/expand-common.c lib/mbfile.c ++src_unexpand_SOURCES = src/unexpand.c src/expand-common.c lib/mbfile.c + + # Ensure we don't link against libcoreutils.a as that lib is + # not compiled with -fPIC which causes issues on 64 bit at least diff --git a/src/pr.c b/src/pr.c -index 46c1938..4f1559f 100644 +index 1606082..6374a7f 100644 --- a/src/pr.c +++ b/src/pr.c @@ -311,6 +311,24 @@ @@ -2181,8 +2197,8 @@ index 46c1938..4f1559f 100644 #include "system.h" #include "die.h" #include "error.h" -@@ -324,6 +342,18 @@ - #include "xstrtol.h" +@@ -325,6 +343,18 @@ + #include "xstrtol-error.h" #include "xdectoint.h" +/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ @@ -2200,7 +2216,7 @@ index 46c1938..4f1559f 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; @@ -2222,7 +2238,7 @@ index 46c1938..4f1559f 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); +@@ -429,6 +472,7 @@ static void add_line_number (COLUMN *p); static void getoptnum (const char *n_str, int min, int *num, const char *errfmt); static void getoptarg (char *arg, char switch_char, char *character, @@ -2230,7 +2246,7 @@ index 46c1938..4f1559f 100644 int *number); static void print_files (int number_of_files, char **av); static void init_parameters (int number_of_files); -@@ -441,7 +485,6 @@ static void store_char (char c); +@@ -442,7 +486,6 @@ static void store_char (char c); static void pad_down (unsigned int lines); static void read_rest_of_line (COLUMN *p); static void skip_read (COLUMN *p, int column_number); @@ -2238,7 +2254,7 @@ index 46c1938..4f1559f 100644 static void cleanup (void); static void print_sep_string (void); static void separator_string (const char *optarg_S); -@@ -453,7 +496,7 @@ static COLUMN *column_vector; +@@ -454,7 +497,7 @@ static COLUMN *column_vector; we store the leftmost columns contiguously in buff. To print a line from buff, get the index of the first character from line_vector[i], and print up to line_vector[i + 1]. */ @@ -2247,7 +2263,7 @@ index 46c1938..4f1559f 100644 /* Index of the position in buff where the next character will be stored. */ -@@ -557,7 +600,7 @@ static int chars_per_column; +@@ -558,7 +601,7 @@ static int chars_per_column; static bool untabify_input = false; /* (-e) The input tab character. */ @@ -2256,7 +2272,7 @@ index 46c1938..4f1559f 100644 /* (-e) Tabstops are at chars_per_tab, 2*chars_per_tab, 3*chars_per_tab, ... where the leftmost column is 1. */ -@@ -567,7 +610,10 @@ static int chars_per_input_tab = 8; +@@ -568,7 +611,10 @@ static int chars_per_input_tab = 8; static bool tabify_output = false; /* (-i) The output tab character. */ @@ -2268,7 +2284,7 @@ index 46c1938..4f1559f 100644 /* (-i) The width of the output tab. */ static int chars_per_output_tab = 8; -@@ -637,7 +683,13 @@ static int line_number; +@@ -638,7 +684,13 @@ static int line_number; static bool numbered_lines = false; /* (-n) Character which follows each line number. */ @@ -2283,7 +2299,7 @@ index 46c1938..4f1559f 100644 /* (-n) line counting starts with 1st line of input file (not with 1st line of 1st page printed). */ -@@ -690,6 +742,7 @@ static bool use_col_separator = false; +@@ -691,6 +743,7 @@ static bool use_col_separator = false; -a|COLUMN|-m is a 'space' and with the -J option a 'tab'. */ static char const *col_sep_string = ""; static int col_sep_length = 0; @@ -2291,7 +2307,7 @@ index 46c1938..4f1559f 100644 static char *column_separator = (char *) " "; static char *line_separator = (char *) "\t"; -@@ -851,6 +904,13 @@ separator_string (const char *optarg_S) +@@ -852,6 +905,13 @@ separator_string (const char *optarg_S) integer_overflow (); col_sep_length = len; col_sep_string = optarg_S; @@ -2305,7 +2321,7 @@ index 46c1938..4f1559f 100644 } int -@@ -875,6 +935,21 @@ main (int argc, char **argv) +@@ -876,6 +936,21 @@ main (int argc, char **argv) atexit (close_stdout); @@ -2327,7 +2343,7 @@ index 46c1938..4f1559f 100644 n_files = 0; file_names = (argc > 1 ? xnmalloc (argc - 1, sizeof (char *)) -@@ -951,8 +1026,12 @@ main (int argc, char **argv) +@@ -952,8 +1027,12 @@ main (int argc, char **argv) break; case 'e': if (optarg) @@ -2342,7 +2358,7 @@ index 46c1938..4f1559f 100644 /* Could check tab width > 0. */ untabify_input = true; break; -@@ -965,8 +1044,12 @@ main (int argc, char **argv) +@@ -966,8 +1045,12 @@ main (int argc, char **argv) break; case 'i': if (optarg) @@ -2357,7 +2373,7 @@ index 46c1938..4f1559f 100644 /* Could check tab width > 0. */ tabify_output = true; break; -@@ -984,8 +1067,8 @@ main (int argc, char **argv) +@@ -985,8 +1068,8 @@ main (int argc, char **argv) case 'n': numbered_lines = true; if (optarg) @@ -2368,7 +2384,7 @@ index 46c1938..4f1559f 100644 break; case 'N': skip_count = false; -@@ -1010,6 +1093,7 @@ main (int argc, char **argv) +@@ -1011,6 +1094,7 @@ main (int argc, char **argv) /* Reset an additional input of -s, -S dominates -s */ col_sep_string = ""; col_sep_length = 0; @@ -2376,7 +2392,7 @@ index 46c1938..4f1559f 100644 use_col_separator = true; if (optarg) separator_string (optarg); -@@ -1165,10 +1249,45 @@ getoptnum (const char *n_str, int min, int *num, const char *err) +@@ -1166,10 +1250,45 @@ getoptnum (const char *n_str, int min, int *num, const char *err) a number. */ static void @@ -2424,7 +2440,7 @@ index 46c1938..4f1559f 100644 if (*arg) { long int tmp_long; -@@ -1190,6 +1309,11 @@ static void +@@ -1191,6 +1310,11 @@ static void init_parameters (int number_of_files) { int chars_used_by_number = 0; @@ -2436,7 +2452,7 @@ index 46c1938..4f1559f 100644 lines_per_body = lines_per_page - lines_per_header - lines_per_footer; if (lines_per_body <= 0) -@@ -1227,7 +1351,7 @@ init_parameters (int number_of_files) +@@ -1228,7 +1352,7 @@ init_parameters (int number_of_files) else col_sep_string = column_separator; @@ -2445,7 +2461,7 @@ index 46c1938..4f1559f 100644 use_col_separator = true; } /* It's rather pointless to define a TAB separator with column -@@ -1257,11 +1381,11 @@ init_parameters (int number_of_files) +@@ -1258,11 +1382,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. */ @@ -2459,7 +2475,7 @@ index 46c1938..4f1559f 100644 /* The number is part of the column width unless we are printing files in parallel. */ -@@ -1270,7 +1394,7 @@ init_parameters (int number_of_files) +@@ -1271,7 +1395,7 @@ init_parameters (int number_of_files) } int sep_chars, useful_chars; @@ -2468,7 +2484,7 @@ index 46c1938..4f1559f 100644 sep_chars = INT_MAX; if (INT_SUBTRACT_WRAPV (chars_per_line - chars_used_by_number, sep_chars, &useful_chars)) -@@ -1293,7 +1417,7 @@ init_parameters (int number_of_files) +@@ -1294,7 +1418,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); @@ -2477,7 +2493,7 @@ index 46c1938..4f1559f 100644 } /* Open the necessary files, -@@ -1399,7 +1523,7 @@ init_funcs (void) +@@ -1400,7 +1524,7 @@ init_funcs (void) /* Enlarge p->start_position of first column to use the same form of padding_not_printed with all columns. */ @@ -2486,7 +2502,7 @@ index 46c1938..4f1559f 100644 /* This loop takes care of all but the rightmost column. */ -@@ -1433,7 +1557,7 @@ init_funcs (void) +@@ -1434,7 +1558,7 @@ init_funcs (void) } else { @@ -2495,7 +2511,7 @@ index 46c1938..4f1559f 100644 h_next = h + chars_per_column; } } -@@ -1724,9 +1848,9 @@ static void +@@ -1725,9 +1849,9 @@ static void align_column (COLUMN *p) { padding_not_printed = p->start_position; @@ -2507,7 +2523,7 @@ index 46c1938..4f1559f 100644 padding_not_printed = ANYWHERE; } -@@ -2001,13 +2125,13 @@ store_char (char c) +@@ -2002,13 +2126,13 @@ store_char (char c) /* May be too generous. */ buff = X2REALLOC (buff, &buff_allocated); } @@ -2523,7 +2539,7 @@ index 46c1938..4f1559f 100644 char *s; int num_width; -@@ -2024,22 +2148,24 @@ add_line_number (COLUMN *p) +@@ -2025,22 +2149,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. */ @@ -2552,7 +2568,7 @@ index 46c1938..4f1559f 100644 output_position = POS_AFTER_TAB (chars_per_output_tab, output_position); } -@@ -2198,7 +2324,7 @@ print_white_space (void) +@@ -2199,7 +2325,7 @@ print_white_space (void) while (goal - h_old > 1 && (h_new = POS_AFTER_TAB (chars_per_output_tab, h_old)) <= goal) { @@ -2561,7 +2577,7 @@ index 46c1938..4f1559f 100644 h_old = h_new; } while (++h_old <= goal) -@@ -2218,6 +2344,7 @@ print_sep_string (void) +@@ -2219,6 +2345,7 @@ print_sep_string (void) { char const *s = col_sep_string; int l = col_sep_length; @@ -2569,7 +2585,7 @@ index 46c1938..4f1559f 100644 if (separators_not_printed <= 0) { -@@ -2229,6 +2356,7 @@ print_sep_string (void) +@@ -2230,6 +2357,7 @@ print_sep_string (void) { for (; separators_not_printed > 0; --separators_not_printed) { @@ -2577,7 +2593,7 @@ index 46c1938..4f1559f 100644 while (l-- > 0) { /* 3 types of sep_strings: spaces only, spaces and chars, -@@ -2242,12 +2370,15 @@ print_sep_string (void) +@@ -2243,12 +2371,15 @@ print_sep_string (void) } else { @@ -2594,7 +2610,7 @@ index 46c1938..4f1559f 100644 /* sep_string ends with some spaces */ if (spaces_not_printed > 0) print_white_space (); -@@ -2275,7 +2406,7 @@ print_clump (COLUMN *p, int n, char *clump) +@@ -2276,7 +2407,7 @@ print_clump (COLUMN *p, int n, char *clump) required number of tabs and spaces. */ static void @@ -2603,7 +2619,7 @@ index 46c1938..4f1559f 100644 { if (tabify_output) { -@@ -2299,6 +2430,74 @@ print_char (char c) +@@ -2300,6 +2431,74 @@ print_char (char c) putchar (c); } @@ -2678,7 +2694,7 @@ index 46c1938..4f1559f 100644 /* Skip to page PAGE before printing. PAGE may be larger than total number of pages. */ -@@ -2476,9 +2675,9 @@ read_line (COLUMN *p) +@@ -2477,9 +2676,9 @@ read_line (COLUMN *p) align_empty_cols = false; } @@ -2690,7 +2706,7 @@ index 46c1938..4f1559f 100644 padding_not_printed = ANYWHERE; } -@@ -2547,7 +2746,7 @@ print_stored (COLUMN *p) +@@ -2548,7 +2747,7 @@ print_stored (COLUMN *p) COLUMN *q; int line = p->current_line++; @@ -2699,7 +2715,7 @@ index 46c1938..4f1559f 100644 /* FIXME UMR: Uninitialized memory read: * This is occurring while in: -@@ -2559,7 +2758,7 @@ print_stored (COLUMN *p) +@@ -2560,7 +2759,7 @@ print_stored (COLUMN *p) xmalloc [xmalloc.c:94] init_store_cols [pr.c:1648] */ @@ -2708,7 +2724,7 @@ index 46c1938..4f1559f 100644 pad_vertically = true; -@@ -2579,9 +2778,9 @@ print_stored (COLUMN *p) +@@ -2580,9 +2779,9 @@ print_stored (COLUMN *p) } } @@ -2720,7 +2736,7 @@ index 46c1938..4f1559f 100644 padding_not_printed = ANYWHERE; } -@@ -2594,8 +2793,8 @@ print_stored (COLUMN *p) +@@ -2595,8 +2794,8 @@ print_stored (COLUMN *p) if (spaces_not_printed == 0) { output_position = p->start_position + end_vector[line]; @@ -2731,7 +2747,7 @@ index 46c1938..4f1559f 100644 } return true; -@@ -2614,7 +2813,7 @@ print_stored (COLUMN *p) +@@ -2615,7 +2814,7 @@ print_stored (COLUMN *p) number of characters is 1.) */ static int @@ -2740,7 +2756,7 @@ index 46c1938..4f1559f 100644 { unsigned char uc = c; char *s = clump_buff; -@@ -2624,10 +2823,10 @@ char_to_clump (char c) +@@ -2625,10 +2824,10 @@ char_to_clump (char c) int chars; int chars_per_c = 8; @@ -2753,7 +2769,7 @@ index 46c1938..4f1559f 100644 { width = TAB_WIDTH (chars_per_c, input_position); -@@ -2708,6 +2907,164 @@ char_to_clump (char c) +@@ -2709,6 +2908,164 @@ char_to_clump (char c) return chars; } @@ -2919,7 +2935,7 @@ index 46c1938..4f1559f 100644 looking for more options and printing the next batch of files. diff --git a/src/sort.c b/src/sort.c -index d812aa9..01f2a9a 100644 +index 329ed45..8e1533e 100644 --- a/src/sort.c +++ b/src/sort.c @@ -29,6 +29,14 @@ @@ -2937,7 +2953,7 @@ index d812aa9..01f2a9a 100644 #include "system.h" #include "argmatch.h" #include "die.h" -@@ -161,14 +169,39 @@ static int decimal_point; +@@ -157,14 +165,39 @@ static int decimal_point; /* Thousands separator; if -1, then there isn't one. */ static int thousands_sep; @@ -2978,7 +2994,7 @@ index d812aa9..01f2a9a 100644 /* The kind of blanks for '-b' to skip in various options. */ enum blanktype { bl_start, bl_end, bl_both }; -@@ -342,13 +375,11 @@ static bool reverse; +@@ -338,13 +371,11 @@ static bool reverse; they were read if all keys compare equal. */ static bool stable; @@ -2995,7 +3011,7 @@ index d812aa9..01f2a9a 100644 /* Flag to remove consecutive duplicate lines from the output. Only the last of a sequence of equal lines will be output. */ -@@ -806,6 +837,46 @@ reap_all (void) +@@ -802,6 +833,46 @@ reap_all (void) reap (-1); } @@ -3042,7 +3058,7 @@ index d812aa9..01f2a9a 100644 /* Clean up any remaining temporary files. */ static void -@@ -1274,7 +1345,7 @@ zaptemp (char const *name) +@@ -1270,7 +1341,7 @@ zaptemp (char const *name) free (node); } @@ -3051,7 +3067,7 @@ index d812aa9..01f2a9a 100644 static int struct_month_cmp (void const *m1, void const *m2) -@@ -1289,7 +1360,7 @@ struct_month_cmp (void const *m1, void const *m2) +@@ -1285,7 +1356,7 @@ struct_month_cmp (void const *m1, void const *m2) /* Initialize the character class tables. */ static void @@ -3060,7 +3076,7 @@ index d812aa9..01f2a9a 100644 { size_t i; -@@ -1301,7 +1372,7 @@ inittables (void) +@@ -1297,7 +1368,7 @@ inittables (void) fold_toupper[i] = toupper (i); } @@ -3069,7 +3085,7 @@ index d812aa9..01f2a9a 100644 /* If we're not in the "C" locale, read different names for months. */ if (hard_LC_TIME) { -@@ -1383,6 +1454,84 @@ specify_nmerge (int oi, char c, char const *s) +@@ -1379,6 +1450,84 @@ specify_nmerge (int oi, char c, char const *s) xstrtol_fatal (e, oi, c, long_options, s); } @@ -3154,7 +3170,7 @@ index d812aa9..01f2a9a 100644 /* Specify the amount of main memory to use when sorting. */ static void specify_sort_size (int oi, char c, char const *s) -@@ -1614,7 +1763,7 @@ buffer_linelim (struct buffer const *buf) +@@ -1610,7 +1759,7 @@ buffer_linelim (struct buffer const *buf) by KEY in LINE. */ static char * @@ -3163,7 +3179,7 @@ index d812aa9..01f2a9a 100644 { char *ptr = line->text, *lim = ptr + line->length - 1; size_t sword = key->sword; -@@ -1623,10 +1772,10 @@ begfield (struct line const *line, struct keyfield const *key) +@@ -1619,10 +1768,10 @@ begfield (struct line const *line, struct keyfield const *key) /* The leading field separator itself is included in a field when -t is absent. */ @@ -3176,7 +3192,7 @@ index d812aa9..01f2a9a 100644 ++ptr; if (ptr < lim) ++ptr; -@@ -1652,11 +1801,70 @@ begfield (struct line const *line, struct keyfield const *key) +@@ -1648,11 +1797,70 @@ begfield (struct line const *line, struct keyfield const *key) return ptr; } @@ -3248,7 +3264,7 @@ index d812aa9..01f2a9a 100644 { char *ptr = line->text, *lim = ptr + line->length - 1; size_t eword = key->eword, echar = key->echar; -@@ -1671,10 +1879,10 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1667,10 +1875,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. */ @@ -3261,7 +3277,7 @@ index d812aa9..01f2a9a 100644 ++ptr; if (ptr < lim && (eword || echar)) ++ptr; -@@ -1720,10 +1928,10 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1716,10 +1924,10 @@ limfield (struct line const *line, struct keyfield const *key) */ /* Make LIM point to the end of (one byte past) the current field. */ @@ -3274,7 +3290,7 @@ index d812aa9..01f2a9a 100644 if (newlim) lim = newlim; } -@@ -1754,6 +1962,130 @@ limfield (struct line const *line, struct keyfield const *key) +@@ -1750,6 +1958,130 @@ limfield (struct line const *line, struct keyfield const *key) return ptr; } @@ -3405,7 +3421,7 @@ index d812aa9..01f2a9a 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 -@@ -1840,8 +2172,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) +@@ -1836,8 +2168,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) else { if (key->skipsblanks) @@ -3430,7 +3446,7 @@ index d812aa9..01f2a9a 100644 line->keybeg = line_start; } } -@@ -1975,12 +2321,10 @@ find_unit_order (char const *number) +@@ -1971,12 +2317,10 @@ find_unit_order (char const *number) < K/k < M < G < T < P < E < Z < Y */ static int @@ -3446,7 +3462,7 @@ index d812aa9..01f2a9a 100644 int diff = find_unit_order (a) - find_unit_order (b); return (diff ? diff : strnumcmp (a, b, decimal_point, thousands_sep)); -@@ -1991,7 +2335,7 @@ human_numcompare (char const *a, char const *b) +@@ -1987,7 +2331,7 @@ human_numcompare (char const *a, char const *b) hideously fast. */ static int @@ -3455,7 +3471,7 @@ index d812aa9..01f2a9a 100644 { while (blanks[to_uchar (*a)]) a++; -@@ -2001,6 +2345,25 @@ numcompare (char const *a, char const *b) +@@ -1997,6 +2341,25 @@ numcompare (char const *a, char const *b) return strnumcmp (a, b, decimal_point, thousands_sep); } @@ -3481,7 +3497,7 @@ index d812aa9..01f2a9a 100644 /* Work around a problem whereby the long double value returned by glibc's strtold ("NaN", ...) contains uninitialized bits: clear all bytes of A and B before calling strtold. FIXME: remove this function if -@@ -2051,7 +2414,7 @@ general_numcompare (char const *sa, char const *sb) +@@ -2047,7 +2410,7 @@ general_numcompare (char const *sa, char const *sb) Return 0 if the name in S is not recognized. */ static int @@ -3490,7 +3506,7 @@ index d812aa9..01f2a9a 100644 { size_t lo = 0; size_t hi = MONTHS_PER_YEAR; -@@ -2327,15 +2690,14 @@ debug_key (struct line const *line, struct keyfield const *key) +@@ -2323,15 +2686,14 @@ debug_key (struct line const *line, struct keyfield const *key) char saved = *lim; *lim = '\0'; @@ -3508,7 +3524,7 @@ index d812aa9..01f2a9a 100644 else if (key->general_numeric) ignore_value (strtold (beg, &tighter_lim)); else if (key->numeric || key->human_numeric) -@@ -2469,7 +2831,7 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2465,7 +2827,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 */ @@ -3517,7 +3533,7 @@ index d812aa9..01f2a9a 100644 && ((!key->skipsblanks && !implicit_skip) || (!key->skipsblanks && key->schar) || (!key->skipeblanks && key->echar))) -@@ -2527,11 +2889,87 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) +@@ -2523,11 +2885,87 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) error (0, 0, _("option '-r' only applies to last-resort comparison")); } @@ -3606,7 +3622,7 @@ index d812aa9..01f2a9a 100644 { struct keyfield *key = keylist; -@@ -2616,7 +3054,7 @@ keycompare (struct line const *a, struct line const *b) +@@ -2612,7 +3050,7 @@ keycompare (struct line const *a, struct line const *b) else if (key->human_numeric) diff = human_numcompare (ta, tb); else if (key->month) @@ -3615,7 +3631,7 @@ index d812aa9..01f2a9a 100644 else if (key->random) diff = compare_random (ta, tlena, tb, tlenb); else if (key->version) -@@ -2732,6 +3170,211 @@ keycompare (struct line const *a, struct line const *b) +@@ -2728,6 +3166,211 @@ keycompare (struct line const *a, struct line const *b) return key->reverse ? -diff : diff; } @@ -3827,7 +3843,7 @@ index d812aa9..01f2a9a 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. */ -@@ -2759,7 +3402,7 @@ compare (struct line const *a, struct line const *b) +@@ -2755,7 +3398,7 @@ compare (struct line const *a, struct line const *b) diff = - NONZERO (blen); else if (blen == 0) diff = 1; @@ -3836,7 +3852,7 @@ index d812aa9..01f2a9a 100644 { /* xmemcoll0 is a performance enhancement as it will not unconditionally write '\0' after the -@@ -4149,6 +4792,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) +@@ -4145,6 +4788,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) break; case 'f': key->translate = fold_toupper; @@ -3844,7 +3860,7 @@ index d812aa9..01f2a9a 100644 break; case 'g': key->general_numeric = true; -@@ -4228,7 +4872,7 @@ main (int argc, char **argv) +@@ -4224,7 +4868,7 @@ main (int argc, char **argv) initialize_exit_failure (SORT_FAILURE); hard_LC_COLLATE = hard_locale (LC_COLLATE); @@ -3853,7 +3869,7 @@ index d812aa9..01f2a9a 100644 hard_LC_TIME = hard_locale (LC_TIME); #endif -@@ -4249,6 +4893,29 @@ main (int argc, char **argv) +@@ -4245,6 +4889,29 @@ main (int argc, char **argv) thousands_sep = -1; } @@ -3883,7 +3899,7 @@ index d812aa9..01f2a9a 100644 have_read_stdin = false; inittables (); -@@ -4523,13 +5190,34 @@ main (int argc, char **argv) +@@ -4519,13 +5186,34 @@ main (int argc, char **argv) case 't': { @@ -3922,7 +3938,7 @@ index d812aa9..01f2a9a 100644 else { /* Provoke with 'sort -txx'. Complain about -@@ -4540,9 +5228,11 @@ main (int argc, char **argv) +@@ -4536,9 +5224,11 @@ main (int argc, char **argv) quote (optarg)); } } @@ -3936,7 +3952,7 @@ index d812aa9..01f2a9a 100644 } break; -@@ -4771,12 +5461,10 @@ main (int argc, char **argv) +@@ -4767,12 +5457,10 @@ main (int argc, char **argv) sort (files, nfiles, outfile, nthreads); } @@ -3950,7 +3966,7 @@ index d812aa9..01f2a9a 100644 if (have_read_stdin && fclose (stdin) == EOF) sort_die (_("close failed"), "-"); diff --git a/src/unexpand.c b/src/unexpand.c -index 9d34749..1f6388b 100644 +index 09dafdb..7d5dd64 100644 --- a/src/unexpand.c +++ b/src/unexpand.c @@ -38,6 +38,9 @@ @@ -4156,7 +4172,7 @@ index 9d34749..1f6388b 100644 } diff --git a/src/uniq.c b/src/uniq.c -index 9600ec0..c2bbf15 100644 +index e024757..534231f 100644 --- a/src/uniq.c +++ b/src/uniq.c @@ -21,6 +21,17 @@ @@ -4177,12 +4193,8 @@ index 9600ec0..c2bbf15 100644 #include "system.h" #include "argmatch.h" #include "linebuffer.h" -@@ -32,9 +43,21 @@ - #include "stdio--.h" - #include "xmemcoll.h" - #include "xstrtol.h" --#include "memcasecmp.h" -+#include "xmemcoll.h" +@@ -33,6 +44,18 @@ + #include "memcasecmp.h" #include "quote.h" +/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC @@ -4200,7 +4212,7 @@ index 9600ec0..c2bbf15 100644 /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "uniq" -@@ -144,6 +167,10 @@ enum +@@ -139,6 +162,10 @@ enum GROUP_OPTION = CHAR_MAX + 1 }; @@ -4211,7 +4223,7 @@ index 9600ec0..c2bbf15 100644 static struct option const longopts[] = { {"count", no_argument, NULL, 'c'}, -@@ -260,7 +287,7 @@ size_opt (char const *opt, char const *msgid) +@@ -253,7 +280,7 @@ size_opt (char const *opt, char const *msgid) return a pointer to the beginning of the line's field to be compared. */ static char * _GL_ATTRIBUTE_PURE @@ -4220,7 +4232,7 @@ index 9600ec0..c2bbf15 100644 { size_t count; char const *lp = line->buffer; -@@ -280,6 +307,83 @@ find_field (struct linebuffer const *line) +@@ -273,6 +300,83 @@ find_field (struct linebuffer const *line) return line->buffer + i; } @@ -4304,228 +4316,7 @@ index 9600ec0..c2bbf15 100644 /* Return false if two strings OLD and NEW match, true if not. OLD and NEW point not to the beginnings of the lines but rather to the beginnings of the fields to compare. -@@ -288,6 +392,8 @@ find_field (struct linebuffer const *line) - static bool - different (char *old, char *new, size_t oldlen, size_t newlen) - { -+ char *copy_old, *copy_new; -+ - if (check_chars < oldlen) - oldlen = check_chars; - if (check_chars < newlen) -@@ -295,15 +401,104 @@ different (char *old, char *new, size_t oldlen, size_t newlen) - - if (ignore_case) - { -- /* FIXME: This should invoke strcoll somehow. */ -- return oldlen != newlen || memcasecmp (old, new, oldlen); -+ size_t i; -+ -+ copy_old = xmalloc (oldlen + 1); -+ copy_new = xmalloc (oldlen + 1); -+ -+ for (i = 0; i < oldlen; i++) -+ { -+ copy_old[i] = toupper (old[i]); -+ copy_new[i] = toupper (new[i]); -+ } -+ bool rc = xmemcoll (copy_old, oldlen, copy_new, newlen); -+ free (copy_old); -+ free (copy_new); -+ return rc; - } -- else if (hard_LC_COLLATE) -- return xmemcoll (old, oldlen, new, newlen) != 0; - else -- return oldlen != newlen || memcmp (old, new, oldlen); -+ { -+ copy_old = (char *)old; -+ copy_new = (char *)new; -+ } -+ -+ return xmemcoll (copy_old, oldlen, copy_new, newlen); -+ - } - -+#if HAVE_MBRTOWC -+static int -+different_multi (const char *old, const char *new, size_t oldlen, size_t newlen, mbstate_t oldstate, mbstate_t newstate) -+{ -+ size_t i, j, chars; -+ const char *str[2]; -+ char *copy[2]; -+ size_t len[2]; -+ mbstate_t state[2]; -+ size_t mblength; -+ wchar_t wc, uwc; -+ mbstate_t state_bak; -+ -+ str[0] = old; -+ str[1] = new; -+ len[0] = oldlen; -+ len[1] = newlen; -+ state[0] = oldstate; -+ state[1] = newstate; -+ -+ for (i = 0; i < 2; i++) -+ { -+ copy[i] = xmalloc (len[i] + 1); -+ memset (copy[i], '\0', len[i] + 1); -+ -+ for (j = 0, chars = 0; j < len[i] && chars < check_chars; chars++) -+ { -+ state_bak = state[i]; -+ mblength = mbrtowc (&wc, str[i] + j, len[i] - j, &(state[i])); -+ -+ switch (mblength) -+ { -+ case (size_t)-1: -+ case (size_t)-2: -+ state[i] = state_bak; -+ /* Fall through */ -+ case 0: -+ mblength = 1; -+ break; -+ -+ default: -+ if (ignore_case) -+ { -+ uwc = towupper (wc); -+ -+ if (uwc != wc) -+ { -+ mbstate_t state_wc; -+ size_t mblen; -+ -+ memset (&state_wc, '\0', sizeof(mbstate_t)); -+ mblen = wcrtomb (copy[i] + j, uwc, &state_wc); -+ assert (mblen != (size_t)-1); -+ } -+ else -+ memcpy (copy[i] + j, str[i] + j, mblength); -+ } -+ else -+ memcpy (copy[i] + j, str[i] + j, mblength); -+ } -+ j += mblength; -+ } -+ copy[i][j] = '\0'; -+ len[i] = j; -+ } -+ int rc = xmemcoll (copy[0], len[0], copy[1], len[1]); -+ free (copy[0]); -+ free (copy[1]); -+ return rc; -+ -+} -+#endif -+ - /* Output the line in linebuffer LINE to standard output - provided that the switches say it should be output. - MATCH is true if the line matches the previous line. -@@ -367,19 +562,38 @@ check_file (const char *infile, const char *outfile, char delimiter) - char *prevfield IF_LINT ( = NULL); - size_t prevlen IF_LINT ( = 0); - bool first_group_printed = false; -+#if HAVE_MBRTOWC -+ mbstate_t prevstate; -+ -+ memset (&prevstate, '\0', sizeof (mbstate_t)); -+#endif - - while (!feof (stdin)) - { - char *thisfield; - size_t thislen; - bool new_group; -+#if HAVE_MBRTOWC -+ mbstate_t thisstate; -+#endif - - if (readlinebuffer_delim (thisline, stdin, delimiter) == 0) - break; - - thisfield = find_field (thisline); - thislen = thisline->length - 1 - (thisfield - thisline->buffer); -+#if HAVE_MBRTOWC -+ if (MB_CUR_MAX > 1) -+ { -+ thisstate = thisline->state; - -+ new_group = (prevline->length == 0 -+ || different_multi (thisfield, prevfield, -+ thislen, prevlen, -+ thisstate, prevstate)); -+ } -+ else -+#endif - new_group = (prevline->length == 0 - || different (thisfield, prevfield, thislen, prevlen)); - -@@ -397,6 +611,10 @@ check_file (const char *infile, const char *outfile, char delimiter) - SWAP_LINES (prevline, thisline); - prevfield = thisfield; - prevlen = thislen; -+#if HAVE_MBRTOWC -+ if (MB_CUR_MAX > 1) -+ prevstate = thisstate; -+#endif - first_group_printed = true; - } - } -@@ -409,17 +627,26 @@ check_file (const char *infile, const char *outfile, char delimiter) - size_t prevlen; - uintmax_t match_count = 0; - bool first_delimiter = true; -+#if HAVE_MBRTOWC -+ mbstate_t prevstate; -+#endif - - if (readlinebuffer_delim (prevline, stdin, delimiter) == 0) - goto closefiles; - prevfield = find_field (prevline); - prevlen = prevline->length - 1 - (prevfield - prevline->buffer); -+#if HAVE_MBRTOWC -+ prevstate = prevline->state; -+#endif - - while (!feof (stdin)) - { - bool match; - char *thisfield; - size_t thislen; -+#if HAVE_MBRTOWC -+ mbstate_t thisstate = thisline->state; -+#endif - if (readlinebuffer_delim (thisline, stdin, delimiter) == 0) - { - if (ferror (stdin)) -@@ -428,6 +655,14 @@ check_file (const char *infile, const char *outfile, char delimiter) - } - thisfield = find_field (thisline); - thislen = thisline->length - 1 - (thisfield - thisline->buffer); -+#if HAVE_MBRTOWC -+ if (MB_CUR_MAX > 1) -+ { -+ match = !different_multi (thisfield, prevfield, -+ thislen, prevlen, thisstate, prevstate); -+ } -+ else -+#endif - match = !different (thisfield, prevfield, thislen, prevlen); - match_count += match; - -@@ -460,6 +695,9 @@ check_file (const char *infile, const char *outfile, char delimiter) - SWAP_LINES (prevline, thisline); - prevfield = thisfield; - prevlen = thislen; -+#if HAVE_MBRTOWC -+ prevstate = thisstate; -+#endif - if (!match) - match_count = 0; - } -@@ -506,6 +744,19 @@ main (int argc, char **argv) +@@ -493,6 +597,19 @@ main (int argc, char **argv) atexit (close_stdout); @@ -4735,7 +4526,7 @@ index 0000000..dd6007c + +exit $fail diff --git a/tests/i18n/sort.sh b/tests/i18n/sort.sh -new file mode 100644 +new file mode 100755 index 0000000..26c95de --- /dev/null +++ b/tests/i18n/sort.sh @@ -4770,10 +4561,10 @@ index 0000000..26c95de + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk -index e88d99f..0382090 100644 +index 594a9d0..5f7f775 100644 --- a/tests/local.mk +++ b/tests/local.mk -@@ -368,6 +368,8 @@ all_tests = \ +@@ -369,6 +369,8 @@ all_tests = \ tests/misc/sort-discrim.sh \ tests/misc/sort-files0-from.pl \ tests/misc/sort-float.sh \ @@ -4782,7 +4573,7 @@ index e88d99f..0382090 100644 tests/misc/sort-h-thousands-sep.sh \ tests/misc/sort-merge.pl \ tests/misc/sort-merge-fdlimit.sh \ -@@ -564,6 +566,7 @@ all_tests = \ +@@ -567,6 +569,7 @@ all_tests = \ tests/du/threshold.sh \ tests/du/trailing-slash.sh \ tests/du/two-args.sh \ @@ -4790,7 +4581,7 @@ index e88d99f..0382090 100644 tests/id/gnu-zero-uids.sh \ tests/id/no-context.sh \ tests/id/context.sh \ -@@ -709,6 +712,7 @@ all_tests = \ +@@ -714,6 +717,7 @@ all_tests = \ tests/touch/read-only.sh \ tests/touch/relative.sh \ tests/touch/trailing-slash.sh \ @@ -4799,7 +4590,7 @@ index e88d99f..0382090 100644 # See tests/factor/create-test.sh. diff --git a/tests/misc/expand.pl b/tests/misc/expand.pl -index 8d490bf..2c01de5 100755 +index 8e5beaf..040e321 100755 --- a/tests/misc/expand.pl +++ b/tests/misc/expand.pl @@ -27,6 +27,15 @@ my $prog = 'expand'; @@ -4866,7 +4657,7 @@ index 8d490bf..2c01de5 100755 my $verbose = $ENV{VERBOSE}; diff --git a/tests/misc/fold.pl b/tests/misc/fold.pl -index 02580c3..d4e2d9e 100755 +index 3a72629..af85ee5 100755 --- a/tests/misc/fold.pl +++ b/tests/misc/fold.pl @@ -20,9 +20,18 @@ use strict; @@ -4939,7 +4730,7 @@ index 02580c3..d4e2d9e 100755 my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); exit $fail; diff --git a/tests/misc/join.pl b/tests/misc/join.pl -index 1e15b29..4aa4f41 100755 +index 8ab93ad..bdd3bc7 100755 --- a/tests/misc/join.pl +++ b/tests/misc/join.pl @@ -25,6 +25,15 @@ my $limits = getlimits (); @@ -5009,7 +4800,7 @@ index 1e15b29..4aa4f41 100755 my $verbose = $ENV{VERBOSE}; diff --git a/tests/misc/sort-mb-tests.sh b/tests/misc/sort-mb-tests.sh -new file mode 100644 +new file mode 100755 index 0000000..11836ba --- /dev/null +++ b/tests/misc/sort-mb-tests.sh @@ -5060,7 +4851,7 @@ index 0000000..11836ba + +Exit $fail diff --git a/tests/misc/sort-merge.pl b/tests/misc/sort-merge.pl -index 215f563..d7ce6cb 100755 +index 3a48580..4540d2f 100755 --- a/tests/misc/sort-merge.pl +++ b/tests/misc/sort-merge.pl @@ -26,6 +26,15 @@ my $prog = 'sort'; @@ -5120,7 +4911,7 @@ index 215f563..d7ce6cb 100755 my $verbose = $ENV{VERBOSE}; diff --git a/tests/misc/sort.pl b/tests/misc/sort.pl -index e2afc94..35bbe93 100755 +index 081618d..af217b4 100755 --- a/tests/misc/sort.pl +++ b/tests/misc/sort.pl @@ -24,10 +24,15 @@ my $prog = 'sort'; @@ -5188,7 +4979,7 @@ index e2afc94..35bbe93 100755 my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE}; diff --git a/tests/misc/unexpand.pl b/tests/misc/unexpand.pl -index 7e2ecc3..9a77315 100755 +index c8f5ff9..518e820 100755 --- a/tests/misc/unexpand.pl +++ b/tests/misc/unexpand.pl @@ -27,6 +27,14 @@ my $limits = getlimits (); @@ -5245,7 +5036,7 @@ index 7e2ecc3..9a77315 100755 my $verbose = $ENV{VERBOSE}; diff --git a/tests/misc/uniq.pl b/tests/misc/uniq.pl -index 8961085..086be4b 100755 +index 6f332c8..ce49925 100755 --- a/tests/misc/uniq.pl +++ b/tests/misc/uniq.pl @@ -23,9 +23,17 @@ my $limits = getlimits (); @@ -5321,7 +5112,7 @@ index 8961085..086be4b 100755 @Tests = triple_test \@Tests; diff --git a/tests/pr/pr-tests.pl b/tests/pr/pr-tests.pl -index 815abba..676e491 100755 +index 2720369..8427f2b 100755 --- a/tests/pr/pr-tests.pl +++ b/tests/pr/pr-tests.pl @@ -24,6 +24,15 @@ use strict; @@ -5568,5 +5359,5 @@ index 0000000..8a82d74 +LC_ALL=C unexpand in in > out || fail=1 +compare exp out > /dev/null 2>&1 || fail=1 -- -1.8.3.1 +2.23.0 diff --git a/bugfix-remove-usr-local-lib-from-m4.patch b/bugfix-remove-usr-local-lib-from-m4.patch index 8537a91d1ce9d0e5b81d949c04d1082f50c49e6f..6ed2fbb44e3f138129e7d468ca33a54aeaefce03 100644 --- a/bugfix-remove-usr-local-lib-from-m4.patch +++ b/bugfix-remove-usr-local-lib-from-m4.patch @@ -1,8 +1,17 @@ +From 28499fa6b233ffe0db6f406b8210ab89c51ca9e8 Mon Sep 17 00:00:00 2001 +From: openEuler Buildteam +Date: Wed, 29 Jul 2020 11:59:54 +0800 +Subject: [PATCH] bugfix remove usr local lib from m4 + +--- + m4/getloadavg.m4 | 12 ------------ + 1 file changed, 12 deletions(-) + diff --git a/m4/getloadavg.m4 b/m4/getloadavg.m4 -index c9f5a6d..e8f94dd 100644 +index 8e96965..63782a2 100644 --- a/m4/getloadavg.m4 +++ b/m4/getloadavg.m4 -@@ -41,16 +41,6 @@ AC_CHECK_FUNC([getloadavg], [], +@@ -41,18 +41,6 @@ AC_CHECK_FUNC([getloadavg], [], [LIBS="-lutil $LIBS" gl_func_getloadavg_done=yes]) fi @@ -10,7 +19,9 @@ index c9f5a6d..e8f94dd 100644 - # There is a commonly available library for RS/6000 AIX. - # Since it is not a standard part of AIX, it might be installed locally. - gl_getloadavg_LIBS=$LIBS -- LIBS="-L/usr/local/lib $LIBS" +- if test $cross_compiling != yes; then +- LIBS="-L/usr/local/lib $LIBS" +- fi - AC_CHECK_LIB([getloadavg], [getloadavg], - [LIBS="-lgetloadavg $LIBS" gl_func_getloadavg_done=yes], - [LIBS=$gl_getloadavg_LIBS]) @@ -19,3 +30,6 @@ index c9f5a6d..e8f94dd 100644 # Set up the replacement function if necessary. if test $gl_func_getloadavg_done = no; then HAVE_GETLOADAVG=0 +-- +2.23.0 + diff --git a/bugfix-selinux-flask.patch b/bugfix-selinux-flask.patch index 9f82f4dd3c90e9b1124c4b9aa56ff2a2c60ae8df..56918b2e34e03e8076275f4aa98659724fd40d48 100644 --- a/bugfix-selinux-flask.patch +++ b/bugfix-selinux-flask.patch @@ -1,13 +1,21 @@ +From 1e764c5b9a3eb9a73370dbcbc04c2462c31aaf45 Mon Sep 17 00:00:00 2001 +From: openEuler Buildteam +Date: Wed, 29 Jul 2020 11:55:45 +0800 +Subject: [PATCH] bugfix selinux flask + +--- + m4/gnulib-comp.m4 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 -index 1401e52..e98db6f 100644 +index dead90e..0abf0bd 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 -@@ -1751,11 +1751,11 @@ AC_DEFUN([gl_INIT], +@@ -1860,10 +1860,10 @@ AC_DEFUN([gl_INIT], AC_LIBOBJ([select]) fi gl_SYS_SELECT_MODULE_INDICATOR([select]) - AC_CHECK_HEADERS([selinux/flask.h]) - AC_LIBOBJ([selinux-at]) gl_HEADERS_SELINUX_SELINUX_H gl_HEADERS_SELINUX_CONTEXT_H if test "$with_selinux" != no && test "$ac_cv_header_selinux_selinux_h" = yes; then @@ -15,3 +23,6 @@ index 1401e52..e98db6f 100644 AC_LIBOBJ([getfilecon]) fi gl_SERVENT +-- +2.23.0 + diff --git a/coreutils-8.32-leaf-opt-xfs.patch b/coreutils-8.32-leaf-opt-xfs.patch new file mode 100644 index 0000000000000000000000000000000000000000..c02db71c148f41db7b7d9fa9e25c27146c5a3552 --- /dev/null +++ b/coreutils-8.32-leaf-opt-xfs.patch @@ -0,0 +1,164 @@ +From b9f9ed14bda93ecb407129b69e6476813c250046 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +Date: Wed, 15 Apr 2020 20:50:32 -0700 +Subject: [PATCH] fts: remove NOSTAT_LEAF_OPTIMIZATION +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +It caused ‘find’ and ‘du’ to dump core, and it was useful +only for obsolescent Linux filesystems anyway. Problem reported in: +https://lists.gnu.org/r/bug-gnulib/2020-04/msg00068.html +Quite possibly there is still a serious underlying fts bug with +tight-loop-check and mutating file systems, but if so this patch +should cause the bug to be triggered less often. +* lib/fts.c (enum leaf_optimization): Remove +NOSTAT_LEAF_OPTIMIZATION, as it’s problematic. +(S_MAGIC_REISERFS, S_MAGIC_XFS): Remove; no longer needed. +(leaf_optimization): Remove special cases for ReiserFS and XFS. +(fts_read): Remove NOSTAT_LEAF_OPTIMIZATION code. +* lib/fts_.h (struct _ftsent.fts_n_dirs_remaining): +Remove. All uses removed. + +Upstream-commit: 47bf2cf3184027c1eb9c1dfeea5c5b8b2d69710d +Signed-off-by: Kamil Dudka +--- + lib/fts.c | 56 ++++++++------------------------------------------- + lib/fts_.h | 5 ----- + 2 files changed, 8 insertions(+), 53 deletions(-) + +diff --git a/lib/fts.c b/lib/fts.c +index 1093ce5..dfe3fef 100644 +--- a/lib/fts.c ++++ b/lib/fts.c +@@ -445,7 +445,6 @@ fts_open (char * const *argv, + if ((parent = fts_alloc(sp, "", 0)) == NULL) + goto mem2; + parent->fts_level = FTS_ROOTPARENTLEVEL; +- parent->fts_n_dirs_remaining = -1; + } + + /* The classic fts implementation would call fts_stat with +@@ -634,9 +633,8 @@ fts_close (FTS *sp) + } + + /* Minimum link count of a traditional Unix directory. When leaf +- optimization is OK and MIN_DIR_NLINK <= st_nlink, then st_nlink is +- an upper bound on the number of subdirectories (counting "." and +- ".."). */ ++ optimization is OK and a directory's st_nlink == MIN_DIR_NLINK, ++ then the directory has no subdirectories. */ + enum { MIN_DIR_NLINK = 2 }; + + /* Whether leaf optimization is OK for a directory. */ +@@ -645,12 +643,8 @@ enum leaf_optimization + /* st_nlink is not reliable for this directory's subdirectories. */ + NO_LEAF_OPTIMIZATION, + +- /* Leaf optimization is OK, but is not useful for avoiding stat calls. */ +- OK_LEAF_OPTIMIZATION, +- +- /* Leaf optimization is not only OK: it is useful for avoiding +- stat calls, because dirent.d_type does not work. */ +- NOSTAT_LEAF_OPTIMIZATION ++ /* st_nlink == 2 means the directory lacks subdirectories. */ ++ OK_LEAF_OPTIMIZATION + }; + + #if (defined __linux__ || defined __ANDROID__) \ +@@ -663,9 +657,7 @@ enum leaf_optimization + # define S_MAGIC_CIFS 0xFF534D42 + # define S_MAGIC_NFS 0x6969 + # define S_MAGIC_PROC 0x9FA0 +-# define S_MAGIC_REISERFS 0x52654973 + # define S_MAGIC_TMPFS 0x1021994 +-# define S_MAGIC_XFS 0x58465342 + + # ifdef HAVE___FSWORD_T + typedef __fsword_t fsword; +@@ -786,23 +778,15 @@ dirent_inode_sort_may_be_useful (FTSENT const *p, int dir_fd) + } + + /* Given an FTS entry P for a directory with descriptor DIR_FD, +- return true if it is both useful and valid to apply leaf optimization. +- The optimization is useful only for file systems that lack usable +- dirent.d_type info. The optimization is valid if an st_nlink value +- of at least MIN_DIR_NLINK is an upper bound on the number of +- subdirectories of D, counting "." and ".." as subdirectories. ++ return whether it is valid to apply leaf optimization. ++ The optimization is valid if a directory's st_nlink value equal ++ to MIN_DIR_NLINK means the directory has no subdirectories. + DIR_FD is negative if unavailable. */ + static enum leaf_optimization + leaf_optimization (FTSENT const *p, int dir_fd) + { + switch (filesystem_type (p, dir_fd)) + { +- /* List here the file system types that may lack usable dirent.d_type +- info, yet for which the optimization does apply. */ +- case S_MAGIC_REISERFS: +- case S_MAGIC_XFS: /* XFS lacked it until 2013-08-22 commit. */ +- return NOSTAT_LEAF_OPTIMIZATION; +- + case 0: + /* Leaf optimization is unsafe if the file system type is unknown. */ + FALLTHROUGH; +@@ -1027,26 +1011,7 @@ check_for_dir: + if (p->fts_info == FTS_NSOK) + { + if (p->fts_statp->st_size == FTS_STAT_REQUIRED) +- { +- FTSENT *parent = p->fts_parent; +- if (parent->fts_n_dirs_remaining == 0 +- && ISSET(FTS_NOSTAT) +- && ISSET(FTS_PHYSICAL) +- && (leaf_optimization (parent, sp->fts_cwd_fd) +- == NOSTAT_LEAF_OPTIMIZATION)) +- { +- /* nothing more needed */ +- } +- else +- { +- p->fts_info = fts_stat(sp, p, false); +- if (S_ISDIR(p->fts_statp->st_mode) +- && p->fts_level != FTS_ROOTLEVEL +- && 0 < parent->fts_n_dirs_remaining +- && parent->fts_n_dirs_remaining != (nlink_t) -1) +- parent->fts_n_dirs_remaining--; +- } +- } ++ p->fts_info = fts_stat(sp, p, false); + else + fts_assert (p->fts_statp->st_size == FTS_NO_STAT_REQUIRED); + } +@@ -1830,11 +1795,6 @@ err: memset(sbp, 0, sizeof(struct stat)); + } + + if (S_ISDIR(sbp->st_mode)) { +- p->fts_n_dirs_remaining +- = ((sbp->st_nlink < MIN_DIR_NLINK +- || p->fts_level <= FTS_ROOTLEVEL) +- ? -1 +- : sbp->st_nlink - (ISSET (FTS_SEEDOT) ? 0 : MIN_DIR_NLINK)); + if (ISDOT(p->fts_name)) { + /* Command-line "." and ".." are real directories. */ + return (p->fts_level == FTS_ROOTLEVEL ? FTS_D : FTS_DOT); +diff --git a/lib/fts_.h b/lib/fts_.h +index d40a116..2e76cc4 100644 +--- a/lib/fts_.h ++++ b/lib/fts_.h +@@ -227,11 +227,6 @@ typedef struct _ftsent { + + size_t fts_namelen; /* strlen(fts_name) */ + +- /* If not (nlink_t) -1, an upper bound on the number of +- remaining subdirectories of interest. If this becomes +- zero, some work can be avoided. */ +- nlink_t fts_n_dirs_remaining; +- + # define FTS_D 1 /* preorder directory */ + # define FTS_DC 2 /* directory that causes cycles */ + # define FTS_DEFAULT 3 /* none of the above */ +-- +2.21.1 + diff --git a/coreutils-8.32-ls-removed-dir.patch b/coreutils-8.32-ls-removed-dir.patch new file mode 100644 index 0000000000000000000000000000000000000000..77dce894e0788d7416f03cb9cadb0f899f365f87 --- /dev/null +++ b/coreutils-8.32-ls-removed-dir.patch @@ -0,0 +1,153 @@ +From 8c022656320592dbad146f5d3a3ae1875f419446 Mon Sep 17 00:00:00 2001 +From: Paul Eggert +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 +(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 +--- + 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 + #endif + +-#ifdef __linux__ +-# include +-#endif +- + #include + #include + #include +@@ -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 +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 +--- + 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 + diff --git a/coreutils-8.31.tar.xz b/coreutils-8.32.tar.xz similarity index 42% rename from coreutils-8.31.tar.xz rename to coreutils-8.32.tar.xz index 3769e33e64fad795370717f912543f834c54000f..ac6ccc8c5a82d5d6fc29535cf5487ea75353eabc 100644 Binary files a/coreutils-8.31.tar.xz and b/coreutils-8.32.tar.xz differ diff --git a/coreutils-getgrouplist.patch b/coreutils-getgrouplist.patch index 5b35f42258038a407fd3a09d4581c3d399f94f85..5349337f42e844963aa10937afbcf90d61ab9aed 100644 --- a/coreutils-getgrouplist.patch +++ b/coreutils-getgrouplist.patch @@ -21,7 +21,15 @@ diff --git a/lib/mgetgroups.c b/lib/mgetgroups.c index 76474c2..0a9d221 100644 --- a/lib/mgetgroups.c +++ b/lib/mgetgroups.c -@@ -121,9 +121,17 @@ mgetgroups (char const *username, gid_t gid, gid_t **groups) +@@ -31,6 +31,7 @@ + #endif + + #include "getugroups.h" ++#include "xalloc.h" + #include "xalloc-oversized.h" + + /* Work around an incompatibility of OS X 10.11: getgrouplist +@@ -121,9 +122,17 @@ mgetgroups (char const *username, gid_t gid, gid_t **groups) /* else no username, so fall through and use getgroups. */ #endif @@ -42,7 +50,7 @@ index 76474c2..0a9d221 100644 /* If we failed to count groups because there is no supplemental group support, then return an array containing just GID. -@@ -145,10 +153,25 @@ mgetgroups (char const *username, gid_t gid, gid_t **groups) +@@ -145,10 +154,25 @@ mgetgroups (char const *username, gid_t gid, gid_t **groups) if (g == NULL) return -1; diff --git a/coreutils.spec b/coreutils.spec index 719195930be1ad22f927a8fb425b7a6bd2f98128..74f35e5edf868493701c64ebab9f1bbcbf9ff886 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,6 +1,6 @@ Name: coreutils -Version: 8.31 -Release: 4 +Version: 8.32 +Release: 1 License: GPLv3+ Summary: A set of basic GNU tools commonly used in shell scripts Url: https://www.gnu.org/software/coreutils/ @@ -10,16 +10,21 @@ Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz %global __requires_exclude ^%{_bindir}/coreutils$ %global user `ls -ld $USR_SCONF|awk '{print $3}'` -Patch1: 0001-coreutils-8.31-i18n.patch -Patch2: 0001-disable-test-of-rwlock.patch +Patch0: 0001-coreutils-8.31-i18n.patch +Patch1: 0001-disable-test-of-rwlock.patch # uname -p/-i to display processor type -Patch3: coreutils-8.2-uname-processortype.patch +Patch2: coreutils-8.2-uname-processortype.patch # df --direct -Patch4: coreutils-df-direct.patch +Patch3: coreutils-df-direct.patch -Patch5: bugfix-remove-usr-local-lib-from-m4.patch -Patch6: bugfix-dummy_help2man.patch -Patch7: bugfix-selinux-flask.patch +Patch4: coreutils-getgrouplist.patch +Patch5: bugfix-remove-usr-local-lib-from-m4.patch +Patch6: bugfix-dummy_help2man.patch +Patch7: bugfix-selinux-flask.patch +Patch8: skip-the-tests-that-require-selinux-if-selinux-is-di.patch + +Patch9: coreutils-8.32-ls-removed-dir.patch +Patch10: coreutils-8.32-leaf-opt-xfs.patch Conflicts: filesystem < 3 # To avoid clobbering installs @@ -130,6 +135,12 @@ fi %{_mandir}/man*/* %changelog +* Wed Jul 29 2020 Liquor - 8.32-1 +- update to 8.32 + +* Thu Apr 30 2020 openEuler Buildteam - 8.31-5 +- Judge if selinux is enabled for the tests that requires selinux + * Sat Mar 14 2020 openEuler Buildteam - 8.31-4 - Add build requires of gdb diff --git a/coreutils.yaml b/coreutils.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1fb4e241291bfbbfd9789eca494c8cd8044a3f83 --- /dev/null +++ b/coreutils.yaml @@ -0,0 +1,4 @@ +version_control: github +src_repo: coreutils/coreutils +tag_prefix: "^v" +seperator: "." diff --git a/skip-the-tests-that-require-selinux-if-selinux-is-di.patch b/skip-the-tests-that-require-selinux-if-selinux-is-di.patch new file mode 100644 index 0000000000000000000000000000000000000000..3146424528883018247cfb1d8d0e6d3e386f3833 --- /dev/null +++ b/skip-the-tests-that-require-selinux-if-selinux-is-di.patch @@ -0,0 +1,30 @@ +From 797f2ff278fd7f0f0448b94350baa05f6752936b Mon Sep 17 00:00:00 2001 +From: openEuler Buildteam +Date: Thu, 30 Apr 2020 09:44:03 +0800 +Subject: [PATCH] skip the tests that require selinux if selinux is disabled + +no-context.sh context.sh install-C-selinux.sh +These three tests requires selinux, and we need to judge if selinux +is enabled, if not, just skip these tests. + +--- + init.cfg | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/init.cfg b/init.cfg +index 739ba33..d536dec 100644 +--- a/init.cfg ++++ b/init.cfg +@@ -114,6 +114,9 @@ require_selinux_() + grep 'selinuxfs$' /proc/filesystems > /dev/null \ + || skip_ "this system lacks SELinux support" + ++ # Judge the selinux is enabled or not ++ selinuxenabled; [ $? = 1] && skip_ "SELinux is disabled" ++ + # Independent of whether SELinux is enabled system-wide, + # the current file system may lack SELinux support. + # Also the current build may have SELinux support disabled. +-- +1.8.3.1 +