]> git.saurik.com Git - wxWidgets.git/commitdiff
Defer retrieval of LANG env var, too. No memory management
authorOve Kaaven <ovek@arcticnet.no>
Sat, 17 Apr 1999 23:01:48 +0000 (23:01 +0000)
committerOve Kaaven <ovek@arcticnet.no>
Sat, 17 Apr 1999 23:01:48 +0000 (23:01 +0000)
or conversion is now performed in wxCSConv constructor.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2224 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/string.cpp

index 7759ed8766ed8c91d33f326ee257dfff63106e3d..532e77b6d584ccce386c9acde210e6c62c0df2bd 100644 (file)
@@ -2021,6 +2021,7 @@ static void wxLoadCharacterSets(void)
 
 static wxCharacterSet *wxFindCharacterSet(const wxChar *charset)
 {
+  if (!charset) return (wxCharacterSet *)NULL;
   wxLoadCharacterSets();
   for (size_t n=0; n<wxCharsets.GetCount(); n++)
     if (wxCharsets[n].names.Index(charset) != wxNOT_FOUND)
@@ -2032,15 +2033,19 @@ WXDLLEXPORT_DATA(wxCSConv) wxConv_local((const wxChar *)NULL);
 
 wxCSConv::wxCSConv(const wxChar *charset)
 {
-  if (!charset) {
-#ifdef __UNIX__
-    wxChar *lang = wxGetenv(_T("LANG"));
-    wxChar *dot = lang ? wxStrchr(lang, _T('.')) : (wxChar *)NULL;
-    if (dot) charset = dot+1;
-#endif
-  }
+  m_name = (wxChar *) NULL;
   m_cset = (wxCharacterSet *) NULL;
-  m_deferred = FALSE;
+  m_deferred = TRUE;
+  SetName(charset);
+}
+
+wxCSConv::~wxCSConv()
+{
+  if (m_name) free(m_name);
+}
+
+void wxCSConv::SetName(const wxChar *charset)
+{
   if (charset) {
 #ifdef __UNIX__
     // first, convert the character set name to standard form
@@ -2065,15 +2070,17 @@ wxCSConv::wxCSConv(const wxChar *charset)
   }
 }
 
-wxCSConv::~wxCSConv()
-{
-  free(m_name);
-}
-
 void wxCSConv::LoadNow()
 {
 //  wxPrintf(_T("Conversion request\n"));
   if (m_deferred) {
+    if (!m_name) {
+#ifdef __UNIX__
+      wxChar *lang = wxGetenv(_T("LANG"));
+      wxChar *dot = lang ? wxStrchr(lang, _T('.')) : (wxChar *)NULL;
+      if (dot) SetName(dot+1);
+#endif
+    }
     m_cset = wxFindCharacterSet(m_name);
     m_deferred = FALSE;
   }