Fix the i18n cut optimization restriction (we need UTF8 to grant uniqueness of characters and using strchr() approach), unset the unnecessary envvars after colorls scripts(#1051703)

This commit is contained in:
Ondřej Vašík 2014-01-13 12:49:45 +01:00
parent be3c926a11
commit 72a0b599c4
4 changed files with 15 additions and 3 deletions

View File

@ -51,6 +51,8 @@ if ( "$color_none" != '' ) then
endif
unset color_none
unset _tmp
unset INCLUDE
unset COLORS
finish:
alias ll 'ls -l --color=auto'

View File

@ -45,6 +45,8 @@ if [ -z "$USER_LS_COLORS" ]; then
grep -qi "^COLOR.*none" $COLORS >/dev/null 2>/dev/null && return
fi
unset TMP COLORS INCLUDE
alias ll='ls -l --color=auto' 2>/dev/null
alias l.='ls -d .* --color=auto' 2>/dev/null
alias ls='ls --color=auto' 2>/dev/null

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. */
static void
@@ -629,13 +786,207 @@ cut_fields (FILE *stream)
@@ -629,13 +786,211 @@ cut_fields (FILE *stream)
}
}
@ -443,8 +443,12 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
+ case field_mode:
+ if (delimlen == 1)
+ {
+ /* Check if we have utf8 multibyte locale, so we can use this
+ optimization because of uniqueness of characters, which is
+ not true for e.g. SJIS */
+ char * loc = setlocale(LC_CTYPE, NULL);
+ if (loc && (strstr (loc, "UTF-8") || strstr (loc, "utf-8")))
+ if (loc && (strstr (loc, "UTF-8") || strstr (loc, "utf-8") ||
+ strstr (loc, "UTF8") || strstr (loc, "utf8")))
+ {
+ cut_fields (stream);
+ break;

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 8.22
Release: 9%{?dist}
Release: 10%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/
@ -372,6 +372,10 @@ fi
%{_sbindir}/chroot
%changelog
* Mon Jan 13 2014 Ondrej Vasik <ovasik@redhat.com> 8.22-10
- unset the unnecessary envvars after colorls scripts(#1051703)
- improve the limitation (check for both utf8 and utf-8)
* Fri Jan 10 2014 Ondrej Oprala <ooprala@redhat.com> 8.22-9
- Limit the cut optimizations to UTF-8 locales only