wxGetenv was incorrectly implemented, caching prevented it from reflecting environment changes -- now fixed
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27605 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1329,36 +1329,16 @@ long WXDLLEXPORT wxAtol(const wxChar *psz)
|
|||||||
|
|
||||||
wxChar * WXDLLEXPORT wxGetenv(const wxChar *name)
|
wxChar * WXDLLEXPORT wxGetenv(const wxChar *name)
|
||||||
{
|
{
|
||||||
static wxHashTable env(wxKEY_STRING);
|
|
||||||
|
|
||||||
// check if we already have stored the converted env var
|
|
||||||
wxObject *data = env.Get(name);
|
|
||||||
if (!data)
|
|
||||||
{
|
|
||||||
// nope, retrieve it,
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
wxCharBuffer buffer = wxConvLocal.cWX2MB(name);
|
// NB: buffer returned by getenv() is allowed to be overwritten next
|
||||||
// printf( "buffer %s\n", (const char*) buffer );
|
// time getenv() is called, so it is OK to use static string
|
||||||
const char *val = getenv( (const char *)buffer );
|
// buffer to hold the data.
|
||||||
|
static wxWCharBuffer value((wxChar*)NULL);
|
||||||
|
value = wxConvLocal.cMB2WX(getenv(wxConvLocal.cWX2MB(name)));
|
||||||
|
return value.data();
|
||||||
#else
|
#else
|
||||||
const char *val = getenv( name );
|
return getenv(name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!val) return (wxChar *)NULL;
|
|
||||||
// printf( "home %s\n", val );
|
|
||||||
|
|
||||||
// convert it,
|
|
||||||
#if wxUSE_UNICODE
|
|
||||||
data = (wxObject *)new wxString(val, wxConvLocal);
|
|
||||||
#else
|
|
||||||
data = (wxObject *)new wxString(val);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// and store it
|
|
||||||
env.Put(name, data);
|
|
||||||
}
|
|
||||||
// return converted env var
|
|
||||||
return (wxChar *)((wxString *)data)->c_str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int WXDLLEXPORT wxSystem(const wxChar *psz)
|
int WXDLLEXPORT wxSystem(const wxChar *psz)
|
||||||
|
Reference in New Issue
Block a user