-const char *wxSysErrorMsg(unsigned long nErrCode)
-{
- if ( nErrCode == 0 )
- nErrCode = wxSysErrorCode();
-
- #ifdef __WXMSW__
- #ifdef __WIN32__
- static char s_szBuf[LOG_BUFFER_SIZE / 2];
-
- // get error message from system
- LPVOID lpMsgBuf;
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, nErrCode,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR)&lpMsgBuf,
- 0, NULL);
-
- // copy it to our buffer and free memory
- strncpy(s_szBuf, (const char *)lpMsgBuf, WXSIZEOF(s_szBuf) - 1);
- s_szBuf[WXSIZEOF(s_szBuf) - 1] = '\0';
- LocalFree(lpMsgBuf);
-
- // returned string is capitalized and ended with '\r\n' - bad
- s_szBuf[0] = (char)wxToLower(s_szBuf[0]);
- size_t len = strlen(s_szBuf);
- if ( len > 0 ) {
- // truncate string
- if ( s_szBuf[len - 2] == '\r' )
- s_szBuf[len - 2] = '\0';
- }
-
- return s_szBuf;
- #else //Win16
- // TODO @@@@
- return NULL;
- #endif // Win16/32
- #else // Unix
- return strerror(nErrCode);
- #endif // Win/Unix
-}
-
-// ----------------------------------------------------------------------------
-// debug helper
-// ----------------------------------------------------------------------------
-
-#ifdef __WXDEBUG__
-
-void Trap()
-{
- #ifdef __WXMSW__
- DebugBreak();
- #elif defined(__WXSTUBS__)
- // TODO
- #else // Unix
- raise(SIGTRAP);
- #endif // Win/Unix
-}
-
-// this function is called when an assert fails
-void wxOnAssert(const char *szFile, int nLine, const char *szMsg)
-{
- // this variable can be set to true to suppress "assert failure" messages
- static bool s_bNoAsserts = FALSE;
- static bool s_bInAssert = FALSE;
-
- if ( s_bInAssert ) {
- // He-e-e-e-elp!! we're trapped in endless loop
- Trap();
- }
-
- s_bInAssert = TRUE;
-
- char szBuf[LOG_BUFFER_SIZE];
- sprintf(szBuf, _("Assert failed in file %s at line %d"), szFile, nLine);
- if ( szMsg != NULL ) {
- strcat(szBuf, ": ");
- strcat(szBuf, szMsg);
- }
- else {
- strcat(szBuf, ".");
- }
-
- if ( !s_bNoAsserts ) {
- // send it to the normal log destination
- wxLogDebug(szBuf);
-
- #ifdef wxUSE_NOGUI
- Trap();
- #else
- strcat(szBuf, _("\nDo you want to stop the program?"
- "\nYou can also choose [Cancel] to suppress "
- "further warnings."));
-
- switch ( wxMessageBox(szBuf, _("Debug"),
- wxYES_NO | wxCANCEL | wxICON_STOP ) ) {
- case wxYES:
- Trap();
- break;
-
- case wxCANCEL:
- s_bNoAsserts = TRUE;
- break;
-
- //case wxNO: nothing to do
- }
- #endif // USE_NOGUI
- }
+const wxChar *wxSysErrorMsg(unsigned long nErrCode)
+{
+ if ( nErrCode == 0 )
+ nErrCode = wxSysErrorCode();
+
+#if defined(__WXMSW__) && !defined(__WXMICROWIN__)
+ static wxChar s_szBuf[LOG_BUFFER_SIZE / 2];
+
+ // get error message from system
+ LPVOID lpMsgBuf;
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL, nErrCode,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR)&lpMsgBuf,
+ 0, NULL);
+
+ // copy it to our buffer and free memory
+ if( lpMsgBuf != 0 ) {
+ wxStrncpy(s_szBuf, (const wxChar *)lpMsgBuf, WXSIZEOF(s_szBuf) - 1);
+ s_szBuf[WXSIZEOF(s_szBuf) - 1] = wxT('\0');
+
+ LocalFree(lpMsgBuf);
+
+ // returned string is capitalized and ended with '\r\n' - bad
+ s_szBuf[0] = (wxChar)wxTolower(s_szBuf[0]);
+ size_t len = wxStrlen(s_szBuf);
+ if ( len > 0 ) {
+ // truncate string
+ if ( s_szBuf[len - 2] == wxT('\r') )
+ s_szBuf[len - 2] = wxT('\0');
+ }
+ }
+ else {
+ s_szBuf[0] = wxT('\0');
+ }