incorporate some i18n patch fixes from SUSE: fix output-delimiter option in cut, prevent infinite loop in sort when ignoring chars, prevent using unitialized variable in cut

This commit is contained in:
Ondrej Vasik 2011-09-05 08:18:24 +02:00
parent 6ff9fce161
commit a68f226c74
2 changed files with 51 additions and 26 deletions

View File

@ -75,7 +75,7 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
+ while (0)
+
+/* Get wide character on BUFPOS. BUFPOS is not included after that.
+ If byte sequence is not valid as a character, CONVFAIL is 1. Otherwise 0. */
+ If byte sequence is not valid as a character, CONVFAIL is 1. Otherwise 0. */
+#define GET_NEXT_WC_FROM_BUFFER(WC, BUFPOS, BUFLEN, MBLENGTH, STATE, CONVFAIL) \
+ do \
+ { \
@ -226,7 +226,7 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
}
max_range_endpoint = 0;
@@ -580,6 +662,63 @@ cut_bytes (FILE *stream)
@@ -580,6 +662,77 @@ cut_bytes (FILE *stream)
}
}
@ -234,11 +234,11 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
+/* This function is in use for the following case.
+
+ 1. Read from the stream STREAM, printing to standard output any selected
+ characters.
+ 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)
+{
@ -251,6 +251,9 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
+ as same character as WC. */
+ mbstate_t state; /* State of the stream. */
+ int convfail = 0; /* 1, when conversion is failed. Otherwise 0. */
+ /* 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;
+
+ idx = 0;
+ buflen = 0;
@ -273,12 +276,23 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
+ {
+ putchar ('\n');
+ idx = 0;
+ print_delimiter = false;
+ }
+ else
+ {
+ bool range_start;
+ bool *rs = output_delimiter_specified ? &range_start : NULL;
+ idx += (operating_mode == byte_mode) ? mblength : 1;
+ if (print_kth (idx, NULL))
+ fwrite (bufpos, mblength, sizeof(char), stdout);
+ if (print_kth (idx, rs))
+ {
+ fwrite (bufpos, mblength, sizeof(char), stdout);
+
+ if (rs && *rs && print_delimiter)
+ {
+ fwrite (output_delimiter_string, sizeof (char),
+ output_delimiter_length, stdout);
+ }
+ }
+ }
+
+ buflen -= mblength;
@ -286,11 +300,11 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
+ }
+}
+#endif
+
+
/* Read from stream STREAM, printing to standard output any selected fields. */
static void
@@ -702,13 +841,192 @@ cut_fields (FILE *stream)
@@ -702,13 +855,195 @@ cut_fields (FILE *stream)
}
}
@ -321,7 +335,10 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
+ c = getc (stream);
+ empty_input = (c == EOF);
+ if (c != EOF)
+ {
+ ungetc (c, stream);
+ wc = 0;
+ }
+ else
+ wc = WEOF;
+
@ -486,7 +503,7 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
}
/* Process file FILE to standard output.
@@ -760,6 +1078,8 @@ main (int argc, char **argv)
@@ -760,6 +1095,8 @@ main (int argc, char **argv)
bool ok;
bool delim_specified = false;
char *spec_list_string IF_LINT ( = NULL);
@ -495,7 +512,7 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
initialize_main (&argc, &argv);
set_program_name (argv[0]);
@@ -782,7 +1102,6 @@ main (int argc, char **argv)
@@ -782,7 +1119,6 @@ main (int argc, char **argv)
switch (optc)
{
case 'b':
@ -503,7 +520,7 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
/* Build the byte list. */
if (operating_mode != undefined_mode)
FATAL_ERROR (_("only one type of list may be specified"));
@@ -790,6 +1109,14 @@ main (int argc, char **argv)
@@ -790,6 +1126,14 @@ main (int argc, char **argv)
spec_list_string = optarg;
break;
@ -518,7 +535,7 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
case 'f':
/* Build the field list. */
if (operating_mode != undefined_mode)
@@ -801,10 +1128,35 @@ main (int argc, char **argv)
@@ -801,10 +1145,35 @@ main (int argc, char **argv)
case 'd':
/* New delimiter. */
/* Interpret -d '' to mean `use the NUL byte as the delimiter.' */
@ -558,7 +575,7 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
break;
case OUTPUT_DELIMITER_OPTION:
@@ -817,6 +1169,7 @@ main (int argc, char **argv)
@@ -817,6 +1187,7 @@ main (int argc, char **argv)
break;
case 'n':
@ -566,7 +583,7 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
break;
case 's':
@@ -839,7 +1192,7 @@ main (int argc, char **argv)
@@ -839,7 +1209,7 @@ main (int argc, char **argv)
if (operating_mode == undefined_mode)
FATAL_ERROR (_("you must specify a list of bytes, characters, or fields"));
@ -575,7 +592,7 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
FATAL_ERROR (_("an input delimiter may be specified only\
when operating on fields"));
@@ -866,15 +1219,34 @@ main (int argc, char **argv)
@@ -866,15 +1236,34 @@ main (int argc, char **argv)
}
if (!delim_specified)
@ -607,7 +624,7 @@ diff -urNp coreutils-8.10-orig/src/cut.c coreutils-8.10/src/cut.c
+ if (MB_CUR_MAX <= 1 || force_singlebyte_mode)
+#endif
+ {
+ static char dummy[2];
+ static char dummy[2];
+ dummy[0] = delim;
+ dummy[1] = '\0';
+ output_delimiter_string = dummy;
@ -1551,7 +1568,7 @@ diff -urNp coreutils-8.10-orig/src/join.c coreutils-8.10/src/join.c
- return xmemcoll (beg1, len1, beg2, len2);
- diff = memcmp (beg1, beg2, MIN (len1, len2));
+ copy[0] = (unsigned char *) beg[0];
+ copy[1] = (unsigned char *) beg[1];
+ copy[1] = (unsigned char *) beg[1];
}
+ if (hard_LC_COLLATE)
@ -1632,7 +1649,7 @@ diff -urNp coreutils-8.10-orig/src/join.c coreutils-8.10/src/join.c
case 't':
{
- unsigned char newtab = optarg[0];
+ char *newtab;
+ char *newtab = NULL;
+ size_t newtablen;
+ newtab = xstrdup (optarg);
+#if HAVE_MBRTOWC
@ -1654,7 +1671,8 @@ diff -urNp coreutils-8.10-orig/src/join.c coreutils-8.10/src/join.c
+ newtablen = 1;
if (! newtab)
+ {
newtab = '\n'; /* '' => process the whole line. */
- newtab = '\n'; /* '' => process the whole line. */
+ newtab = "\n"; /* '' => process the whole line. */
+ }
else if (optarg[1])
{
@ -3085,7 +3103,7 @@ diff -urNp coreutils-8.10-orig/src/sort.c coreutils-8.10/src/sort.c
else if (key->random)
diff = compare_random (ta, tlena, tb, tlenb);
else if (key->version)
@@ -2624,6 +3058,179 @@ keycompare (struct line const *a, struct
@@ -2624,6 +3058,180 @@ keycompare (struct line const *a, struct
return key->reverse ? -diff : diff;
}
@ -3167,7 +3185,8 @@ diff -urNp coreutils-8.10-orig/src/sort.c coreutils-8.10/src/sort.c
+ if (MBLENGTH == (size_t)-2 || MBLENGTH == (size_t)-1) \
+ STATE = state_bak; \
+ if (!ignore) \
+ COPY[NEW_LEN++] = TEXT[i++]; \
+ COPY[NEW_LEN++] = TEXT[i]; \
+ i++; \
+ continue; \
+ } \
+ \
@ -3265,7 +3284,7 @@ diff -urNp coreutils-8.10-orig/src/sort.c coreutils-8.10/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. */
@@ -4087,7 +4694,7 @@ main (int argc, char **argv)
@@ -4087,7 +4695,7 @@ main (int argc, char **argv)
initialize_exit_failure (SORT_FAILURE);
hard_LC_COLLATE = hard_locale (LC_COLLATE);
@ -3274,7 +3293,7 @@ diff -urNp coreutils-8.10-orig/src/sort.c coreutils-8.10/src/sort.c
hard_LC_TIME = hard_locale (LC_TIME);
#endif
@@ -4108,6 +4715,29 @@ main (int argc, char **argv)
@@ -4108,6 +4716,29 @@ main (int argc, char **argv)
thousands_sep = -1;
}
@ -3304,7 +3323,7 @@ diff -urNp coreutils-8.10-orig/src/sort.c coreutils-8.10/src/sort.c
have_read_stdin = false;
inittables ();
@@ -4378,13 +5008,34 @@ main (int argc, char **argv)
@@ -4378,13 +5009,34 @@ main (int argc, char **argv)
case 't':
{
@ -3343,7 +3362,7 @@ diff -urNp coreutils-8.10-orig/src/sort.c coreutils-8.10/src/sort.c
else
{
/* Provoke with `sort -txx'. Complain about
@@ -4395,9 +5046,12 @@ main (int argc, char **argv)
@@ -4395,9 +5047,12 @@ main (int argc, char **argv)
quote (optarg));
}
}

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 8.12
Release: 6%{?dist}
Release: 7%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/
@ -335,6 +335,12 @@ fi
%{_libdir}/coreutils
%changelog
* Mon Sep 05 2011 Ondrej Vasik <ovasik@redhat.com> - 8.12-7
- incorporate some i18n patch fixes from OpenSUSE:
- fix cut output-delimiter option
- prevent infinite loop in sort when ignoring chars
- prevent using unitialized variable in cut
* Tue Aug 23 2011 Ondrej Vasik <ovasik@redhat.com> - 8.12-6
- su: fix shell suspend in tcsh (#597928)