[git commit master] Fix gen_wc8bit support for finding a UTF8 locale on host.

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Wed May 5 10:37:13 UTC 2010


commit: http://git.uclibc.org/uClibc/commit/?id=c1505e73d00ed26b7c250e331b213e63a948b1dd
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

gen_wc8bit was previously patched to support UTF8 locales other than the
default en_US.UTF-8 by patch id 0e14b8f425c562749d3821a42414b1ce6b3b0923.

This was incomplete in its implementation and still failed where item(s)
in the list returned by 'locale -a' already had 'UTF8' appended to the
name. This patch rectifies this situation, plus adds an extra fix to
avoid trimming '\n' from an empty line which could cause a segfault.

Signed-off-by: Andy Gibbs <andyg1001 at hotmail.co.uk>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 extra/locale/gen_wc8bit.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/extra/locale/gen_wc8bit.c b/extra/locale/gen_wc8bit.c
index 349f7cf..a861caa 100644
--- a/extra/locale/gen_wc8bit.c
+++ b/extra/locale/gen_wc8bit.c
@@ -112,9 +112,10 @@ int main(int argc, char **argv)
 				goto locale_failure;
 
 			len = strlen(buf);
-			if (buf[len - 1] == '\n')
+			if (len > 0 && buf[len - 1] == '\n')
 				buf[--len] = '\0';
-			strcat(buf, ".UTF8");
+			if (len < 5 || strcasecmp(&buf[len-5], ".UTF8") != 0)
+				strcat(buf, ".UTF8");
 			if (setlocale(LC_CTYPE, buf))
 				goto locale_success;
 		}
-- 
1.6.3.3



More information about the uClibc-cvs mailing list