fix uniq group support in multibyte

This commit is contained in:
Ondřej Vašík 2013-12-16 17:48:21 +01:00
parent 3a87513acc
commit 8ff0950897

View File

@ -1,6 +1,6 @@
diff -urNp coreutils-8.21-orig/lib/linebuffer.h coreutils-8.21/lib/linebuffer.h diff -urNp coreutils-8.22-orig/lib/linebuffer.h coreutils-8.22/lib/linebuffer.h
--- coreutils-8.21-orig/lib/linebuffer.h 2013-01-02 13:34:46.000000000 +0100 --- coreutils-8.22-orig/lib/linebuffer.h 2013-12-04 15:53:33.000000000 +0100
+++ coreutils-8.21/lib/linebuffer.h 2013-02-15 14:25:07.758469108 +0100 +++ coreutils-8.22/lib/linebuffer.h 2013-12-16 17:40:25.933887985 +0100
@@ -21,6 +21,11 @@ @@ -21,6 +21,11 @@
# include <stdio.h> # include <stdio.h>
@ -23,9 +23,9 @@ diff -urNp coreutils-8.21-orig/lib/linebuffer.h coreutils-8.21/lib/linebuffer.h
}; };
/* Initialize linebuffer LINEBUFFER for use. */ /* Initialize linebuffer LINEBUFFER for use. */
diff -urNp coreutils-8.21-orig/src/cut.c coreutils-8.21/src/cut.c diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
--- coreutils-8.21-orig/src/cut.c 2013-02-05 00:40:31.000000000 +0100 --- coreutils-8.22-orig/src/cut.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/src/cut.c 2013-02-15 14:25:07.760467982 +0100 +++ coreutils-8.22/src/cut.c 2013-12-16 17:40:25.935887295 +0100
@@ -28,6 +28,11 @@ @@ -28,6 +28,11 @@
#include <assert.h> #include <assert.h>
#include <getopt.h> #include <getopt.h>
@ -110,7 +110,7 @@ diff -urNp coreutils-8.21-orig/src/cut.c coreutils-8.21/src/cut.c
struct range_pair struct range_pair
{ {
@@ -114,15 +178,25 @@ enum operating_mode @@ -106,15 +169,25 @@ enum operating_mode
{ {
undefined_mode, undefined_mode,
@ -137,7 +137,7 @@ diff -urNp coreutils-8.21-orig/src/cut.c coreutils-8.21/src/cut.c
/* If true do not output lines containing no delimeter characters. /* If true do not output lines containing no delimeter characters.
Otherwise, all such lines are printed. This option is valid only Otherwise, all such lines are printed. This option is valid only
with field mode. */ with field mode. */
@@ -134,6 +208,9 @@ static bool complement; @@ -126,6 +199,9 @@ static bool complement;
/* The delimeter character for field mode. */ /* The delimeter character for field mode. */
static unsigned char delim; static unsigned char delim;
@ -147,7 +147,7 @@ diff -urNp coreutils-8.21-orig/src/cut.c coreutils-8.21/src/cut.c
/* True if the --output-delimiter=STRING option was specified. */ /* True if the --output-delimiter=STRING option was specified. */
static bool output_delimiter_specified; static bool output_delimiter_specified;
@@ -205,7 +282,7 @@ Print selected parts of lines from each @@ -188,7 +264,7 @@ Print selected parts of lines from each
-f, --fields=LIST select only these fields; also print any line\n\ -f, --fields=LIST select only these fields; also print any line\n\
that contains no delimiter character, unless\n\ that contains no delimiter character, unless\n\
the -s option is specified\n\ the -s option is specified\n\
@ -156,7 +156,7 @@ diff -urNp coreutils-8.21-orig/src/cut.c coreutils-8.21/src/cut.c
"), stdout); "), stdout);
fputs (_("\ fputs (_("\
--complement complement the set of selected bytes, characters\n\ --complement complement the set of selected bytes, characters\n\
@@ -480,6 +557,9 @@ set_fields (const char *fieldstr) @@ -381,6 +457,9 @@ set_fields (const char *fieldstr)
if (operating_mode == byte_mode) if (operating_mode == byte_mode)
error (0, 0, error (0, 0,
_("byte offset %s is too large"), quote (bad_num)); _("byte offset %s is too large"), quote (bad_num));
@ -449,7 +449,7 @@ diff -urNp coreutils-8.21-orig/src/cut.c coreutils-8.21/src/cut.c
} }
/* Process file FILE to standard output. /* Process file FILE to standard output.
@@ -767,6 +1100,8 @@ main (int argc, char **argv) @@ -687,6 +1025,8 @@ main (int argc, char **argv)
bool ok; bool ok;
bool delim_specified = false; bool delim_specified = false;
char *spec_list_string IF_LINT ( = NULL); char *spec_list_string IF_LINT ( = NULL);
@ -458,7 +458,7 @@ diff -urNp coreutils-8.21-orig/src/cut.c coreutils-8.21/src/cut.c
initialize_main (&argc, &argv); initialize_main (&argc, &argv);
set_program_name (argv[0]); set_program_name (argv[0]);
@@ -789,7 +1124,6 @@ main (int argc, char **argv) @@ -709,7 +1049,6 @@ main (int argc, char **argv)
switch (optc) switch (optc)
{ {
case 'b': case 'b':
@ -466,7 +466,7 @@ diff -urNp coreutils-8.21-orig/src/cut.c coreutils-8.21/src/cut.c
/* Build the byte list. */ /* Build the byte list. */
if (operating_mode != undefined_mode) if (operating_mode != undefined_mode)
FATAL_ERROR (_("only one type of list may be specified")); FATAL_ERROR (_("only one type of list may be specified"));
@@ -797,6 +1131,14 @@ main (int argc, char **argv) @@ -717,6 +1056,14 @@ main (int argc, char **argv)
spec_list_string = optarg; spec_list_string = optarg;
break; break;
@ -481,7 +481,7 @@ diff -urNp coreutils-8.21-orig/src/cut.c coreutils-8.21/src/cut.c
case 'f': case 'f':
/* Build the field list. */ /* Build the field list. */
if (operating_mode != undefined_mode) if (operating_mode != undefined_mode)
@@ -808,10 +1150,36 @@ main (int argc, char **argv) @@ -728,10 +1075,36 @@ main (int argc, char **argv)
case 'd': case 'd':
/* New delimiter. */ /* New delimiter. */
/* Interpret -d '' to mean 'use the NUL byte as the delimiter.' */ /* Interpret -d '' to mean 'use the NUL byte as the delimiter.' */
@ -522,7 +522,7 @@ diff -urNp coreutils-8.21-orig/src/cut.c coreutils-8.21/src/cut.c
break; break;
case OUTPUT_DELIMITER_OPTION: case OUTPUT_DELIMITER_OPTION:
@@ -824,6 +1191,7 @@ main (int argc, char **argv) @@ -744,6 +1117,7 @@ main (int argc, char **argv)
break; break;
case 'n': case 'n':
@ -530,7 +530,7 @@ diff -urNp coreutils-8.21-orig/src/cut.c coreutils-8.21/src/cut.c
break; break;
case 's': case 's':
@@ -873,15 +1241,34 @@ main (int argc, char **argv) @@ -783,15 +1157,34 @@ main (int argc, char **argv)
} }
if (!delim_specified) if (!delim_specified)
@ -571,9 +571,9 @@ diff -urNp coreutils-8.21-orig/src/cut.c coreutils-8.21/src/cut.c
} }
if (optind == argc) if (optind == argc)
diff -urNp coreutils-8.21-orig/src/expand.c coreutils-8.21/src/expand.c diff -urNp coreutils-8.22-orig/src/expand.c coreutils-8.22/src/expand.c
--- coreutils-8.21-orig/src/expand.c 2013-01-31 01:46:24.000000000 +0100 --- coreutils-8.22-orig/src/expand.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/src/expand.c 2013-02-15 14:25:07.774467536 +0100 +++ coreutils-8.22/src/expand.c 2013-12-16 17:40:25.936886952 +0100
@@ -37,12 +37,29 @@ @@ -37,12 +37,29 @@
#include <stdio.h> #include <stdio.h>
#include <getopt.h> #include <getopt.h>
@ -761,9 +761,9 @@ diff -urNp coreutils-8.21-orig/src/expand.c coreutils-8.21/src/expand.c
if (have_read_stdin && fclose (stdin) != 0) if (have_read_stdin && fclose (stdin) != 0)
error (EXIT_FAILURE, errno, "-"); error (EXIT_FAILURE, errno, "-");
diff -urNp coreutils-8.21-orig/src/fold.c coreutils-8.21/src/fold.c diff -urNp coreutils-8.22-orig/src/fold.c coreutils-8.22/src/fold.c
--- coreutils-8.21-orig/src/fold.c 2013-01-31 01:46:24.000000000 +0100 --- coreutils-8.22-orig/src/fold.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/src/fold.c 2013-02-15 14:25:07.789467891 +0100 +++ coreutils-8.22/src/fold.c 2013-12-16 17:40:25.938886274 +0100
@@ -22,12 +22,34 @@ @@ -22,12 +22,34 @@
#include <getopt.h> #include <getopt.h>
#include <sys/types.h> #include <sys/types.h>
@ -1161,9 +1161,9 @@ diff -urNp coreutils-8.21-orig/src/fold.c coreutils-8.21/src/fold.c
break; break;
case 's': /* Break at word boundaries. */ case 's': /* Break at word boundaries. */
diff -urNp coreutils-8.21-orig/src/join.c coreutils-8.21/src/join.c diff -urNp coreutils-8.22-orig/src/join.c coreutils-8.22/src/join.c
--- coreutils-8.21-orig/src/join.c 2013-01-31 01:46:24.000000000 +0100 --- coreutils-8.22-orig/src/join.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/src/join.c 2013-02-15 14:25:07.804467922 +0100 +++ coreutils-8.22/src/join.c 2013-12-16 17:40:25.940885607 +0100
@@ -22,18 +22,32 @@ @@ -22,18 +22,32 @@
#include <sys/types.h> #include <sys/types.h>
#include <getopt.h> #include <getopt.h>
@ -1215,7 +1215,7 @@ diff -urNp coreutils-8.21-orig/src/join.c coreutils-8.21/src/join.c
/* If nonzero, check that the input is correctly ordered. */ /* If nonzero, check that the input is correctly ordered. */
static enum static enum
@@ -262,13 +278,14 @@ xfields (struct line *line) @@ -269,13 +285,14 @@ xfields (struct line *line)
if (ptr == lim) if (ptr == lim)
return; return;
@ -1233,7 +1233,7 @@ diff -urNp coreutils-8.21-orig/src/join.c coreutils-8.21/src/join.c
{ {
/* Skip leading blanks before the first field. */ /* Skip leading blanks before the first field. */
while (isblank (to_uchar (*ptr))) while (isblank (to_uchar (*ptr)))
@@ -292,6 +309,148 @@ xfields (struct line *line) @@ -299,6 +316,148 @@ xfields (struct line *line)
extract_field (line, ptr, lim - ptr); extract_field (line, ptr, lim - ptr);
} }
@ -1382,7 +1382,7 @@ diff -urNp coreutils-8.21-orig/src/join.c coreutils-8.21/src/join.c
static void static void
freeline (struct line *line) freeline (struct line *line)
{ {
@@ -313,56 +472,130 @@ keycmp (struct line const *line1, struct @@ -320,56 +479,130 @@ keycmp (struct line const *line1, struct
size_t jf_1, size_t jf_2) size_t jf_1, size_t jf_2)
{ {
/* Start of field to compare in each file. */ /* Start of field to compare in each file. */
@ -1536,7 +1536,7 @@ diff -urNp coreutils-8.21-orig/src/join.c coreutils-8.21/src/join.c
} }
/* Check that successive input lines PREV and CURRENT from input file /* Check that successive input lines PREV and CURRENT from input file
@@ -454,6 +687,11 @@ get_line (FILE *fp, struct line **linep, @@ -461,6 +694,11 @@ get_line (FILE *fp, struct line **linep,
} }
++line_no[which - 1]; ++line_no[which - 1];
@ -1548,7 +1548,7 @@ diff -urNp coreutils-8.21-orig/src/join.c coreutils-8.21/src/join.c
xfields (line); xfields (line);
if (prevline[which - 1]) if (prevline[which - 1])
@@ -553,21 +791,28 @@ prfield (size_t n, struct line const *li @@ -560,21 +798,28 @@ prfield (size_t n, struct line const *li
/* Output all the fields in line, other than the join field. */ /* Output all the fields in line, other than the join field. */
@ -1580,7 +1580,7 @@ diff -urNp coreutils-8.21-orig/src/join.c coreutils-8.21/src/join.c
prfield (i, line); prfield (i, line);
} }
} }
@@ -578,7 +823,6 @@ static void @@ -585,7 +830,6 @@ static void
prjoin (struct line const *line1, struct line const *line2) prjoin (struct line const *line1, struct line const *line2)
{ {
const struct outlist *outlist; const struct outlist *outlist;
@ -1588,7 +1588,7 @@ diff -urNp coreutils-8.21-orig/src/join.c coreutils-8.21/src/join.c
size_t field; size_t field;
struct line const *line; struct line const *line;
@@ -612,7 +856,7 @@ prjoin (struct line const *line1, struct @@ -619,7 +863,7 @@ prjoin (struct line const *line1, struct
o = o->next; o = o->next;
if (o == NULL) if (o == NULL)
break; break;
@ -1597,7 +1597,7 @@ diff -urNp coreutils-8.21-orig/src/join.c coreutils-8.21/src/join.c
} }
putchar (eolchar); putchar (eolchar);
} }
@@ -1090,21 +1334,46 @@ main (int argc, char **argv) @@ -1097,21 +1341,46 @@ main (int argc, char **argv)
case 't': case 't':
{ {
@ -1654,9 +1654,9 @@ diff -urNp coreutils-8.21-orig/src/join.c coreutils-8.21/src/join.c
break; break;
case 'z': case 'z':
diff -urNp coreutils-8.21-orig/src/pr.c coreutils-8.21/src/pr.c diff -urNp coreutils-8.22-orig/src/pr.c coreutils-8.22/src/pr.c
--- coreutils-8.21-orig/src/pr.c 2013-01-31 01:46:24.000000000 +0100 --- coreutils-8.22-orig/src/pr.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/src/pr.c 2013-02-15 14:25:07.819467936 +0100 +++ coreutils-8.22/src/pr.c 2013-12-16 17:40:25.944884263 +0100
@@ -312,6 +312,32 @@ @@ -312,6 +312,32 @@
#include <getopt.h> #include <getopt.h>
@ -2410,9 +2410,9 @@ diff -urNp coreutils-8.21-orig/src/pr.c coreutils-8.21/src/pr.c
/* We've just printed some files and need to clean up things before /* We've just printed some files and need to clean up things before
looking for more options and printing the next batch of files. looking for more options and printing the next batch of files.
diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c diff -urNp coreutils-8.22-orig/src/sort.c coreutils-8.22/src/sort.c
--- coreutils-8.21-orig/src/sort.c 2013-08-14 18:14:06.172216606 +0200 --- coreutils-8.22-orig/src/sort.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/src/sort.c 2013-08-14 18:13:30.295247905 +0200 +++ coreutils-8.22/src/sort.c 2013-12-16 17:40:25.949882582 +0100
@@ -29,6 +29,14 @@ @@ -29,6 +29,14 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <signal.h> #include <signal.h>
@ -2432,8 +2432,8 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
/* Nonzero if the corresponding locales are hard. */ /* Nonzero if the corresponding locales are hard. */
static bool hard_LC_COLLATE; static bool hard_LC_COLLATE;
+#if HAVE_LANGINFO_CODESET
-#if HAVE_NL_LANGINFO -#if HAVE_NL_LANGINFO
+#if HAVE_LANGINFO_CODESET
static bool hard_LC_TIME; static bool hard_LC_TIME;
#endif #endif
@ -2468,20 +2468,20 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
they were read if all keys compare equal. */ they were read if all keys compare equal. */
static bool stable; static bool stable;
+/* Tab character separating fields. If tab_length is 0, then fields are
-/* If TAB has this value, blanks separate fields. */ -/* If TAB has this value, blanks separate fields. */
-enum { TAB_DEFAULT = CHAR_MAX + 1 }; -enum { TAB_DEFAULT = CHAR_MAX + 1 };
- -
-/* Tab character separating fields. If TAB_DEFAULT, then fields are -/* Tab character separating fields. If TAB_DEFAULT, then fields are
+/* Tab character separating fields. If tab_length is 0, then fields are
separated by the empty string between a non-blank character and a blank separated by the empty string between a non-blank character and a blank
character. */ character. */
-static int tab = TAB_DEFAULT;
+static char tab[MB_LEN_MAX + 1]; +static char tab[MB_LEN_MAX + 1];
+static size_t tab_length = 0; +static size_t tab_length = 0;
-static int tab = TAB_DEFAULT;
/* Flag to remove consecutive duplicate lines from the output. /* Flag to remove consecutive duplicate lines from the output.
Only the last of a sequence of equal lines will be output. */ Only the last of a sequence of equal lines will be output. */
@@ -783,6 +811,46 @@ reap_all (void) @@ -811,6 +839,46 @@ reap_all (void)
reap (-1); reap (-1);
} }
@ -2528,34 +2528,34 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
/* Clean up any remaining temporary files. */ /* Clean up any remaining temporary files. */
static void static void
@@ -1223,7 +1291,7 @@ zaptemp (char const *name) @@ -1255,7 +1323,7 @@ zaptemp (char const *name)
free (node); free (node);
} }
+#if HAVE_LANGINFO_CODESET
-#if HAVE_NL_LANGINFO -#if HAVE_NL_LANGINFO
+#if HAVE_LANGINFO_CODESET
static int static int
struct_month_cmp (void const *m1, void const *m2) struct_month_cmp (void const *m1, void const *m2)
@@ -1238,7 +1306,7 @@ struct_month_cmp (void const *m1, void c @@ -1270,7 +1338,7 @@ struct_month_cmp (void const *m1, void c
/* Initialize the character class tables. */ /* Initialize the character class tables. */
static void static void
+inittables_uni (void)
-inittables (void) -inittables (void)
+inittables_uni (void)
{ {
size_t i; size_t i;
@@ -1250,7 +1318,7 @@ inittables_uni (void) @@ -1282,7 +1350,7 @@ inittables (void)
fold_toupper[i] = toupper (i); fold_toupper[i] = toupper (i);
} }
+#if HAVE_LANGINFO_CODESET
-#if HAVE_NL_LANGINFO -#if HAVE_NL_LANGINFO
+#if HAVE_LANGINFO_CODESET
/* If we're not in the "C" locale, read different names for months. */ /* If we're not in the "C" locale, read different names for months. */
if (hard_LC_TIME) if (hard_LC_TIME)
{ {
@@ -1332,6 +1400,84 @@ specify_nmerge (int oi, char c, char con @@ -1364,6 +1432,84 @@ specify_nmerge (int oi, char c, char con
xstrtol_fatal (e, oi, c, long_options, s); xstrtol_fatal (e, oi, c, long_options, s);
} }
@ -2640,29 +2640,29 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
/* Specify the amount of main memory to use when sorting. */ /* Specify the amount of main memory to use when sorting. */
static void static void
specify_sort_size (int oi, char c, char const *s) specify_sort_size (int oi, char c, char const *s)
@@ -1564,7 +1710,7 @@ buffer_linelim (struct buffer const *buf @@ -1597,7 +1743,7 @@ buffer_linelim (struct buffer const *buf
by KEY in LINE. */ by KEY in LINE. */
static char * static char *
+begfield_uni (const struct line *line, const struct keyfield *key)
-begfield (struct line const *line, struct keyfield const *key) -begfield (struct line const *line, struct keyfield const *key)
+begfield_uni (const struct line *line, const struct keyfield *key)
{ {
char *ptr = line->text, *lim = ptr + line->length - 1; char *ptr = line->text, *lim = ptr + line->length - 1;
size_t sword = key->sword; size_t sword = key->sword;
@@ -1573,10 +1719,10 @@ begfield_uni (const struct line *line, c @@ -1606,10 +1752,10 @@ begfield (struct line const *line, struc
/* The leading field separator itself is included in a field when -t /* The leading field separator itself is included in a field when -t
is absent. */ is absent. */
+ if (tab_length)
- if (tab != TAB_DEFAULT) - if (tab != TAB_DEFAULT)
+ if (tab_length)
while (ptr < lim && sword--) while (ptr < lim && sword--)
{ {
+ while (ptr < lim && *ptr != tab[0])
- while (ptr < lim && *ptr != tab) - while (ptr < lim && *ptr != tab)
+ while (ptr < lim && *ptr != tab[0])
++ptr; ++ptr;
if (ptr < lim) if (ptr < lim)
++ptr; ++ptr;
@@ -1602,11 +1748,70 @@ begfield_uni (const struct line *line, c @@ -1635,11 +1781,70 @@ begfield (struct line const *line, struc
return ptr; return ptr;
} }
@ -2729,38 +2729,38 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
in LINE specified by KEY. */ in LINE specified by KEY. */
static char * static char *
+limfield_uni (const struct line *line, const struct keyfield *key)
-limfield (struct line const *line, struct keyfield const *key) -limfield (struct line const *line, struct keyfield const *key)
+limfield_uni (const struct line *line, const struct keyfield *key)
{ {
char *ptr = line->text, *lim = ptr + line->length - 1; char *ptr = line->text, *lim = ptr + line->length - 1;
size_t eword = key->eword, echar = key->echar; size_t eword = key->eword, echar = key->echar;
@@ -1621,10 +1826,10 @@ limfield_uni (const struct line *line, c @@ -1654,10 +1859,10 @@ limfield (struct line const *line, struc
'beginning' is the first character following the delimiting TAB. 'beginning' is the first character following the delimiting TAB.
Otherwise, leave PTR pointing at the first 'blank' character after Otherwise, leave PTR pointing at the first 'blank' character after
the preceding field. */ the preceding field. */
+ if (tab_length)
- if (tab != TAB_DEFAULT) - if (tab != TAB_DEFAULT)
+ if (tab_length)
while (ptr < lim && eword--) while (ptr < lim && eword--)
{ {
+ while (ptr < lim && *ptr != tab[0])
- while (ptr < lim && *ptr != tab) - while (ptr < lim && *ptr != tab)
+ while (ptr < lim && *ptr != tab[0])
++ptr; ++ptr;
if (ptr < lim && (eword || echar)) if (ptr < lim && (eword || echar))
++ptr; ++ptr;
@@ -1670,10 +1875,10 @@ limfield_uni (const struct line *line, c @@ -1703,10 +1908,10 @@ limfield (struct line const *line, struc
*/ */
/* Make LIM point to the end of (one byte past) the current field. */ /* Make LIM point to the end of (one byte past) the current field. */
+ if (tab_length)
- if (tab != TAB_DEFAULT) - if (tab != TAB_DEFAULT)
+ if (tab_length)
{ {
char *newlim; char *newlim;
+ newlim = memchr (ptr, tab[0], lim - ptr);
- newlim = memchr (ptr, tab, lim - ptr); - newlim = memchr (ptr, tab, lim - ptr);
+ newlim = memchr (ptr, tab[0], lim - ptr);
if (newlim) if (newlim)
lim = newlim; lim = newlim;
} }
@@ -1704,6 +1909,130 @@ limfield_uni (const struct line *line, c @@ -1737,6 +1942,130 @@ limfield (struct line const *line, struc
return ptr; return ptr;
} }
@ -2891,10 +2891,12 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
/* Fill BUF reading from FP, moving buf->left bytes from the end /* 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 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 file wasn't terminated by a newline, supply one. Set up BUF's line
@@ -1790,8 +2119,22 @@ fillbuf (struct buffer *buf, FILE *fp, c @@ -1823,8 +2152,22 @@ fillbuf (struct buffer *buf, FILE *fp, c
else else
{ {
if (key->skipsblanks) if (key->skipsblanks)
- while (blanks[to_uchar (*line_start)])
- line_start++;
+ { + {
+#if HAVE_MBRTOWC +#if HAVE_MBRTOWC
+ if (MB_CUR_MAX > 1) + if (MB_CUR_MAX > 1)
@ -2911,21 +2913,19 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
+ while (blanks[to_uchar (*line_start)]) + while (blanks[to_uchar (*line_start)])
+ line_start++; + line_start++;
+ } + }
- while (blanks[to_uchar (*line_start)])
- line_start++;
line->keybeg = line_start; line->keybeg = line_start;
} }
} }
@@ -1912,7 +2255,7 @@ human_numcompare (char const *a, char co @@ -1945,7 +2288,7 @@ human_numcompare (char const *a, char co
hideously fast. */ hideously fast. */
static int static int
+numcompare_uni (const char *a, const char *b)
-numcompare (char const *a, char const *b) -numcompare (char const *a, char const *b)
+numcompare_uni (const char *a, const char *b)
{ {
while (blanks[to_uchar (*a)]) while (blanks[to_uchar (*a)])
a++; a++;
@@ -1922,6 +2265,25 @@ numcompare_uni (const char *a, const cha @@ -1955,6 +2298,25 @@ numcompare (char const *a, char const *b
return strnumcmp (a, b, decimal_point, thousands_sep); return strnumcmp (a, b, decimal_point, thousands_sep);
} }
@ -2951,43 +2951,43 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
/* Work around a problem whereby the long double value returned by glibc's /* Work around a problem whereby the long double value returned by glibc's
strtold ("NaN", ...) contains uninitialized bits: clear all bytes of strtold ("NaN", ...) contains uninitialized bits: clear all bytes of
A and B before calling strtold. FIXME: remove this function once A and B before calling strtold. FIXME: remove this function once
@@ -1972,7 +2334,7 @@ general_numcompare (char const *sa, char @@ -2005,7 +2367,7 @@ general_numcompare (char const *sa, char
Return 0 if the name in S is not recognized. */ Return 0 if the name in S is not recognized. */
static int static int
+getmonth_uni (char const *month, size_t len, char **ea)
-getmonth (char const *month, char **ea) -getmonth (char const *month, char **ea)
+getmonth_uni (char const *month, size_t len, char **ea)
{ {
size_t lo = 0; size_t lo = 0;
size_t hi = MONTHS_PER_YEAR; size_t hi = MONTHS_PER_YEAR;
@@ -2247,15 +2609,14 @@ debug_key (struct line const *line, stru @@ -2280,15 +2642,14 @@ debug_key (struct line const *line, stru
char saved = *lim; char saved = *lim;
*lim = '\0'; *lim = '\0';
+ skipblanks (&beg, lim);
- while (blanks[to_uchar (*beg)]) - while (blanks[to_uchar (*beg)])
- beg++; - beg++;
+ skipblanks (&beg, lim);
char *tighter_lim = beg; char *tighter_lim = beg;
if (lim < beg) if (lim < beg)
tighter_lim = lim; tighter_lim = lim;
else if (key->month) else if (key->month)
+ getmonth (beg, lim-beg, &tighter_lim);
- getmonth (beg, &tighter_lim); - getmonth (beg, &tighter_lim);
+ getmonth (beg, lim-beg, &tighter_lim);
else if (key->general_numeric) else if (key->general_numeric)
ignore_value (strtold (beg, &tighter_lim)); ignore_value (strtold (beg, &tighter_lim));
else if (key->numeric || key->human_numeric) else if (key->numeric || key->human_numeric)
@@ -2399,7 +2760,7 @@ key_warnings (struct keyfield const *gke @@ -2432,7 +2793,7 @@ key_warnings (struct keyfield const *gke
bool maybe_space_aligned = !hard_LC_COLLATE && default_key_compare (key) bool maybe_space_aligned = !hard_LC_COLLATE && default_key_compare (key)
&& !(key->schar || key->echar); && !(key->schar || key->echar);
bool line_offset = key->eword == 0 && key->echar != 0; /* -k1.x,1.y */ bool line_offset = key->eword == 0 && key->echar != 0; /* -k1.x,1.y */
+ if (!gkey_only && !tab_length && !line_offset
- if (!gkey_only && tab == TAB_DEFAULT && !line_offset - if (!gkey_only && tab == TAB_DEFAULT && !line_offset
+ if (!gkey_only && !tab_length && !line_offset
&& ((!key->skipsblanks && !(implicit_skip || maybe_space_aligned)) && ((!key->skipsblanks && !(implicit_skip || maybe_space_aligned))
|| (!key->skipsblanks && key->schar) || (!key->skipsblanks && key->schar)
|| (!key->skipeblanks && key->echar))) || (!key->skipeblanks && key->echar)))
@@ -2457,11 +2818,87 @@ key_warnings (struct keyfield const *gke @@ -2490,11 +2851,87 @@ key_warnings (struct keyfield const *gke
error (0, 0, _("option '-r' only applies to last-resort comparison")); error (0, 0, _("option '-r' only applies to last-resort comparison"));
} }
@ -3071,21 +3071,21 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
are no more keys or a difference is found. */ are no more keys or a difference is found. */
static int static int
+keycompare_uni (const struct line *a, const struct line *b)
-keycompare (struct line const *a, struct line const *b) -keycompare (struct line const *a, struct line const *b)
+keycompare_uni (const struct line *a, const struct line *b)
{ {
struct keyfield *key = keylist; struct keyfield *key = keylist;
@@ -2546,7 +2983,7 @@ keycompare_uni (const struct line *a, co @@ -2579,7 +3016,7 @@ keycompare (struct line const *a, struct
else if (key->human_numeric) else if (key->human_numeric)
diff = human_numcompare (ta, tb); diff = human_numcompare (ta, tb);
else if (key->month) else if (key->month)
+ diff = getmonth (ta, tlena, NULL) - getmonth (tb, tlenb, NULL);
- diff = getmonth (ta, NULL) - getmonth (tb, NULL); - diff = getmonth (ta, NULL) - getmonth (tb, NULL);
+ diff = getmonth (ta, tlena, NULL) - getmonth (tb, tlenb, NULL);
else if (key->random) else if (key->random)
diff = compare_random (ta, tlena, tb, tlenb); diff = compare_random (ta, tlena, tb, tlenb);
else if (key->version) else if (key->version)
@@ -2662,6 +3099,191 @@ keycompare_uni (const struct line *a, co @@ -2695,6 +3132,191 @@ keycompare (struct line const *a, struct
return key->reverse ? -diff : diff; return key->reverse ? -diff : diff;
} }
@ -3277,7 +3277,7 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
/* Compare two lines A and B, returning negative, zero, or positive /* Compare two lines A and B, returning negative, zero, or positive
depending on whether A compares less than, equal to, or greater than B. */ depending on whether A compares less than, equal to, or greater than B. */
@@ -2689,14 +3311,6 @@ compare (struct line const *a, struct li @@ -2722,14 +3344,6 @@ compare (struct line const *a, struct li
diff = - NONZERO (blen); diff = - NONZERO (blen);
else if (blen == 0) else if (blen == 0)
diff = 1; diff = 1;
@ -3292,16 +3292,16 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
else if (! (diff = memcmp (a->text, b->text, MIN (alen, blen)))) else if (! (diff = memcmp (a->text, b->text, MIN (alen, blen))))
diff = alen < blen ? -1 : alen != blen; diff = alen < blen ? -1 : alen != blen;
@@ -4157,7 +4771,7 @@ main (int argc, char **argv) @@ -4190,7 +4804,7 @@ main (int argc, char **argv)
initialize_exit_failure (SORT_FAILURE); initialize_exit_failure (SORT_FAILURE);
hard_LC_COLLATE = hard_locale (LC_COLLATE); hard_LC_COLLATE = hard_locale (LC_COLLATE);
+#if HAVE_LANGINFO_CODESET
-#if HAVE_NL_LANGINFO -#if HAVE_NL_LANGINFO
+#if HAVE_LANGINFO_CODESET
hard_LC_TIME = hard_locale (LC_TIME); hard_LC_TIME = hard_locale (LC_TIME);
#endif #endif
@@ -4178,6 +4792,29 @@ main (int argc, char **argv) @@ -4211,6 +4825,29 @@ main (int argc, char **argv)
thousands_sep = -1; thousands_sep = -1;
} }
@ -3331,17 +3331,18 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
have_read_stdin = false; have_read_stdin = false;
inittables (); inittables ();
@@ -4452,13 +5089,34 @@ main (int argc, char **argv) @@ -4485,13 +5122,34 @@ main (int argc, char **argv)
case 't': case 't':
{ {
- char newtab = optarg[0];
- if (! newtab)
+ char newtab[MB_LEN_MAX + 1]; + char newtab[MB_LEN_MAX + 1];
+ size_t newtab_length = 1; + size_t newtab_length = 1;
+ strncpy (newtab, optarg, MB_LEN_MAX); + strncpy (newtab, optarg, MB_LEN_MAX);
+ if (! newtab[0]) + if (! newtab[0])
- char newtab = optarg[0];
- if (! newtab)
error (SORT_FAILURE, 0, _("empty tab")); error (SORT_FAILURE, 0, _("empty tab"));
- if (optarg[1])
+#if HAVE_MBRTOWC +#if HAVE_MBRTOWC
+ if (MB_CUR_MAX > 1) + if (MB_CUR_MAX > 1)
+ { + {
@ -3362,32 +3363,31 @@ diff -urNp coreutils-8.21-orig/src/sort.c coreutils-8.21/src/sort.c
+ } + }
+#endif +#endif
+ if (newtab_length == 1 && optarg[1]) + if (newtab_length == 1 && optarg[1])
- if (optarg[1])
{ {
if (STREQ (optarg, "\\0")) if (STREQ (optarg, "\\0"))
+ newtab[0] = '\0';
- newtab = '\0'; - newtab = '\0';
+ newtab[0] = '\0';
else else
{ {
/* Provoke with 'sort -txx'. Complain about /* Provoke with 'sort -txx'. Complain about
@@ -4469,9 +5127,12 @@ main (int argc, char **argv) @@ -4502,9 +5160,12 @@ main (int argc, char **argv)
quote (optarg)); quote (optarg));
} }
} }
- if (tab != TAB_DEFAULT && tab != newtab)
+ if (tab_length + if (tab_length
+ && (tab_length != newtab_length + && (tab_length != newtab_length
+ || memcmp (tab, newtab, tab_length) != 0)) + || memcmp (tab, newtab, tab_length) != 0))
- if (tab != TAB_DEFAULT && tab != newtab)
error (SORT_FAILURE, 0, _("incompatible tabs")); error (SORT_FAILURE, 0, _("incompatible tabs"));
- tab = newtab;
+ memcpy (tab, newtab, newtab_length); + memcpy (tab, newtab, newtab_length);
+ tab_length = newtab_length; + tab_length = newtab_length;
- tab = newtab;
} }
break; break;
diff -urNp coreutils-8.21-orig/src/unexpand.c coreutils-8.21/src/unexpand.c diff -urNp coreutils-8.22-orig/src/unexpand.c coreutils-8.22/src/unexpand.c
--- coreutils-8.21-orig/src/unexpand.c 2013-01-31 01:46:24.000000000 +0100 --- coreutils-8.22-orig/src/unexpand.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/src/unexpand.c 2013-02-15 14:25:07.834467715 +0100 +++ coreutils-8.22/src/unexpand.c 2013-12-16 17:40:25.951881910 +0100
@@ -38,12 +38,29 @@ @@ -38,12 +38,29 @@
#include <stdio.h> #include <stdio.h>
#include <getopt.h> #include <getopt.h>
@ -3629,7 +3629,7 @@ diff -urNp coreutils-8.21-orig/src/unexpand.c coreutils-8.21/src/unexpand.c
void void
usage (int status) usage (int status)
{ {
@@ -523,7 +742,12 @@ main (int argc, char **argv) @@ -523,7 +744,12 @@ main (int argc, char **argv)
file_list = (optind < argc ? &argv[optind] : stdin_argv); file_list = (optind < argc ? &argv[optind] : stdin_argv);
@ -3643,9 +3643,9 @@ diff -urNp coreutils-8.21-orig/src/unexpand.c coreutils-8.21/src/unexpand.c
if (have_read_stdin && fclose (stdin) != 0) if (have_read_stdin && fclose (stdin) != 0)
error (EXIT_FAILURE, errno, "-"); error (EXIT_FAILURE, errno, "-");
diff -urNp coreutils-8.21-orig/src/uniq.c coreutils-8.21/src/uniq.c diff -urNp coreutils-8.22-orig/src/uniq.c coreutils-8.22/src/uniq.c
--- coreutils-8.21-orig/src/uniq.c 2013-01-31 01:46:24.000000000 +0100 --- coreutils-8.22-orig/src/uniq.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/src/uniq.c 2013-02-15 14:25:07.839467991 +0100 +++ coreutils-8.22/src/uniq.c 2013-12-16 17:41:06.711697074 +0100
@@ -21,6 +21,16 @@ @@ -21,6 +21,16 @@
#include <getopt.h> #include <getopt.h>
#include <sys/types.h> #include <sys/types.h>
@ -3684,7 +3684,7 @@ diff -urNp coreutils-8.21-orig/src/uniq.c coreutils-8.21/src/uniq.c
/* The official name of this program (e.g., no 'g' prefix). */ /* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "uniq" #define PROGRAM_NAME "uniq"
@@ -108,6 +130,10 @@ @@ -143,6 +165,10 @@ enum
GROUP_OPTION = CHAR_MAX + 1 GROUP_OPTION = CHAR_MAX + 1
}; };
@ -3695,7 +3695,7 @@ diff -urNp coreutils-8.21-orig/src/uniq.c coreutils-8.21/src/uniq.c
static struct option const longopts[] = static struct option const longopts[] =
{ {
{"count", no_argument, NULL, 'c'}, {"count", no_argument, NULL, 'c'},
@@ -205,7 +231,7 @@ size_opt (char const *opt, char const *m @@ -249,7 +275,7 @@ size_opt (char const *opt, char const *m
return a pointer to the beginning of the line's field to be compared. */ return a pointer to the beginning of the line's field to be compared. */
static char * _GL_ATTRIBUTE_PURE static char * _GL_ATTRIBUTE_PURE
@ -3704,7 +3704,7 @@ diff -urNp coreutils-8.21-orig/src/uniq.c coreutils-8.21/src/uniq.c
{ {
size_t count; size_t count;
char const *lp = line->buffer; char const *lp = line->buffer;
@@ -225,6 +251,83 @@ find_field (struct linebuffer const *lin @@ -269,6 +295,83 @@ find_field (struct linebuffer const *lin
return line->buffer + i; return line->buffer + i;
} }
@ -3788,7 +3788,7 @@ diff -urNp coreutils-8.21-orig/src/uniq.c coreutils-8.21/src/uniq.c
/* Return false if two strings OLD and NEW match, true if not. /* Return false if two strings OLD and NEW match, true if not.
OLD and NEW point not to the beginnings of the lines OLD and NEW point not to the beginnings of the lines
but rather to the beginnings of the fields to compare. but rather to the beginnings of the fields to compare.
@@ -233,6 +336,8 @@ find_field (struct linebuffer const *lin @@ -277,6 +380,8 @@ find_field (struct linebuffer const *lin
static bool static bool
different (char *old, char *new, size_t oldlen, size_t newlen) different (char *old, char *new, size_t oldlen, size_t newlen)
{ {
@ -3797,7 +3797,7 @@ diff -urNp coreutils-8.21-orig/src/uniq.c coreutils-8.21/src/uniq.c
if (check_chars < oldlen) if (check_chars < oldlen)
oldlen = check_chars; oldlen = check_chars;
if (check_chars < newlen) if (check_chars < newlen)
@@ -240,14 +345,100 @@ different (char *old, char *new, size_t @@ -284,14 +389,100 @@ different (char *old, char *new, size_t
if (ignore_case) if (ignore_case)
{ {
@ -3903,7 +3903,7 @@ diff -urNp coreutils-8.21-orig/src/uniq.c coreutils-8.21/src/uniq.c
/* Output the line in linebuffer LINE to standard output /* Output the line in linebuffer LINE to standard output
provided that the switches say it should be output. provided that the switches say it should be output.
@@ -303,18 +494,45 @@ check_file (const char *infile, const ch @@ -356,18 +547,55 @@ check_file (const char *infile, const ch
char *prevfield IF_LINT ( = NULL); char *prevfield IF_LINT ( = NULL);
size_t prevlen IF_LINT ( = 0); size_t prevlen IF_LINT ( = 0);
bool first_group_printed = false; bool first_group_printed = false;
@ -3932,8 +3932,16 @@ diff -urNp coreutils-8.21-orig/src/uniq.c coreutils-8.21/src/uniq.c
+ { + {
+ thisstate = thisline->state; + thisstate = thisline->state;
+ +
+ if (prevline->length == 0 || different_multi + new_group = (prevline->length == 0 || different_multi
+ (thisfield, prevfield, thislen, prevlen, thisstate, prevstate)) + (thisfield, prevfield, thislen, prevlen, thisstate, prevstate));
+
+ if (new_group && grouping != GM_NONE
+ && (grouping == GM_PREPEND || grouping == GM_BOTH
+ || (first_group_printed && (grouping == GM_APPEND
+ || grouping == GM_SEPARATE))))
+ putchar (delimiter);
+
+ if (new_group || grouping != GM_NONE)
+ { + {
+ fwrite (thisline->buffer, sizeof (char), + fwrite (thisline->buffer, sizeof (char),
+ thisline->length, stdout); + thisline->length, stdout);
@ -3942,14 +3950,35 @@ diff -urNp coreutils-8.21-orig/src/uniq.c coreutils-8.21/src/uniq.c
+ prevfield = thisfield; + prevfield = thisfield;
+ prevlen = thislen; + prevlen = thislen;
+ prevstate = thisstate; + prevstate = thisstate;
+ first_group_printed = true;
+ } + }
+ } + }
+ else + else
+ {
+#endif +#endif
new_group = (prevline->length == 0 new_group = (prevline->length == 0
|| different (thisfield, prevfield, thislen, prevlen)); || different (thisfield, prevfield, thislen, prevlen));
@@ -330,17 +549,26 @@ check_file (const char *infile, const ch @@ -376,7 +604,7 @@ check_file (const char *infile, const ch
&& (grouping == GM_PREPEND || grouping == GM_BOTH
|| (first_group_printed && (grouping == GM_APPEND
|| grouping == GM_SEPARATE))))
- putchar (delimiter);
+ putchar (delimiter);
if (new_group || grouping != GM_NONE)
{
@@ -388,6 +616,9 @@ check_file (const char *infile, const ch
prevlen = thislen;
first_group_printed = true;
}
+#if HAVE_MBRTOWC
+ }
+#endif
}
if ((grouping == GM_BOTH || grouping == GM_APPEND) && first_group_printed)
putchar (delimiter);
@@ -398,17 +629,26 @@ check_file (const char *infile, const ch
size_t prevlen; size_t prevlen;
uintmax_t match_count = 0; uintmax_t match_count = 0;
bool first_delimiter = true; bool first_delimiter = true;
@ -3976,7 +4005,7 @@ diff -urNp coreutils-8.21-orig/src/uniq.c coreutils-8.21/src/uniq.c
if (readlinebuffer_delim (thisline, stdin, delimiter) == 0) if (readlinebuffer_delim (thisline, stdin, delimiter) == 0)
{ {
if (ferror (stdin)) if (ferror (stdin))
@@ -349,6 +577,14 @@ check_file (const char *infile, const ch @@ -417,6 +657,14 @@ check_file (const char *infile, const ch
} }
thisfield = find_field (thisline); thisfield = find_field (thisline);
thislen = thisline->length - 1 - (thisfield - thisline->buffer); thislen = thisline->length - 1 - (thisfield - thisline->buffer);
@ -3991,7 +4020,7 @@ diff -urNp coreutils-8.21-orig/src/uniq.c coreutils-8.21/src/uniq.c
match = !different (thisfield, prevfield, thislen, prevlen); match = !different (thisfield, prevfield, thislen, prevlen);
match_count += match; match_count += match;
@@ -381,6 +617,9 @@ check_file (const char *infile, const ch @@ -449,6 +697,9 @@ check_file (const char *infile, const ch
SWAP_LINES (prevline, thisline); SWAP_LINES (prevline, thisline);
prevfield = thisfield; prevfield = thisfield;
prevlen = thislen; prevlen = thislen;
@ -4001,7 +4030,7 @@ diff -urNp coreutils-8.21-orig/src/uniq.c coreutils-8.21/src/uniq.c
if (!match) if (!match)
match_count = 0; match_count = 0;
} }
@@ -426,6 +665,19 @@ main (int argc, char **argv) @@ -495,6 +746,19 @@ main (int argc, char **argv)
atexit (close_stdout); atexit (close_stdout);
@ -4021,10 +4050,10 @@ diff -urNp coreutils-8.21-orig/src/uniq.c coreutils-8.21/src/uniq.c
skip_chars = 0; skip_chars = 0;
skip_fields = 0; skip_fields = 0;
check_chars = SIZE_MAX; check_chars = SIZE_MAX;
diff -urNp coreutils-8.21-orig/tests/local.mk coreutils-8.21/tests/local.mk diff -urNp coreutils-8.22-orig/tests/local.mk coreutils-8.22/tests/local.mk
--- coreutils-8.21-orig/tests/local.mk 2013-02-15 14:24:32.645654553 +0100 --- coreutils-8.22-orig/tests/local.mk 2013-12-16 17:39:49.187181544 +0100
+++ coreutils-8.21/tests/local.mk 2013-02-15 14:25:07.873467648 +0100 +++ coreutils-8.22/tests/local.mk 2013-12-16 17:40:25.955880566 +0100
@@ -325,6 +325,7 @@ all_tests = \ @@ -324,6 +324,7 @@ all_tests = \
tests/misc/sort-discrim.sh \ tests/misc/sort-discrim.sh \
tests/misc/sort-files0-from.pl \ tests/misc/sort-files0-from.pl \
tests/misc/sort-float.sh \ tests/misc/sort-float.sh \
@ -4032,9 +4061,9 @@ diff -urNp coreutils-8.21-orig/tests/local.mk coreutils-8.21/tests/local.mk
tests/misc/sort-merge.pl \ tests/misc/sort-merge.pl \
tests/misc/sort-merge-fdlimit.sh \ tests/misc/sort-merge-fdlimit.sh \
tests/misc/sort-month.sh \ tests/misc/sort-month.sh \
diff -urNp coreutils-8.21-orig/tests/misc/cut.pl coreutils-8.21/tests/misc/cut.pl diff -urNp coreutils-8.22-orig/tests/misc/cut.pl coreutils-8.22/tests/misc/cut.pl
--- coreutils-8.21-orig/tests/misc/cut.pl 2013-02-05 00:40:31.000000000 +0100 --- coreutils-8.22-orig/tests/misc/cut.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/tests/misc/cut.pl 2013-11-27 19:47:58.430539269 +0100 +++ coreutils-8.22/tests/misc/cut.pl 2013-12-16 17:40:25.956880230 +0100
@@ -23,9 +23,11 @@ use strict; @@ -23,9 +23,11 @@ use strict;
# Turn off localization of executable's output. # Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
@ -4049,7 +4078,7 @@ diff -urNp coreutils-8.21-orig/tests/misc/cut.pl coreutils-8.21/tests/misc/cut.p
my $prog = 'cut'; my $prog = 'cut';
my $try = "Try '$prog --help' for more information.\n"; my $try = "Try '$prog --help' for more information.\n";
@@ -224,6 +226,7 @@ @@ -225,6 +227,7 @@ if ($mb_locale ne 'C')
my @new_t = @$t; my @new_t = @$t;
my $test_name = shift @new_t; my $test_name = shift @new_t;
@ -4057,9 +4086,9 @@ diff -urNp coreutils-8.21-orig/tests/misc/cut.pl coreutils-8.21/tests/misc/cut.p
push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}]; push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}];
} }
push @Tests, @new; push @Tests, @new;
diff -urNp coreutils-8.21-orig/tests/misc/expand.pl coreutils-8.21/tests/misc/expand.pl diff -urNp coreutils-8.22-orig/tests/misc/expand.pl coreutils-8.22/tests/misc/expand.pl
--- coreutils-8.21-orig/tests/misc/expand.pl 2013-01-31 01:46:24.000000000 +0100 --- coreutils-8.22-orig/tests/misc/expand.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/tests/misc/expand.pl 2013-11-27 19:47:58.431538769 +0100 +++ coreutils-8.22/tests/misc/expand.pl 2013-12-16 17:40:25.957879894 +0100
@@ -23,6 +23,15 @@ use strict; @@ -23,6 +23,15 @@ use strict;
# Turn off localization of executable's output. # Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
@ -4114,9 +4143,9 @@ diff -urNp coreutils-8.21-orig/tests/misc/expand.pl coreutils-8.21/tests/misc/ex
my $save_temps = $ENV{DEBUG}; my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE}; my $verbose = $ENV{VERBOSE};
diff -urNp coreutils-8.21-orig/tests/misc/fold.pl coreutils-8.21/tests/misc/fold.pl diff -urNp coreutils-8.22-orig/tests/misc/fold.pl coreutils-8.22/tests/misc/fold.pl
--- coreutils-8.21-orig/tests/misc/fold.pl 2013-01-31 01:46:24.000000000 +0100 --- coreutils-8.22-orig/tests/misc/fold.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/tests/misc/fold.pl 2013-11-27 19:47:58.431538769 +0100 +++ coreutils-8.22/tests/misc/fold.pl 2013-12-16 17:40:25.958879558 +0100
@@ -20,9 +20,18 @@ use strict; @@ -20,9 +20,18 @@ use strict;
(my $program_name = $0) =~ s|.*/||; (my $program_name = $0) =~ s|.*/||;
@ -4186,9 +4215,9 @@ diff -urNp coreutils-8.21-orig/tests/misc/fold.pl coreutils-8.21/tests/misc/fold
-my $prog = 'fold'; -my $prog = 'fold';
my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose); my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
exit $fail; exit $fail;
diff -urNp coreutils-8.21-orig/tests/misc/join.pl coreutils-8.21/tests/misc/join.pl diff -urNp coreutils-8.22-orig/tests/misc/join.pl coreutils-8.22/tests/misc/join.pl
--- coreutils-8.21-orig/tests/misc/join.pl 2013-01-31 01:46:24.000000000 +0100 --- coreutils-8.22-orig/tests/misc/join.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/tests/misc/join.pl 2013-11-27 19:47:58.432538269 +0100 +++ coreutils-8.22/tests/misc/join.pl 2013-12-16 17:40:25.959879222 +0100
@@ -25,6 +25,15 @@ my $limits = getlimits (); @@ -25,6 +25,15 @@ my $limits = getlimits ();
my $prog = 'join'; my $prog = 'join';
@ -4205,7 +4234,7 @@ diff -urNp coreutils-8.21-orig/tests/misc/join.pl coreutils-8.21/tests/misc/join
my $delim = chr 0247; my $delim = chr 0247;
sub t_subst ($) sub t_subst ($)
{ {
@@ -306,8 +315,49 @@ foreach my $t (@tv) @@ -326,8 +335,49 @@ foreach my $t (@tv)
push @Tests, $new_ent; push @Tests, $new_ent;
} }
@ -4255,9 +4284,9 @@ diff -urNp coreutils-8.21-orig/tests/misc/join.pl coreutils-8.21/tests/misc/join
my $save_temps = $ENV{DEBUG}; my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE}; my $verbose = $ENV{VERBOSE};
diff -urNp coreutils-8.21-orig/tests/misc/sort-mb-tests.sh coreutils-8.21/tests/misc/sort-mb-tests.sh diff -urNp coreutils-8.22-orig/tests/misc/sort-mb-tests.sh coreutils-8.22/tests/misc/sort-mb-tests.sh
--- coreutils-8.21-orig/tests/misc/sort-mb-tests.sh 1970-01-01 01:00:00.000000000 +0100 --- coreutils-8.22-orig/tests/misc/sort-mb-tests.sh 1970-01-01 01:00:00.000000000 +0100
+++ coreutils-8.21/tests/misc/sort-mb-tests.sh 2013-02-18 17:44:03.852275681 +0100 +++ coreutils-8.22/tests/misc/sort-mb-tests.sh 2013-12-16 17:40:25.959879222 +0100
@@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
+#!/bin/sh +#!/bin/sh
+# Verify sort's multi-byte support. +# Verify sort's multi-byte support.
@ -4304,9 +4333,9 @@ diff -urNp coreutils-8.21-orig/tests/misc/sort-mb-tests.sh coreutils-8.21/tests/
+compare exp out || { fail=1; cat out; } +compare exp out || { fail=1; cat out; }
+ +
+Exit $fail +Exit $fail
diff -urNp coreutils-8.21-orig/tests/misc/sort-merge.pl coreutils-8.21/tests/misc/sort-merge.pl diff -urNp coreutils-8.22-orig/tests/misc/sort-merge.pl coreutils-8.22/tests/misc/sort-merge.pl
--- coreutils-8.21-orig/tests/misc/sort-merge.pl 2013-01-31 01:46:24.000000000 +0100 --- coreutils-8.22-orig/tests/misc/sort-merge.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/tests/misc/sort-merge.pl 2013-11-27 19:47:58.435536769 +0100 +++ coreutils-8.22/tests/misc/sort-merge.pl 2013-12-16 17:40:25.960878886 +0100
@@ -26,6 +26,15 @@ my $prog = 'sort'; @@ -26,6 +26,15 @@ my $prog = 'sort';
# Turn off localization of executable's output. # Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
@ -4363,9 +4392,9 @@ diff -urNp coreutils-8.21-orig/tests/misc/sort-merge.pl coreutils-8.21/tests/mis
my $save_temps = $ENV{DEBUG}; my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE}; my $verbose = $ENV{VERBOSE};
diff -urNp coreutils-8.21-orig/tests/misc/sort.pl coreutils-8.21/tests/misc/sort.pl diff -urNp coreutils-8.22-orig/tests/misc/sort.pl coreutils-8.22/tests/misc/sort.pl
--- coreutils-8.21-orig/tests/misc/sort.pl 2013-01-31 01:46:24.000000000 +0100 --- coreutils-8.22-orig/tests/misc/sort.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/tests/misc/sort.pl 2013-11-27 19:47:58.436536269 +0100 +++ coreutils-8.22/tests/misc/sort.pl 2013-12-16 17:40:25.962878214 +0100
@@ -24,10 +24,15 @@ my $prog = 'sort'; @@ -24,10 +24,15 @@ my $prog = 'sort';
# Turn off localization of executable's output. # Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3; @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
@ -4383,11 +4412,10 @@ diff -urNp coreutils-8.21-orig/tests/misc/sort.pl coreutils-8.21/tests/misc/sort
# Since each test is run with a file name and with redirected stdin, # Since each test is run with a file name and with redirected stdin,
# the name in the diagnostic is either the file name or "-". # the name in the diagnostic is either the file name or "-".
# Normalize each diagnostic to use '-'. # Normalize each diagnostic to use '-'.
@@ -414,6 +419,37 @@ @@ -415,6 +420,37 @@ foreach my $t (@Tests)
and push (@$t, {ENV=>'_POSIX2_VERSION=199209'}), last;
} }
} }
+
+if ($mb_locale ne 'C') +if ($mb_locale ne 'C')
+ { + {
+ # Duplicate each test vector, appending "-mb" to the test name and + # Duplicate each test vector, appending "-mb" to the test name and
@ -4418,9 +4446,10 @@ diff -urNp coreutils-8.21-orig/tests/misc/sort.pl coreutils-8.21/tests/misc/sort
+ } + }
+ push @Tests, @new; + push @Tests, @new;
+ } + }
+
@Tests = triple_test \@Tests; @Tests = triple_test \@Tests;
# Remember that triple_test creates from each test with exactly one "IN"
@@ -424,6 +460,7 @@ foreach my $t (@Tests) @@ -424,6 +460,7 @@ foreach my $t (@Tests)
# Remove the IN_PIPE version of the "output-is-input" test above. # Remove the IN_PIPE version of the "output-is-input" test above.
# The others aren't susceptible because they have three inputs each. # The others aren't susceptible because they have three inputs each.
@ -4429,9 +4458,9 @@ diff -urNp coreutils-8.21-orig/tests/misc/sort.pl coreutils-8.21/tests/misc/sort
my $save_temps = $ENV{DEBUG}; my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE}; my $verbose = $ENV{VERBOSE};
diff -urNp coreutils-8.21-orig/tests/misc/unexpand.pl coreutils-8.21/tests/misc/unexpand.pl diff -urNp coreutils-8.22-orig/tests/misc/unexpand.pl coreutils-8.22/tests/misc/unexpand.pl
--- coreutils-8.21-orig/tests/misc/unexpand.pl 2013-01-31 01:46:24.000000000 +0100 --- coreutils-8.22-orig/tests/misc/unexpand.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/tests/misc/unexpand.pl 2013-11-27 19:47:58.436536269 +0100 +++ coreutils-8.22/tests/misc/unexpand.pl 2013-12-16 17:40:25.962878214 +0100
@@ -27,6 +27,14 @@ my $limits = getlimits (); @@ -27,6 +27,14 @@ my $limits = getlimits ();
my $prog = 'unexpand'; my $prog = 'unexpand';
@ -4485,9 +4514,9 @@ diff -urNp coreutils-8.21-orig/tests/misc/unexpand.pl coreutils-8.21/tests/misc/
my $save_temps = $ENV{DEBUG}; my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE}; my $verbose = $ENV{VERBOSE};
diff -urNp coreutils-8.21-orig/tests/misc/uniq.pl coreutils-8.21/tests/misc/uniq.pl diff -urNp coreutils-8.22-orig/tests/misc/uniq.pl coreutils-8.22/tests/misc/uniq.pl
--- coreutils-8.21-orig/tests/misc/uniq.pl 2013-01-31 01:46:25.000000000 +0100 --- coreutils-8.22-orig/tests/misc/uniq.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/tests/misc/uniq.pl 2013-11-27 19:47:58.437535769 +0100 +++ coreutils-8.22/tests/misc/uniq.pl 2013-12-16 17:41:34.077961751 +0100
@@ -23,9 +23,17 @@ my $limits = getlimits (); @@ -23,9 +23,17 @@ my $limits = getlimits ();
my $prog = 'uniq'; my $prog = 'uniq';
my $try = "Try '$prog --help' for more information.\n"; my $try = "Try '$prog --help' for more information.\n";
@ -4506,11 +4535,10 @@ diff -urNp coreutils-8.21-orig/tests/misc/uniq.pl coreutils-8.21/tests/misc/uniq
# When possible, create a "-z"-testing variant of each test. # When possible, create a "-z"-testing variant of each test.
sub add_z_variants($) sub add_z_variants($)
{ {
@@ -207,7 +215,45 @@ @@ -261,6 +269,45 @@ foreach my $t (@Tests)
$t->[0] =~ /^obs-plus/
and push @$t, {ENV=>'_POSIX2_VERSION=199209'}; and push @$t, {ENV=>'_POSIX2_VERSION=199209'};
} }
+
+if ($mb_locale ne 'C') +if ($mb_locale ne 'C')
+ { + {
+ # Duplicate each test vector, appending "-mb" to the test name and + # Duplicate each test vector, appending "-mb" to the test name and
@ -4534,12 +4562,13 @@ diff -urNp coreutils-8.21-orig/tests/misc/uniq.pl coreutils-8.21/tests/misc/uniq
+ push @new_t, $sub; + push @new_t, $sub;
+ push @$t, $sub; + push @$t, $sub;
+ } + }
+ next if ($test_name =~ "schar" or $test_name =~ "^obs-plus" or $test_name =~ "119" or $test_name =~ "128" or $test_name =~ "129" or $test_name =~ "130" or $test_name =~ "131" or $test_name =~ "132" or $test_name =~ "133" or $test_name =~ "145"); + next if ($test_name =~ "schar" or $test_name =~ "^obs-plus"
+ or $test_name =~ "119" or $test_name =~ "145");
+ push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}]; + push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}];
+ } + }
+ push @Tests, @new; + push @Tests, @new;
+ } + }
+
+# Remember that triple_test creates from each test with exactly one "IN" +# Remember that triple_test creates from each test with exactly one "IN"
+# file two more tests (.p and .r suffix on name) corresponding to reading +# file two more tests (.p and .r suffix on name) corresponding to reading
+# input from a file and from a pipe. The pipe-reading test would fail +# input from a file and from a pipe. The pipe-reading test would fail
@ -4552,9 +4581,9 @@ diff -urNp coreutils-8.21-orig/tests/misc/uniq.pl coreutils-8.21/tests/misc/uniq
@Tests = add_z_variants \@Tests; @Tests = add_z_variants \@Tests;
@Tests = triple_test \@Tests; @Tests = triple_test \@Tests;
diff -urNp coreutils-8.21-orig/tests/pr/pr-tests.pl coreutils-8.21/tests/pr/pr-tests.pl diff -urNp coreutils-8.22-orig/tests/pr/pr-tests.pl coreutils-8.22/tests/pr/pr-tests.pl
--- coreutils-8.21-orig/tests/pr/pr-tests.pl 2013-01-31 01:46:25.000000000 +0100 --- coreutils-8.22-orig/tests/pr/pr-tests.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.21/tests/pr/pr-tests.pl 2013-11-27 19:48:12.683409258 +0100 +++ coreutils-8.22/tests/pr/pr-tests.pl 2013-12-16 17:40:25.965877206 +0100
@@ -23,6 +23,15 @@ use strict; @@ -23,6 +23,15 @@ use strict;
my $prog = 'pr'; my $prog = 'pr';