Limit the cut optimizations to UTF-8 locales only

This commit is contained in:
Ondrej Oprala 2014-01-10 16:06:15 +01:00
parent b3c0c98841
commit be3c926a11
2 changed files with 21 additions and 12 deletions

View File

@ -258,7 +258,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
/* Read from stream STREAM, printing to standard output any selected fields. */ /* Read from stream STREAM, printing to standard output any selected fields. */
static void static void
@@ -629,13 +786,201 @@ cut_fields (FILE *stream) @@ -629,13 +786,207 @@ cut_fields (FILE *stream)
} }
} }
@ -442,9 +442,15 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
+ +
+ case field_mode: + case field_mode:
+ if (delimlen == 1) + if (delimlen == 1)
+ cut_fields (stream); + {
+ else + char * loc = setlocale(LC_CTYPE, NULL);
+ cut_fields_mb (stream); + if (loc && (strstr (loc, "UTF-8") || strstr (loc, "utf-8")))
+ {
+ cut_fields (stream);
+ break;
+ }
+ }
+ cut_fields_mb (stream);
+ break; + break;
+ +
+ default: + default:
@ -463,7 +469,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
} }
/* Process file FILE to standard output. /* Process file FILE to standard output.
@@ -687,6 +1032,7 @@ main (int argc, char **argv) @@ -687,6 +1038,7 @@ 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);
@ -471,7 +477,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
initialize_main (&argc, &argv); initialize_main (&argc, &argv);
set_program_name (argv[0]); set_program_name (argv[0]);
@@ -709,7 +1055,6 @@ main (int argc, char **argv) @@ -709,7 +1061,6 @@ main (int argc, char **argv)
switch (optc) switch (optc)
{ {
case 'b': case 'b':
@ -479,7 +485,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/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"));
@@ -717,6 +1062,14 @@ main (int argc, char **argv) @@ -717,6 +1068,14 @@ main (int argc, char **argv)
spec_list_string = optarg; spec_list_string = optarg;
break; break;
@ -494,7 +500,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/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)
@@ -728,10 +1081,38 @@ main (int argc, char **argv) @@ -728,10 +1087,38 @@ 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.' */
@ -537,7 +543,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
break; break;
case OUTPUT_DELIMITER_OPTION: case OUTPUT_DELIMITER_OPTION:
@@ -744,6 +1125,7 @@ main (int argc, char **argv) @@ -744,6 +1131,7 @@ main (int argc, char **argv)
break; break;
case 'n': case 'n':
@ -545,7 +551,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
break; break;
case 's': case 's':
@@ -783,15 +1165,34 @@ main (int argc, char **argv) @@ -783,15 +1171,34 @@ main (int argc, char **argv)
} }
if (!delim_specified) if (!delim_specified)

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils Name: coreutils
Version: 8.22 Version: 8.22
Release: 8%{?dist} Release: 9%{?dist}
License: GPLv3+ License: GPLv3+
Group: System Environment/Base Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/ Url: http://www.gnu.org/software/coreutils/
@ -372,6 +372,9 @@ fi
%{_sbindir}/chroot %{_sbindir}/chroot
%changelog %changelog
* Fri Jan 10 2014 Ondrej Oprala <ooprala@redhat.com> 8.22-9
- Limit the cut optimizations to UTF-8 locales only
* Wed Jan 08 2014 Ondrej Oprala <ooprala@redhat.com> 8.22-8 * Wed Jan 08 2014 Ondrej Oprala <ooprala@redhat.com> 8.22-8
- Don't use cut mb path if not necessary (#1021403, #499220) - Don't use cut mb path if not necessary (#1021403, #499220)
- several i18n patch improvements merged from OpenSUSE (fixed - several i18n patch improvements merged from OpenSUSE (fixed