Files
git/gettext.c
Ævar Arnfjörð Bjarmason 107880a701 gettext: setlocale(LC_CTYPE, "") breaks Git's C function assumptions
Remove the setlocale/LC_CTYPE call from gettext.c, we only need
setlocale/LC_MESSAGES to use the message catalog, and setting LC_CTYPE
from the environment breaks Git's assumptions about C library
functions.

Under a non-C locale functions like vsnprintf become locale sensitive,
so that they'll e.g. refuse to process ISO-8895-1 data under a UTF-8
locale.

This triggered a "your vsnprintf is broken" error on Git's own
repository when inspecting v0.99.6~1 under a UTF-8 locale.

That commit contains a ISO-8859-1 encoded author name, which the
locale aware vsnprintf(3) won't interpolate in the format argument,
due to mismatch between the data encoding and the locale.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-12 15:38:31 -07:00

22 lines
435 B
C

#include "exec_cmd.h"
#include <locale.h>
#include <libintl.h>
#include <stdlib.h>
extern void git_setup_gettext(void) {
char *podir;
char *envdir = getenv("GIT_TEXTDOMAINDIR");
if (envdir) {
(void)bindtextdomain("git", envdir);
} else {
podir = (char *)system_path("share/locale");
if (!podir) return;
(void)bindtextdomain("git", podir);
free(podir);
}
(void)setlocale(LC_MESSAGES, "");
(void)textdomain("git");
}