-diff -urNp coreutils-8.13-orig/lib/linebuffer.h coreutils-8.13/lib/linebuffer.h
---- coreutils-8.13-orig/lib/linebuffer.h 2011-04-24 19:21:45.000000000 +0200
-+++ coreutils-8.13/lib/linebuffer.h 2011-09-09 10:23:14.163704760 +0200
+diff -urNp coreutils-8.16-orig/lib/linebuffer.h coreutils-8.16/lib/linebuffer.h
+--- coreutils-8.16-orig/lib/linebuffer.h 2012-01-06 10:14:31.000000000 +0100
++++ coreutils-8.16/lib/linebuffer.h 2012-03-26 18:02:00.993889446 +0200
@@ -21,6 +21,11 @@
# include <stdio.h>
};
/* Initialize linebuffer LINEBUFFER for use. */
-diff -urNp coreutils-8.13-orig/src/cut.c coreutils-8.13/src/cut.c
---- coreutils-8.13-orig/src/cut.c 2011-07-28 12:38:27.000000000 +0200
-+++ coreutils-8.13/src/cut.c 2011-09-09 10:23:14.165701039 +0200
+diff -urNp coreutils-8.16-orig/src/cut.c coreutils-8.16/src/cut.c
+--- coreutils-8.16-orig/src/cut.c 2012-03-24 21:26:51.000000000 +0100
++++ coreutils-8.16/src/cut.c 2012-03-26 17:46:48.000000000 +0200
@@ -28,6 +28,11 @@
#include <assert.h>
#include <getopt.h>
+# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
+#endif
+
- /* 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 "cut"
@@ -72,6 +89,52 @@
+/* The largest byte, character or field index used as an endpoint of a closed
or degenerate range specification; this doesn't include the starting
index of right-open-ended ranges. For example, with either range spec
- `2-5,9-', `2-3,5,9-' this variable would be set to 5. */
+ '2-5,9-', '2-3,5,9-' this variable would be set to 5. */
@@ -102,10 +165,11 @@ static size_t eol_range_start;
/* This is a bit vector.
/* True if the --output-delimiter=STRING option was specified. */
static bool output_delimiter_specified;
-@@ -207,7 +284,7 @@ Mandatory arguments to long options are
+@@ -206,7 +283,7 @@ Mandatory arguments to long options are
-f, --fields=LIST select only these fields; also print any line\n\
that contains no delimiter character, unless\n\
the -s option is specified\n\
"), stdout);
fputs (_("\
--complement complement the set of selected bytes, characters\n\
-@@ -366,7 +443,7 @@ set_fields (const char *fieldstr)
+@@ -365,7 +442,7 @@ set_fields (const char *fieldstr)
in_digits = false;
/* Starting a range. */
if (dash_found)
dash_found = true;
fieldstr++;
-@@ -390,14 +467,16 @@ set_fields (const char *fieldstr)
+@@ -389,14 +466,16 @@ set_fields (const char *fieldstr)
if (!rhs_specified)
{
- /* `n-'. From `initial' to end of line. */
+ /* 'n-'. From 'initial' to end of line. */
- eol_range_start = initial;
+ if (eol_range_start == 0 ||
+ (eol_range_start != 0 && eol_range_start > initial))
}
else
{
- /* `m-n' or `-n' (1-n). */
+ /* 'm-n' or '-n' (1-n). */
if (value < initial)
- FATAL_ERROR (_("invalid decreasing range"));
+ FATAL_ERROR (_("invalid byte, character or field list"));
/* Is there already a range going to end of line? */
if (eol_range_start != 0)
-@@ -477,6 +556,9 @@ set_fields (const char *fieldstr)
+@@ -476,6 +555,9 @@ set_fields (const char *fieldstr)
if (operating_mode == byte_mode)
error (0, 0,
_("byte offset %s is too large"), quote (bad_num));
else
error (0, 0,
_("field number %s is too large"), quote (bad_num));
-@@ -487,7 +569,7 @@ set_fields (const char *fieldstr)
+@@ -486,7 +568,7 @@ set_fields (const char *fieldstr)
fieldstr++;
}
else
}
max_range_endpoint = 0;
-@@ -582,6 +664,77 @@ cut_bytes (FILE *stream)
+@@ -581,6 +663,77 @@ cut_bytes (FILE *stream)
}
}
/* Read from stream STREAM, printing to standard output any selected fields. */
static void
-@@ -704,13 +843,195 @@ cut_fields (FILE *stream)
+@@ -703,13 +856,195 @@ cut_fields (FILE *stream)
}
}
}
/* Process file FILE to standard output.
-@@ -762,6 +1080,8 @@ main (int argc, char **argv)
+@@ -761,6 +1096,8 @@ main (int argc, char **argv)
bool ok;
bool delim_specified = false;
char *spec_list_string IF_LINT ( = NULL);
initialize_main (&argc, &argv);
set_program_name (argv[0]);
-@@ -784,7 +1104,6 @@ main (int argc, char **argv)
+@@ -783,7 +1120,6 @@ main (int argc, char **argv)
switch (optc)
{
case 'b':
/* Build the byte list. */
if (operating_mode != undefined_mode)
FATAL_ERROR (_("only one type of list may be specified"));
-@@ -792,6 +1111,14 @@ main (int argc, char **argv)
+@@ -791,6 +1127,14 @@ main (int argc, char **argv)
spec_list_string = optarg;
break;
case 'f':
/* Build the field list. */
if (operating_mode != undefined_mode)
-@@ -803,10 +1130,35 @@ main (int argc, char **argv)
+@@ -802,10 +1146,35 @@ main (int argc, char **argv)
case 'd':
/* New delimiter. */
- /* Interpret -d '' to mean `use the NUL byte as the 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];
break;
case OUTPUT_DELIMITER_OPTION:
-@@ -819,6 +1171,7 @@ main (int argc, char **argv)
+@@ -818,6 +1187,7 @@ main (int argc, char **argv)
break;
case 'n':
break;
case 's':
-@@ -841,7 +1194,7 @@ main (int argc, char **argv)
+@@ -840,7 +1210,7 @@ main (int argc, char **argv)
if (operating_mode == undefined_mode)
FATAL_ERROR (_("you must specify a list of bytes, characters, or fields"));
FATAL_ERROR (_("an input delimiter may be specified only\
when operating on fields"));
-@@ -868,15 +1221,34 @@ main (int argc, char **argv)
+@@ -867,15 +1237,34 @@ main (int argc, char **argv)
}
if (!delim_specified)
}
if (optind == argc)
-diff -urNp coreutils-8.13-orig/src/expand.c coreutils-8.13/src/expand.c
---- coreutils-8.13-orig/src/expand.c 2011-07-28 12:38:27.000000000 +0200
-+++ coreutils-8.13/src/expand.c 2011-09-09 10:23:14.167583399 +0200
-@@ -38,12 +38,29 @@
+diff -urNp coreutils-8.16-orig/src/expand.c coreutils-8.16/src/expand.c
+--- coreutils-8.16-orig/src/expand.c 2012-03-24 21:26:51.000000000 +0100
++++ coreutils-8.16/src/expand.c 2012-03-26 17:42:56.000000000 +0200
+@@ -37,12 +37,29 @@
#include <stdio.h>
#include <getopt.h>
#include <sys/types.h>
+# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
+#endif
+
- /* 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 "expand"
-@@ -360,6 +377,142 @@ expand (void)
+@@ -358,6 +375,142 @@ expand (void)
}
}
int
main (int argc, char **argv)
{
-@@ -424,7 +577,12 @@ main (int argc, char **argv)
+@@ -422,7 +575,12 @@ main (int argc, char **argv)
file_list = (optind < argc ? &argv[optind] : stdin_argv);
if (have_read_stdin && fclose (stdin) != 0)
error (EXIT_FAILURE, errno, "-");
-diff -urNp coreutils-8.13-orig/src/fold.c coreutils-8.13/src/fold.c
---- coreutils-8.13-orig/src/fold.c 2011-07-28 12:38:27.000000000 +0200
-+++ coreutils-8.13/src/fold.c 2011-09-09 10:23:14.169583741 +0200
+diff -urNp coreutils-8.16-orig/src/fold.c coreutils-8.16/src/fold.c
+--- coreutils-8.16-orig/src/fold.c 2012-03-24 19:22:13.000000000 +0100
++++ coreutils-8.16/src/fold.c 2012-03-26 17:48:37.000000000 +0200
@@ -22,12 +22,34 @@
#include <getopt.h>
#include <sys/types.h>
+
#define TAB_WIDTH 8
- /* The official name of this program (e.g., no `g' prefix). */
+ /* The official name of this program (e.g., no 'g' prefix). */
@@ -35,20 +57,41 @@
#define AUTHORS proper_name ("David MacKenzie")
{"spaces", no_argument, NULL, 's'},
{"width", required_argument, NULL, 'w'},
{GETOPT_HELP_OPTION_DECL},
-@@ -78,6 +121,7 @@ Mandatory arguments to long options are
+@@ -77,6 +120,7 @@ Mandatory arguments to long options are
"), stdout);
fputs (_("\
-b, --bytes count bytes rather than columns\n\
-s, --spaces break at spaces\n\
-w, --width=WIDTH use WIDTH columns instead of 80\n\
"), stdout);
-@@ -95,7 +139,7 @@ Mandatory arguments to long options are
+@@ -94,7 +138,7 @@ Mandatory arguments to long options are
static size_t
adjust_column (size_t column, char c)
{
{
if (c == '\b')
{
-@@ -118,30 +162,14 @@ adjust_column (size_t column, char c)
+@@ -117,30 +161,14 @@ adjust_column (size_t column, char c)
to stdout, with maximum line length WIDTH.
Return true if successful. */
- FILE *istream;
int c;
size_t column = 0; /* Screen column where next char will go. */
- size_t offset_out = 0; /* Index in `line_out' for next char. */
+ size_t offset_out = 0; /* Index in 'line_out' for next char. */
static char *line_out = NULL;
static size_t allocated_out = 0;
- int saved_errno;
fadvise (istream, FADVISE_SEQUENTIAL);
-@@ -171,6 +199,15 @@ fold_file (char const *filename, size_t
+@@ -170,6 +198,15 @@ fold_file (char const *filename, size_t
bool found_blank = false;
size_t logical_end = offset_out;
/* Look for the last blank. */
while (logical_end)
{
-@@ -217,11 +254,221 @@ fold_file (char const *filename, size_t
+@@ -216,11 +253,221 @@ fold_file (char const *filename, size_t
line_out[offset_out++] = c;
}
if (ferror (istream))
{
error (0, saved_errno, "%s", filename);
-@@ -254,7 +501,8 @@ main (int argc, char **argv)
+@@ -253,7 +500,8 @@ main (int argc, char **argv)
atexit (close_stdout);
while ((optc = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1)
{
-@@ -263,7 +511,15 @@ main (int argc, char **argv)
+@@ -262,7 +510,15 @@ main (int argc, char **argv)
switch (optc)
{
case 'b': /* Count bytes rather than columns. */
break;
case 's': /* Break at word boundaries. */
-diff -urNp coreutils-8.13-orig/src/join.c coreutils-8.13/src/join.c
---- coreutils-8.13-orig/src/join.c 2011-08-08 10:16:09.000000000 +0200
-+++ coreutils-8.13/src/join.c 2011-09-09 10:23:14.172687087 +0200
+diff -urNp coreutils-8.16-orig/src/join.c coreutils-8.16/src/join.c
+--- coreutils-8.16-orig/src/join.c 2012-03-24 21:26:51.000000000 +0100
++++ coreutils-8.16/src/join.c 2012-03-26 17:50:02.000000000 +0200
@@ -22,18 +22,32 @@
#include <sys/types.h>
#include <getopt.h>
+# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
+#endif
+
- /* 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 "join"
@@ -135,10 +149,12 @@ static struct outlist outlist_head;
- /* Last element in `outlist', where a new element can be added. */
+ /* Last element in 'outlist', where a new element can be added. */
static struct outlist *outlist_end = &outlist_head;
-/* Tab character separating fields. If negative, fields are separated
/* If nonzero, check that the input is correctly ordered. */
static enum
-@@ -263,13 +279,14 @@ xfields (struct line *line)
+@@ -262,13 +278,14 @@ xfields (struct line *line)
if (ptr == lim)
return;
{
/* Skip leading blanks before the first field. */
while (isblank (to_uchar (*ptr)))
-@@ -293,6 +310,148 @@ xfields (struct line *line)
+@@ -292,6 +309,148 @@ xfields (struct line *line)
extract_field (line, ptr, lim - ptr);
}
static void
freeline (struct line *line)
{
-@@ -314,56 +473,115 @@ keycmp (struct line const *line1, struct
+@@ -313,56 +472,115 @@ keycmp (struct line const *line1, struct
size_t jf_1, size_t jf_2)
{
/* Start of field to compare in each file. */
}
/* Check that successive input lines PREV and CURRENT from input file
-@@ -455,6 +673,11 @@ get_line (FILE *fp, struct line **linep,
+@@ -454,6 +672,11 @@ get_line (FILE *fp, struct line **linep,
}
++line_no[which - 1];
xfields (line);
if (prevline[which - 1])
-@@ -554,21 +777,28 @@ prfield (size_t n, struct line const *li
+@@ -553,21 +776,28 @@ prfield (size_t n, struct line const *li
/* Output all the fields in line, other than the join field. */
prfield (i, line);
}
}
-@@ -579,7 +809,6 @@ static void
+@@ -578,7 +808,6 @@ static void
prjoin (struct line const *line1, struct line const *line2)
{
const struct outlist *outlist;
size_t field;
struct line const *line;
-@@ -613,7 +842,7 @@ prjoin (struct line const *line1, struct
+@@ -612,7 +841,7 @@ prjoin (struct line const *line1, struct
o = o->next;
if (o == NULL)
break;
}
putchar ('\n');
}
-@@ -1091,21 +1320,46 @@ main (int argc, char **argv)
+@@ -1090,21 +1319,46 @@ main (int argc, char **argv)
case 't':
{
+#endif
+ newtablen = 1;
if (! newtab)
-+ {
- newtab = '\n'; /* '' => process the whole line. */
++ {
+ newtab = "\n"; /* '' => process the whole line. */
+ }
else if (optarg[1])
break;
case NOCHECK_ORDER_OPTION:
-diff -urNp coreutils-8.13-orig/src/pr.c coreutils-8.13/src/pr.c
---- coreutils-8.13-orig/src/pr.c 2011-08-30 23:01:40.000000000 +0200
-+++ coreutils-8.13/src/pr.c 2011-09-09 10:23:14.177658905 +0200
+diff -urNp coreutils-8.16-orig/src/pr.c coreutils-8.16/src/pr.c
+--- coreutils-8.16-orig/src/pr.c 2012-03-24 21:26:51.000000000 +0100
++++ coreutils-8.16/src/pr.c 2012-03-26 17:50:48.000000000 +0200
@@ -312,6 +312,32 @@
#include <getopt.h>
+extern int wcwidth ();
+#endif
+
- /* 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 "pr"
@@ -415,7 +453,20 @@ struct COLUMN
int *number);
static void print_files (int number_of_files, char **av);
static void init_parameters (int number_of_files);
-@@ -439,7 +491,6 @@ static void store_char (char c);
+@@ -438,7 +490,6 @@ static void store_char (char c);
static void pad_down (int lines);
static void read_rest_of_line (COLUMN *p);
static void skip_read (COLUMN *p, int column_number);
static void cleanup (void);
static void print_sep_string (void);
static void separator_string (const char *optarg_S);
-@@ -451,7 +502,7 @@ static COLUMN *column_vector;
+@@ -450,7 +501,7 @@ static COLUMN *column_vector;
we store the leftmost columns contiguously in buff.
To print a line from buff, get the index of the first character
from line_vector[i], and print up to line_vector[i + 1]. */
/* Index of the position in buff where the next character
will be stored. */
-@@ -555,7 +606,7 @@ static int chars_per_column;
+@@ -554,7 +605,7 @@ static int chars_per_column;
static bool untabify_input = false;
/* (-e) The input tab character. */
/* (-e) Tabstops are at chars_per_tab, 2*chars_per_tab, 3*chars_per_tab, ...
where the leftmost column is 1. */
-@@ -565,7 +616,10 @@ static int chars_per_input_tab = 8;
+@@ -564,7 +615,10 @@ static int chars_per_input_tab = 8;
static bool tabify_output = false;
/* (-i) The output tab character. */
/* (-i) The width of the output tab. */
static int chars_per_output_tab = 8;
-@@ -639,7 +693,13 @@ static int power_10;
+@@ -638,7 +692,13 @@ static int power_10;
static bool numbered_lines = false;
/* (-n) Character which follows each line number. */
/* (-n) line counting starts with 1st line of input file (not with 1st
line of 1st page printed). */
-@@ -692,6 +752,7 @@ static bool use_col_separator = false;
- -a|COLUMN|-m is a `space' and with the -J option a `tab'. */
+@@ -691,6 +751,7 @@ static bool use_col_separator = false;
+ -a|COLUMN|-m is a 'space' and with the -J option a 'tab'. */
static char *col_sep_string = (char *) "";
static int col_sep_length = 0;
+static int col_sep_width = 0;
static char *column_separator = (char *) " ";
static char *line_separator = (char *) "\t";
-@@ -848,6 +909,13 @@ separator_string (const char *optarg_S)
+@@ -847,6 +908,13 @@ separator_string (const char *optarg_S)
col_sep_length = (int) strlen (optarg_S);
col_sep_string = xmalloc (col_sep_length + 1);
strcpy (col_sep_string, optarg_S);
}
int
-@@ -872,6 +940,21 @@ main (int argc, char **argv)
+@@ -871,6 +939,21 @@ main (int argc, char **argv)
atexit (close_stdout);
n_files = 0;
file_names = (argc > 1
? xmalloc ((argc - 1) * sizeof (char *))
-@@ -948,8 +1031,12 @@ main (int argc, char **argv)
+@@ -947,8 +1030,12 @@ main (int argc, char **argv)
break;
case 'e':
if (optarg)
/* Could check tab width > 0. */
untabify_input = true;
break;
-@@ -962,8 +1049,12 @@ main (int argc, char **argv)
+@@ -961,8 +1048,12 @@ main (int argc, char **argv)
break;
case 'i':
if (optarg)
/* Could check tab width > 0. */
tabify_output = true;
break;
-@@ -990,8 +1081,8 @@ main (int argc, char **argv)
+@@ -989,8 +1080,8 @@ main (int argc, char **argv)
case 'n':
numbered_lines = true;
if (optarg)
break;
case 'N':
skip_count = false;
-@@ -1030,7 +1121,7 @@ main (int argc, char **argv)
+@@ -1029,7 +1120,7 @@ main (int argc, char **argv)
old_s = false;
/* Reset an additional input of -s, -S dominates -s */
col_sep_string = bad_cast ("");
use_col_separator = true;
if (optarg)
separator_string (optarg);
-@@ -1187,10 +1278,45 @@ main (int argc, char **argv)
+@@ -1186,10 +1277,45 @@ main (int argc, char **argv)
a number. */
static void
if (*arg)
{
long int tmp_long;
-@@ -1249,7 +1375,7 @@ init_parameters (int number_of_files)
+@@ -1211,6 +1337,11 @@ static void
+ init_parameters (int number_of_files)
+ {
+ int chars_used_by_number = 0;
++ int mb_len = 1;
++#if HAVE_MBRTOWC
++ if (MB_CUR_MAX > 1)
++ mb_len = MB_LEN_MAX;
++#endif
+
+ lines_per_body = lines_per_page - lines_per_header - lines_per_footer;
+ if (lines_per_body <= 0)
+@@ -1248,7 +1379,7 @@ init_parameters (int number_of_files)
else
col_sep_string = column_separator;
use_col_separator = true;
}
/* It's rather pointless to define a TAB separator with column
-@@ -1280,11 +1406,11 @@ init_parameters (int number_of_files)
+@@ -1279,11 +1410,11 @@ init_parameters (int number_of_files)
TAB_WIDTH (chars_per_input_tab, chars_per_number); */
/* Estimate chars_per_text without any margin and keep it constant. */
/* The number is part of the column width unless we are
printing files in parallel. */
-@@ -1299,7 +1425,7 @@ init_parameters (int number_of_files)
+@@ -1298,7 +1429,7 @@ init_parameters (int number_of_files)
}
chars_per_column = (chars_per_line - chars_used_by_number -
if (chars_per_column < 1)
error (EXIT_FAILURE, 0, _("page width too narrow"));
-@@ -1424,7 +1550,7 @@ init_funcs (void)
+@@ -1315,7 +1446,7 @@ init_parameters (int number_of_files)
+ We've to use 8 as the lower limit, if we use chars_per_default_tab = 8
+ to expand a tab which is not an input_tab-char. */
+ free (clump_buff);
+- clump_buff = xmalloc (MAX (8, chars_per_input_tab));
++ clump_buff = xmalloc (mb_len * MAX (8, chars_per_input_tab));
+ }
+ \f
+ /* Open the necessary files,
+@@ -1423,7 +1554,7 @@ init_funcs (void)
/* Enlarge p->start_position of first column to use the same form of
padding_not_printed with all columns. */
/* This loop takes care of all but the rightmost column. */
-@@ -1458,7 +1584,7 @@ init_funcs (void)
+@@ -1457,7 +1588,7 @@ init_funcs (void)
}
else
{
h_next = h + chars_per_column;
}
}
-@@ -1749,9 +1875,9 @@ static void
+@@ -1748,9 +1879,9 @@ static void
align_column (COLUMN *p)
{
padding_not_printed = p->start_position;
padding_not_printed = ANYWHERE;
}
-@@ -2022,13 +2148,13 @@ store_char (char c)
+@@ -2021,13 +2152,13 @@ store_char (char c)
/* May be too generous. */
buff = X2REALLOC (buff, &buff_allocated);
}
char *s;
int left_cut;
-@@ -2051,22 +2177,24 @@ add_line_number (COLUMN *p)
+@@ -2050,22 +2181,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
+ but 'default n-separator = TAB' hasn't been given priority over
equal column_width also specified by POSIX. */
- if (number_separator == '\t')
+ if (number_separator[0] == '\t')
output_position = POS_AFTER_TAB (chars_per_output_tab,
output_position);
}
-@@ -2227,7 +2355,7 @@ print_white_space (void)
+@@ -2226,7 +2359,7 @@ print_white_space (void)
while (goal - h_old > 1
&& (h_new = POS_AFTER_TAB (chars_per_output_tab, h_old)) <= goal)
{
h_old = h_new;
}
while (++h_old <= goal)
-@@ -2247,6 +2375,7 @@ print_sep_string (void)
+@@ -2246,6 +2379,7 @@ print_sep_string (void)
{
char *s;
int l = col_sep_length;
s = col_sep_string;
-@@ -2260,6 +2389,7 @@ print_sep_string (void)
+@@ -2259,6 +2393,7 @@ print_sep_string (void)
{
for (; separators_not_printed > 0; --separators_not_printed)
{
while (l-- > 0)
{
/* 3 types of sep_strings: spaces only, spaces and chars,
-@@ -2273,12 +2403,15 @@ print_sep_string (void)
+@@ -2272,12 +2407,15 @@ print_sep_string (void)
}
else
{
/* sep_string ends with some spaces */
if (spaces_not_printed > 0)
print_white_space ();
-@@ -2306,7 +2439,7 @@ print_clump (COLUMN *p, int n, char *clu
+@@ -2305,7 +2443,7 @@ print_clump (COLUMN *p, int n, char *clu
required number of tabs and spaces. */
static void
{
if (tabify_output)
{
-@@ -2330,6 +2463,74 @@ print_char (char c)
+@@ -2329,6 +2467,74 @@ print_char (char c)
putchar (c);
}
/* Skip to page PAGE before printing.
PAGE may be larger than total number of pages. */
-@@ -2509,9 +2710,9 @@ read_line (COLUMN *p)
+@@ -2508,9 +2714,9 @@ read_line (COLUMN *p)
align_empty_cols = false;
}
padding_not_printed = ANYWHERE;
}
-@@ -2612,9 +2813,9 @@ print_stored (COLUMN *p)
+@@ -2611,9 +2817,9 @@ print_stored (COLUMN *p)
}
}
padding_not_printed = ANYWHERE;
}
-@@ -2627,8 +2828,8 @@ print_stored (COLUMN *p)
+@@ -2626,8 +2832,8 @@ print_stored (COLUMN *p)
if (spaces_not_printed == 0)
{
output_position = p->start_position + end_vector[line];
}
return true;
-@@ -2647,7 +2848,7 @@ print_stored (COLUMN *p)
+@@ -2646,7 +2852,7 @@ print_stored (COLUMN *p)
number of characters is 1.) */
static int
{
unsigned char uc = c;
char *s = clump_buff;
-@@ -2657,10 +2858,10 @@ char_to_clump (char c)
+@@ -2656,10 +2862,10 @@ char_to_clump (char c)
int chars;
int chars_per_c = 8;
{
width = TAB_WIDTH (chars_per_c, input_position);
-@@ -2741,6 +2942,155 @@ char_to_clump (char c)
+@@ -2740,6 +2946,154 @@ char_to_clump (char c)
return chars;
}
+static int
+char_to_clump_multi (char c)
+{
-+ unsigned char uc = c;
+ static size_t mbc_pos = 0;
+ static char mbc[MB_LEN_MAX] = {'\0'};
+ static mbstate_t state = {'\0'};
+ width = +4;
+ chars = +4;
+ *s++ = '\\';
-+ sprintf (esc_buff, "%03o", mbc[0]);
++ sprintf (esc_buff, "%03o", (unsigned char) mbc[0]);
+ for (i = 0; i <= 2; ++i)
+ *s++ = (int) esc_buff[i];
+ }
+ width += 4;
+ chars += 4;
+ *s++ = '\\';
-+ sprintf (esc_buff, "%03o", uc);
++ sprintf (esc_buff, "%03o", (unsigned char) mbc[i]);
+ for (j = 0; j <= 2; ++j)
+ *s++ = (int) esc_buff[j];
+ }
+ width += 4;
+ chars += 4;
+ *s++ = '\\';
-+ sprintf (esc_buff, "%03o", uc);
++ sprintf (esc_buff, "%03o", (unsigned char) mbc[i]);
+ for (j = 0; j <= 2; ++j)
+ *s++ = (int) esc_buff[j];
+ }
/* 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 -urNp coreutils-8.13-orig/src/sort.c coreutils-8.13/src/sort.c
---- coreutils-8.13-orig/src/sort.c 2011-07-29 10:12:25.000000000 +0200
-+++ coreutils-8.13/src/sort.c 2011-09-09 10:23:14.183686800 +0200
+diff -urNp coreutils-8.16-orig/src/sort.c coreutils-8.16/src/sort.c
+--- coreutils-8.16-orig/src/sort.c 2012-03-24 21:26:51.000000000 +0100
++++ coreutils-8.16/src/sort.c 2012-03-26 17:35:09.000000000 +0200
@@ -22,11 +22,20 @@
#include <config.h>
/* Flag to remove consecutive duplicate lines from the output.
Only the last of a sequence of equal lines will be output. */
-@@ -783,6 +812,46 @@ reap_all (void)
+@@ -782,6 +811,46 @@ reap_all (void)
reap (-1);
}
/* Clean up any remaining temporary files. */
static void
-@@ -1215,7 +1284,7 @@ zaptemp (char const *name)
+@@ -1214,7 +1283,7 @@ zaptemp (char const *name)
free (node);
}
static int
struct_month_cmp (void const *m1, void const *m2)
-@@ -1230,7 +1299,7 @@ struct_month_cmp (void const *m1, void c
+@@ -1229,7 +1298,7 @@ struct_month_cmp (void const *m1, void c
/* Initialize the character class tables. */
static void
{
size_t i;
-@@ -1242,7 +1311,7 @@ inittables (void)
+@@ -1241,7 +1310,7 @@ inittables (void)
fold_toupper[i] = toupper (i);
}
/* If we're not in the "C" locale, read different names for months. */
if (hard_LC_TIME)
{
-@@ -1324,6 +1393,84 @@ specify_nmerge (int oi, char c, char con
+@@ -1323,6 +1392,84 @@ specify_nmerge (int oi, char c, char con
xstrtol_fatal (e, oi, c, long_options, s);
}
/* Specify the amount of main memory to use when sorting. */
static void
specify_sort_size (int oi, char c, char const *s)
-@@ -1552,7 +1699,7 @@ buffer_linelim (struct buffer const *buf
+@@ -1551,7 +1698,7 @@ buffer_linelim (struct buffer const *buf
by KEY in LINE. */
static char *
{
char *ptr = line->text, *lim = ptr + line->length - 1;
size_t sword = key->sword;
-@@ -1561,10 +1708,10 @@ begfield (struct line const *line, struc
+@@ -1560,10 +1707,10 @@ begfield (struct line const *line, struc
/* The leading field separator itself is included in a field when -t
is absent. */
++ptr;
if (ptr < lim)
++ptr;
-@@ -1590,11 +1737,70 @@ begfield (struct line const *line, struc
+@@ -1589,11 +1736,70 @@ begfield (struct line const *line, struc
return ptr;
}
{
char *ptr = line->text, *lim = ptr + line->length - 1;
size_t eword = key->eword, echar = key->echar;
-@@ -1609,10 +1815,10 @@ limfield (struct line const *line, struc
- `beginning' is the first character following the delimiting TAB.
- Otherwise, leave PTR pointing at the first `blank' character after
+@@ -1608,10 +1814,10 @@ limfield (struct line const *line, struc
+ 'beginning' is the first character following the delimiting TAB.
+ Otherwise, leave PTR pointing at the first 'blank' character after
the preceding field. */
- if (tab != TAB_DEFAULT)
+ if (tab_length)
++ptr;
if (ptr < lim && (eword || echar))
++ptr;
-@@ -1658,10 +1864,10 @@ limfield (struct line const *line, struc
+@@ -1657,10 +1863,10 @@ limfield (struct line const *line, struc
*/
/* Make LIM point to the end of (one byte past) the current field. */
if (newlim)
lim = newlim;
}
-@@ -1692,6 +1898,130 @@ limfield (struct line const *line, struc
+@@ -1691,6 +1897,130 @@ limfield (struct line const *line, struc
return ptr;
}
/* Fill BUF reading from FP, moving buf->left bytes from the end
of buf->buf to the beginning first. If EOF is reached and the
file wasn't terminated by a newline, supply one. Set up BUF's line
-@@ -1778,8 +2108,22 @@ fillbuf (struct buffer *buf, FILE *fp, c
+@@ -1777,8 +2107,22 @@ fillbuf (struct buffer *buf, FILE *fp, c
else
{
if (key->skipsblanks)
line->keybeg = line_start;
}
}
-@@ -1900,7 +2244,7 @@ human_numcompare (char const *a, char co
+@@ -1899,7 +2243,7 @@ human_numcompare (char const *a, char co
hideously fast. */
static int
{
while (blanks[to_uchar (*a)])
a++;
-@@ -1910,6 +2254,25 @@ numcompare (char const *a, char const *b
+@@ -1909,6 +2253,25 @@ numcompare (char const *a, char const *b
return strnumcmp (a, b, decimal_point, thousands_sep);
}
/* Work around a problem whereby the long double value returned by glibc's
strtold ("NaN", ...) contains uninitialized bits: clear all bytes of
A and B before calling strtold. FIXME: remove this function once
-@@ -1942,7 +2305,7 @@ general_numcompare (char const *sa, char
+@@ -1959,7 +2322,7 @@ general_numcompare (char const *sa, char
Return 0 if the name in S is not recognized. */
static int
{
size_t lo = 0;
size_t hi = MONTHS_PER_YEAR;
-@@ -2217,15 +2580,14 @@ debug_key (struct line const *line, stru
+@@ -2234,15 +2597,14 @@ debug_key (struct line const *line, stru
char saved = *lim;
*lim = '\0';
else if (key->general_numeric)
ignore_value (strtold (beg, &tighter_lim));
else if (key->numeric || key->human_numeric)
-@@ -2369,7 +2731,7 @@ key_warnings (struct keyfield const *gke
+@@ -2386,7 +2748,7 @@ key_warnings (struct keyfield const *gke
bool maybe_space_aligned = !hard_LC_COLLATE && default_key_compare (key)
&& !(key->schar || key->echar);
bool line_offset = key->eword == 0 && key->echar != 0; /* -k1.x,1.y */
&& ((!key->skipsblanks && !(implicit_skip || maybe_space_aligned))
|| (!key->skipsblanks && key->schar)
|| (!key->skipeblanks && key->echar)))
-@@ -2427,11 +2789,83 @@ key_warnings (struct keyfield const *gke
- error (0, 0, _("option `-r' only applies to last-resort comparison"));
+@@ -2444,11 +2806,83 @@ key_warnings (struct keyfield const *gke
+ error (0, 0, _("option '-r' only applies to last-resort comparison"));
}
+#if HAVE_MBRTOWC
+ }
+ while (hi - lo > 1);
+
-+ if (ea)
-+ *ea = (char *) month;
-+
+ result = (!strncmp (month, monthtab[lo].name, strlen (monthtab[lo].name))
+ ? monthtab[lo].val : 0);
+
++ if (ea && result)
++ *ea = s + strlen (monthtab[lo].name);
++
+ return result;
+}
+#endif
{
struct keyfield *key = keylist;
-@@ -2516,7 +2950,7 @@ keycompare (struct line const *a, struct
+@@ -2533,7 +2967,7 @@ keycompare (struct line const *a, struct
else if (key->human_numeric)
diff = human_numcompare (ta, tb);
else if (key->month)
else if (key->random)
diff = compare_random (ta, tlena, tb, tlenb);
else if (key->version)
-@@ -2632,6 +3066,180 @@ keycompare (struct line const *a, struct
+@@ -2649,6 +3083,180 @@ keycompare (struct line const *a, struct
return key->reverse ? -diff : diff;
}
/* Compare two lines A and B, returning negative, zero, or positive
depending on whether A compares less than, equal to, or greater than B. */
-@@ -4095,7 +4702,7 @@ main (int argc, char **argv)
+@@ -4109,7 +4717,7 @@ main (int argc, char **argv)
initialize_exit_failure (SORT_FAILURE);
hard_LC_COLLATE = hard_locale (LC_COLLATE);
hard_LC_TIME = hard_locale (LC_TIME);
#endif
-@@ -4116,6 +4723,29 @@ main (int argc, char **argv)
+@@ -4130,6 +4738,29 @@ main (int argc, char **argv)
thousands_sep = -1;
}
have_read_stdin = false;
inittables ();
-@@ -4386,13 +5016,34 @@ main (int argc, char **argv)
+@@ -4400,13 +5031,34 @@ main (int argc, char **argv)
case 't':
{
+ newtab[0] = '\0';
else
{
- /* Provoke with `sort -txx'. Complain about
-@@ -4403,9 +5054,12 @@ main (int argc, char **argv)
+ /* Provoke with 'sort -txx'. Complain about
+@@ -4417,9 +5069,12 @@ main (int argc, char **argv)
quote (optarg));
}
}
}
break;
-diff -urNp coreutils-8.13-orig/src/unexpand.c coreutils-8.13/src/unexpand.c
---- coreutils-8.13-orig/src/unexpand.c 2011-07-28 12:38:27.000000000 +0200
-+++ coreutils-8.13/src/unexpand.c 2011-09-09 10:23:14.185647633 +0200
-@@ -39,12 +39,29 @@
+diff -urNp coreutils-8.16-orig/src/unexpand.c coreutils-8.16/src/unexpand.c
+--- coreutils-8.16-orig/src/unexpand.c 2012-03-24 21:26:51.000000000 +0100
++++ coreutils-8.16/src/unexpand.c 2012-03-26 17:51:46.000000000 +0200
+@@ -38,12 +38,29 @@
#include <stdio.h>
#include <getopt.h>
#include <sys/types.h>
+# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
+#endif
+
- /* 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 "unexpand"
-@@ -104,6 +121,208 @@ static struct option const longopts[] =
+@@ -103,6 +120,208 @@ static struct option const longopts[] =
{NULL, 0, NULL, 0}
};
void
usage (int status)
{
-@@ -526,7 +745,12 @@ main (int argc, char **argv)
+@@ -524,7 +743,12 @@ main (int argc, char **argv)
file_list = (optind < argc ? &argv[optind] : stdin_argv);
if (have_read_stdin && fclose (stdin) != 0)
error (EXIT_FAILURE, errno, "-");
-diff -urNp coreutils-8.13-orig/src/uniq.c coreutils-8.13/src/uniq.c
---- coreutils-8.13-orig/src/uniq.c 2011-07-28 12:38:27.000000000 +0200
-+++ coreutils-8.13/src/uniq.c 2011-09-09 10:24:19.631560964 +0200
+diff -urNp coreutils-8.16-orig/src/uniq.c coreutils-8.16/src/uniq.c
+--- coreutils-8.16-orig/src/uniq.c 2012-03-24 21:26:51.000000000 +0100
++++ coreutils-8.16/src/uniq.c 2012-03-26 17:35:09.000000000 +0200
@@ -21,6 +21,16 @@
#include <getopt.h>
#include <sys/types.h>
+#endif
+
- /* 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"
@@ -108,6 +130,10 @@ static enum delimit_method const delimit
/* Select whether/how to delimit groups of duplicate lines. */
static struct option const longopts[] =
{
{"count", no_argument, NULL, 'c'},
-@@ -207,7 +233,7 @@ size_opt (char const *opt, char const *m
+@@ -206,7 +232,7 @@ size_opt (char const *opt, char const *m
return a pointer to the beginning of the line's field to be compared. */
static char * _GL_ATTRIBUTE_PURE
{
size_t count;
char const *lp = line->buffer;
-@@ -227,6 +253,83 @@ find_field (struct linebuffer const *lin
+@@ -226,6 +252,83 @@ find_field (struct linebuffer const *lin
return line->buffer + i;
}
/* 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.
-@@ -235,6 +338,8 @@ find_field (struct linebuffer const *lin
+@@ -234,6 +337,8 @@ find_field (struct linebuffer const *lin
static bool
different (char *old, char *new, size_t oldlen, size_t newlen)
{
if (check_chars < oldlen)
oldlen = check_chars;
if (check_chars < newlen)
-@@ -242,14 +347,92 @@ different (char *old, char *new, size_t
+@@ -241,14 +346,92 @@ different (char *old, char *new, size_t
if (ignore_case)
{
/* Output the line in linebuffer LINE to standard output
provided that the switches say it should be output.
-@@ -305,15 +488,43 @@ check_file (const char *infile, const ch
+@@ -304,15 +487,43 @@ check_file (const char *infile, const ch
{
char *prevfield IF_LINT ( = NULL);
size_t prevlen IF_LINT ( = 0);
if (prevline->length == 0
|| different (thisfield, prevfield, thislen, prevlen))
{
-@@ -332,17 +543,26 @@ check_file (const char *infile, const ch
+@@ -331,17 +542,26 @@ check_file (const char *infile, const ch
size_t prevlen;
uintmax_t match_count = 0;
bool first_delimiter = true;
if (readlinebuffer_delim (thisline, stdin, delimiter) == 0)
{
if (ferror (stdin))
-@@ -351,6 +571,14 @@ check_file (const char *infile, const ch
+@@ -350,6 +570,14 @@ check_file (const char *infile, const ch
}
thisfield = find_field (thisline);
thislen = thisline->length - 1 - (thisfield - thisline->buffer);
match = !different (thisfield, prevfield, thislen, prevlen);
match_count += match;
-@@ -383,6 +611,9 @@ check_file (const char *infile, const ch
+@@ -382,6 +610,9 @@ check_file (const char *infile, const ch
SWAP_LINES (prevline, thisline);
prevfield = thisfield;
prevlen = thislen;
if (!match)
match_count = 0;
}
-@@ -428,6 +659,19 @@ main (int argc, char **argv)
+@@ -427,6 +658,19 @@ main (int argc, char **argv)
atexit (close_stdout);
skip_chars = 0;
skip_fields = 0;
check_chars = SIZE_MAX;
-diff -urNp coreutils-8.13-orig/tests/Makefile.am coreutils-8.13/tests/Makefile.am
---- coreutils-8.13-orig/tests/Makefile.am 2011-09-09 10:22:43.352561668 +0200
-+++ coreutils-8.13/tests/Makefile.am 2011-09-09 10:23:14.189688942 +0200
-@@ -238,6 +238,7 @@ TESTS = \
- misc/sort-debug-keys \
+diff -urNp coreutils-8.16-orig/tests/Makefile.am coreutils-8.16/tests/Makefile.am
+--- coreutils-8.16-orig/tests/Makefile.am 2012-03-26 18:01:35.564014659 +0200
++++ coreutils-8.16/tests/Makefile.am 2012-03-26 18:02:01.023015013 +0200
+@@ -242,6 +242,7 @@ TESTS = \
misc/sort-debug-warn \
+ misc/sort-discrim \
misc/sort-files0-from \
+ misc/sort-mb-tests \
misc/sort-float \
misc/sort-merge \
misc/sort-merge-fdlimit \
-@@ -518,6 +519,10 @@ TESTS = \
+@@ -537,6 +538,10 @@ TESTS = \
$(root_tests)
pr_data = \
pr/0F \
pr/0FF \
pr/0FFnt \
-diff -urNp coreutils-8.13-orig/tests/misc/cut coreutils-8.13/tests/misc/cut
---- coreutils-8.13-orig/tests/misc/cut 2011-09-02 14:08:40.000000000 +0200
-+++ coreutils-8.13/tests/misc/cut 2011-09-09 10:23:14.190686793 +0200
-@@ -23,14 +23,15 @@ my $mb_locale = $ENV{LOCALE_FR_UTF8};
+diff -urNp coreutils-8.16-orig/tests/misc/cut coreutils-8.16/tests/misc/cut
+--- coreutils-8.16-orig/tests/misc/cut 2012-02-03 10:22:06.000000000 +0100
++++ coreutils-8.16/tests/misc/cut 2012-03-26 17:40:49.000000000 +0200
+@@ -23,14 +23,15 @@ use strict;
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
+my $mb_locale = 'C';
my $prog = 'cut';
- my $try = "Try \`$prog --help' for more information.\n";
+ my $try = "Try '$prog --help' for more information.\n";
my $from_1 = "$prog: fields and positions are numbered from 1\n$try";
-my $inval = "$prog: invalid byte or field list\n$try";
+my $inval = "$prog: invalid byte, character or field list\n$try";
my $no_endpoint = "$prog: invalid range with no endpoint: -\n$try";
my @Tests =
-@@ -147,7 +147,7 @@ my @Tests =
+@@ -147,7 +148,7 @@ my @Tests =
# None of the following invalid ranges provoked an error up to coreutils-6.9.
['inval1', qw(-f 2-0), {IN=>''}, {OUT=>''}, {EXIT=>1},
['inval2', qw(-f -), {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}],
['inval3', '-f', '4,-', {IN=>''}, {OUT=>''}, {EXIT=>1}, {ERR=>$no_endpoint}],
['inval4', '-f', '1-2,-', {IN=>''}, {OUT=>''}, {EXIT=>1},
-diff -urNp coreutils-8.13-orig/tests/misc/mb1.I coreutils-8.13/tests/misc/mb1.I
---- coreutils-8.13-orig/tests/misc/mb1.I 1970-01-01 01:00:00.000000000 +0100
-+++ coreutils-8.13/tests/misc/mb1.I 2011-09-09 10:23:14.191687037 +0200
+diff -urNp coreutils-8.16-orig/tests/misc/mb1.I coreutils-8.16/tests/misc/mb1.I
+--- coreutils-8.16-orig/tests/misc/mb1.I 1970-01-01 01:00:00.000000000 +0100
++++ coreutils-8.16/tests/misc/mb1.I 2012-03-26 17:35:09.000000000 +0200
@@ -0,0 +1,4 @@
+Apple@10
+Banana@5
+Citrus@20
+Cherry@30
-diff -urNp coreutils-8.13-orig/tests/misc/mb1.X coreutils-8.13/tests/misc/mb1.X
---- coreutils-8.13-orig/tests/misc/mb1.X 1970-01-01 01:00:00.000000000 +0100
-+++ coreutils-8.13/tests/misc/mb1.X 2011-09-09 10:23:14.192581910 +0200
+diff -urNp coreutils-8.16-orig/tests/misc/mb1.X coreutils-8.16/tests/misc/mb1.X
+--- coreutils-8.16-orig/tests/misc/mb1.X 1970-01-01 01:00:00.000000000 +0100
++++ coreutils-8.16/tests/misc/mb1.X 2012-03-26 17:35:09.000000000 +0200
@@ -0,0 +1,4 @@
+Banana@5
+Apple@10
+Citrus@20
+Cherry@30
-diff -urNp coreutils-8.13-orig/tests/misc/mb2.I coreutils-8.13/tests/misc/mb2.I
---- coreutils-8.13-orig/tests/misc/mb2.I 1970-01-01 01:00:00.000000000 +0100
-+++ coreutils-8.13/tests/misc/mb2.I 2011-09-09 10:23:14.192581910 +0200
+diff -urNp coreutils-8.16-orig/tests/misc/mb2.I coreutils-8.16/tests/misc/mb2.I
+--- coreutils-8.16-orig/tests/misc/mb2.I 1970-01-01 01:00:00.000000000 +0100
++++ coreutils-8.16/tests/misc/mb2.I 2012-03-26 17:35:09.000000000 +0200
@@ -0,0 +1,4 @@
+Apple@AA10@@20
+Banana@AA5@@30
+Citrus@AA20@@5
+Cherry@AA30@@10
-diff -urNp coreutils-8.13-orig/tests/misc/mb2.X coreutils-8.13/tests/misc/mb2.X
---- coreutils-8.13-orig/tests/misc/mb2.X 1970-01-01 01:00:00.000000000 +0100
-+++ coreutils-8.13/tests/misc/mb2.X 2011-09-09 10:23:14.193687456 +0200
+diff -urNp coreutils-8.16-orig/tests/misc/mb2.X coreutils-8.16/tests/misc/mb2.X
+--- coreutils-8.16-orig/tests/misc/mb2.X 1970-01-01 01:00:00.000000000 +0100
++++ coreutils-8.16/tests/misc/mb2.X 2012-03-26 17:35:09.000000000 +0200
@@ -0,0 +1,4 @@
+Citrus@AA20@@5
+Cherry@AA30@@10
+Apple@AA10@@20
+Banana@AA5@@30
-diff -urNp coreutils-8.13-orig/tests/misc/sort-mb-tests coreutils-8.13/tests/misc/sort-mb-tests
---- coreutils-8.13-orig/tests/misc/sort-mb-tests 1970-01-01 01:00:00.000000000 +0100
-+++ coreutils-8.13/tests/misc/sort-mb-tests 2011-09-09 10:23:14.194687565 +0200
+diff -urNp coreutils-8.16-orig/tests/misc/sort-mb-tests coreutils-8.16/tests/misc/sort-mb-tests
+--- coreutils-8.16-orig/tests/misc/sort-mb-tests 1970-01-01 01:00:00.000000000 +0100
++++ coreutils-8.16/tests/misc/sort-mb-tests 2012-03-26 17:35:09.000000000 +0200
@@ -0,0 +1,58 @@
+#! /bin/sh
+case $# in