From 6a23b17509dccbaccfaf664017d407bb913076d1 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Sun, 13 May 2012 00:04:17 +0200 Subject: [PATCH] Work around broken libs that call setlocale(LC_ALL, ""); Because that can fuck up parsing floats if your locale uses ',' as a radix. LADSPA plugins that may be used by ALSA do this. A PITA to debug. --- neo/sys/linux/main.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/neo/sys/linux/main.cpp b/neo/sys/linux/main.cpp index d1cfe60f..be074027 100644 --- a/neo/sys/linux/main.cpp +++ b/neo/sys/linux/main.cpp @@ -42,6 +42,8 @@ If you have questions concerning this license or the applicable additional terms #include "sys/linux/local.h" +#include + static idStr basepath; static idStr savepath; @@ -285,8 +287,16 @@ main =============== */ int main(int argc, char **argv) { + setlocale(LC_ALL, "C"); Posix_EarlyInit( ); + // some ladspa-plugins (that may be indirectly loaded by doom3 if they're + // used by alsa) call setlocale(LC_ALL, ""); This sets LC_ALL to $LANG or + // $LC_ALL which usually is not "C" and will fuck up scanf, strtod + // etc when using a locale that uses ',' as a float radix. + // so set $LC_ALL to "C". + setenv("LC_ALL", "C", 1); + if ( argc > 1 ) { common->Init( argc-1, &argv[1] ); } else { @@ -298,4 +308,5 @@ int main(int argc, char **argv) { while (1) { common->Frame(); } + return 0; }