[PATCH] gen_wc8bit: use a configurable UTF-8 locale
Daniel Cordero
theappleman at gmail.com
Mon Jun 1 17:40:16 UTC 2009
In some situations, the en_US.UTF-8 locale is not available (e.g. the
user does not have it installed).
Make a new option in the configuration for the user to specify an
alternative.
Signed-off-by: Daniel Cordero <theappleman at gmail.com>
---
(Please Cc me)
Hi all, I'm new to uClibc (grabbed the sources about 2 hours ago).
If I've done something wrong or missed anything out, I'd love to know.
extra/Configs/Config.in | 8 ++++++++
extra/locale/Makefile.in | 2 +-
extra/locale/gen_wc8bit.c | 4 ++--
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index 6c37039..f226e56 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -1303,6 +1303,14 @@ config UCLIBC_HAS_XLOCALE
Most people will answer N.
+config UCLIBC_SET_UTF_8_LOCALE
+ string "UTF-8 locale to setlocale()"
+ depends on UCLIBC_HAS_LOCALE
+ default "en_US.UTF-8"
+ help
+ If you do not have the default UTF-8 locale (en_US.UTF-8) installed,
+ or wish to use another, say so here.
+
config UCLIBC_HAS_HEXADECIMAL_FLOATS
bool "Support hexadecimal float notation"
depends on UCLIBC_HAS_CTYPE_TABLES
diff --git a/extra/locale/Makefile.in b/extra/locale/Makefile.in
index 66e14fb..ad820e0 100644
--- a/extra/locale/Makefile.in
+++ b/extra/locale/Makefile.in
@@ -21,7 +21,7 @@ BUILD_CFLAGS-gen_wc8bit := $(BUILD_CFLAGS-locale-common) -DCTYPE_PACKED=1
BUILD_CFLAGS-gen_wctype := $(BUILD_CFLAGS-locale-common)
BUILD_CFLAGS-gen_ldc :=
ifeq ($(UCLIBC_HAS_WCHAR),y)
-BUILD_CFLAGS-gen_wc8bit += -DDO_WIDE_CHAR=1
+BUILD_CFLAGS-gen_wc8bit += -DDO_WIDE_CHAR=1 -DSET_LOCALE=\"$(UCLIBC_SET_UTF_8_LOCALE)\"
BUILD_CFLAGS-gen_ldc += -D__WCHAR_ENABLED=1
endif
BUILD_CFLAGS-gen_locale := -D_GNU_SOURCE -I$(locale_OUT)
diff --git a/extra/locale/gen_wc8bit.c b/extra/locale/gen_wc8bit.c
index 418a1ac..027cbd6 100644
--- a/extra/locale/gen_wc8bit.c
+++ b/extra/locale/gen_wc8bit.c
@@ -97,8 +97,8 @@ int main(int argc, char **argv)
int codeset_list_end = 0;
int total_size = 0;
- if (!setlocale(LC_CTYPE, "en_US.UTF-8")) {
- printf("setlocale(LC_CTYPE,\"en_US.UTF-8\") failed!\n");
+ if (!setlocale(LC_CTYPE, SET_LOCALE)) {
+ printf("setlocale(LC_CTYPE,\"" SET_LOCALE "\") failed!\n");
return EXIT_FAILURE;
}
--
1.6.3.1.287.g5aed1
More information about the uClibc
mailing list