Commit 865041b7 authored by Erik de Castro Lopo's avatar Erik de Castro Lopo
Browse files

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>
parent 491475e6
......@@ -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;
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment