gettext.c: detect the vsnprintf bug at runtime
commit9c0495d23e6999375976ca44e3812fc65b73626e
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sun, 1 Dec 2013 02:45:38 +0000 (1 09:45 +0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Dec 2013 00:10:51 +0000 (4 16:10 -0800)
tree3836743bccef2ce0d9ae1be497021bc5eab90a83
parenta155a5f075cdc09e584a58d68bdce0c80e6c4b5a
gettext.c: detect the vsnprintf bug at runtime

Bug 6530 [1] in glibc causes "git show v0.99.6~1" to fail with error
"your vsnprintf is broken". The workaround avoids that, but it
corrupts system error messages in non-C locales.

The bug has been fixed since 2.17. We could know running glibc version
with gnu_get_libc_version(). But version is not a sure way to detect
the bug because downstream may back port the fix to older versions. Do
a runtime test that immitates the call flow that leads to "your
vsnprintf is broken". Only enable the workaround if the test fails.

Tested on Gentoo Linux, glibc 2.16.0 and 2.17, amd64.

[1] http://sourceware.org/bugzilla/show_bug.cgi?id=6530

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gettext.c