diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-07-05 22:00:57 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-07-05 22:00:57 +0200 |
commit | 2301d127a2676303eac563e7932c03d9d72c446e (patch) | |
tree | 9bb912bd5df0a5b5676837e26625672a61f41ad8 | |
parent | 4f9fc1e5f5897dd2d143fa837f9288d55cf57f51 (diff) | |
download | busybox-w32-2301d127a2676303eac563e7932c03d9d72c446e.tar.gz busybox-w32-2301d127a2676303eac563e7932c03d9d72c446e.tar.bz2 busybox-w32-2301d127a2676303eac563e7932c03d9d72c446e.zip |
unicode: check $LC_CTYPE too to detect Unicode mode
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | Config.in | 5 | ||||
-rw-r--r-- | libbb/unicode.c | 8 | ||||
-rw-r--r-- | shell/ash.c | 1 | ||||
-rw-r--r-- | shell/hush.c | 1 |
4 files changed, 13 insertions, 2 deletions
@@ -161,12 +161,13 @@ config UNICODE_USING_LOCALE | |||
161 | Internal implementation is smaller. | 161 | Internal implementation is smaller. |
162 | 162 | ||
163 | config FEATURE_CHECK_UNICODE_IN_ENV | 163 | config FEATURE_CHECK_UNICODE_IN_ENV |
164 | bool "Check $LANG environment variable" | 164 | bool "Check $LC_ALL, $LC_CTYPE and $LANG environment variables" |
165 | default n | 165 | default n |
166 | depends on UNICODE_SUPPORT && !UNICODE_USING_LOCALE | 166 | depends on UNICODE_SUPPORT && !UNICODE_USING_LOCALE |
167 | help | 167 | help |
168 | With this option on, Unicode support is activated | 168 | With this option on, Unicode support is activated |
169 | only if LANG variable has the value of the form "xxxx.utf8" | 169 | only if locale-related variables have the value of the form |
170 | "xxxx.utf8" | ||
170 | 171 | ||
171 | Otherwise, Unicode support will be always enabled and active. | 172 | Otherwise, Unicode support will be always enabled and active. |
172 | 173 | ||
diff --git a/libbb/unicode.c b/libbb/unicode.c index c1e3966fe..35e88d307 100644 --- a/libbb/unicode.c +++ b/libbb/unicode.c | |||
@@ -39,8 +39,15 @@ void FAST_FUNC reinit_unicode(const char *LANG) | |||
39 | 39 | ||
40 | void FAST_FUNC init_unicode(void) | 40 | void FAST_FUNC init_unicode(void) |
41 | { | 41 | { |
42 | /* Some people set only $LC_CTYPE, not $LC_ALL, because they want | ||
43 | * only Unicode to be activated on their system, not the whole | ||
44 | * shebang of wrong decimal points, strange date formats and so on. | ||
45 | * | ||
46 | * TODO? Maybe we should use LC_CTYPE instead of LC_ALL in setlocale()? | ||
47 | */ | ||
42 | if (unicode_status == UNICODE_UNKNOWN) { | 48 | if (unicode_status == UNICODE_UNKNOWN) { |
43 | char *s = getenv("LC_ALL"); | 49 | char *s = getenv("LC_ALL"); |
50 | if (!s) s = getenv("LC_CTYPE"); | ||
44 | if (!s) s = getenv("LANG"); | 51 | if (!s) s = getenv("LANG"); |
45 | reinit_unicode(s); | 52 | reinit_unicode(s); |
46 | } | 53 | } |
@@ -63,6 +70,7 @@ void FAST_FUNC init_unicode(void) | |||
63 | { | 70 | { |
64 | if (unicode_status == UNICODE_UNKNOWN) { | 71 | if (unicode_status == UNICODE_UNKNOWN) { |
65 | char *s = getenv("LC_ALL"); | 72 | char *s = getenv("LC_ALL"); |
73 | if (!s) s = getenv("LC_CTYPE"); | ||
66 | if (!s) s = getenv("LANG"); | 74 | if (!s) s = getenv("LANG"); |
67 | reinit_unicode(s); | 75 | reinit_unicode(s); |
68 | } | 76 | } |
diff --git a/shell/ash.c b/shell/ash.c index 90f222467..d696bbdac 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -9659,6 +9659,7 @@ preadfd(void) | |||
9659 | */ | 9659 | */ |
9660 | { | 9660 | { |
9661 | const char *s = lookupvar("LC_ALL"); | 9661 | const char *s = lookupvar("LC_ALL"); |
9662 | if (!s) s = lookupvar("LC_CTYPE"); | ||
9662 | if (!s) s = lookupvar("LANG"); | 9663 | if (!s) s = lookupvar("LANG"); |
9663 | reinit_unicode(s); | 9664 | reinit_unicode(s); |
9664 | } | 9665 | } |
diff --git a/shell/hush.c b/shell/hush.c index 1fa84dc4f..fc9b89b55 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -2045,6 +2045,7 @@ static void get_user_input(struct in_str *i) | |||
2045 | * shell was started. Therefore, re-check LANG every time: | 2045 | * shell was started. Therefore, re-check LANG every time: |
2046 | */ | 2046 | */ |
2047 | const char *s = get_local_var_value("LC_ALL"); | 2047 | const char *s = get_local_var_value("LC_ALL"); |
2048 | if (!s) s = get_local_var_value("LC_CTYPE"); | ||
2048 | if (!s) s = get_local_var_value("LANG"); | 2049 | if (!s) s = get_local_var_value("LANG"); |
2049 | reinit_unicode(s); | 2050 | reinit_unicode(s); |
2050 | 2051 | ||