]> git.saurik.com Git - wxWidgets.git/commitdiff
fixing strange bug under OS X (null strings from within CoreFoundation)
authorStefan Csomor <csomor@advancedconcepts.ch>
Wed, 19 Dec 2007 17:05:57 +0000 (17:05 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Wed, 19 Dec 2007 17:05:57 +0000 (17:05 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50833 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/wxcrt.cpp

index c50a880767d011c72845fa1c681c3305131341e6..9ae281d008da750a34f8246e6b17f3b9fbea3b05 100644 (file)
@@ -167,26 +167,17 @@ char* wxSetlocale(int category, const char *locale)
     char *rv = NULL ;
     if ( locale != NULL && locale[0] == 0 )
     {
-        locale_t lt = newlocale(LC_ALL_MASK, "", NULL);
-        if ( lt )
-        {
-            rv = (char*) querylocale( LC_ALL_MASK, lt );
-            freelocale(lt);
-        }
-        if ( rv == NULL || rv[0] == 0  || strcmp( rv , "C" ) == 0 || strcmp( rv, "POSIX" ) == 0 )
-        {
-            // we have to emulate the behaviour under OS X
-            wxCFRef<CFLocaleRef> userLocaleRef(CFLocaleCopyCurrent());
-            wxCFStringRef str(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleLanguageCode)));
-            wxString langFull = str.AsString()+"_";
-            str.reset(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleCountryCode)));
-            langFull += str.AsString();
-            rv = setlocale(category, langFull.c_str());
-        }
-        else
-        {
-            rv = setlocale(category, rv);
-        }
+        // the attempt to use newlocale(LC_ALL_MASK, "", NULL);
+        // here in order to deduce the language along the environment vars rules
+        // lead to strange crashes later...
+
+        // we have to emulate the behaviour under OS X
+        wxCFRef<CFLocaleRef> userLocaleRef(CFLocaleCopyCurrent());
+        wxCFStringRef str(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleLanguageCode)));
+        wxString langFull = str.AsString()+"_";
+        str.reset(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleCountryCode)));
+        langFull += str.AsString();
+        rv = setlocale(category, langFull.c_str());
     }
     else
         rv = setlocale(category, locale);