-Submitted by: Matt Burgess (matthew_at_linuxfromscratch_dot_org)
-Date: 2013-12-16
-Initial Package Version: 8.22 (Rebased for version 8.23 by bdubbs@linuxfromscratch.org))
+Submitted by: DJ Lucas (dj_AT_linuxfromscratch_DOT_org)
+Date: 2016-02-09
+Initial Package Version: 8.25
Upstream Status: Rejected
-Origin: Based on Fedora's i18n patch at
- http://pkgs.fedoraproject.org/cgit/coreutils.git/plain/coreutils-i18n.patch
+Origin: Based on Suse's i18n patches at https://build.opensuse.org/package/view_file/Base:System/coreutils/coreutils-i18n.patch
Description: Fixes several i18n issues with various Coreutils programs
-
-diff -Naur coreutils-8.23.orig/Makefile.in coreutils-8.23/Makefile.in
---- coreutils-8.23.orig/Makefile.in 2014-07-18 17:22:24.000000000 -0500
-+++ coreutils-8.23/Makefile.in 2014-07-18 22:36:17.404066931 -0500
-@@ -5057,6 +5057,7 @@
- tests/misc/chcon.sh \
- tests/misc/chroot-credentials.sh \
- tests/misc/selinux.sh \
-+ tests/misc/sort-mb-tests.sh \
- tests/misc/truncate-owned-by-other.sh \
- tests/mkdir/writable-under-readonly.sh \
- tests/mkdir/smack-root.sh \
-diff -Naur coreutils-8.23.orig/lib/linebuffer.h coreutils-8.23/lib/linebuffer.h
---- coreutils-8.23.orig/lib/linebuffer.h 2014-05-29 07:05:50.000000000 -0500
-+++ coreutils-8.23/lib/linebuffer.h 2014-07-18 22:36:17.392067256 -0500
+diff -Naurp coreutils-8.25-orig/lib/linebuffer.h coreutils-8.25/lib/linebuffer.h
+--- coreutils-8.25-orig/lib/linebuffer.h 2016-01-01 07:45:55.000000000 -0600
++++ coreutils-8.25/lib/linebuffer.h 2016-02-08 19:07:10.298944609 -0600
@@ -21,6 +21,11 @@
# include <stdio.h>
/* A 'struct linebuffer' holds a line of text. */
struct linebuffer
-@@ -28,6 +33,9 @@
+@@ -28,6 +33,9 @@ struct linebuffer
size_t size; /* Allocated. */
size_t length; /* Used. */
char *buffer;
};
/* Initialize linebuffer LINEBUFFER for use. */
-diff -Naur coreutils-8.23.orig/src/cut.c coreutils-8.23/src/cut.c
---- coreutils-8.23.orig/src/cut.c 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/src/cut.c 2014-07-18 22:44:56.489482312 -0500
+diff -Naurp coreutils-8.25-orig/src/cut.c coreutils-8.25/src/cut.c
+--- coreutils-8.25-orig/src/cut.c 2016-01-13 05:08:59.000000000 -0600
++++ coreutils-8.25/src/cut.c 2016-02-08 19:07:10.300944616 -0600
@@ -28,6 +28,11 @@
#include <assert.h>
#include <getopt.h>
#include "system.h"
#include "error.h"
-@@ -37,6 +42,18 @@
- #include "quote.h"
- #include "xstrndup.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. */
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "cut"
-@@ -53,6 +70,52 @@
+@@ -54,6 +71,52 @@
} \
while (0)
+ while (0)
+
- struct range_pair
- {
-@@ -75,6 +138,8 @@
- /* Number of `struct range_pair's allocated. */
- static size_t n_rp_allocated;
+ /* 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;
-
- /* Append LOW, HIGH to the list RP of range pairs, allocating additional
- space if necessary. Update global variable N_RP. When allocating,
-@@ -106,15 +171,25 @@
++
+ /* 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,
/* If true do not output lines containing no delimiter characters.
Otherwise, all such lines are printed. This option is valid only
with field mode. */
-@@ -126,6 +201,9 @@
+@@ -97,6 +173,9 @@ static bool complement;
/* The delimiter character for field mode. */
static unsigned char delim;
+static wchar_t wcdelim;
+#endif
- /* True if the --output-delimiter=STRING option was specified. */
- static bool output_delimiter_specified;
-@@ -188,7 +266,7 @@
+ /* The delimiter for each line/record. */
+ static unsigned char line_delim = '\n';
+@@ -164,7 +243,7 @@ Print selected parts of lines from each
-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\
"), stdout);
fputs (_("\
--complement complement the set of selected bytes, characters\n\
-@@ -381,6 +459,9 @@
- if (operating_mode == byte_mode)
- error (0, 0,
- _("byte offset %s is too large"), quote (bad_num));
-+ else if (operating_mode == character_mode)
-+ error (0, 0,
-+ _("character offset %s is too large"), quote (bad_num));
- else
- error (0, 0,
- _("field number %s is too large"), quote (bad_num));
-@@ -505,6 +586,82 @@
+@@ -280,6 +359,82 @@ cut_bytes (FILE *stream)
}
}
+ bufpos = buf;
+ memset (&state, '\0', sizeof(mbstate_t));
+
-+ current_rp = rp;
++ current_rp = frp;
+
+ while (1)
+ {
+ if (wc == WEOF)
+ {
+ if (idx > 0)
-+ putchar ('\n');
++ putchar (line_delim);
+ break;
+ }
-+ else if (wc == L'\n')
++ else if (wc == line_delim)
+ {
-+ putchar ('\n');
++ putchar (line_delim);
+ idx = 0;
+ print_delimiter = false;
-+ current_rp = rp;
++ current_rp = frp;
+ }
+ else
+ {
/* Read from stream STREAM, printing to standard output any selected fields. */
static void
-@@ -649,13 +806,211 @@
+@@ -425,13 +580,211 @@ cut_fields (FILE *stream)
}
}
+ mbstate_t state; /* State of the stream. */
+ bool convfail = false; /* true, when conversion failed. Otherwise false. */
+
-+ current_rp = rp;
++ current_rp = frp;
+
+ found_any_selected_field = 0;
+ field_idx = 1;
+ buflen -= mblength;
+ bufpos += mblength;
+
-+ if (!convfail && (wc == L'\n' || wc == wcdelim))
++ if (!convfail && (wc == line_delim || wc == wcdelim))
+ break;
+ }
+
+ {
+ fwrite (field_1_buffer, sizeof (char), len, stdout);
+ /* Make sure the output line is newline terminated. */
-+ if (convfail || (!convfail && wc != L'\n'))
-+ putchar ('\n');
++ if (convfail || (!convfail && wc != line_delim))
++ putchar (line_delim);
+ }
+ continue;
+ }
+
+ if (wc == WEOF)
+ break;
-+ else if (!convfail && (wc == wcdelim || wc == L'\n'))
++ else if (!convfail && (wc == wcdelim || wc == line_delim))
+ {
+ buflen -= mblength;
+ bufpos += mblength;
+ }
+ }
+
-+ if ((!convfail || wc == L'\n') && buflen < 1)
++ if ((!convfail || wc == line_delim) && buflen < 1)
+ wc = WEOF;
+
+ if (!convfail && wc == wcdelim)
+ next_item (&field_idx);
-+ else if (wc == WEOF || (!convfail && wc == L'\n'))
++ else if (wc == WEOF || (!convfail && wc == line_delim))
+ {
+ if (found_any_selected_field
+ || (!empty_input && !(suppress_non_delimited && field_idx == 1)))
-+ putchar ('\n');
++ putchar (line_delim);
+ if (wc == WEOF)
+ break;
+ field_idx = 1;
-+ current_rp = rp;
++ current_rp = frp;
+ found_any_selected_field = 0;
+ }
+ }
}
/* Process file FILE to standard output.
-@@ -707,6 +1062,7 @@
+@@ -483,6 +836,7 @@ main (int argc, char **argv)
bool ok;
bool delim_specified = false;
char *spec_list_string IF_LINT ( = NULL);
initialize_main (&argc, &argv);
set_program_name (argv[0]);
-@@ -729,7 +1085,6 @@
+@@ -505,7 +859,6 @@ main (int argc, char **argv)
switch (optc)
{
case 'b':
/* Build the byte list. */
if (operating_mode != undefined_mode)
FATAL_ERROR (_("only one type of list may be specified"));
-@@ -737,6 +1092,14 @@
+@@ -513,6 +866,14 @@ main (int argc, char **argv)
spec_list_string = optarg;
break;
case 'f':
/* Build the field list. */
if (operating_mode != undefined_mode)
-@@ -748,10 +1111,38 @@
+@@ -524,10 +885,38 @@ main (int argc, char **argv)
case 'd':
/* New delimiter. */
/* Interpret -d '' to mean 'use the NUL byte as the delimiter.' */
break;
case OUTPUT_DELIMITER_OPTION:
-@@ -764,6 +1155,7 @@
+@@ -540,6 +929,7 @@ main (int argc, char **argv)
break;
case 'n':
break;
case 's':
-@@ -803,15 +1195,34 @@
- }
+@@ -579,15 +969,34 @@ main (int argc, char **argv)
+ | (complement ? SETFLD_COMPLEMENT : 0) );
if (!delim_specified)
- delim = '\t';
}
if (optind == argc)
-diff -Naur coreutils-8.23.orig/src/expand.c coreutils-8.23/src/expand.c
---- coreutils-8.23.orig/src/expand.c 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/src/expand.c 2014-07-18 22:36:17.394067191 -0500
+diff -Naurp coreutils-8.25-orig/src/expand.c coreutils-8.25/src/expand.c
+--- coreutils-8.25-orig/src/expand.c 2016-01-01 07:48:50.000000000 -0600
++++ coreutils-8.25/src/expand.c 2016-02-08 19:07:10.301944619 -0600
@@ -37,12 +37,34 @@
#include <stdio.h>
#include <getopt.h>
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "expand"
-@@ -357,6 +379,142 @@
+@@ -357,6 +379,142 @@ expand (void)
}
}
int
main (int argc, char **argv)
{
-@@ -421,7 +579,12 @@
+@@ -421,7 +579,12 @@ main (int argc, char **argv)
file_list = (optind < argc ? &argv[optind] : stdin_argv);
if (have_read_stdin && fclose (stdin) != 0)
error (EXIT_FAILURE, errno, "-");
-diff -Naur coreutils-8.23.orig/src/fold.c coreutils-8.23/src/fold.c
---- coreutils-8.23.orig/src/fold.c 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/src/fold.c 2014-07-18 22:36:17.394067191 -0500
-@@ -22,12 +22,34 @@
+diff -Naurp coreutils-8.25-orig/src/fold.c coreutils-8.25/src/fold.c
+--- coreutils-8.25-orig/src/fold.c 2016-01-01 07:48:50.000000000 -0600
++++ coreutils-8.25/src/fold.c 2016-02-08 19:07:10.302944622 -0600
+@@ -22,11 +22,33 @@
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
#include "error.h"
#include "fadvise.h"
- #include "quote.h"
- #include "xstrtol.h"
+ #include "xdectoint.h"
+/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC
+ installation; work around this configuration error. */
#define TAB_WIDTH 8
/* The official name of this program (e.g., no 'g' prefix). */
-@@ -35,20 +57,41 @@
+@@ -34,20 +56,41 @@
#define AUTHORS proper_name ("David MacKenzie")
{"spaces", no_argument, NULL, 's'},
{"width", required_argument, NULL, 'w'},
{GETOPT_HELP_OPTION_DECL},
-@@ -76,6 +119,7 @@
+@@ -75,6 +118,7 @@ Wrap input lines in each FILE, writing t
fputs (_("\
-b, --bytes count bytes rather than columns\n\
-s, --spaces break at spaces\n\
-w, --width=WIDTH use WIDTH columns instead of 80\n\
"), stdout);
-@@ -93,7 +137,7 @@
+@@ -92,7 +136,7 @@ Wrap input lines in each FILE, writing t
static size_t
adjust_column (size_t column, char c)
{
{
if (c == '\b')
{
-@@ -116,30 +160,14 @@
+@@ -115,30 +159,14 @@ adjust_column (size_t column, char c)
to stdout, with maximum line length WIDTH.
Return true if successful. */
-
- if (istream == NULL)
- {
-- error (0, errno, "%s", filename);
+- error (0, errno, "%s", quotef (filename));
- return false;
- }
fadvise (istream, FADVISE_SEQUENTIAL);
-@@ -169,6 +197,15 @@
+@@ -168,6 +196,15 @@ fold_file (char const *filename, size_t
bool found_blank = false;
size_t logical_end = offset_out;
/* Look for the last blank. */
while (logical_end)
{
-@@ -215,11 +252,221 @@
+@@ -214,11 +251,221 @@ fold_file (char const *filename, size_t
line_out[offset_out++] = c;
}
+ fwrite (line_out, sizeof(char), offset_out, stdout);
+ START_NEW_LINE;
+ continue;
-+
++
+ case L'\b':
+ increment = (column > 0) ? -1 : 0;
+ break;
+
+ if (istream == NULL)
+ {
-+ error (0, errno, "%s", filename);
++ error (0, errno, "%s", quotef (filename));
+ return 1;
+ }
+
+
if (ferror (istream))
{
- error (0, saved_errno, "%s", filename);
-@@ -252,7 +499,8 @@
+ error (0, saved_errno, "%s", quotef (filename));
+@@ -251,7 +498,8 @@ main (int argc, char **argv)
atexit (close_stdout);
while ((optc = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1)
{
-@@ -261,7 +509,15 @@
+@@ -260,7 +508,15 @@ main (int argc, char **argv)
switch (optc)
{
case 'b': /* Count bytes rather than columns. */
break;
case 's': /* Break at word boundaries. */
-diff -Naur coreutils-8.23.orig/src/join.c coreutils-8.23/src/join.c
---- coreutils-8.23.orig/src/join.c 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/src/join.c 2014-07-18 22:36:17.394067191 -0500
+diff -Naurp coreutils-8.25-orig/src/join.c coreutils-8.25/src/join.c
+--- coreutils-8.25-orig/src/join.c 2016-01-13 05:08:59.000000000 -0600
++++ coreutils-8.25/src/join.c 2016-02-08 19:07:10.303944625 -0600
@@ -22,18 +22,32 @@
#include <sys/types.h>
#include <getopt.h>
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "join"
-@@ -135,10 +149,12 @@
+@@ -135,10 +149,12 @@ static struct outlist outlist_head;
/* Last element in 'outlist', where a new element can be added. */
static struct outlist *outlist_end = &outlist_head;
/* If nonzero, check that the input is correctly ordered. */
static enum
-@@ -269,13 +285,14 @@
+@@ -275,13 +291,14 @@ xfields (struct line *line)
if (ptr == lim)
return;
+ else
{
/* Skip leading blanks before the first field. */
- while (isblank (to_uchar (*ptr)))
-@@ -299,6 +316,147 @@
+ while (field_sep (*ptr))
+@@ -305,6 +322,147 @@ xfields (struct line *line)
extract_field (line, ptr, lim - ptr);
}
+ }
+ mblength = (mblength < 1) ? 1 : mblength;
+
-+ if (!iswblank(wc))
++ if (!iswblank(wc) && wc != '\n')
+ break;
+ ptr += mblength;
+ }
+ }
+ mblength = (mblength < 1) ? 1 : mblength;
+
-+ if (iswblank (wc))
++ if (iswblank (wc) || wc == '\n')
+ break;
+
+ sep += mblength;
+ }
+ mblength = (mblength < 1) ? 1 : mblength;
+
-+ if (!iswblank (wc))
++ if (!iswblank (wc) && wc != '\n')
+ break;
+
+ ptr += mblength;
+ extract_field (line, ptr, lim - ptr);
+}
+#endif
-+
++
static void
freeline (struct line *line)
{
-@@ -320,56 +478,133 @@
+@@ -326,56 +484,133 @@ keycmp (struct line const *line1, struct
size_t jf_1, size_t jf_2)
{
/* Start of field to compare in each file. */
}
/* Check that successive input lines PREV and CURRENT from input file
-@@ -461,6 +696,11 @@
+@@ -467,6 +702,11 @@ get_line (FILE *fp, struct line **linep,
}
++line_no[which - 1];
xfields (line);
if (prevline[which - 1])
-@@ -560,21 +800,28 @@
+@@ -566,21 +806,28 @@ prfield (size_t n, struct line const *li
/* Output all the fields in line, other than the join field. */
prfield (i, line);
}
}
-@@ -585,7 +832,6 @@
+@@ -591,7 +838,6 @@ static void
prjoin (struct line const *line1, struct line const *line2)
{
const struct outlist *outlist;
size_t field;
struct line const *line;
-@@ -619,7 +865,7 @@
+@@ -625,7 +871,7 @@ prjoin (struct line const *line1, struct
o = o->next;
if (o == NULL)
break;
}
putchar (eolchar);
}
-@@ -1097,21 +1343,46 @@
+@@ -1103,21 +1349,46 @@ main (int argc, char **argv)
case 't':
{
break;
case 'z':
-diff -Naur coreutils-8.23.orig/src/pr.c coreutils-8.23/src/pr.c
---- coreutils-8.23.orig/src/pr.c 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/src/pr.c 2014-07-18 22:36:17.395067159 -0500
-@@ -312,6 +312,24 @@
+diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c
+--- coreutils-8.25-orig/src/pr.c 2016-01-01 07:48:50.000000000 -0600
++++ coreutils-8.25/src/pr.c 2016-02-08 19:07:10.306944635 -0600
+@@ -311,6 +311,24 @@
#include <getopt.h>
#include <sys/types.h>
#include "error.h"
#include "fadvise.h"
@@ -323,6 +341,18 @@
- #include "strftime.h"
#include "xstrtol.h"
+ #include "xdectoint.h"
+/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */
+#if HAVE_MBRTOWC && defined mbstate_t
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "pr"
-@@ -415,7 +445,20 @@
+@@ -415,7 +445,20 @@ struct COLUMN
typedef struct COLUMN COLUMN;
static bool read_line (COLUMN *p);
static bool print_page (void);
static bool print_stored (COLUMN *p);
-@@ -425,6 +468,7 @@
- static void pad_across_to (int position);
- static void add_line_number (COLUMN *p);
+@@ -427,6 +470,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,
+ int *character_length, int *character_width,
int *number);
static void print_files (int number_of_files, char **av);
static void init_parameters (int number_of_files);
-@@ -438,7 +482,6 @@
- static void pad_down (int lines);
+@@ -440,7 +484,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);
-static void print_char (char c);
static void cleanup (void);
static void print_sep_string (void);
static void separator_string (const char *optarg_S);
-@@ -450,7 +493,7 @@
+@@ -452,7 +495,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]. */
/* Index of the position in buff where the next character
will be stored. */
-@@ -554,7 +597,7 @@
+@@ -556,7 +599,7 @@ static int chars_per_column;
static bool untabify_input = false;
/* (-e) The input tab character. */
/* (-e) Tabstops are at chars_per_tab, 2*chars_per_tab, 3*chars_per_tab, ...
where the leftmost column is 1. */
-@@ -564,7 +607,10 @@
+@@ -566,7 +609,10 @@ static int chars_per_input_tab = 8;
static bool tabify_output = false;
/* (-i) The output tab character. */
/* (-i) The width of the output tab. */
static int chars_per_output_tab = 8;
-@@ -634,7 +680,13 @@
+@@ -636,7 +682,13 @@ static int line_number;
static bool numbered_lines = false;
/* (-n) Character which follows each line number. */
/* (-n) line counting starts with 1st line of input file (not with 1st
line of 1st page printed). */
-@@ -687,6 +739,7 @@
+@@ -689,6 +741,7 @@ static bool use_col_separator = false;
-a|COLUMN|-m is a 'space' and with the -J option a 'tab'. */
static char *col_sep_string = (char *) "";
static int col_sep_length = 0;
static char *column_separator = (char *) " ";
static char *line_separator = (char *) "\t";
-@@ -843,6 +896,13 @@
+@@ -839,6 +892,13 @@ separator_string (const char *optarg_S)
col_sep_length = (int) strlen (optarg_S);
col_sep_string = xmalloc (col_sep_length + 1);
strcpy (col_sep_string, optarg_S);
}
int
-@@ -867,6 +927,21 @@
+@@ -863,6 +923,21 @@ main (int argc, char **argv)
atexit (close_stdout);
n_files = 0;
file_names = (argc > 1
? xmalloc ((argc - 1) * sizeof (char *))
-@@ -943,8 +1018,12 @@
+@@ -939,8 +1014,12 @@ main (int argc, char **argv)
break;
case 'e':
if (optarg)
/* Could check tab width > 0. */
untabify_input = true;
break;
-@@ -957,8 +1036,12 @@
+@@ -953,8 +1032,12 @@ main (int argc, char **argv)
break;
case 'i':
if (optarg)
/* Could check tab width > 0. */
tabify_output = true;
break;
-@@ -985,8 +1068,8 @@
+@@ -972,8 +1055,8 @@ main (int argc, char **argv)
case 'n':
numbered_lines = true;
if (optarg)
break;
case 'N':
skip_count = false;
-@@ -1025,7 +1108,7 @@
+@@ -997,7 +1080,7 @@ main (int argc, char **argv)
old_s = false;
/* Reset an additional input of -s, -S dominates -s */
col_sep_string = bad_cast ("");
use_col_separator = true;
if (optarg)
separator_string (optarg);
-@@ -1182,10 +1265,45 @@
+@@ -1152,10 +1235,45 @@ getoptnum (const char *n_str, int min, i
a number. */
static void
if (*arg)
{
long int tmp_long;
-@@ -1207,6 +1325,11 @@
+@@ -1177,6 +1295,11 @@ static void
init_parameters (int number_of_files)
{
int chars_used_by_number = 0;
lines_per_body = lines_per_page - lines_per_header - lines_per_footer;
if (lines_per_body <= 0)
-@@ -1244,7 +1367,7 @@
+@@ -1214,7 +1337,7 @@ init_parameters (int number_of_files)
else
col_sep_string = column_separator;
use_col_separator = true;
}
/* It's rather pointless to define a TAB separator with column
-@@ -1274,11 +1397,11 @@
+@@ -1244,11 +1367,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. */
/* The number is part of the column width unless we are
printing files in parallel. */
-@@ -1287,7 +1410,7 @@
+@@ -1257,7 +1380,7 @@ init_parameters (int number_of_files)
}
chars_per_column = (chars_per_line - chars_used_by_number
if (chars_per_column < 1)
error (EXIT_FAILURE, 0, _("page width too narrow"));
-@@ -1305,7 +1428,7 @@
+@@ -1275,7 +1398,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);
- clump_buff = xmalloc (MAX (8, chars_per_input_tab));
+ clump_buff = xmalloc (mb_len * MAX (8, chars_per_input_tab));
}
- \f
+
/* Open the necessary files,
-@@ -1413,7 +1536,7 @@
+@@ -1383,7 +1506,7 @@ init_funcs (void)
/* Enlarge p->start_position of first column to use the same form of
padding_not_printed with all columns. */
/* This loop takes care of all but the rightmost column. */
-@@ -1447,7 +1570,7 @@
+@@ -1417,7 +1540,7 @@ init_funcs (void)
}
else
{
h_next = h + chars_per_column;
}
}
-@@ -1738,9 +1861,9 @@
+@@ -1708,9 +1831,9 @@ static void
align_column (COLUMN *p)
{
padding_not_printed = p->start_position;
padding_not_printed = ANYWHERE;
}
-@@ -2011,13 +2134,13 @@
+@@ -1981,13 +2104,13 @@ store_char (char c)
/* May be too generous. */
buff = X2REALLOC (buff, &buff_allocated);
}
char *s;
int num_width;
-@@ -2034,22 +2157,24 @@
+@@ -2004,22 +2127,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. */
output_position = POS_AFTER_TAB (chars_per_output_tab,
output_position);
}
-@@ -2210,7 +2335,7 @@
+@@ -2180,7 +2305,7 @@ print_white_space (void)
while (goal - h_old > 1
&& (h_new = POS_AFTER_TAB (chars_per_output_tab, h_old)) <= goal)
{
h_old = h_new;
}
while (++h_old <= goal)
-@@ -2230,6 +2355,7 @@
+@@ -2200,6 +2325,7 @@ print_sep_string (void)
{
char *s;
int l = col_sep_length;
s = col_sep_string;
-@@ -2243,6 +2369,7 @@
+@@ -2213,6 +2339,7 @@ print_sep_string (void)
{
for (; separators_not_printed > 0; --separators_not_printed)
{
while (l-- > 0)
{
/* 3 types of sep_strings: spaces only, spaces and chars,
-@@ -2256,12 +2383,15 @@
+@@ -2226,12 +2353,15 @@ print_sep_string (void)
}
else
{
/* sep_string ends with some spaces */
if (spaces_not_printed > 0)
print_white_space ();
-@@ -2289,7 +2419,7 @@
+@@ -2259,7 +2389,7 @@ print_clump (COLUMN *p, int n, char *clu
required number of tabs and spaces. */
static void
{
if (tabify_output)
{
-@@ -2313,6 +2443,74 @@
+@@ -2283,6 +2413,74 @@ print_char (char c)
putchar (c);
}
/* Skip to page PAGE before printing.
PAGE may be larger than total number of pages. */
-@@ -2492,9 +2690,9 @@
+@@ -2462,9 +2660,9 @@ read_line (COLUMN *p)
align_empty_cols = false;
}
padding_not_printed = ANYWHERE;
}
-@@ -2564,7 +2762,7 @@
+@@ -2534,7 +2732,7 @@ print_stored (COLUMN *p)
int i;
int line = p->current_line++;
/* FIXME
UMR: Uninitialized memory read:
* This is occurring while in:
-@@ -2576,7 +2774,7 @@
+@@ -2546,7 +2744,7 @@ print_stored (COLUMN *p)
xmalloc [xmalloc.c:94]
init_store_cols [pr.c:1648]
*/
pad_vertically = true;
-@@ -2595,9 +2793,9 @@
+@@ -2565,9 +2763,9 @@ print_stored (COLUMN *p)
}
}
padding_not_printed = ANYWHERE;
}
-@@ -2610,8 +2808,8 @@
+@@ -2580,8 +2778,8 @@ print_stored (COLUMN *p)
if (spaces_not_printed == 0)
{
output_position = p->start_position + end_vector[line];
}
return true;
-@@ -2630,7 +2828,7 @@
+@@ -2600,7 +2798,7 @@ print_stored (COLUMN *p)
number of characters is 1.) */
static int
{
unsigned char uc = c;
char *s = clump_buff;
-@@ -2640,10 +2838,10 @@
+@@ -2610,10 +2808,10 @@ char_to_clump (char c)
int chars;
int chars_per_c = 8;
{
width = TAB_WIDTH (chars_per_c, input_position);
-@@ -2724,6 +2922,164 @@
+@@ -2694,6 +2892,164 @@ char_to_clump (char c)
return chars;
}
/* We've just printed some files and need to clean up things before
looking for more options and printing the next batch of files.
-diff -Naur coreutils-8.23.orig/src/sort.c coreutils-8.23/src/sort.c
---- coreutils-8.23.orig/src/sort.c 2014-07-13 17:09:52.000000000 -0500
-+++ coreutils-8.23/src/sort.c 2014-07-18 22:36:17.397067101 -0500
+diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c
+--- coreutils-8.25-orig/src/sort.c 2016-01-16 13:09:33.000000000 -0600
++++ coreutils-8.25/src/sort.c 2016-02-08 19:07:10.310944648 -0600
@@ -29,6 +29,14 @@
#include <sys/wait.h>
#include <signal.h>
#include "system.h"
#include "argmatch.h"
#include "error.h"
-@@ -164,14 +172,39 @@
+@@ -163,14 +171,39 @@ static int decimal_point;
/* Thousands separator; if -1, then there isn't one. */
static int thousands_sep;
/* The kind of blanks for '-b' to skip in various options. */
enum blanktype { bl_start, bl_end, bl_both };
-@@ -345,13 +378,11 @@
+@@ -344,13 +377,11 @@ static bool reverse;
they were read if all keys compare equal. */
static bool stable;
/* Flag to remove consecutive duplicate lines from the output.
Only the last of a sequence of equal lines will be output. */
-@@ -811,6 +842,46 @@
+@@ -810,6 +841,46 @@ reap_all (void)
reap (-1);
}
+ }
+
+ *length = (mblength < 1) ? 1 : mblength;
-+ return iswblank (wc);
++ return iswblank (wc) || wc == '\n';
+}
+#endif
+
/* Clean up any remaining temporary files. */
static void
-@@ -1255,7 +1326,7 @@
+@@ -1254,7 +1325,7 @@ zaptemp (char const *name)
free (node);
}
static int
struct_month_cmp (void const *m1, void const *m2)
-@@ -1270,7 +1341,7 @@
+@@ -1269,7 +1340,7 @@ struct_month_cmp (void const *m1, void c
/* Initialize the character class tables. */
static void
{
size_t i;
-@@ -1282,7 +1353,7 @@
+@@ -1281,7 +1352,7 @@ inittables (void)
fold_toupper[i] = toupper (i);
}
/* If we're not in the "C" locale, read different names for months. */
if (hard_LC_TIME)
{
-@@ -1364,6 +1435,84 @@
+@@ -1363,6 +1434,84 @@ specify_nmerge (int oi, char c, char con
xstrtol_fatal (e, oi, c, long_options, s);
}
/* Specify the amount of main memory to use when sorting. */
static void
specify_sort_size (int oi, char c, char const *s)
-@@ -1597,7 +1746,7 @@
+@@ -1596,7 +1745,7 @@ buffer_linelim (struct buffer const *buf
by KEY in LINE. */
static char *
{
char *ptr = line->text, *lim = ptr + line->length - 1;
size_t sword = key->sword;
-@@ -1606,10 +1755,10 @@
+@@ -1605,10 +1754,10 @@ begfield (struct line const *line, struc
/* The leading field separator itself is included in a field when -t
is absent. */
++ptr;
if (ptr < lim)
++ptr;
-@@ -1635,11 +1784,70 @@
+@@ -1634,11 +1783,70 @@ begfield (struct line const *line, struc
return ptr;
}
{
char *ptr = line->text, *lim = ptr + line->length - 1;
size_t eword = key->eword, echar = key->echar;
-@@ -1654,10 +1862,10 @@
+@@ -1653,10 +1861,10 @@ limfield (struct line const *line, struc
'beginning' is the first character following the delimiting TAB.
Otherwise, leave PTR pointing at the first 'blank' character after
the preceding field. */
++ptr;
if (ptr < lim && (eword || echar))
++ptr;
-@@ -1703,10 +1911,10 @@
+@@ -1702,10 +1910,10 @@ limfield (struct line const *line, struc
*/
/* Make LIM point to the end of (one byte past) the current field. */
if (newlim)
lim = newlim;
}
-@@ -1737,6 +1945,130 @@
+@@ -1736,6 +1944,130 @@ limfield (struct line const *line, struc
return ptr;
}
/* 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
-@@ -1823,8 +2155,22 @@
+@@ -1822,8 +2154,22 @@ fillbuf (struct buffer *buf, FILE *fp, c
else
{
if (key->skipsblanks)
line->keybeg = line_start;
}
}
-@@ -1945,7 +2291,7 @@
+@@ -1944,7 +2290,7 @@ human_numcompare (char const *a, char co
hideously fast. */
static int
{
while (blanks[to_uchar (*a)])
a++;
-@@ -1955,6 +2301,25 @@
+@@ -1954,6 +2300,25 @@ numcompare (char const *a, char const *b
return strnumcmp (a, b, decimal_point, thousands_sep);
}
/* Work around a problem whereby the long double value returned by glibc's
strtold ("NaN", ...) contains uninitialized bits: clear all bytes of
A and B before calling strtold. FIXME: remove this function once
-@@ -2005,7 +2370,7 @@
+@@ -2004,7 +2369,7 @@ general_numcompare (char const *sa, char
Return 0 if the name in S is not recognized. */
static int
{
size_t lo = 0;
size_t hi = MONTHS_PER_YEAR;
-@@ -2280,15 +2645,14 @@
+@@ -2280,15 +2645,14 @@ debug_key (struct line const *line, stru
char saved = *lim;
*lim = '\0';
else if (key->general_numeric)
ignore_value (strtold (beg, &tighter_lim));
else if (key->numeric || key->human_numeric)
-@@ -2432,7 +2796,7 @@
+@@ -2432,7 +2796,7 @@ key_warnings (struct keyfield const *gke
bool maybe_space_aligned = !hard_LC_COLLATE && default_key_compare (key)
&& !(key->schar || key->echar);
bool line_offset = key->eword == 0 && key->echar != 0; /* -k1.x,1.y */
&& ((!key->skipsblanks && !(implicit_skip || maybe_space_aligned))
|| (!key->skipsblanks && key->schar)
|| (!key->skipeblanks && key->echar)))
-@@ -2490,11 +2854,87 @@
+@@ -2490,11 +2854,87 @@ key_warnings (struct keyfield const *gke
error (0, 0, _("option '-r' only applies to last-resort comparison"));
}
+ register int lo = 0, hi = MONTHS_PER_YEAR, result;
+ char *tmp;
+ size_t wclength, mblength;
-+ const char **pp;
-+ const wchar_t **wpp;
++ const char *pp;
++ const wchar_t *wpp;
+ wchar_t *month_wcs;
+ mbstate_t state;
+
+ if (len == 0)
+ return 0;
+
-+ month = (char *) xmalloc (len + 1);
++ if (SIZE_MAX - len < 1)
++ xalloc_die ();
++
++ month = (char *) xnmalloc (len + 1, MB_CUR_MAX);
+
-+ tmp = (char *) xmalloc (len + 1);
++ pp = tmp = (char *) xnmalloc (len + 1, MB_CUR_MAX);
+ memcpy (tmp, s, len);
+ tmp[len] = '\0';
-+ pp = (const char **)&tmp;
-+ month_wcs = (wchar_t *) xmalloc ((len + 1) * sizeof (wchar_t));
-+ memset (&state, '\0', sizeof(mbstate_t));
++ wpp = month_wcs = (wchar_t *) xnmalloc (len + 1, sizeof (wchar_t));
++ memset (&state, '\0', sizeof (mbstate_t));
+
-+ wclength = mbsrtowcs (month_wcs, pp, len + 1, &state);
-+ if (wclength == (size_t)-1 || *pp != NULL)
++ wclength = mbsrtowcs (month_wcs, &pp, len + 1, &state);
++ if (wclength == (size_t)-1 || pp != NULL)
+ error (SORT_FAILURE, 0, _("Invalid multibyte input %s."), quote(s));
+
+ for (i = 0; i < wclength; i++)
+ }
+ }
+
-+ wpp = (const wchar_t **)&month_wcs;
-+
-+ mblength = wcsrtombs (month, wpp, len + 1, &state);
-+ assert (mblength != (-1) && *wpp == NULL);
++ mblength = wcsrtombs (month, &wpp, (len + 1) * MB_CUR_MAX, &state);
++ assert (mblength != (-1) && wpp == NULL);
+
+ do
+ {
{
struct keyfield *key = keylist;
-@@ -2579,7 +3019,7 @@
+@@ -2579,7 +3019,7 @@ keycompare (struct line const *a, struct
else if (key->human_numeric)
diff = human_numcompare (ta, tb);
else if (key->month)
else if (key->random)
diff = compare_random (ta, tlena, tb, tlenb);
else if (key->version)
-@@ -2695,6 +3135,191 @@
+@@ -2695,6 +3135,211 @@ keycompare (struct line const *a, struct
return key->reverse ? -diff : diff;
}
+ size_t lena = lima <= texta ? 0 : lima - texta;
+ size_t lenb = limb <= textb ? 0 : limb - textb;
+
++ char enda IF_LINT (= 0);
++ char endb IF_LINT (= 0);
++
+ char const *translate = key->translate;
+ bool const *ignore = key->ignore;
+
+ if (ignore || translate)
+ {
-+ char *copy_a = (char *) xmalloc (lena + 1 + lenb + 1);
-+ char *copy_b = copy_a + lena + 1;
++ if (SIZE_MAX - lenb - 2 < lena)
++ xalloc_die ();
++ char *copy_a = (char *) xnmalloc (lena + lenb + 2, MB_CUR_MAX);
++ char *copy_b = copy_a + lena * MB_CUR_MAX + 1;
+ size_t new_len_a, new_len_b;
+ size_t i, j;
+
+ texta = copy_a; textb = copy_b;
+ lena = new_len_a; lenb = new_len_b;
+ }
++ else
++ {
++ /* Use the keys in-place, temporarily null-terminated. */
++ enda = texta[lena]; texta[lena] = '\0';
++ endb = textb[lenb]; textb[lenb] = '\0';
++ }
+
+ if (key->random)
+ diff = compare_random (texta, lena, textb, lenb);
+ diff = 1;
+ else if (hard_LC_COLLATE && !folding)
+ {
-+ diff = xmemcoll0 (texta, lena, textb, lenb);
++ diff = xmemcoll0 (texta, lena + 1, textb, lenb + 1);
+ }
+ else
-+ diff = memcmp (texta, textb, MIN (lena + 1,lenb + 1));
++ {
++ diff = memcmp (texta, textb, MIN (lena, lenb));
++ if (diff == 0)
++ diff = lena < lenb ? -1 : lena != lenb;
++ }
+
+ if (ignore || translate)
+ free (texta);
++ else
++ {
++ texta[lena] = enda;
++ textb[lenb] = endb;
++ }
+
+ if (diff)
+ goto not_equal;
/* Compare two lines A and B, returning negative, zero, or positive
depending on whether A compares less than, equal to, or greater than B. */
-@@ -2722,7 +3347,7 @@
+@@ -2722,7 +3367,7 @@ compare (struct line const *a, struct li
diff = - NONZERO (blen);
else if (blen == 0)
diff = 1;
{
/* Note xmemcoll0 is a performance enhancement as
it will not unconditionally write '\0' after the
-@@ -4121,6 +4746,7 @@
+@@ -4121,6 +4766,7 @@ set_ordering (char const *s, struct keyf
break;
case 'f':
key->translate = fold_toupper;
break;
case 'g':
key->general_numeric = true;
-@@ -4198,7 +4824,7 @@
+@@ -4199,7 +4845,7 @@ main (int argc, char **argv)
initialize_exit_failure (SORT_FAILURE);
hard_LC_COLLATE = hard_locale (LC_COLLATE);
hard_LC_TIME = hard_locale (LC_TIME);
#endif
-@@ -4219,6 +4845,29 @@
+@@ -4220,6 +4866,29 @@ main (int argc, char **argv)
thousands_sep = -1;
}
have_read_stdin = false;
inittables ();
-@@ -4493,13 +5142,34 @@
+@@ -4494,13 +5163,34 @@ main (int argc, char **argv)
case 't':
{
else
{
/* Provoke with 'sort -txx'. Complain about
-@@ -4510,9 +5180,12 @@
+@@ -4511,9 +5201,12 @@ main (int argc, char **argv)
quote (optarg));
}
}
}
break;
-diff -Naur coreutils-8.23.orig/src/unexpand.c coreutils-8.23/src/unexpand.c
---- coreutils-8.23.orig/src/unexpand.c 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/src/unexpand.c 2014-07-18 22:36:17.397067101 -0500
+@@ -4751,12 +5444,10 @@ main (int argc, char **argv)
+ sort (files, nfiles, outfile, nthreads);
+ }
+
+-#ifdef lint
+ if (files_from)
+ readtokens0_free (&tok);
+ else
+ free (files);
+-#endif
+
+ if (have_read_stdin && fclose (stdin) == EOF)
+ die (_("close failed"), "-");
+diff -Naurp coreutils-8.25-orig/src/unexpand.c coreutils-8.25/src/unexpand.c
+--- coreutils-8.25-orig/src/unexpand.c 2016-01-01 07:48:50.000000000 -0600
++++ coreutils-8.25/src/unexpand.c 2016-02-08 19:07:10.311944651 -0600
@@ -38,12 +38,29 @@
#include <stdio.h>
#include <getopt.h>
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "unexpand"
-@@ -103,6 +120,210 @@
+@@ -103,6 +120,210 @@ static struct option const longopts[] =
{NULL, 0, NULL, 0}
};
void
usage (int status)
{
-@@ -523,7 +744,12 @@
+@@ -523,7 +744,12 @@ main (int argc, char **argv)
file_list = (optind < argc ? &argv[optind] : stdin_argv);
if (have_read_stdin && fclose (stdin) != 0)
error (EXIT_FAILURE, errno, "-");
-diff -Naur coreutils-8.23.orig/src/uniq.c coreutils-8.23/src/uniq.c
---- coreutils-8.23.orig/src/uniq.c 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/src/uniq.c 2014-07-18 22:36:17.398067074 -0500
+diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c
+--- coreutils-8.25-orig/src/uniq.c 2016-01-13 05:08:59.000000000 -0600
++++ coreutils-8.25/src/uniq.c 2016-02-08 19:07:10.312944654 -0600
@@ -21,6 +21,17 @@
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
#include "argmatch.h"
#include "linebuffer.h"
-@@ -32,7 +43,19 @@
- #include "stdio--.h"
- #include "xmemcoll.h"
+@@ -33,6 +44,18 @@
#include "xstrtol.h"
--#include "memcasecmp.h"
+ #include "memcasecmp.h"
+ #include "quote.h"
+#include "xmemcoll.h"
+
+/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC
+#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 "uniq"
-@@ -143,6 +166,10 @@
+@@ -143,6 +166,10 @@ enum
GROUP_OPTION = CHAR_MAX + 1
};
static struct option const longopts[] =
{
{"count", no_argument, NULL, 'c'},
-@@ -251,7 +278,7 @@
+@@ -252,7 +279,7 @@ size_opt (char const *opt, char const *m
return a pointer to the beginning of the line's field to be compared. */
static char * _GL_ATTRIBUTE_PURE
{
size_t count;
char const *lp = line->buffer;
-@@ -271,6 +298,83 @@
+@@ -272,6 +299,83 @@ find_field (struct linebuffer const *lin
return line->buffer + i;
}
+ while (pos < size)
+ {
+ MBCHAR_TO_WCHAR (wc, mblength, lp, pos, size, statep, convfail);
-+
-+ if (convfail || !iswblank (wc))
++
++ if (convfail || !(iswblank (wc) || wc == '\n'))
+ {
+ pos += mblength;
+ break;
+ {
+ MBCHAR_TO_WCHAR (wc, mblength, lp, pos, size, statep, convfail);
+
-+ if (!convfail && iswblank (wc))
++ if (!convfail && (iswblank (wc) || wc == '\n'))
+ break;
+
+ pos += mblength;
/* 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.
-@@ -279,6 +383,8 @@
+@@ -280,6 +384,8 @@ find_field (struct linebuffer const *lin
static bool
different (char *old, char *new, size_t oldlen, size_t newlen)
{
if (check_chars < oldlen)
oldlen = check_chars;
if (check_chars < newlen)
-@@ -286,15 +392,104 @@
+@@ -287,15 +393,104 @@ different (char *old, char *new, size_t
if (ignore_case)
{
/* 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.
-@@ -358,19 +553,38 @@
+@@ -359,19 +554,38 @@ check_file (const char *infile, const ch
char *prevfield IF_LINT ( = NULL);
size_t prevlen IF_LINT ( = 0);
bool first_group_printed = false;
new_group = (prevline->length == 0
|| different (thisfield, prevfield, thislen, prevlen));
-@@ -388,6 +602,10 @@
+@@ -389,6 +603,10 @@ check_file (const char *infile, const ch
SWAP_LINES (prevline, thisline);
prevfield = thisfield;
prevlen = thislen;
first_group_printed = true;
}
}
-@@ -400,17 +618,26 @@
+@@ -401,17 +619,26 @@ check_file (const char *infile, const ch
size_t prevlen;
uintmax_t match_count = 0;
bool first_delimiter = true;
if (readlinebuffer_delim (thisline, stdin, delimiter) == 0)
{
if (ferror (stdin))
-@@ -419,6 +646,14 @@
+@@ -420,6 +647,14 @@ check_file (const char *infile, const ch
}
thisfield = find_field (thisline);
thislen = thisline->length - 1 - (thisfield - thisline->buffer);
match = !different (thisfield, prevfield, thislen, prevlen);
match_count += match;
-@@ -451,6 +686,9 @@
+@@ -452,6 +687,9 @@ check_file (const char *infile, const ch
SWAP_LINES (prevline, thisline);
prevfield = thisfield;
prevlen = thislen;
if (!match)
match_count = 0;
}
-@@ -497,6 +735,19 @@
+@@ -498,6 +736,19 @@ main (int argc, char **argv)
atexit (close_stdout);
skip_chars = 0;
skip_fields = 0;
check_chars = SIZE_MAX;
-diff -Naur coreutils-8.23.orig/tests/local.mk coreutils-8.23/tests/local.mk
---- coreutils-8.23.orig/tests/local.mk 2014-07-13 17:09:52.000000000 -0500
-+++ coreutils-8.23/tests/local.mk 2014-07-18 22:36:17.398067074 -0500
-@@ -331,6 +331,7 @@
+diff -Naurp coreutils-8.25-orig/tests/i18n/sort-month.sh coreutils-8.25/tests/i18n/sort-month.sh
+--- coreutils-8.25-orig/tests/i18n/sort-month.sh 1969-12-31 18:00:00.000000000 -0600
++++ coreutils-8.25/tests/i18n/sort-month.sh 2016-02-08 19:07:10.312944654 -0600
+@@ -0,0 +1,34 @@
++#!/bin/sh
++# Verify sort -M multi-byte support.
++
++. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
++print_ver_ sort
++require_valgrind_
++
++# Skip this test if some deallocations are
++# avoided at process end.
++grep '^#define lint 1' $CONFIG_HEADER > /dev/null ||
++ skip_ 'Allocation checks only work reliably in "lint" mode'
++
++export LC_ALL=en_US.UTF-8
++locale -k LC_CTYPE | grep -q "charmap.*UTF-8" \
++ || skip_ "No UTF-8 locale available"
++
++# Note the use of ɑ here which expands to
++# a wider representation upon case conversion
++# which triggered an assertion in sort -M
++cat <<EOF > exp
++.
++ɑ
++EOF
++
++
++# check large mem leak with --month-sort
++# https://bugzilla.redhat.com/show_bug.cgi?id=1259942
++valgrind --leak-check=full \
++ --error-exitcode=1 --errors-for-leak-kinds=definite \
++ sort -M < exp > out || fail=1
++compare exp out || { fail=1; cat out; }
++
++
++Exit $fail
+diff -Naurp coreutils-8.25-orig/tests/i18n/sort.sh coreutils-8.25/tests/i18n/sort.sh
+--- coreutils-8.25-orig/tests/i18n/sort.sh 1969-12-31 18:00:00.000000000 -0600
++++ coreutils-8.25/tests/i18n/sort.sh 2016-02-08 19:07:10.312944654 -0600
+@@ -0,0 +1,29 @@
++#!/bin/sh
++# Verify sort's multi-byte support.
++
++. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
++print_ver_ sort
++
++export LC_ALL=en_US.UTF-8
++locale -k LC_CTYPE | grep -q "charmap.*UTF-8" \
++ || skip_ "No UTF-8 locale available"
++
++# Enable heap consistency checkng on older systems
++export MALLOC_CHECK_=2
++
++
++# check buffer overflow issue due to
++# expanding multi-byte representation due to case conversion
++# https://bugzilla.suse.com/show_bug.cgi?id=928749
++cat <<EOF > exp
++.
++ɑ
++EOF
++cat <<EOF | sort -f > out || fail=1
++.
++ɑ
++EOF
++compare exp out || { fail=1; cat out; }
++
++
++Exit $fail
+diff -Naurp coreutils-8.25-orig/tests/local.mk coreutils-8.25/tests/local.mk
+--- coreutils-8.25-orig/tests/local.mk 2016-01-16 12:18:13.000000000 -0600
++++ coreutils-8.25/tests/local.mk 2016-02-08 19:07:10.313944658 -0600
+@@ -344,6 +344,9 @@ all_tests = \
tests/misc/sort-discrim.sh \
tests/misc/sort-files0-from.pl \
tests/misc/sort-float.sh \
+ tests/misc/sort-mb-tests.sh \
++ tests/i18n/sort.sh \
++ tests/i18n/sort-month.sh \
tests/misc/sort-merge.pl \
tests/misc/sort-merge-fdlimit.sh \
tests/misc/sort-month.sh \
-diff -Naur coreutils-8.23.orig/tests/misc/cut.pl coreutils-8.23/tests/misc/cut.pl
---- coreutils-8.23.orig/tests/misc/cut.pl 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/tests/misc/cut.pl 2014-07-18 22:36:17.398067074 -0500
-@@ -23,9 +23,11 @@
+diff -Naurp coreutils-8.25-orig/tests/misc/cut.pl coreutils-8.25/tests/misc/cut.pl
+--- coreutils-8.25-orig/tests/misc/cut.pl 2016-01-16 12:18:13.000000000 -0600
++++ coreutils-8.25/tests/misc/cut.pl 2016-02-08 19:07:10.314944661 -0600
+@@ -23,9 +23,11 @@ use strict;
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
my $prog = 'cut';
my $try = "Try '$prog --help' for more information.\n";
-@@ -227,6 +229,7 @@
+@@ -240,6 +242,7 @@ if ($mb_locale ne 'C')
my @new_t = @$t;
my $test_name = shift @new_t;
push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}];
}
push @Tests, @new;
-diff -Naur coreutils-8.23.orig/tests/misc/expand.pl coreutils-8.23/tests/misc/expand.pl
---- coreutils-8.23.orig/tests/misc/expand.pl 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/tests/misc/expand.pl 2014-07-18 22:36:17.399067050 -0500
-@@ -23,6 +23,15 @@
+diff -Naurp coreutils-8.25-orig/tests/misc/expand.pl coreutils-8.25/tests/misc/expand.pl
+--- coreutils-8.25-orig/tests/misc/expand.pl 2016-01-16 12:18:13.000000000 -0600
++++ coreutils-8.25/tests/misc/expand.pl 2016-02-08 19:07:10.314944661 -0600
+@@ -23,6 +23,15 @@ use strict;
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
my @Tests =
(
['t1', '--tabs=3', {IN=>"a\tb"}, {OUT=>"a b"}],
-@@ -31,6 +40,37 @@
+@@ -31,6 +40,37 @@ my @Tests =
['i2', '--tabs=3 -i', {IN=>" \ta\tb"}, {OUT=>" a\tb"}],
);
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
-diff -Naur coreutils-8.23.orig/tests/misc/fold.pl coreutils-8.23/tests/misc/fold.pl
---- coreutils-8.23.orig/tests/misc/fold.pl 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/tests/misc/fold.pl 2014-07-18 22:36:17.399067050 -0500
-@@ -20,9 +20,18 @@
+diff -Naurp coreutils-8.25-orig/tests/misc/fold.pl coreutils-8.25/tests/misc/fold.pl
+--- coreutils-8.25-orig/tests/misc/fold.pl 2016-01-16 12:18:13.000000000 -0600
++++ coreutils-8.25/tests/misc/fold.pl 2016-02-08 19:07:10.314944661 -0600
+@@ -20,9 +20,18 @@ use strict;
(my $program_name = $0) =~ s|.*/||;
my @Tests =
(
['s1', '-w2 -s', {IN=>"a\t"}, {OUT=>"a\n\t"}],
-@@ -31,9 +40,48 @@
+@@ -31,9 +40,48 @@ my @Tests =
['s4', '-w4 -s', {IN=>"abc ef\n"}, {OUT=>"abc \nef\n"}],
);
-my $prog = 'fold';
my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
exit $fail;
-diff -Naur coreutils-8.23.orig/tests/misc/join.pl coreutils-8.23/tests/misc/join.pl
---- coreutils-8.23.orig/tests/misc/join.pl 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/tests/misc/join.pl 2014-07-18 22:36:17.399067050 -0500
-@@ -25,6 +25,15 @@
+diff -Naurp coreutils-8.25-orig/tests/misc/join.pl coreutils-8.25/tests/misc/join.pl
+--- coreutils-8.25-orig/tests/misc/join.pl 2016-01-16 12:18:13.000000000 -0600
++++ coreutils-8.25/tests/misc/join.pl 2016-02-08 19:07:10.315944664 -0600
+@@ -25,6 +25,15 @@ my $limits = getlimits ();
my $prog = 'join';
my $delim = chr 0247;
sub t_subst ($)
{
-@@ -326,8 +335,49 @@
+@@ -329,8 +338,49 @@ foreach my $t (@tv)
push @Tests, $new_ent;
}
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
-diff -Naur coreutils-8.23.orig/tests/misc/sort-mb-tests.sh coreutils-8.23/tests/misc/sort-mb-tests.sh
---- coreutils-8.23.orig/tests/misc/sort-mb-tests.sh 1969-12-31 18:00:00.000000000 -0600
-+++ coreutils-8.23/tests/misc/sort-mb-tests.sh 2014-07-18 22:36:17.399067050 -0500
+diff -Naurp coreutils-8.25-orig/tests/misc/sort-mb-tests.sh coreutils-8.25/tests/misc/sort-mb-tests.sh
+--- coreutils-8.25-orig/tests/misc/sort-mb-tests.sh 1969-12-31 18:00:00.000000000 -0600
++++ coreutils-8.25/tests/misc/sort-mb-tests.sh 2016-02-08 19:07:10.315944664 -0600
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Verify sort's multi-byte support.
+compare exp out || { fail=1; cat out; }
+
+Exit $fail
-diff -Naur coreutils-8.23.orig/tests/misc/sort-merge.pl coreutils-8.23/tests/misc/sort-merge.pl
---- coreutils-8.23.orig/tests/misc/sort-merge.pl 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/tests/misc/sort-merge.pl 2014-07-18 22:36:17.399067050 -0500
-@@ -26,6 +26,15 @@
+diff -Naurp coreutils-8.25-orig/tests/misc/sort-merge.pl coreutils-8.25/tests/misc/sort-merge.pl
+--- coreutils-8.25-orig/tests/misc/sort-merge.pl 2016-01-16 12:18:14.000000000 -0600
++++ coreutils-8.25/tests/misc/sort-merge.pl 2016-02-08 19:07:10.316944667 -0600
+@@ -26,6 +26,15 @@ my $prog = 'sort';
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
# three empty files and one that says 'foo'
my @inputs = (+(map{{IN=> {"empty$_"=> ''}}}1..3), {IN=> {foo=> "foo\n"}});
-@@ -77,6 +86,39 @@
+@@ -77,6 +86,39 @@ my @Tests =
{OUT=>$big_input}],
);
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
-diff -Naur coreutils-8.23.orig/tests/misc/sort.pl coreutils-8.23/tests/misc/sort.pl
---- coreutils-8.23.orig/tests/misc/sort.pl 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/tests/misc/sort.pl 2014-07-18 22:36:17.400067026 -0500
-@@ -24,10 +24,15 @@
+diff -Naurp coreutils-8.25-orig/tests/misc/sort.pl coreutils-8.25/tests/misc/sort.pl
+--- coreutils-8.25-orig/tests/misc/sort.pl 2016-01-16 12:18:14.000000000 -0600
++++ coreutils-8.25/tests/misc/sort.pl 2016-02-08 19:07:10.316944667 -0600
+@@ -24,10 +24,15 @@ my $prog = 'sort';
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
# Since each test is run with a file name and with redirected stdin,
# the name in the diagnostic is either the file name or "-".
# Normalize each diagnostic to use '-'.
-@@ -415,6 +420,37 @@
+@@ -424,6 +429,38 @@ foreach my $t (@Tests)
}
}
+ #disable several failing tests until investigation, disable all tests with envvars set
+ next if (grep {ref $_ eq 'HASH' && exists $_->{ENV}} (@new_t));
+ next if ($test_name =~ "18g" or $test_name =~ "sort-numeric" or $test_name =~ "08[ab]" or $test_name =~ "03[def]" or $test_name =~ "h4" or $test_name =~ "n1" or $test_name =~ "2[01]a");
++ next if ($test_name =~ "11[ab]"); # avoid FP: expected result differs to MB result due to collation rules.
+ push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}];
+ }
+ push @Tests, @new;
@Tests = triple_test \@Tests;
# Remember that triple_test creates from each test with exactly one "IN"
-@@ -424,6 +460,7 @@
+@@ -433,6 +470,7 @@ foreach my $t (@Tests)
# Remove the IN_PIPE version of the "output-is-input" test above.
# The others aren't susceptible because they have three inputs each.
@Tests = grep {$_->[0] ne 'output-is-input.p'} @Tests;
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
-diff -Naur coreutils-8.23.orig/tests/misc/unexpand.pl coreutils-8.23/tests/misc/unexpand.pl
---- coreutils-8.23.orig/tests/misc/unexpand.pl 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/tests/misc/unexpand.pl 2014-07-18 22:36:17.400067026 -0500
-@@ -27,6 +27,14 @@
+diff -Naurp coreutils-8.25-orig/tests/misc/unexpand.pl coreutils-8.25/tests/misc/unexpand.pl
+--- coreutils-8.25-orig/tests/misc/unexpand.pl 2016-01-16 12:18:14.000000000 -0600
++++ coreutils-8.25/tests/misc/unexpand.pl 2016-02-08 19:07:10.317944671 -0600
+@@ -27,6 +27,14 @@ my $limits = getlimits ();
my $prog = 'unexpand';
my @Tests =
(
['a1', {IN=> ' 'x 1 ."y\n"}, {OUT=> ' 'x 1 ."y\n"}],
-@@ -92,6 +100,37 @@
+@@ -92,6 +100,37 @@ my @Tests =
{EXIT => 1}, {ERR => "$prog: tab stop value is too large\n"}],
);
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
-diff -Naur coreutils-8.23.orig/tests/misc/uniq.pl coreutils-8.23/tests/misc/uniq.pl
---- coreutils-8.23.orig/tests/misc/uniq.pl 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/tests/misc/uniq.pl 2014-07-18 22:36:17.400067026 -0500
-@@ -23,9 +23,17 @@
+diff -Naurp coreutils-8.25-orig/tests/misc/uniq.pl coreutils-8.25/tests/misc/uniq.pl
+--- coreutils-8.25-orig/tests/misc/uniq.pl 2016-01-16 12:18:14.000000000 -0600
++++ coreutils-8.25/tests/misc/uniq.pl 2016-02-08 19:07:10.317944671 -0600
+@@ -23,9 +23,17 @@ my $limits = getlimits ();
my $prog = 'uniq';
my $try = "Try '$prog --help' for more information.\n";
# When possible, create a "-z"-testing variant of each test.
sub add_z_variants($)
{
-@@ -261,6 +269,53 @@
+@@ -262,6 +270,53 @@ foreach my $t (@Tests)
and push @$t, {ENV=>'_POSIX2_VERSION=199209'};
}
@Tests = add_z_variants \@Tests;
@Tests = triple_test \@Tests;
-diff -Naur coreutils-8.23.orig/tests/pr/pr-tests.pl coreutils-8.23/tests/pr/pr-tests.pl
---- coreutils-8.23.orig/tests/pr/pr-tests.pl 2014-07-11 06:00:07.000000000 -0500
-+++ coreutils-8.23/tests/pr/pr-tests.pl 2014-07-18 22:36:17.401067000 -0500
-@@ -23,6 +23,15 @@
-
+diff -Naurp coreutils-8.25-orig/tests/pr/pr-tests.pl coreutils-8.25/tests/pr/pr-tests.pl
+--- coreutils-8.25-orig/tests/pr/pr-tests.pl 2016-01-16 12:18:14.000000000 -0600
++++ coreutils-8.25/tests/pr/pr-tests.pl 2016-02-08 19:07:10.318944674 -0600
+@@ -24,6 +24,15 @@ use strict;
my $prog = 'pr';
+ my $normalize_strerror = "s/': .*/'/";
+my $mb_locale;
+#Uncomment the following line to enable multibyte tests
my @tv = (
# -b option is no longer an official option. But it's still working to
-@@ -466,8 +475,48 @@
+@@ -467,8 +476,48 @@ push @Tests,
{IN=>{3=>"x\ty\tz\n"}},
{OUT=>join("\t", qw(a b c m n o x y z)) . "\n"} ];