X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=gettext.c;h=35d2c1218db2e27a6ac07fbf3c1244987e3e3021;hb=4a58c3d7f7a83ebcd4ede635871cab7be24f7f3f;hp=d4021d690c07237edefb0cf2869eb6795d227a54;hpb=83b13e284ce3e349aedfc48fc0fb885c390bb18b;p=thirdparty%2Fgit.git diff --git a/gettext.c b/gettext.c index d4021d690c..35d2c1218d 100644 --- a/gettext.c +++ b/gettext.c @@ -12,7 +12,25 @@ #ifndef NO_GETTEXT # include # include -# ifdef HAVE_LIBCHARSET_H +# ifdef GIT_WINDOWS_NATIVE + +static const char *locale_charset(void) +{ + const char *env = getenv("LC_ALL"), *dot; + + if (!env || !*env) + env = getenv("LC_CTYPE"); + if (!env || !*env) + env = getenv("LANG"); + + if (!env) + return "UTF-8"; + + dot = strchr(env, '.'); + return !dot ? env : dot + 1; +} + +# elif defined HAVE_LIBCHARSET_H # include # else # include @@ -50,10 +68,8 @@ const char *get_preferred_languages(void) int use_gettext_poison(void) { static int poison_requested = -1; - if (poison_requested == -1) { - const char *v = getenv("GIT_TEST_GETTEXT_POISON"); - poison_requested = v && strlen(v) ? 1 : 0; - } + if (poison_requested == -1) + poison_requested = git_env_bool("GIT_TEST_GETTEXT_POISON", 0); return poison_requested; }