From 250e0055fe0596f0f13d6e30f0bfe086702f5a25 Mon Sep 17 00:00:00 2001 From: Felix Janda Date: Wed, 21 Nov 2012 20:38:29 +0100 Subject: Make internalization support optional --- Config.in | 6 ++++++ main.c | 3 +++ scripts/test/wc.test | 2 ++ toys.h | 5 ++++- toys/posix/wc.c | 8 +++++--- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Config.in b/Config.in index 835e703b..73ab01e6 100644 --- a/Config.in +++ b/Config.in @@ -32,6 +32,12 @@ config TOYBOX_FLOAT Include floating point support infrastructure and commands that require it. +config TOYBOX_I18N + bool "Internalization support" + default y + help + Add support for locales in commands. + config TOYBOX_FREE bool "Free memory unnecessarily" default n diff --git a/main.c b/main.c index 4a9795ca..2b04d135 100644 --- a/main.c +++ b/main.c @@ -101,6 +101,9 @@ void toy_exec(char *argv[]) which = toy_find(argv[0]); if (!which) return; toy_init(which, argv); +#ifdef CFG_TOYBOX_I18N + setlocale(LC_ALL, ""); +#endif toys.which->toy_main(); exit(toys.exitval); } diff --git a/scripts/test/wc.test b/scripts/test/wc.test index 801cd713..40891323 100755 --- a/scripts/test/wc.test +++ b/scripts/test/wc.test @@ -21,6 +21,8 @@ testing "wc format" "wc file1" "4 5 26 file1\n" "" "" testing "wc multiple files" "wc input - file1" \ "1 2 3 input\n0 2 3 -\n4 5 26 file1\n5 9 32 total\n" "a\nb" "a b" +optional TOYBOX_I18N + #Tests for wc -m if printf "%s" "$LANG" | grep -q UTF-8 then diff --git a/toys.h b/toys.h index 55256efe..69876f23 100644 --- a/toys.h +++ b/toys.h @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -47,8 +46,12 @@ #include #include #include + +#ifdef CFG_TOYBOX_I18N +#include #include #include +#endif #include "lib/lib.h" #include "toys/e2fs.h" diff --git a/toys/posix/wc.c b/toys/posix/wc.c index 19ba4b8b..63128d67 100644 --- a/toys/posix/wc.c +++ b/toys/posix/wc.c @@ -48,7 +48,6 @@ static void show_lengths(unsigned long *lengths, char *name) static void do_wc(int fd, char *name) { int i, len, clen=1, space; - wchar_t wchar; unsigned long word=0, lengths[]={0,0,0}; for (;;) { @@ -59,6 +58,8 @@ static void do_wc(int fd, char *name) } if (len<1) break; for (i=0; i>1; loopfiles(toys.optargs, do_wc); if (toys.optc>1) show_lengths(TT.totals, "total"); -- cgit v1.2.3