diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-12-17 11:47:10 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-12-17 11:47:10 -0800 |
commit | 7dc8a65c86b4405dee8a4ee0fa4dcded96b7b900 (patch) | |
tree | 5cd889594404173aabd59ee2ab189119ee2aad92 | |
parent | fb230b35236c0d510bc0fdbabaafee027550c7eb (diff) | |
parent | 9c0495d23e6999375976ca44e3812fc65b73626e (diff) | |
download | git-7dc8a65c86b4405dee8a4ee0fa4dcded96b7b900.tar.gz git-7dc8a65c86b4405dee8a4ee0fa4dcded96b7b900.tar.xz |
Merge branch 'nd/gettext-vsnprintf'
* nd/gettext-vsnprintf:
gettext.c: detect the vsnprintf bug at runtime
-rw-r--r-- | gettext.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -29,6 +29,17 @@ int use_gettext_poison(void) #endif #ifndef NO_GETTEXT +static int test_vsnprintf(const char *fmt, ...) +{ + char buf[26]; + int ret; + va_list ap; + va_start(ap, fmt); + ret = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + return ret; +} + static const char *charset; static void init_gettext_charset(const char *domain) { @@ -99,9 +110,7 @@ static void init_gettext_charset(const char *domain) $ LANGUAGE= LANG=de_DE.utf8 ./test test: Kein passendes Ger?t gefunden - In the long term we should probably see about getting that - vsnprintf bug in glibc fixed, and audit our code so it won't - fall apart under a non-C locale. + The vsnprintf bug has been fixed since glibc 2.17. Then we could simply set LC_CTYPE from the environment, which would make things like the external perror(3) messages work. @@ -115,7 +124,9 @@ static void init_gettext_charset(const char *domain) setlocale(LC_CTYPE, ""); charset = locale_charset(); bind_textdomain_codeset(domain, charset); - setlocale(LC_CTYPE, "C"); + /* the string is taken from v0.99.6~1 */ + if (test_vsnprintf("%.*s", 13, "David_K\345gedal") < 0) + setlocale(LC_CTYPE, "C"); } void git_setup_gettext(void) |