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

@ -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)

View File

@ -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 <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
- Don't use cut mb path if not necessary (#1021403, #499220)
- several i18n patch improvements merged from OpenSUSE (fixed