blind fix to wxGetCwd crash on NT when wxUSE_UNICODE=1 and wxUSE_UNICODE_MSLU=0

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14681 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2002-03-19 00:04:57 +00:00
parent a4f2452697
commit 247f8a77bc

View File

@@ -1396,30 +1396,30 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
// for the compilers which have Unicode version of _getcwd(), call it // for the compilers which have Unicode version of _getcwd(), call it
// directly, for the others call the ANSI version and do the translation // directly, for the others call the ANSI version and do the translation
#if !wxUSE_UNICODE #if !wxUSE_UNICODE
#define cbuf buf #define cbuf buf
#else // wxUSE_UNICODE #else // wxUSE_UNICODE
bool needsANSI = TRUE; bool needsANSI = TRUE;
#if !defined(HAVE_WGETCWD) || wxUSE_UNICODE_MSLU #if !defined(HAVE_WGETCWD) || wxUSE_UNICODE_MSLU
wxCharBuffer c_buffer(sz); wxCharBuffer c_buffer(sz);
char *cbuf = (char*)(const char*)c_buffer; char *cbuf = (char*)(const char*)c_buffer;
#endif
#ifdef HAVE_WGETCWD
#if wxUSE_UNICODE_MSLU
if ( wxGetOsVersion() != wxWIN95 )
#else
char *cbuf = NULL; // never really used because needsANSI will always be FALSE
#endif
{
ok = _wgetcwd(buf, sz) != NULL;
needsANSI = FALSE;
}
#endif #endif
if ( needsANSI ) #ifdef HAVE_WGETCWD
#if wxUSE_UNICODE_MSLU
if ( wxGetOsVersion() != wxWIN95 )
#else
char *cbuf = NULL; // never really used because needsANSI will always be FALSE
#endif
{
ok = _wgetcwd(buf, sz) != NULL;
needsANSI = FALSE;
}
#endif
if ( needsANSI )
#endif // wxUSE_UNICODE #endif // wxUSE_UNICODE
{ {
#ifdef _MSC_VER #ifdef _MSC_VER
ok = _getcwd(cbuf, sz) != NULL; ok = _getcwd(cbuf, sz) != NULL;
#elif defined(__WXMAC__) && !defined(__DARWIN__) #elif defined(__WXMAC__) && !defined(__DARWIN__)
@@ -1458,7 +1458,12 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
#else // !Win32/VC++ !Mac !OS2 #else // !Win32/VC++ !Mac !OS2
ok = getcwd(cbuf, sz) != NULL; ok = getcwd(cbuf, sz) != NULL;
#endif // platform #endif // platform
}
#if wxUSE_UNICODE
// finally convert the result to Unicode if needed
wxConvFile.MB2WC(buf, cbuf, sz);
#endif // wxUSE_UNICODE
}
if ( !ok ) if ( !ok )
{ {
@@ -1487,17 +1492,12 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
wxString pathUnix = buf; wxString pathUnix = buf;
cygwin_conv_to_full_win32_path(pathUnix, buf); cygwin_conv_to_full_win32_path(pathUnix, buf);
#endif // __CYGWIN__ #endif // __CYGWIN__
// finally convert the result to Unicode if needed
#if wxUSE_UNICODE
wxConvFile.MB2WC(buf, cbuf, sz);
#endif // wxUSE_UNICODE
} }
return buf; return buf;
#if !wxUSE_UNICODE #if !wxUSE_UNICODE
#undef cbuf #undef cbuf
#endif #endif
} }