This is an major update to the latest stable version.
* Drop SELinux support.
Fixes #11200.
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- coreutils/coreutils.nm | 5 +- coreutils/patches/coreutils-i18n.patch | 1635 ++++---------------- .../patches/coreutils-ipfire-disabled-tests.patch | 52 - 3 files changed, 318 insertions(+), 1374 deletions(-) delete mode 100644 coreutils/patches/coreutils-ipfire-disabled-tests.patch
diff --git a/coreutils/coreutils.nm b/coreutils/coreutils.nm index 2c59057..e9c4fa4 100644 --- a/coreutils/coreutils.nm +++ b/coreutils/coreutils.nm @@ -4,8 +4,8 @@ ###############################################################################
name = coreutils -version = 8.25 -release = 2 +version = 8.26 +release = 1
groups = System/Base url = http://www.gnu.org/software/coreutils/ @@ -30,7 +30,6 @@ build libacl-devel libattr-devel libcap-devel - libselinux-devel ncurses-devel texinfo end diff --git a/coreutils/patches/coreutils-i18n.patch b/coreutils/patches/coreutils-i18n.patch index ad984ec..d7cf59c 100644 --- a/coreutils/patches/coreutils-i18n.patch +++ b/coreutils/patches/coreutils-i18n.patch @@ -1,798 +1,63 @@ -Submitted by: DJ Lucas (dj_AT_linuxfromscratch_DOT_org) -Date: 2016-02-09 -Initial Package Version: 8.25 -Upstream Status: Rejected -Origin: Based on Suse's i18n patches at https://build.opensuse.org/package/view_file/Base:System/coreutils/coreutils... -Description: Fixes several i18n issues with various Coreutils programs +From 29117b2d07af00f4d4b87cf778e4294588ab1a83 Mon Sep 17 00:00:00 2001 +From: Kamil Dudka kdudka@redhat.com +Date: Thu, 1 Dec 2016 15:10:04 +0100 +Subject: [PATCH] coreutils-i18n.patch
-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> - -+/* Get mbstate_t. */ -+# if HAVE_WCHAR_H -+# include <wchar.h> -+# endif -+ - /* A 'struct linebuffer' holds a line of text. */ - - struct linebuffer -@@ -28,6 +33,9 @@ struct linebuffer - size_t size; /* Allocated. */ - size_t length; /* Used. */ - char *buffer; -+# if HAVE_WCHAR_H -+ mbstate_t state; -+# endif - }; - - /* Initialize linebuffer LINEBUFFER for use. */ -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 <sys/types.h> -+ -+/* Get mbstate_t, mbrtowc(). */ -+#if HAVE_WCHAR_H -+# include <wchar.h> -+#endif - #include "system.h" - - #include "error.h" -@@ -38,6 +43,18 @@ - - #include "set-fields.h" - -+/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC -+ installation; work around this configuration error. */ -+#if !defined MB_LEN_MAX || MB_LEN_MAX < 2 -+# undef MB_LEN_MAX -+# define MB_LEN_MAX 16 -+#endif -+ -+/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ -+#if HAVE_MBRTOWC && defined mbstate_t -+# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0) -+#endif -+ - /* The official name of this program (e.g., no 'g' prefix). */ - #define PROGRAM_NAME "cut" - -@@ -54,6 +71,52 @@ - } \ - while (0) - -+/* Refill the buffer BUF to get a multibyte character. */ -+#define REFILL_BUFFER(BUF, BUFPOS, BUFLEN, STREAM) \ -+ do \ -+ { \ -+ if (BUFLEN < MB_LEN_MAX && !feof (STREAM) && !ferror (STREAM)) \ -+ { \ -+ memmove (BUF, BUFPOS, BUFLEN); \ -+ BUFLEN += fread (BUF + BUFLEN, sizeof(char), BUFSIZ, STREAM); \ -+ BUFPOS = BUF; \ -+ } \ -+ } \ -+ while (0) -+ -+/* Get wide character on BUFPOS. BUFPOS is not included after that. -+ If byte sequence is not valid as a character, CONVFAIL is true. Otherwise false. */ -+#define GET_NEXT_WC_FROM_BUFFER(WC, BUFPOS, BUFLEN, MBLENGTH, STATE, CONVFAIL) \ -+ do \ -+ { \ -+ mbstate_t state_bak; \ -+ \ -+ if (BUFLEN < 1) \ -+ { \ -+ WC = WEOF; \ -+ break; \ -+ } \ -+ \ -+ /* Get a wide character. */ \ -+ CONVFAIL = false; \ -+ state_bak = STATE; \ -+ MBLENGTH = mbrtowc ((wchar_t *)&WC, BUFPOS, BUFLEN, &STATE); \ -+ \ -+ switch (MBLENGTH) \ -+ { \ -+ case (size_t)-1: \ -+ case (size_t)-2: \ -+ CONVFAIL = true; \ -+ STATE = state_bak; \ -+ /* Fall througn. */ \ -+ \ -+ case 0: \ -+ MBLENGTH = 1; \ -+ break; \ -+ } \ -+ } \ -+ while (0) -+ - - /* Pointer inside RP. When checking if a byte or field is selected - by a finite range, we check if it is between CURRENT_RP.LO -@@ -61,6 +124,9 @@ - CURRENT_RP.HI then we make CURRENT_RP to point to the next range pair. */ - static struct field_range_pair *current_rp; - -+/* Length of the delimiter given as argument to -d. */ -+size_t delimlen; -+ - /* This buffer is used to support the semantics of the -s option - (or lack of same) when the specified field list includes (does - not include) the first field. In both of those cases, the entire -@@ -77,15 +143,25 @@ enum operating_mode - { - undefined_mode, - -- /* Output characters that are in the given bytes. */ -+ /* Output bytes that are at the given positions. */ - byte_mode, - -+ /* Output characters that are at the given positions. */ -+ character_mode, -+ - /* Output the given delimiter-separated fields. */ - field_mode - }; - - static enum operating_mode operating_mode; - -+/* If nonzero, when in byte mode, don't split multibyte characters. */ -+static int byte_mode_character_aware; -+ -+/* If nonzero, the function for single byte locale is work -+ if this program runs on multibyte locale. */ -+static int force_singlebyte_mode; -+ - /* If true do not output lines containing no delimiter characters. - Otherwise, all such lines are printed. This option is valid only - with field mode. */ -@@ -97,6 +173,9 @@ static bool complement; - - /* The delimiter character for field mode. */ - static unsigned char delim; -+#if HAVE_WCHAR_H -+static wchar_t wcdelim; -+#endif - - /* The delimiter for each line/record. */ - static unsigned char line_delim = '\n'; -@@ -164,7 +243,7 @@ Print selected parts of lines from each - -f, --fields=LIST select only these fields; also print any line\n\ - that contains no delimiter character, unless\n\ - the -s option is specified\n\ -- -n (ignored)\n\ -+ -n with -b: don't split multibyte characters\n\ - "), stdout); - fputs (_("\ - --complement complement the set of selected bytes, characters\n\ -@@ -280,6 +359,82 @@ cut_bytes (FILE *stream) - } - } - -+#if HAVE_MBRTOWC -+/* This function is in use for the following case. -+ -+ 1. Read from the stream STREAM, printing to standard output any selected -+ characters. -+ -+ 2. Read from stream STREAM, printing to standard output any selected bytes, -+ without splitting multibyte characters. */ -+ -+static void -+cut_characters_or_cut_bytes_no_split (FILE *stream) -+{ -+ size_t idx; /* number of bytes or characters in the line so far. */ -+ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */ -+ char *bufpos; /* Next read position of BUF. */ -+ size_t buflen; /* The length of the byte sequence in buf. */ -+ wint_t wc; /* A gotten wide character. */ -+ size_t mblength; /* The byte size of a multibyte character which shows -+ as same character as WC. */ -+ mbstate_t state; /* State of the stream. */ -+ bool convfail = false; /* true, when conversion failed. Otherwise false. */ -+ /* Whether to begin printing delimiters between ranges for the current line. -+ Set after we've begun printing data corresponding to the first range. */ -+ bool print_delimiter = false; -+ -+ idx = 0; -+ buflen = 0; -+ bufpos = buf; -+ memset (&state, '\0', sizeof(mbstate_t)); -+ -+ current_rp = frp; -+ -+ while (1) -+ { -+ REFILL_BUFFER (buf, bufpos, buflen, stream); -+ -+ GET_NEXT_WC_FROM_BUFFER (wc, bufpos, buflen, mblength, state, convfail); -+ (void) convfail; /* ignore unused */ -+ -+ if (wc == WEOF) -+ { -+ if (idx > 0) -+ putchar (line_delim); -+ break; -+ } -+ else if (wc == line_delim) -+ { -+ putchar (line_delim); -+ idx = 0; -+ print_delimiter = false; -+ current_rp = frp; -+ } -+ else -+ { -+ next_item (&idx); -+ if (print_kth (idx)) -+ { -+ if (output_delimiter_specified) -+ { -+ if (print_delimiter && is_range_start_index (idx)) -+ { -+ fwrite (output_delimiter_string, sizeof (char), -+ output_delimiter_length, stdout); -+ } -+ print_delimiter = true; -+ } -+ fwrite (bufpos, mblength, sizeof(char), stdout); -+ } -+ } -+ -+ buflen -= mblength; -+ bufpos += mblength; -+ } -+} -+#endif -+ - /* Read from stream STREAM, printing to standard output any selected fields. */ - - static void -@@ -425,13 +580,211 @@ cut_fields (FILE *stream) - } - } - -+#if HAVE_MBRTOWC -+static void -+cut_fields_mb (FILE *stream) -+{ -+ int c; -+ size_t field_idx; -+ int found_any_selected_field; -+ int buffer_first_field; -+ int empty_input; -+ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */ -+ char *bufpos; /* Next read position of BUF. */ -+ size_t buflen; /* The length of the byte sequence in buf. */ -+ wint_t wc = 0; /* A gotten wide character. */ -+ size_t mblength; /* The byte size of a multibyte character which shows -+ as same character as WC. */ -+ mbstate_t state; /* State of the stream. */ -+ bool convfail = false; /* true, when conversion failed. Otherwise false. */ -+ -+ current_rp = frp; -+ -+ found_any_selected_field = 0; -+ field_idx = 1; -+ bufpos = buf; -+ buflen = 0; -+ memset (&state, '\0', sizeof(mbstate_t)); -+ -+ c = getc (stream); -+ empty_input = (c == EOF); -+ if (c != EOF) -+ { -+ ungetc (c, stream); -+ wc = 0; -+ } -+ else -+ wc = WEOF; -+ -+ /* To support the semantics of the -s flag, we may have to buffer -+ all of the first field to determine whether it is `delimited.' -+ But that is unnecessary if all non-delimited lines must be printed -+ and the first field has been selected, or if non-delimited lines -+ must be suppressed and the first field has *not* been selected. -+ That is because a non-delimited line has exactly one field. */ -+ buffer_first_field = (suppress_non_delimited ^ !print_kth (1)); -+ -+ while (1) -+ { -+ if (field_idx == 1 && buffer_first_field) -+ { -+ int len = 0; -+ -+ while (1) -+ { -+ REFILL_BUFFER (buf, bufpos, buflen, stream); -+ -+ GET_NEXT_WC_FROM_BUFFER -+ (wc, bufpos, buflen, mblength, state, convfail); -+ -+ if (wc == WEOF) -+ break; -+ -+ field_1_buffer = xrealloc (field_1_buffer, len + mblength); -+ memcpy (field_1_buffer + len, bufpos, mblength); -+ len += mblength; -+ buflen -= mblength; -+ bufpos += mblength; -+ -+ if (!convfail && (wc == line_delim || wc == wcdelim)) -+ break; -+ } -+ -+ if (len <= 0 && wc == WEOF) -+ break; -+ -+ /* If the first field extends to the end of line (it is not -+ delimited) and we are printing all non-delimited lines, -+ print this one. */ -+ if (convfail || (!convfail && wc != wcdelim)) -+ { -+ if (suppress_non_delimited) -+ { -+ /* Empty. */ -+ } -+ else -+ { -+ fwrite (field_1_buffer, sizeof (char), len, stdout); -+ /* Make sure the output line is newline terminated. */ -+ if (convfail || (!convfail && wc != line_delim)) -+ putchar (line_delim); -+ } -+ continue; -+ } -+ -+ if (print_kth (1)) -+ { -+ /* Print the field, but not the trailing delimiter. */ -+ fwrite (field_1_buffer, sizeof (char), len - 1, stdout); -+ found_any_selected_field = 1; -+ } -+ next_item (&field_idx); -+ } -+ -+ if (wc != WEOF) -+ { -+ if (print_kth (field_idx)) -+ { -+ if (found_any_selected_field) -+ { -+ fwrite (output_delimiter_string, sizeof (char), -+ output_delimiter_length, stdout); -+ } -+ found_any_selected_field = 1; -+ } -+ -+ while (1) -+ { -+ REFILL_BUFFER (buf, bufpos, buflen, stream); -+ -+ GET_NEXT_WC_FROM_BUFFER -+ (wc, bufpos, buflen, mblength, state, convfail); -+ -+ if (wc == WEOF) -+ break; -+ else if (!convfail && (wc == wcdelim || wc == line_delim)) -+ { -+ buflen -= mblength; -+ bufpos += mblength; -+ break; -+ } -+ -+ if (print_kth (field_idx)) -+ fwrite (bufpos, mblength, sizeof(char), stdout); -+ -+ buflen -= mblength; -+ bufpos += mblength; -+ } -+ } -+ -+ if ((!convfail || wc == line_delim) && buflen < 1) -+ wc = WEOF; -+ -+ if (!convfail && wc == wcdelim) -+ next_item (&field_idx); -+ else if (wc == WEOF || (!convfail && wc == line_delim)) -+ { -+ if (found_any_selected_field -+ || (!empty_input && !(suppress_non_delimited && field_idx == 1))) -+ putchar (line_delim); -+ if (wc == WEOF) -+ break; -+ field_idx = 1; -+ current_rp = frp; -+ found_any_selected_field = 0; -+ } -+ } -+} -+#endif -+ - static void - cut_stream (FILE *stream) - { -- if (operating_mode == byte_mode) -- cut_bytes (stream); -+#if HAVE_MBRTOWC -+ if (MB_CUR_MAX > 1 && !force_singlebyte_mode) -+ { -+ switch (operating_mode) -+ { -+ case byte_mode: -+ if (byte_mode_character_aware) -+ cut_characters_or_cut_bytes_no_split (stream); -+ else -+ cut_bytes (stream); -+ break; -+ -+ case character_mode: -+ cut_characters_or_cut_bytes_no_split (stream); -+ break; -+ -+ case field_mode: -+ if (delimlen == 1) -+ { -+ /* Check if we have utf8 multibyte locale, so we can use this -+ optimization because of uniqueness of characters, which is -+ not true for e.g. SJIS */ -+ char * loc = setlocale(LC_CTYPE, NULL); -+ if (loc && (strstr (loc, "UTF-8") || strstr (loc, "utf-8") || -+ strstr (loc, "UTF8") || strstr (loc, "utf8"))) -+ { -+ cut_fields (stream); -+ break; -+ } -+ } -+ cut_fields_mb (stream); -+ break; -+ -+ default: -+ abort (); -+ } -+ } - else -- cut_fields (stream); -+#endif -+ { -+ if (operating_mode == field_mode) -+ cut_fields (stream); -+ else -+ cut_bytes (stream); -+ } - } - - /* Process file FILE to standard output. -@@ -483,6 +836,7 @@ main (int argc, char **argv) - bool ok; - bool delim_specified = false; - char *spec_list_string IF_LINT ( = NULL); -+ char mbdelim[MB_LEN_MAX + 1]; - - initialize_main (&argc, &argv); - set_program_name (argv[0]); -@@ -505,7 +859,6 @@ main (int argc, char **argv) - switch (optc) - { - case 'b': -- case 'c': - /* Build the byte list. */ - if (operating_mode != undefined_mode) - FATAL_ERROR (_("only one type of list may be specified")); -@@ -513,6 +866,14 @@ main (int argc, char **argv) - spec_list_string = optarg; - break; - -+ case 'c': -+ /* Build the character list. */ -+ if (operating_mode != undefined_mode) -+ FATAL_ERROR (_("only one type of list may be specified")); -+ operating_mode = character_mode; -+ spec_list_string = optarg; -+ break; -+ - case 'f': - /* Build the field list. */ - if (operating_mode != undefined_mode) -@@ -524,10 +885,38 @@ main (int argc, char **argv) - case 'd': - /* New delimiter. */ - /* Interpret -d '' to mean 'use the NUL byte as the delimiter.' */ -- if (optarg[0] != '\0' && optarg[1] != '\0') -- FATAL_ERROR (_("the delimiter must be a single character")); -- delim = optarg[0]; -- delim_specified = true; -+ { -+#if HAVE_MBRTOWC -+ if(MB_CUR_MAX > 1) -+ { -+ mbstate_t state; -+ -+ memset (&state, '\0', sizeof(mbstate_t)); -+ delimlen = mbrtowc (&wcdelim, optarg, strnlen(optarg, MB_LEN_MAX), &state); -+ -+ if (delimlen == (size_t)-1 || delimlen == (size_t)-2) -+ ++force_singlebyte_mode; -+ else -+ { -+ delimlen = (delimlen < 1) ? 1 : delimlen; -+ if (wcdelim != L'\0' && *(optarg + delimlen) != '\0') -+ FATAL_ERROR (_("the delimiter must be a single character")); -+ memcpy (mbdelim, optarg, delimlen); -+ mbdelim[delimlen] = '\0'; -+ if (delimlen == 1) -+ delim = *optarg; -+ } -+ } -+ -+ if (MB_CUR_MAX <= 1 || force_singlebyte_mode) -+#endif -+ { -+ if (optarg[0] != '\0' && optarg[1] != '\0') -+ FATAL_ERROR (_("the delimiter must be a single character")); -+ delim = (unsigned char) optarg[0]; -+ } -+ delim_specified = true; -+ } - break; - - case OUTPUT_DELIMITER_OPTION: -@@ -540,6 +929,7 @@ main (int argc, char **argv) - break; - - case 'n': -+ byte_mode_character_aware = 1; - break; - - case 's': -@@ -579,15 +969,34 @@ main (int argc, char **argv) - | (complement ? SETFLD_COMPLEMENT : 0) ); - - if (!delim_specified) -- delim = '\t'; -+ { -+ delim = '\t'; -+#ifdef HAVE_MBRTOWC -+ wcdelim = L'\t'; -+ mbdelim[0] = '\t'; -+ mbdelim[1] = '\0'; -+ delimlen = 1; -+#endif -+ } - - if (output_delimiter_string == NULL) - { -- static char dummy[2]; -- dummy[0] = delim; -- dummy[1] = '\0'; -- output_delimiter_string = dummy; -- output_delimiter_length = 1; -+#ifdef HAVE_MBRTOWC -+ if (MB_CUR_MAX > 1 && !force_singlebyte_mode) -+ { -+ output_delimiter_string = xstrdup(mbdelim); -+ output_delimiter_length = delimlen; -+ } -+ -+ if (MB_CUR_MAX <= 1 || force_singlebyte_mode) -+#endif -+ { -+ static char dummy[2]; -+ dummy[0] = delim; -+ dummy[1] = '\0'; -+ output_delimiter_string = dummy; -+ output_delimiter_length = 1; -+ } - } - - if (optind == argc) -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> - #include <sys/types.h> -+ -+/* Get mbstate_t, mbrtowc(), wcwidth(). */ -+#if HAVE_WCHAR_H -+# include <wchar.h> -+#endif -+ -+/* Get iswblank(). */ -+#if HAVE_WCTYPE_H -+# include <wctype.h> -+#endif -+ - #include "system.h" - #include "error.h" - #include "fadvise.h" - #include "quote.h" - #include "xstrndup.h" - -+/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC -+ installation; work around this configuration error. */ -+#if !defined MB_LEN_MAX || MB_LEN_MAX < 2 -+# define MB_LEN_MAX 16 -+#endif -+ -+/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ -+#if HAVE_MBRTOWC && defined mbstate_t -+# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0) -+#endif -+ - /* The official name of this program (e.g., no 'g' prefix). */ - #define PROGRAM_NAME "expand" - -@@ -357,6 +379,142 @@ expand (void) - } - } - -+#if HAVE_MBRTOWC -+static void -+expand_multibyte (void) -+{ -+ FILE *fp; /* Input strem. */ -+ mbstate_t i_state; /* Current shift state of the input stream. */ -+ mbstate_t i_state_bak; /* Back up the I_STATE. */ -+ mbstate_t o_state; /* Current shift state of the output stream. */ -+ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */ -+ char *bufpos = buf; /* Next read position of BUF. */ -+ size_t buflen = 0; /* The length of the byte sequence in buf. */ -+ wchar_t wc; /* A gotten wide character. */ -+ size_t mblength; /* The byte size of a multibyte character -+ which shows as same character as WC. */ -+ int tab_index = 0; /* Index in `tab_list' of next tabstop. */ -+ int column = 0; /* Column on screen of the next char. */ -+ int next_tab_column; /* Column the next tab stop is on. */ -+ int convert = 1; /* If nonzero, perform translations. */ -+ -+ fp = next_file ((FILE *) NULL); -+ if (fp == NULL) -+ return; -+ -+ memset (&o_state, '\0', sizeof(mbstate_t)); -+ memset (&i_state, '\0', sizeof(mbstate_t)); -+ -+ for (;;) -+ { -+ /* Refill the buffer BUF. */ -+ if (buflen < MB_LEN_MAX && !feof(fp) && !ferror(fp)) -+ { -+ memmove (buf, bufpos, buflen); -+ buflen += fread (buf + buflen, sizeof(char), BUFSIZ, fp); -+ bufpos = buf; -+ } -+ -+ /* No character is left in BUF. */ -+ if (buflen < 1) -+ { -+ fp = next_file (fp); -+ -+ if (fp == NULL) -+ break; /* No more files. */ -+ else -+ { -+ memset (&i_state, '\0', sizeof(mbstate_t)); -+ continue; -+ } -+ } -+ -+ /* Get a wide character. */ -+ i_state_bak = i_state; -+ mblength = mbrtowc (&wc, bufpos, buflen, &i_state); -+ -+ switch (mblength) -+ { -+ case (size_t)-1: /* illegal byte sequence. */ -+ case (size_t)-2: -+ mblength = 1; -+ i_state = i_state_bak; -+ if (convert) -+ { -+ ++column; -+ if (convert_entire_line == 0 && !isblank(*bufpos)) -+ convert = 0; -+ } -+ putchar (*bufpos); -+ break; -+ -+ case 0: /* null. */ -+ mblength = 1; -+ if (convert && convert_entire_line == 0) -+ convert = 0; -+ putchar ('\0'); -+ break; -+ -+ default: -+ if (wc == L'\n') /* LF. */ -+ { -+ tab_index = 0; -+ column = 0; -+ convert = 1; -+ putchar ('\n'); -+ } -+ else if (wc == L'\t' && convert) /* Tab. */ -+ { -+ if (tab_size == 0) -+ { -+ /* Do not let tab_index == first_free_tab; -+ stop when it is 1 less. */ -+ while (tab_index < first_free_tab - 1 -+ && column >= tab_list[tab_index]) -+ tab_index++; -+ next_tab_column = tab_list[tab_index]; -+ if (tab_index < first_free_tab - 1) -+ tab_index++; -+ if (column >= next_tab_column) -+ next_tab_column = column + 1; -+ } -+ else -+ next_tab_column = column + tab_size - column % tab_size; -+ -+ while (column < next_tab_column) -+ { -+ putchar (' '); -+ ++column; -+ } -+ } -+ else /* Others. */ -+ { -+ if (convert) -+ { -+ if (wc == L'\b') -+ { -+ if (column > 0) -+ --column; -+ } -+ else -+ { -+ int width; /* The width of WC. */ -+ -+ width = wcwidth (wc); -+ column += (width > 0) ? width : 0; -+ if (convert_entire_line == 0 && !iswblank(wc)) -+ convert = 0; -+ } -+ } -+ fwrite (bufpos, sizeof(char), mblength, stdout); -+ } -+ } -+ buflen -= mblength; -+ bufpos += mblength; -+ } -+} -+#endif +TODO: merge upstream +--- + lib/linebuffer.h | 8 + + src/fold.c | 308 ++++++++++++++++-- + src/join.c | 359 ++++++++++++++++++--- + src/pr.c | 443 ++++++++++++++++++++++--- + src/sort.c | 764 +++++++++++++++++++++++++++++++++++++++++--- + src/uniq.c | 265 ++++++++++++++- + tests/i18n/sort.sh | 29 ++ + tests/local.mk | 2 + + tests/misc/cut.pl | 7 +- + 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/pr/pr-tests.pl | 49 +++ + 18 files changed, 2435 insertions(+), 162 deletions(-) + create mode 100644 tests/i18n/sort.sh + create mode 100644 tests/misc/sort-mb-tests.sh + +diff --git a/lib/linebuffer.h b/lib/linebuffer.h +index 64181af..9b8fe5a 100644 +--- a/lib/linebuffer.h ++++ b/lib/linebuffer.h +@@ -21,6 +21,11 @@ + + # include <stdio.h> + ++/* Get mbstate_t. */ ++# if HAVE_WCHAR_H ++# include <wchar.h> ++# endif + - int - main (int argc, char **argv) - { -@@ -421,7 +579,12 @@ main (int argc, char **argv) + /* A 'struct linebuffer' holds a line of text. */
- file_list = (optind < argc ? &argv[optind] : stdin_argv); + struct linebuffer +@@ -28,6 +33,9 @@ struct linebuffer + size_t size; /* Allocated. */ + size_t length; /* Used. */ + char *buffer; ++# if HAVE_WCHAR_H ++ mbstate_t state; ++# endif + };
-- expand (); -+#if HAVE_MBRTOWC -+ if (MB_CUR_MAX > 1) -+ expand_multibyte (); -+ else -+#endif -+ expand (); - - if (have_read_stdin && fclose (stdin) != 0) - error (EXIT_FAILURE, errno, "-"); -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 @@ + /* Initialize linebuffer LINEBUFFER for use. */ +diff --git a/src/fold.c b/src/fold.c +index 8cd0d6b..d23edd5 100644 +--- a/src/fold.c ++++ b/src/fold.c +@@ -22,12 +22,34 @@ #include <getopt.h> #include <sys/types.h>
@@ -807,6 +72,7 @@ diff -Naurp coreutils-8.25-orig/src/fold.c coreutils-8.25/src/fold.c +#endif + #include "system.h" + #include "die.h" #include "error.h" #include "fadvise.h" #include "xdectoint.h" @@ -826,7 +92,7 @@ diff -Naurp coreutils-8.25-orig/src/fold.c coreutils-8.25/src/fold.c #define TAB_WIDTH 8
/* The official name of this program (e.g., no 'g' prefix). */ -@@ -34,20 +56,41 @@ +@@ -35,20 +57,41 @@
#define AUTHORS proper_name ("David MacKenzie")
@@ -872,7 +138,7 @@ diff -Naurp coreutils-8.25-orig/src/fold.c coreutils-8.25/src/fold.c {"spaces", no_argument, NULL, 's'}, {"width", required_argument, NULL, 'w'}, {GETOPT_HELP_OPTION_DECL}, -@@ -75,6 +118,7 @@ Wrap input lines in each FILE, writing t +@@ -76,6 +119,7 @@ Wrap input lines in each FILE, writing to standard output.\n\
fputs (_("\ -b, --bytes count bytes rather than columns\n\ @@ -880,7 +146,7 @@ diff -Naurp coreutils-8.25-orig/src/fold.c coreutils-8.25/src/fold.c -s, --spaces break at spaces\n\ -w, --width=WIDTH use WIDTH columns instead of 80\n\ "), stdout); -@@ -92,7 +136,7 @@ Wrap input lines in each FILE, writing t +@@ -93,7 +137,7 @@ Wrap input lines in each FILE, writing to standard output.\n\ static size_t adjust_column (size_t column, char c) { @@ -889,7 +155,7 @@ diff -Naurp coreutils-8.25-orig/src/fold.c coreutils-8.25/src/fold.c { if (c == '\b') { -@@ -115,30 +159,14 @@ adjust_column (size_t column, char c) +@@ -116,30 +160,14 @@ adjust_column (size_t column, char c) to stdout, with maximum line length WIDTH. Return true if successful. */
@@ -922,7 +188,7 @@ diff -Naurp coreutils-8.25-orig/src/fold.c coreutils-8.25/src/fold.c
fadvise (istream, FADVISE_SEQUENTIAL);
-@@ -168,6 +196,15 @@ fold_file (char const *filename, size_t +@@ -169,6 +197,15 @@ fold_file (char const *filename, size_t width) bool found_blank = false; size_t logical_end = offset_out;
@@ -938,16 +204,16 @@ diff -Naurp coreutils-8.25-orig/src/fold.c coreutils-8.25/src/fold.c /* Look for the last blank. */ while (logical_end) { -@@ -214,11 +251,221 @@ fold_file (char const *filename, size_t +@@ -215,11 +252,221 @@ fold_file (char const *filename, size_t width) line_out[offset_out++] = c; }
- saved_errno = errno; + *saved_errno = errno; -+ -+ if (offset_out) -+ fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); -+ + + if (offset_out) + fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); + +} + +#if HAVE_MBRTOWC @@ -1049,7 +315,7 @@ diff -Naurp coreutils-8.25-orig/src/fold.c coreutils-8.25/src/fold.c + fwrite (line_out, sizeof(char), offset_out, stdout); + START_NEW_LINE; + continue; -+ ++ + case L'\b': + increment = (column > 0) ? -1 : 0; + break; @@ -1119,10 +385,10 @@ diff -Naurp coreutils-8.25-orig/src/fold.c coreutils-8.25/src/fold.c + } + + *saved_errno = errno; - - if (offset_out) - fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); - ++ ++ if (offset_out) ++ fwrite (line_out, sizeof (char), (size_t) offset_out, stdout); ++ +} +#endif + @@ -1146,7 +412,7 @@ diff -Naurp coreutils-8.25-orig/src/fold.c coreutils-8.25/src/fold.c + + if (istream == NULL) + { -+ error (0, errno, "%s", quotef (filename)); ++ error (0, errno, "%s", filename); + return 1; + } + @@ -1161,7 +427,7 @@ diff -Naurp coreutils-8.25-orig/src/fold.c coreutils-8.25/src/fold.c if (ferror (istream)) { error (0, saved_errno, "%s", quotef (filename)); -@@ -251,7 +498,8 @@ main (int argc, char **argv) +@@ -252,7 +499,8 @@ main (int argc, char **argv)
atexit (close_stdout);
@@ -1171,7 +437,7 @@ diff -Naurp coreutils-8.25-orig/src/fold.c coreutils-8.25/src/fold.c
while ((optc = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1) { -@@ -260,7 +508,15 @@ main (int argc, char **argv) +@@ -261,7 +509,15 @@ main (int argc, char **argv) switch (optc) { case 'b': /* Count bytes rather than columns. */ @@ -1188,10 +454,11 @@ diff -Naurp coreutils-8.25-orig/src/fold.c coreutils-8.25/src/fold.c break;
case 's': /* Break at word boundaries. */ -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 @@ +diff --git a/src/join.c b/src/join.c +index 98b461c..9990f38 100644 +--- a/src/join.c ++++ b/src/join.c +@@ -22,19 +22,33 @@ #include <sys/types.h> #include <getopt.h>
@@ -1206,6 +473,7 @@ diff -Naurp coreutils-8.25-orig/src/join.c coreutils-8.25/src/join.c +#endif + #include "system.h" + #include "die.h" #include "error.h" #include "fadvise.h" #include "hard-locale.h" @@ -1225,7 +493,7 @@ diff -Naurp coreutils-8.25-orig/src/join.c coreutils-8.25/src/join.c /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "join"
-@@ -135,10 +149,12 @@ static struct outlist outlist_head; +@@ -136,10 +150,12 @@ static struct outlist outlist_head; /* Last element in 'outlist', where a new element can be added. */ static struct outlist *outlist_end = &outlist_head;
@@ -1242,7 +510,7 @@ diff -Naurp coreutils-8.25-orig/src/join.c coreutils-8.25/src/join.c
/* If nonzero, check that the input is correctly ordered. */ static enum -@@ -275,13 +291,14 @@ xfields (struct line *line) +@@ -276,13 +292,14 @@ xfields (struct line *line) if (ptr == lim) return;
@@ -1260,7 +528,7 @@ diff -Naurp coreutils-8.25-orig/src/join.c coreutils-8.25/src/join.c { /* Skip leading blanks before the first field. */ while (field_sep (*ptr)) -@@ -305,6 +322,147 @@ xfields (struct line *line) +@@ -306,6 +323,147 @@ xfields (struct line *line) extract_field (line, ptr, lim - ptr); }
@@ -1404,11 +672,11 @@ diff -Naurp coreutils-8.25-orig/src/join.c coreutils-8.25/src/join.c + extract_field (line, ptr, lim - ptr); +} +#endif -+ ++ static void freeline (struct line *line) { -@@ -326,56 +484,133 @@ keycmp (struct line const *line1, struct +@@ -327,56 +485,133 @@ keycmp (struct line const *line1, struct line const *line2, size_t jf_1, size_t jf_2) { /* Start of field to compare in each file. */ @@ -1539,8 +807,8 @@ diff -Naurp coreutils-8.25-orig/src/join.c coreutils-8.25/src/join.c - diff = memcmp (beg1, beg2, MIN (len1, len2)); + copy[0] = beg[0]; + copy[1] = beg[1]; -+ } -+ + } + + if (hard_LC_COLLATE) + { + diff = xmemcoll ((char *) copy[0], len[0], (char *) copy[1], len[1]); @@ -1550,14 +818,14 @@ diff -Naurp coreutils-8.25-orig/src/join.c coreutils-8.25/src/join.c + free (copy[i]); + + return diff; - } ++ } + diff = memcmp (copy[0], copy[1], MIN (len[0], len[1])); + + if (mallocd) + for (i = 0; i < 2; i++) + free (copy[i]); + - ++ if (diff) return diff; - return len1 < len2 ? -1 : len1 != len2; @@ -1565,7 +833,7 @@ diff -Naurp coreutils-8.25-orig/src/join.c coreutils-8.25/src/join.c }
/* Check that successive input lines PREV and CURRENT from input file -@@ -467,6 +702,11 @@ get_line (FILE *fp, struct line **linep, +@@ -468,6 +703,11 @@ get_line (FILE *fp, struct line **linep, int which) } ++line_no[which - 1];
@@ -1577,7 +845,7 @@ diff -Naurp coreutils-8.25-orig/src/join.c coreutils-8.25/src/join.c xfields (line);
if (prevline[which - 1]) -@@ -566,21 +806,28 @@ prfield (size_t n, struct line const *li +@@ -567,21 +807,28 @@ prfield (size_t n, struct line const *line)
/* Output all the fields in line, other than the join field. */
@@ -1609,7 +877,7 @@ diff -Naurp coreutils-8.25-orig/src/join.c coreutils-8.25/src/join.c prfield (i, line); } } -@@ -591,7 +838,6 @@ static void +@@ -592,7 +839,6 @@ static void prjoin (struct line const *line1, struct line const *line2) { const struct outlist *outlist; @@ -1617,7 +885,7 @@ diff -Naurp coreutils-8.25-orig/src/join.c coreutils-8.25/src/join.c size_t field; struct line const *line;
-@@ -625,7 +871,7 @@ prjoin (struct line const *line1, struct +@@ -626,7 +872,7 @@ prjoin (struct line const *line1, struct line const *line2) o = o->next; if (o == NULL) break; @@ -1626,7 +894,7 @@ diff -Naurp coreutils-8.25-orig/src/join.c coreutils-8.25/src/join.c } putchar (eolchar); } -@@ -1103,21 +1349,46 @@ main (int argc, char **argv) +@@ -1104,20 +1350,43 @@ main (int argc, char **argv)
case 't': { @@ -1653,16 +921,14 @@ diff -Naurp coreutils-8.25-orig/src/join.c coreutils-8.25/src/join.c + newtablen = 1; if (! newtab) - newtab = '\n'; /* '' => process the whole line. */ -+ { + newtab = (char*)"\n"; /* '' => process the whole line. */ -+ } else if (optarg[1]) { - if (STREQ (optarg, "\0")) - newtab = '\0'; - else -- error (EXIT_FAILURE, 0, _("multi-character tab %s"), -- quote (optarg)); +- die (EXIT_FAILURE, 0, _("multi-character tab %s"), +- quote (optarg)); + if (newtablen == 1 && newtab[1]) + { + if (STREQ (newtab, "\0")) @@ -1672,20 +938,19 @@ diff -Naurp coreutils-8.25-orig/src/join.c coreutils-8.25/src/join.c + if (tab != NULL && strcmp (tab, newtab)) + { + free (newtab); -+ error (EXIT_FAILURE, 0, _("incompatible tabs")); ++ die (EXIT_FAILURE, 0, _("incompatible tabs")); } - if (0 <= tab && tab != newtab) -- error (EXIT_FAILURE, 0, _("incompatible tabs")); +- die (EXIT_FAILURE, 0, _("incompatible tabs")); tab = newtab; -- } + tablen = newtablen; -+ } + } break;
- case 'z': -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 +diff --git a/src/pr.c b/src/pr.c +index 26f221f..633f50e 100644 +--- a/src/pr.c ++++ b/src/pr.c @@ -311,6 +311,24 @@
#include <getopt.h> @@ -1709,9 +974,9 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c +#endif + #include "system.h" + #include "die.h" #include "error.h" - #include "fadvise.h" -@@ -323,6 +341,18 @@ +@@ -324,6 +342,18 @@ #include "xstrtol.h" #include "xdectoint.h"
@@ -1730,7 +995,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "pr"
-@@ -415,7 +445,20 @@ struct COLUMN +@@ -416,7 +446,20 @@ struct COLUMN
typedef struct COLUMN COLUMN;
@@ -1752,7 +1017,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c static bool read_line (COLUMN *p); static bool print_page (void); static bool print_stored (COLUMN *p); -@@ -427,6 +470,7 @@ static void add_line_number (COLUMN *p); +@@ -428,6 +471,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, @@ -1760,7 +1025,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c int *number); static void print_files (int number_of_files, char **av); static void init_parameters (int number_of_files); -@@ -440,7 +484,6 @@ static void store_char (char c); +@@ -441,7 +485,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); @@ -1768,7 +1033,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c static void cleanup (void); static void print_sep_string (void); static void separator_string (const char *optarg_S); -@@ -452,7 +495,7 @@ static COLUMN *column_vector; +@@ -453,7 +496,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]. */ @@ -1777,7 +1042,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c
/* Index of the position in buff where the next character will be stored. */ -@@ -556,7 +599,7 @@ static int chars_per_column; +@@ -557,7 +600,7 @@ static int chars_per_column; static bool untabify_input = false;
/* (-e) The input tab character. */ @@ -1786,7 +1051,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c
/* (-e) Tabstops are at chars_per_tab, 2*chars_per_tab, 3*chars_per_tab, ... where the leftmost column is 1. */ -@@ -566,7 +609,10 @@ static int chars_per_input_tab = 8; +@@ -567,7 +610,10 @@ static int chars_per_input_tab = 8; static bool tabify_output = false;
/* (-i) The output tab character. */ @@ -1798,7 +1063,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c
/* (-i) The width of the output tab. */ static int chars_per_output_tab = 8; -@@ -636,7 +682,13 @@ static int line_number; +@@ -637,7 +683,13 @@ static int line_number; static bool numbered_lines = false;
/* (-n) Character which follows each line number. */ @@ -1813,18 +1078,18 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c
/* (-n) line counting starts with 1st line of input file (not with 1st line of 1st page printed). */ -@@ -689,6 +741,7 @@ static bool use_col_separator = false; +@@ -690,6 +742,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 char const *col_sep_string = ""; static int col_sep_length = 0; +static int col_sep_width = 0; static char *column_separator = (char *) " "; static char *line_separator = (char *) "\t";
-@@ -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); +@@ -851,6 +904,13 @@ separator_string (const char *optarg_S) + integer_overflow (); + col_sep_length = len; + col_sep_string = optarg_S; + +#if HAVE_MBRTOWC + if (MB_CUR_MAX > 1) @@ -1835,7 +1100,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c }
int -@@ -863,6 +923,21 @@ main (int argc, char **argv) +@@ -875,6 +935,21 @@ main (int argc, char **argv)
atexit (close_stdout);
@@ -1856,8 +1121,8 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c + n_files = 0; file_names = (argc > 1 - ? xmalloc ((argc - 1) * sizeof (char *)) -@@ -939,8 +1014,12 @@ main (int argc, char **argv) + ? xnmalloc (argc - 1, sizeof (char *)) +@@ -951,8 +1026,12 @@ main (int argc, char **argv) break; case 'e': if (optarg) @@ -1872,7 +1137,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c /* Could check tab width > 0. */ untabify_input = true; break; -@@ -953,8 +1032,12 @@ main (int argc, char **argv) +@@ -965,8 +1044,12 @@ main (int argc, char **argv) break; case 'i': if (optarg) @@ -1887,7 +1152,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c /* Could check tab width > 0. */ tabify_output = true; break; -@@ -972,8 +1055,8 @@ main (int argc, char **argv) +@@ -984,8 +1067,8 @@ main (int argc, char **argv) case 'n': numbered_lines = true; if (optarg) @@ -1898,16 +1163,15 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c break; case 'N': skip_count = false; -@@ -997,7 +1080,7 @@ main (int argc, char **argv) - old_s = false; +@@ -1010,6 +1093,7 @@ main (int argc, char **argv) /* Reset an additional input of -s, -S dominates -s */ - col_sep_string = bad_cast (""); -- col_sep_length = 0; -+ col_sep_length = col_sep_width = 0; + col_sep_string = ""; + col_sep_length = 0; ++ col_sep_width = 0; use_col_separator = true; if (optarg) separator_string (optarg); -@@ -1152,10 +1235,45 @@ getoptnum (const char *n_str, int min, i +@@ -1166,10 +1250,45 @@ getoptnum (const char *n_str, int min, int *num, const char *err) a number. */
static void @@ -1955,7 +1219,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c if (*arg) { long int tmp_long; -@@ -1177,6 +1295,11 @@ static void +@@ -1191,6 +1310,11 @@ static void init_parameters (int number_of_files) { int chars_used_by_number = 0; @@ -1967,7 +1231,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c
lines_per_body = lines_per_page - lines_per_header - lines_per_footer; if (lines_per_body <= 0) -@@ -1214,7 +1337,7 @@ init_parameters (int number_of_files) +@@ -1228,7 +1352,7 @@ init_parameters (int number_of_files) else col_sep_string = column_separator;
@@ -1976,7 +1240,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c use_col_separator = true; } /* It's rather pointless to define a TAB separator with column -@@ -1244,11 +1367,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. */ @@ -1990,16 +1254,16 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c
/* The number is part of the column width unless we are printing files in parallel. */ -@@ -1257,7 +1380,7 @@ init_parameters (int number_of_files) +@@ -1271,7 +1395,7 @@ init_parameters (int number_of_files) }
- chars_per_column = (chars_per_line - chars_used_by_number -- - (columns - 1) * col_sep_length) / columns; -+ - (columns - 1) * col_sep_width) / columns; - - if (chars_per_column < 1) - error (EXIT_FAILURE, 0, _("page width too narrow")); -@@ -1275,7 +1398,7 @@ init_parameters (int number_of_files) + int sep_chars, useful_chars; +- if (INT_MULTIPLY_WRAPV (columns - 1, col_sep_length, &sep_chars)) ++ if (INT_MULTIPLY_WRAPV (columns - 1, col_sep_width, &sep_chars)) + sep_chars = INT_MAX; + if (INT_SUBTRACT_WRAPV (chars_per_line - chars_used_by_number, sep_chars, + &useful_chars)) +@@ -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); @@ -2008,7 +1272,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c }
/* Open the necessary files, -@@ -1383,7 +1506,7 @@ init_funcs (void) +@@ -1402,7 +1526,7 @@ init_funcs (void)
/* Enlarge p->start_position of first column to use the same form of padding_not_printed with all columns. */ @@ -2017,7 +1281,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c
/* This loop takes care of all but the rightmost column. */
-@@ -1417,7 +1540,7 @@ init_funcs (void) +@@ -1436,7 +1560,7 @@ init_funcs (void) } else { @@ -2026,19 +1290,19 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c h_next = h + chars_per_column; } } -@@ -1708,9 +1831,9 @@ static void +@@ -1727,9 +1851,9 @@ static void align_column (COLUMN *p) { padding_not_printed = p->start_position; -- if (padding_not_printed - col_sep_length > 0) -+ if (padding_not_printed - col_sep_width > 0) +- if (col_sep_length < padding_not_printed) ++ if (col_sep_width < padding_not_printed) { - pad_across_to (padding_not_printed - col_sep_length); + pad_across_to (padding_not_printed - col_sep_width); padding_not_printed = ANYWHERE; }
-@@ -1981,13 +2104,13 @@ store_char (char c) +@@ -2004,13 +2128,13 @@ store_char (char c) /* May be too generous. */ buff = X2REALLOC (buff, &buff_allocated); } @@ -2054,7 +1318,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c char *s; int num_width;
-@@ -2004,22 +2127,24 @@ add_line_number (COLUMN *p) +@@ -2027,22 +2151,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. */ @@ -2083,7 +1347,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c output_position = POS_AFTER_TAB (chars_per_output_tab, output_position); } -@@ -2180,7 +2305,7 @@ print_white_space (void) +@@ -2203,7 +2329,7 @@ print_white_space (void) while (goal - h_old > 1 && (h_new = POS_AFTER_TAB (chars_per_output_tab, h_old)) <= goal) { @@ -2092,15 +1356,15 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c h_old = h_new; } while (++h_old <= goal) -@@ -2200,6 +2325,7 @@ print_sep_string (void) +@@ -2223,6 +2349,7 @@ print_sep_string (void) { - char *s; + char const *s = col_sep_string; int l = col_sep_length; + int not_space_flag;
- s = col_sep_string; - -@@ -2213,6 +2339,7 @@ print_sep_string (void) + if (separators_not_printed <= 0) + { +@@ -2234,6 +2361,7 @@ print_sep_string (void) { for (; separators_not_printed > 0; --separators_not_printed) { @@ -2108,7 +1372,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c while (l-- > 0) { /* 3 types of sep_strings: spaces only, spaces and chars, -@@ -2226,12 +2353,15 @@ print_sep_string (void) +@@ -2247,12 +2375,15 @@ print_sep_string (void) } else { @@ -2125,7 +1389,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c /* sep_string ends with some spaces */ if (spaces_not_printed > 0) print_white_space (); -@@ -2259,7 +2389,7 @@ print_clump (COLUMN *p, int n, char *clu +@@ -2280,7 +2411,7 @@ print_clump (COLUMN *p, int n, char *clump) required number of tabs and spaces. */
static void @@ -2134,7 +1398,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c { if (tabify_output) { -@@ -2283,6 +2413,74 @@ print_char (char c) +@@ -2304,6 +2435,74 @@ print_char (char c) putchar (c); }
@@ -2209,19 +1473,19 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c /* Skip to page PAGE before printing. PAGE may be larger than total number of pages. */
-@@ -2462,9 +2660,9 @@ read_line (COLUMN *p) +@@ -2483,9 +2682,9 @@ read_line (COLUMN *p) align_empty_cols = false; }
-- if (padding_not_printed - col_sep_length > 0) -+ if (padding_not_printed - col_sep_width > 0) +- if (col_sep_length < padding_not_printed) ++ if (col_sep_width < padding_not_printed) { - pad_across_to (padding_not_printed - col_sep_length); + pad_across_to (padding_not_printed - col_sep_width); padding_not_printed = ANYWHERE; }
-@@ -2534,7 +2732,7 @@ print_stored (COLUMN *p) +@@ -2555,7 +2754,7 @@ print_stored (COLUMN *p) int i;
int line = p->current_line++; @@ -2230,7 +1494,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c /* FIXME UMR: Uninitialized memory read: * This is occurring while in: -@@ -2546,7 +2744,7 @@ print_stored (COLUMN *p) +@@ -2567,7 +2766,7 @@ print_stored (COLUMN *p) xmalloc [xmalloc.c:94] init_store_cols [pr.c:1648] */ @@ -2239,19 +1503,19 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c
pad_vertically = true;
-@@ -2565,9 +2763,9 @@ print_stored (COLUMN *p) +@@ -2586,9 +2785,9 @@ print_stored (COLUMN *p) } }
-- if (padding_not_printed - col_sep_length > 0) -+ if (padding_not_printed - col_sep_width > 0) +- if (col_sep_length < padding_not_printed) ++ if (col_sep_width < padding_not_printed) { - pad_across_to (padding_not_printed - col_sep_length); + pad_across_to (padding_not_printed - col_sep_width); padding_not_printed = ANYWHERE; }
-@@ -2580,8 +2778,8 @@ print_stored (COLUMN *p) +@@ -2601,8 +2800,8 @@ print_stored (COLUMN *p) if (spaces_not_printed == 0) { output_position = p->start_position + end_vector[line]; @@ -2262,7 +1526,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c }
return true; -@@ -2600,7 +2798,7 @@ print_stored (COLUMN *p) +@@ -2621,7 +2820,7 @@ print_stored (COLUMN *p) number of characters is 1.) */
static int @@ -2271,7 +1535,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c { unsigned char uc = c; char *s = clump_buff; -@@ -2610,10 +2808,10 @@ char_to_clump (char c) +@@ -2631,10 +2830,10 @@ char_to_clump (char c) int chars; int chars_per_c = 8;
@@ -2284,7 +1548,7 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c { width = TAB_WIDTH (chars_per_c, input_position);
-@@ -2694,6 +2892,164 @@ char_to_clump (char c) +@@ -2715,6 +2914,164 @@ char_to_clump (char c) return chars; }
@@ -2449,9 +1713,10 @@ diff -Naurp coreutils-8.25-orig/src/pr.c coreutils-8.25/src/pr.c /* 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 -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 +diff --git a/src/sort.c b/src/sort.c +index 6d2eec5..f189a0d 100644 +--- a/src/sort.c ++++ b/src/sort.c @@ -29,6 +29,14 @@ #include <sys/wait.h> #include <signal.h> @@ -2466,8 +1731,8 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c + #include "system.h" #include "argmatch.h" - #include "error.h" -@@ -163,14 +171,39 @@ static int decimal_point; + #include "die.h" +@@ -165,14 +173,39 @@ static int decimal_point; /* Thousands separator; if -1, then there isn't one. */ static int thousands_sep;
@@ -2508,7 +1773,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c /* The kind of blanks for '-b' to skip in various options. */ enum blanktype { bl_start, bl_end, bl_both };
-@@ -344,13 +377,11 @@ static bool reverse; +@@ -346,13 +379,11 @@ static bool reverse; they were read if all keys compare equal. */ static bool stable;
@@ -2525,7 +1790,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c
/* Flag to remove consecutive duplicate lines from the output. Only the last of a sequence of equal lines will be output. */ -@@ -810,6 +841,46 @@ reap_all (void) +@@ -811,6 +842,46 @@ reap_all (void) reap (-1); }
@@ -2572,7 +1837,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c /* Clean up any remaining temporary files. */
static void -@@ -1254,7 +1325,7 @@ zaptemp (char const *name) +@@ -1255,7 +1326,7 @@ zaptemp (char const *name) free (node); }
@@ -2581,7 +1846,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c
static int struct_month_cmp (void const *m1, void const *m2) -@@ -1269,7 +1340,7 @@ struct_month_cmp (void const *m1, void c +@@ -1270,7 +1341,7 @@ struct_month_cmp (void const *m1, void const *m2) /* Initialize the character class tables. */
static void @@ -2590,7 +1855,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c { size_t i;
-@@ -1281,7 +1352,7 @@ inittables (void) +@@ -1282,7 +1353,7 @@ inittables (void) fold_toupper[i] = toupper (i); }
@@ -2599,7 +1864,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c /* If we're not in the "C" locale, read different names for months. */ if (hard_LC_TIME) { -@@ -1363,6 +1434,84 @@ specify_nmerge (int oi, char c, char con +@@ -1364,6 +1435,84 @@ specify_nmerge (int oi, char c, char const *s) xstrtol_fatal (e, oi, c, long_options, s); }
@@ -2684,7 +1949,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c /* Specify the amount of main memory to use when sorting. */ static void specify_sort_size (int oi, char c, char const *s) -@@ -1596,7 +1745,7 @@ buffer_linelim (struct buffer const *buf +@@ -1597,7 +1746,7 @@ buffer_linelim (struct buffer const *buf) by KEY in LINE. */
static char * @@ -2693,7 +1958,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c { char *ptr = line->text, *lim = ptr + line->length - 1; size_t sword = key->sword; -@@ -1605,10 +1754,10 @@ begfield (struct line const *line, struc +@@ -1606,10 +1755,10 @@ begfield (struct line const *line, struct keyfield const *key) /* The leading field separator itself is included in a field when -t is absent. */
@@ -2706,7 +1971,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c ++ptr; if (ptr < lim) ++ptr; -@@ -1634,11 +1783,70 @@ begfield (struct line const *line, struc +@@ -1635,11 +1784,70 @@ begfield (struct line const *line, struct keyfield const *key) return ptr; }
@@ -2778,7 +2043,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c { char *ptr = line->text, *lim = ptr + line->length - 1; size_t eword = key->eword, echar = key->echar; -@@ -1653,10 +1861,10 @@ limfield (struct line const *line, struc +@@ -1654,10 +1862,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. */ @@ -2791,7 +2056,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c ++ptr; if (ptr < lim && (eword || echar)) ++ptr; -@@ -1702,10 +1910,10 @@ limfield (struct line const *line, struc +@@ -1703,10 +1911,10 @@ limfield (struct line const *line, struct keyfield const *key) */
/* Make LIM point to the end of (one byte past) the current field. */ @@ -2804,7 +2069,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c if (newlim) lim = newlim; } -@@ -1736,6 +1944,130 @@ limfield (struct line const *line, struc +@@ -1737,6 +1945,130 @@ limfield (struct line const *line, struct keyfield const *key) return ptr; }
@@ -2935,7 +2200,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c /* Fill BUF reading from FP, moving buf->left bytes from the end of buf->buf to the beginning first. If EOF is reached and the file wasn't terminated by a newline, supply one. Set up BUF's line -@@ -1822,8 +2154,22 @@ fillbuf (struct buffer *buf, FILE *fp, c +@@ -1823,8 +2155,22 @@ fillbuf (struct buffer *buf, FILE *fp, char const *file) else { if (key->skipsblanks) @@ -2960,7 +2225,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c line->keybeg = line_start; } } -@@ -1944,7 +2290,7 @@ human_numcompare (char const *a, char co +@@ -1974,7 +2320,7 @@ human_numcompare (char const *a, char const *b) hideously fast. */
static int @@ -2969,7 +2234,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c { while (blanks[to_uchar (*a)]) a++; -@@ -1954,6 +2300,25 @@ numcompare (char const *a, char const *b +@@ -1984,6 +2330,25 @@ numcompare (char const *a, char const *b) return strnumcmp (a, b, decimal_point, thousands_sep); }
@@ -2995,7 +2260,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c /* Work around a problem whereby the long double value returned by glibc's strtold ("NaN", ...) contains uninitialized bits: clear all bytes of A and B before calling strtold. FIXME: remove this function once -@@ -2004,7 +2369,7 @@ general_numcompare (char const *sa, char +@@ -2034,7 +2399,7 @@ general_numcompare (char const *sa, char const *sb) Return 0 if the name in S is not recognized. */
static int @@ -3004,7 +2269,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c { size_t lo = 0; size_t hi = MONTHS_PER_YEAR; -@@ -2280,15 +2645,14 @@ debug_key (struct line const *line, stru +@@ -2310,15 +2675,14 @@ debug_key (struct line const *line, struct keyfield const *key) char saved = *lim; *lim = '\0';
@@ -3022,16 +2287,16 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c else if (key->general_numeric) ignore_value (strtold (beg, &tighter_lim)); else if (key->numeric || key->human_numeric) -@@ -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); +@@ -2452,7 +2816,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 */ -- if (!gkey_only && tab == TAB_DEFAULT && !line_offset -+ if (!gkey_only && !tab_length && !line_offset - && ((!key->skipsblanks && !(implicit_skip || maybe_space_aligned)) +- if (!zero_width && !gkey_only && tab == TAB_DEFAULT && !line_offset ++ if (!zero_width && !gkey_only && !tab_length && !line_offset + && ((!key->skipsblanks && !implicit_skip) || (!key->skipsblanks && key->schar) || (!key->skipeblanks && key->echar))) -@@ -2490,11 +2854,87 @@ key_warnings (struct keyfield const *gke +@@ -2510,11 +2874,87 @@ key_warnings (struct keyfield const *gkey, bool gkey_only) error (0, 0, _("option '-r' only applies to last-resort comparison")); }
@@ -3120,7 +2385,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c { struct keyfield *key = keylist;
-@@ -2579,7 +3019,7 @@ keycompare (struct line const *a, struct +@@ -2599,7 +3039,7 @@ keycompare (struct line const *a, struct line const *b) else if (key->human_numeric) diff = human_numcompare (ta, tb); else if (key->month) @@ -3129,7 +2394,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c else if (key->random) diff = compare_random (ta, tlena, tb, tlenb); else if (key->version) -@@ -2695,6 +3135,211 @@ keycompare (struct line const *a, struct +@@ -2715,6 +3155,211 @@ keycompare (struct line const *a, struct line const *b) return key->reverse ? -diff : diff; }
@@ -3341,7 +2606,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c /* Compare two lines A and B, returning negative, zero, or positive depending on whether A compares less than, equal to, or greater than B. */
-@@ -2722,7 +3367,7 @@ compare (struct line const *a, struct li +@@ -2742,7 +3387,7 @@ compare (struct line const *a, struct line const *b) diff = - NONZERO (blen); else if (blen == 0) diff = 1; @@ -3350,7 +2615,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c { /* Note xmemcoll0 is a performance enhancement as it will not unconditionally write '\0' after the -@@ -4121,6 +4766,7 @@ set_ordering (char const *s, struct keyf +@@ -4139,6 +4784,7 @@ set_ordering (char const *s, struct keyfield *key, enum blanktype blanktype) break; case 'f': key->translate = fold_toupper; @@ -3358,7 +2623,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c break; case 'g': key->general_numeric = true; -@@ -4199,7 +4845,7 @@ main (int argc, char **argv) +@@ -4218,7 +4864,7 @@ main (int argc, char **argv) initialize_exit_failure (SORT_FAILURE);
hard_LC_COLLATE = hard_locale (LC_COLLATE); @@ -3367,7 +2632,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c hard_LC_TIME = hard_locale (LC_TIME); #endif
-@@ -4220,6 +4866,29 @@ main (int argc, char **argv) +@@ -4239,6 +4885,29 @@ main (int argc, char **argv) thousands_sep = -1; }
@@ -3397,7 +2662,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c have_read_stdin = false; inittables ();
-@@ -4494,13 +5163,34 @@ main (int argc, char **argv) +@@ -4513,13 +5182,34 @@ main (int argc, char **argv)
case 't': { @@ -3407,7 +2672,7 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c + size_t newtab_length = 1; + strncpy (newtab, optarg, MB_LEN_MAX); + if (! newtab[0]) - error (SORT_FAILURE, 0, _("empty tab")); + die (SORT_FAILURE, 0, _("empty tab")); - if (optarg[1]) +#if HAVE_MBRTOWC + if (MB_CUR_MAX > 1) @@ -3436,22 +2701,21 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c else { /* Provoke with 'sort -txx'. Complain about -@@ -4511,9 +5201,12 @@ main (int argc, char **argv) - quote (optarg)); +@@ -4530,9 +5220,11 @@ main (int argc, char **argv) + quote (optarg)); } } - if (tab != TAB_DEFAULT && tab != newtab) -+ if (tab_length -+ && (tab_length != newtab_length -+ || memcmp (tab, newtab, tab_length) != 0)) - error (SORT_FAILURE, 0, _("incompatible tabs")); ++ if (tab_length && (tab_length != newtab_length ++ || memcmp (tab, newtab, tab_length) != 0)) + die (SORT_FAILURE, 0, _("incompatible tabs")); - tab = newtab; + memcpy (tab, newtab, newtab_length); + tab_length = newtab_length; } break;
-@@ -4751,12 +5444,10 @@ main (int argc, char **argv) +@@ -4770,12 +5462,10 @@ main (int argc, char **argv) sort (files, nfiles, outfile, nthreads); }
@@ -3463,268 +2727,11 @@ diff -Naurp coreutils-8.25-orig/src/sort.c coreutils-8.25/src/sort.c -#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> - #include <sys/types.h> -+ -+/* Get mbstate_t, mbrtowc(), wcwidth(). */ -+#if HAVE_WCHAR_H -+# include <wchar.h> -+#endif -+ - #include "system.h" - #include "error.h" - #include "fadvise.h" - #include "quote.h" - #include "xstrndup.h" - -+/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC -+ installation; work around this configuration error. */ -+#if !defined MB_LEN_MAX || MB_LEN_MAX < 2 -+# define MB_LEN_MAX 16 -+#endif -+ -+/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */ -+#if HAVE_MBRTOWC && defined mbstate_t -+# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0) -+#endif -+ - /* The official name of this program (e.g., no 'g' prefix). */ - #define PROGRAM_NAME "unexpand" - -@@ -103,6 +120,210 @@ static struct option const longopts[] = - {NULL, 0, NULL, 0} - }; - -+static FILE *next_file (FILE *fp); -+ -+#if HAVE_MBRTOWC -+static void -+unexpand_multibyte (void) -+{ -+ FILE *fp; /* Input stream. */ -+ mbstate_t i_state; /* Current shift state of the input stream. */ -+ mbstate_t i_state_bak; /* Back up the I_STATE. */ -+ mbstate_t o_state; /* Current shift state of the output stream. */ -+ char buf[MB_LEN_MAX + BUFSIZ]; /* For spooling a read byte sequence. */ -+ char *bufpos = buf; /* Next read position of BUF. */ -+ size_t buflen = 0; /* The length of the byte sequence in buf. */ -+ wint_t wc; /* A gotten wide character. */ -+ size_t mblength; /* The byte size of a multibyte character -+ which shows as same character as WC. */ -+ bool prev_tab = false; -+ -+ /* Index in `tab_list' of next tabstop: */ -+ int tab_index = 0; /* For calculating width of pending tabs. */ -+ int print_tab_index = 0; /* For printing as many tabs as possible. */ -+ unsigned int column = 0; /* Column on screen of next char. */ -+ int next_tab_column; /* Column the next tab stop is on. */ -+ int convert = 1; /* If nonzero, perform translations. */ -+ unsigned int pending = 0; /* Pending columns of blanks. */ -+ -+ fp = next_file ((FILE *) NULL); -+ if (fp == NULL) -+ return; -+ -+ memset (&o_state, '\0', sizeof(mbstate_t)); -+ memset (&i_state, '\0', sizeof(mbstate_t)); -+ -+ for (;;) -+ { -+ if (buflen < MB_LEN_MAX && !feof(fp) && !ferror(fp)) -+ { -+ memmove (buf, bufpos, buflen); -+ buflen += fread (buf + buflen, sizeof(char), BUFSIZ, fp); -+ bufpos = buf; -+ } -+ -+ /* Get a wide character. */ -+ if (buflen < 1) -+ { -+ mblength = 1; -+ wc = WEOF; -+ } -+ else -+ { -+ i_state_bak = i_state; -+ mblength = mbrtowc ((wchar_t *)&wc, bufpos, buflen, &i_state); -+ } -+ -+ if (mblength == (size_t)-1 || mblength == (size_t)-2) -+ { -+ i_state = i_state_bak; -+ wc = L'\0'; -+ } -+ -+ if (wc == L' ' && convert && column < INT_MAX) -+ { -+ ++pending; -+ ++column; -+ } -+ else if (wc == L'\t' && convert) -+ { -+ if (tab_size == 0) -+ { -+ /* Do not let tab_index == first_free_tab; -+ stop when it is 1 less. */ -+ while (tab_index < first_free_tab - 1 -+ && column >= tab_list[tab_index]) -+ tab_index++; -+ next_tab_column = tab_list[tab_index]; -+ if (tab_index < first_free_tab - 1) -+ tab_index++; -+ if (column >= next_tab_column) -+ { -+ convert = 0; /* Ran out of tab stops. */ -+ goto flush_pend_mb; -+ } -+ } -+ else -+ { -+ next_tab_column = column + tab_size - column % tab_size; -+ } -+ pending += next_tab_column - column; -+ column = next_tab_column; -+ } -+ else -+ { -+flush_pend_mb: -+ /* Flush pending spaces. Print as many tabs as possible, -+ then print the rest as spaces. */ -+ if (pending == 1 && column != 1 && !prev_tab) -+ { -+ putchar (' '); -+ pending = 0; -+ } -+ column -= pending; -+ while (pending > 0) -+ { -+ if (tab_size == 0) -+ { -+ /* Do not let print_tab_index == first_free_tab; -+ stop when it is 1 less. */ -+ while (print_tab_index < first_free_tab - 1 -+ && column >= tab_list[print_tab_index]) -+ print_tab_index++; -+ next_tab_column = tab_list[print_tab_index]; -+ if (print_tab_index < first_free_tab - 1) -+ print_tab_index++; -+ } -+ else -+ { -+ next_tab_column = -+ column + tab_size - column % tab_size; -+ } -+ if (next_tab_column - column <= pending) -+ { -+ putchar ('\t'); -+ pending -= next_tab_column - column; -+ column = next_tab_column; -+ } -+ else -+ { -+ --print_tab_index; -+ column += pending; -+ while (pending != 0) -+ { -+ putchar (' '); -+ pending--; -+ } -+ } -+ } -+ -+ if (wc == WEOF) -+ { -+ fp = next_file (fp); -+ if (fp == NULL) -+ break; /* No more files. */ -+ else -+ { -+ memset (&i_state, '\0', sizeof(mbstate_t)); -+ continue; -+ } -+ } -+ -+ if (mblength == (size_t)-1 || mblength == (size_t)-2) -+ { -+ if (convert) -+ { -+ ++column; -+ if (convert_entire_line == 0) -+ convert = 0; -+ } -+ mblength = 1; -+ putchar (buf[0]); -+ } -+ else if (mblength == 0) -+ { -+ if (convert && convert_entire_line == 0) -+ convert = 0; -+ mblength = 1; -+ putchar ('\0'); -+ } -+ else -+ { -+ if (convert) -+ { -+ if (wc == L'\b') -+ { -+ if (column > 0) -+ --column; -+ } -+ else -+ { -+ int width; /* The width of WC. */ -+ -+ width = wcwidth (wc); -+ column += (width > 0) ? width : 0; -+ if (convert_entire_line == 0) -+ convert = 0; -+ } -+ } -+ -+ if (wc == L'\n') -+ { -+ tab_index = print_tab_index = 0; -+ column = pending = 0; -+ convert = 1; -+ } -+ fwrite (bufpos, sizeof(char), mblength, stdout); -+ } -+ } -+ prev_tab = wc == L'\t'; -+ buflen -= mblength; -+ bufpos += mblength; -+ } -+} -+#endif -+ -+ - void - usage (int status) - { -@@ -523,7 +744,12 @@ main (int argc, char **argv) - - file_list = (optind < argc ? &argv[optind] : stdin_argv); - -- unexpand (); -+#if HAVE_MBRTOWC -+ if (MB_CUR_MAX > 1) -+ unexpand_multibyte (); -+ else -+#endif -+ unexpand (); - - if (have_read_stdin && fclose (stdin) != 0) - error (EXIT_FAILURE, errno, "-"); -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 + sort_die (_("close failed"), "-"); +diff --git a/src/uniq.c b/src/uniq.c +index 87a0c93..9f755d9 100644 +--- a/src/uniq.c ++++ b/src/uniq.c @@ -21,6 +21,17 @@ #include <getopt.h> #include <sys/types.h> @@ -3743,12 +2750,14 @@ diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c #include "system.h" #include "argmatch.h" #include "linebuffer.h" -@@ -33,6 +44,18 @@ +@@ -32,9 +43,21 @@ + #include "stdio--.h" + #include "xmemcoll.h" #include "xstrtol.h" - #include "memcasecmp.h" - #include "quote.h" +-#include "memcasecmp.h" +#include "xmemcoll.h" -+ + #include "quote.h" + +/* MB_LEN_MAX is incorrectly defined to be 1 in at least one GCC + installation; work around this configuration error. */ +#if !defined MB_LEN_MAX || MB_LEN_MAX < 2 @@ -3759,10 +2768,12 @@ diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c +#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 @@ enum + +@@ -144,6 +167,10 @@ enum GROUP_OPTION = CHAR_MAX + 1 };
@@ -3773,7 +2784,7 @@ diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c static struct option const longopts[] = { {"count", no_argument, NULL, 'c'}, -@@ -252,7 +279,7 @@ size_opt (char const *opt, char const *m +@@ -260,7 +287,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 @@ -3782,7 +2793,7 @@ diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c { size_t count; char const *lp = line->buffer; -@@ -272,6 +299,83 @@ find_field (struct linebuffer const *lin +@@ -280,6 +307,83 @@ find_field (struct linebuffer const *line) return line->buffer + i; }
@@ -3832,7 +2843,7 @@ diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c + while (pos < size) + { + MBCHAR_TO_WCHAR (wc, mblength, lp, pos, size, statep, convfail); -+ ++ + if (convfail || !(iswblank (wc) || wc == '\n')) + { + pos += mblength; @@ -3866,7 +2877,7 @@ diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c /* 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. -@@ -280,6 +384,8 @@ find_field (struct linebuffer const *lin +@@ -288,6 +392,8 @@ find_field (struct linebuffer const *line) static bool different (char *old, char *new, size_t oldlen, size_t newlen) { @@ -3875,7 +2886,7 @@ diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c if (check_chars < oldlen) oldlen = check_chars; if (check_chars < newlen) -@@ -287,15 +393,104 @@ different (char *old, char *new, size_t +@@ -295,14 +401,103 @@ different (char *old, char *new, size_t oldlen, size_t newlen)
if (ignore_case) { @@ -3907,8 +2918,8 @@ diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c + + 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) @@ -3979,13 +2990,12 @@ diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c + 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. -@@ -359,19 +554,38 @@ check_file (const char *infile, const ch +@@ -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; @@ -4024,7 +3034,7 @@ diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c new_group = (prevline->length == 0 || different (thisfield, prevfield, thislen, prevlen));
-@@ -389,6 +603,10 @@ check_file (const char *infile, const ch +@@ -397,6 +611,10 @@ check_file (const char *infile, const char *outfile, char delimiter) SWAP_LINES (prevline, thisline); prevfield = thisfield; prevlen = thislen; @@ -4035,7 +3045,7 @@ diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c first_group_printed = true; } } -@@ -401,17 +619,26 @@ check_file (const char *infile, const ch +@@ -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; @@ -4062,7 +3072,7 @@ diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c if (readlinebuffer_delim (thisline, stdin, delimiter) == 0) { if (ferror (stdin)) -@@ -420,6 +647,14 @@ check_file (const char *infile, const ch +@@ -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); @@ -4077,7 +3087,7 @@ diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c match = !different (thisfield, prevfield, thislen, prevlen); match_count += match;
-@@ -452,6 +687,9 @@ check_file (const char *infile, const ch +@@ -460,6 +695,9 @@ check_file (const char *infile, const char *outfile, char delimiter) SWAP_LINES (prevline, thisline); prevfield = thisfield; prevlen = thislen; @@ -4087,7 +3097,7 @@ diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c if (!match) match_count = 0; } -@@ -498,6 +736,19 @@ main (int argc, char **argv) +@@ -506,6 +744,19 @@ main (int argc, char **argv)
atexit (close_stdout);
@@ -4107,47 +3117,11 @@ diff -Naurp coreutils-8.25-orig/src/uniq.c coreutils-8.25/src/uniq.c skip_chars = 0; skip_fields = 0; check_chars = SIZE_MAX; -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 +diff --git a/tests/i18n/sort.sh b/tests/i18n/sort.sh +new file mode 100644 +index 0000000..26c95de +--- /dev/null ++++ b/tests/i18n/sort.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Verify sort's multi-byte support. @@ -4178,22 +3152,23 @@ diff -Naurp coreutils-8.25-orig/tests/i18n/sort.sh coreutils-8.25/tests/i18n/sor + + +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 = \ +diff --git a/tests/local.mk b/tests/local.mk +index 568944e..192f776 100644 +--- a/tests/local.mk ++++ b/tests/local.mk +@@ -350,6 +350,8 @@ all_tests = \ tests/misc/sort-discrim.sh \ tests/misc/sort-files0-from.pl \ tests/misc/sort-float.sh \ + tests/misc/sort-mb-tests.sh \ + tests/i18n/sort.sh \ -+ tests/i18n/sort-month.sh \ + tests/misc/sort-h-thousands-sep.sh \ tests/misc/sort-merge.pl \ tests/misc/sort-merge-fdlimit.sh \ - tests/misc/sort-month.sh \ -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 +diff --git a/tests/misc/cut.pl b/tests/misc/cut.pl +index f6f8a56..b426a80 100755 +--- a/tests/misc/cut.pl ++++ b/tests/misc/cut.pl @@ -23,9 +23,11 @@ use strict; # Turn off localization of executable's output. @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; @@ -4216,10 +3191,11 @@ diff -Naurp coreutils-8.25-orig/tests/misc/cut.pl coreutils-8.25/tests/misc/cut. push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}]; } push @Tests, @new; -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; +diff --git a/tests/misc/expand.pl b/tests/misc/expand.pl +index 8a9cad1..9293e39 100755 +--- a/tests/misc/expand.pl ++++ b/tests/misc/expand.pl +@@ -27,6 +27,15 @@ my $prog = 'expand'; # Turn off localization of executable's output. @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
@@ -4235,8 +3211,17 @@ diff -Naurp coreutils-8.25-orig/tests/misc/expand.pl coreutils-8.25/tests/misc/e my @Tests = ( ['t1', '--tabs=3', {IN=>"a\tb"}, {OUT=>"a b"}], -@@ -31,6 +40,37 @@ my @Tests = - ['i2', '--tabs=3 -i', {IN=>" \ta\tb"}, {OUT=>" a\tb"}], +@@ -140,6 +149,8 @@ my @Tests = + + + # Test errors ++ # FIXME: The following tests contain ‘quoting’ specific to LC_MESSAGES ++ # So we force LC_MESSAGES=C to make them pass. + ['e1', '--tabs="a"', {IN=>''}, {OUT=>''}, {EXIT=>1}, + {ERR => "$prog: tab size contains invalid character(s): 'a'\n"}], + ['e2', "-t $UINTMAX_OFLOW", {IN=>''}, {OUT=>''}, {EXIT=>1}, +@@ -150,6 +161,37 @@ my @Tests = + {ERR => "$prog: tab sizes must be ascending\n"}], );
+if ($mb_locale ne 'C') @@ -4262,7 +3247,7 @@ diff -Naurp coreutils-8.25-orig/tests/misc/expand.pl coreutils-8.25/tests/misc/e + push @new_t, $sub; + push @$t, $sub; + } -+ push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}]; ++ push @new, ["$test_name-mb", @new_t, {ENV => "LANG=$mb_locale LC_MESSAGES=C"}]; + } + push @Tests, @new; + } @@ -4273,9 +3258,10 @@ diff -Naurp coreutils-8.25-orig/tests/misc/expand.pl coreutils-8.25/tests/misc/e my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE};
-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 +diff --git a/tests/misc/fold.pl b/tests/misc/fold.pl +index 7b192b4..76f073f 100755 +--- a/tests/misc/fold.pl ++++ b/tests/misc/fold.pl @@ -20,9 +20,18 @@ use strict;
(my $program_name = $0) =~ s|.*/||; @@ -4345,9 +3331,10 @@ diff -Naurp coreutils-8.25-orig/tests/misc/fold.pl coreutils-8.25/tests/misc/fol -my $prog = 'fold'; my $fail = run_tests ($program_name, $prog, @Tests, $save_temps, $verbose); exit $fail; -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 +diff --git a/tests/misc/join.pl b/tests/misc/join.pl +index 4d399d8..07f2823 100755 +--- a/tests/misc/join.pl ++++ b/tests/misc/join.pl @@ -25,6 +25,15 @@ my $limits = getlimits ();
my $prog = 'join'; @@ -4414,9 +3401,11 @@ diff -Naurp coreutils-8.25-orig/tests/misc/join.pl coreutils-8.25/tests/misc/joi my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE};
-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 +diff --git a/tests/misc/sort-mb-tests.sh b/tests/misc/sort-mb-tests.sh +new file mode 100644 +index 0000000..11836ba +--- /dev/null ++++ b/tests/misc/sort-mb-tests.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# Verify sort's multi-byte support. @@ -4463,9 +3452,10 @@ diff -Naurp coreutils-8.25-orig/tests/misc/sort-mb-tests.sh coreutils-8.25/tests +compare exp out || { fail=1; cat out; } + +Exit $fail -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 +diff --git a/tests/misc/sort-merge.pl b/tests/misc/sort-merge.pl +index 23f6ed2..402a987 100755 +--- a/tests/misc/sort-merge.pl ++++ b/tests/misc/sort-merge.pl @@ -26,6 +26,15 @@ my $prog = 'sort'; # Turn off localization of executable's output. @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; @@ -4522,9 +3512,10 @@ diff -Naurp coreutils-8.25-orig/tests/misc/sort-merge.pl coreutils-8.25/tests/mi my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE};
-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 +diff --git a/tests/misc/sort.pl b/tests/misc/sort.pl +index c3e7f8e..6ecd3ff 100755 +--- a/tests/misc/sort.pl ++++ b/tests/misc/sort.pl @@ -24,10 +24,15 @@ my $prog = 'sort'; # Turn off localization of executable's output. @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; @@ -4589,9 +3580,10 @@ diff -Naurp coreutils-8.25-orig/tests/misc/sort.pl coreutils-8.25/tests/misc/sor
my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE}; -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 +diff --git a/tests/misc/unexpand.pl b/tests/misc/unexpand.pl +index 6ba6d40..de86723 100755 +--- a/tests/misc/unexpand.pl ++++ b/tests/misc/unexpand.pl @@ -27,6 +27,14 @@ my $limits = getlimits ();
my $prog = 'unexpand'; @@ -4607,8 +3599,8 @@ diff -Naurp coreutils-8.25-orig/tests/misc/unexpand.pl coreutils-8.25/tests/misc my @Tests = ( ['a1', {IN=> ' 'x 1 ."y\n"}, {OUT=> ' 'x 1 ."y\n"}], -@@ -92,6 +100,37 @@ my @Tests = - {EXIT => 1}, {ERR => "$prog: tab stop value is too large\n"}], +@@ -128,6 +136,37 @@ my @Tests = + ['ts2', '-t5,8', {IN=>"x\t \t y\n"}, {OUT=>"x\t\t y\n"}], );
+if ($mb_locale ne 'C') @@ -4645,9 +3637,10 @@ diff -Naurp coreutils-8.25-orig/tests/misc/unexpand.pl coreutils-8.25/tests/misc my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE};
-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 +diff --git a/tests/misc/uniq.pl b/tests/misc/uniq.pl +index f028036..8eaf59a 100755 +--- a/tests/misc/uniq.pl ++++ b/tests/misc/uniq.pl @@ -23,9 +23,17 @@ my $limits = getlimits (); my $prog = 'uniq'; my $try = "Try '$prog --help' for more information.\n"; @@ -4720,9 +3713,10 @@ diff -Naurp coreutils-8.25-orig/tests/misc/uniq.pl coreutils-8.25/tests/misc/uni @Tests = add_z_variants @Tests; @Tests = triple_test @Tests;
-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 +diff --git a/tests/pr/pr-tests.pl b/tests/pr/pr-tests.pl +index ec3980a..136657d 100755 +--- a/tests/pr/pr-tests.pl ++++ b/tests/pr/pr-tests.pl @@ -24,6 +24,15 @@ use strict; my $prog = 'pr'; my $normalize_strerror = "s/': .*/'/"; @@ -4739,9 +3733,9 @@ diff -Naurp coreutils-8.25-orig/tests/pr/pr-tests.pl coreutils-8.25/tests/pr/pr- my @tv = (
# -b option is no longer an official option. But it's still working to -@@ -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"} ]; +@@ -474,8 +483,48 @@ push @Tests, + {IN=>{2=>"a\n"}}, + {OUT=>"a\t\t\t\t \t\t\ta\n"} ];
+# Add _POSIX2_VERSION=199209 to the environment of each test +# that uses an old-style option like +1. @@ -4769,7 +3763,7 @@ diff -Naurp coreutils-8.25-orig/tests/pr/pr-tests.pl coreutils-8.25/tests/pr/pr- + push @$t, $sub; + } + #temporarily skip some failing tests -+ next if ($test_name =~ "col-0" or $test_name =~ "col-inval"); ++ next if ($test_name =~ "col-0" or $test_name =~ "col-inval" or $test_name =~ "asan1"); + push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}]; + } + push @Tests, @new; @@ -4788,3 +3782,6 @@ diff -Naurp coreutils-8.25-orig/tests/pr/pr-tests.pl coreutils-8.25/tests/pr/pr- my $save_temps = $ENV{DEBUG}; my $verbose = $ENV{VERBOSE};
+-- +2.7.4 + diff --git a/coreutils/patches/coreutils-ipfire-disabled-tests.patch b/coreutils/patches/coreutils-ipfire-disabled-tests.patch deleted file mode 100644 index 0f7a04b..0000000 --- a/coreutils/patches/coreutils-ipfire-disabled-tests.patch +++ /dev/null @@ -1,52 +0,0 @@ ---- coreutils-8.25_old/tests/local.mk 2016-01-16 19:18:13.000000000 +0100 -+++ coreutils-8.25_new/tests/local.mk 2016-09-03 12:59:41.798241660 +0200 -@@ -107,7 +107,6 @@ - - all_root_tests = \ - tests/chown/basic.sh \ -- tests/cp/cp-a-selinux.sh \ - tests/cp/preserve-gid.sh \ - tests/cp/special-bits.sh \ - tests/cp/cp-mv-enotsup-xattr.sh \ -@@ -122,8 +121,6 @@ - tests/install/install-C-root.sh \ - tests/ls/capability.sh \ - tests/ls/nameless-uid.sh \ -- tests/misc/chcon.sh \ -- tests/misc/chroot-credentials.sh \ - tests/misc/selinux.sh \ - tests/misc/truncate-owned-by-other.sh \ - tests/mkdir/writable-under-readonly.sh \ -@@ -236,7 +233,6 @@ - tests/misc/test.pl \ - tests/misc/seq.pl \ - tests/misc/seq-long-double.sh \ -- tests/misc/seq-precision.sh \ - tests/misc/head.pl \ - tests/misc/head-elide-tail.pl \ - tests/tail-2/tail-n0f.sh \ -@@ -535,8 +531,6 @@ - tests/du/trailing-slash.sh \ - tests/du/two-args.sh \ - tests/id/gnu-zero-uids.sh \ -- tests/id/no-context.sh \ -- tests/id/context.sh \ - tests/id/uid.sh \ - tests/id/zero.sh \ - tests/id/smack.sh \ -@@ -544,7 +538,6 @@ - tests/install/create-leading.sh \ - tests/install/d-slashdot.sh \ - tests/install/install-C.sh \ -- tests/install/install-C-selinux.sh \ - tests/install/strip-program.sh \ - tests/install/trap.sh \ - tests/ln/backup-1.sh \ -@@ -598,7 +591,6 @@ - tests/mkdir/parents.sh \ - tests/mkdir/perm.sh \ - tests/mkdir/selinux.sh \ -- tests/mkdir/restorecon.sh \ - tests/mkdir/special-1.sh \ - tests/mkdir/t-slash.sh \ - tests/mkdir/smack-no-root.sh \