From be3c926a11df3806f8afdd5f3857b46fdb498b4a Mon Sep 17 00:00:00 2001 From: Ondrej Oprala Date: Fri, 10 Jan 2014 16:06:15 +0100 Subject: [PATCH] Limit the cut optimizations to UTF-8 locales only --- coreutils-i18n.patch | 28 +++++++++++++++++----------- coreutils.spec | 5 ++++- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/coreutils-i18n.patch b/coreutils-i18n.patch index 70541f8..a0c2717 100644 --- a/coreutils-i18n.patch +++ b/coreutils-i18n.patch @@ -156,7 +156,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c /* True if the --output-delimiter=STRING option was specified. */ static bool output_delimiter_specified; -@@ -188,7 +266,7 @@ Print selected parts of lines from each +@@ -188,7 +266,7 @@ Print selected parts of lines from each -f, --fields=LIST select only these fields; also print any line\n\ that contains no delimiter character, unless\n\ the -s option is specified\n\ @@ -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. */ 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: + if (delimlen == 1) -+ cut_fields (stream); -+ else -+ cut_fields_mb (stream); ++ { ++ char * loc = setlocale(LC_CTYPE, NULL); ++ if (loc && (strstr (loc, "UTF-8") || strstr (loc, "utf-8"))) ++ { ++ cut_fields (stream); ++ break; ++ } ++ } ++ cut_fields_mb (stream); + break; + + 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. -@@ -687,6 +1032,7 @@ main (int argc, char **argv) +@@ -687,6 +1038,7 @@ main (int argc, char **argv) bool ok; bool delim_specified = false; 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); 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) { 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. */ if (operating_mode != undefined_mode) 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; break; @@ -494,7 +500,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c case 'f': /* Build the field list. */ 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': /* New 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; case OUTPUT_DELIMITER_OPTION: -@@ -744,6 +1125,7 @@ main (int argc, char **argv) +@@ -744,6 +1131,7 @@ main (int argc, char **argv) break; case 'n': @@ -545,7 +551,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c break; case 's': -@@ -783,15 +1165,34 @@ main (int argc, char **argv) +@@ -783,15 +1171,34 @@ main (int argc, char **argv) } if (!delim_specified) diff --git a/coreutils.spec b/coreutils.spec index 28c816f..cd65278 100644 --- a/coreutils.spec +++ b/coreutils.spec @@ -1,7 +1,7 @@ Summary: A set of basic GNU tools commonly used in shell scripts Name: coreutils Version: 8.22 -Release: 8%{?dist} +Release: 9%{?dist} License: GPLv3+ Group: System Environment/Base Url: http://www.gnu.org/software/coreutils/ @@ -372,6 +372,9 @@ fi %{_sbindir}/chroot %changelog +* Fri Jan 10 2014 Ondrej Oprala 8.22-9 +- Limit the cut optimizations to UTF-8 locales only + * Wed Jan 08 2014 Ondrej Oprala 8.22-8 - Don't use cut mb path if not necessary (#1021403, #499220) - several i18n patch improvements merged from OpenSUSE (fixed