flac and metaflac : Don't always call setlocale() in Windows.

Windows (MSVC, MinGW) versions of setlocale don't care about LC_*
environment variables. For example, flac cannot pass the test for
--until and --skip options the script calls it with --skip=0:01.1001
and it expects decimal comma (--skip=0:01,1001) on some locales.

Solve this (on Windows) by calling setlocale(LC_ALL, "") if some
LC_* variable is set to "C".

Patch-from: lvqcl <lvqcl.mail@gmail.com>
This commit is contained in:
Erik de Castro Lopo 2014-07-19 18:17:25 +10:00
parent 491475e61a
commit 865041b7ca
2 changed files with 26 additions and 0 deletions

View File

@ -310,7 +310,20 @@ int main(int argc, char *argv[])
#endif
srand((unsigned)time(0));
#ifdef _WIN32
{
const char *var;
var = getenv("LC_ALL");
if (!var)
var = getenv("LC_NUMERIC");
if (!var)
var = getenv("LANG");
if (!var || strcmp(var, "C") != 0)
setlocale(LC_ALL, "");
}
#else
setlocale(LC_ALL, "");
#endif
if(!init_options()) {
flac__utils_printf(stderr, 1, "ERROR: allocating memory\n");
retval = 1;

View File

@ -43,7 +43,20 @@ int main(int argc, char *argv[])
}
#endif
#ifdef _WIN32
{
const char *var;
var = getenv("LC_ALL");
if (!var)
var = getenv("LC_NUMERIC");
if (!var)
var = getenv("LANG");
if (!var || strcmp(var, "C") != 0)
setlocale(LC_ALL, "");
}
#else
setlocale(LC_ALL, "");
#endif
init_options(&options);
if ((ret = parse_options(argc, argv, &options)) == 0)