Date: Friday, March 17, 2006 @ 18:57:06
  Author: marc
    Path: /cvsroot/carob/carob/src

Modified: Common.cpp (1.32 -> 1.33)

Do not abort any more on misconfigured LANG variable, but fallback on current 
global locale instead.


------------+
 Common.cpp |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletion(-)


Index: carob/src/Common.cpp
diff -u carob/src/Common.cpp:1.32 carob/src/Common.cpp:1.33
--- carob/src/Common.cpp:1.32   Thu Mar 16 18:24:25 2006
+++ carob/src/Common.cpp        Fri Mar 17 18:57:05 2006
@@ -31,6 +31,7 @@
 
 #include <iostream>
 #include <sstream> //for wostringstream
+#include <stdexcept>
 
 #include <stdlib.h>
 
@@ -195,11 +196,23 @@
       throw;
     }
   }
+
+  std::locale tryuserlocale()
+  {
+    try {
+      return std::locale("");
+    } catch (std::runtime_error& ) {
+      logWarn(__WFILE__ L":tryuserlocale()",
+              L"Missing user-preferred locale (check LANG). "
+              "Falling back on current global locale.");
+      return std::locale();
+    }
+  }
 }
 
 // init order matters here, since a failure to init utf8_codec will
 // call user_codec
-const CarobNS::MBSCodec CarobNS::StaticCodecs::user_codec;
+const CarobNS::MBSCodec CarobNS::StaticCodecs::user_codec(tryuserlocale());
 const CarobNS::MBSCodec CarobNS::StaticCodecs::utf8_codec(tryUTF8locale());
 
 //Can this be factorized with ParameterStatement ?

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to