From 7502ba2975bfd348dc50fef2a978e91f543d6bfe Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 17 Jul 1998 21:00:11 +0000 Subject: [PATCH] last traces of wxTString removed git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@293 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/config.cpp | 4 +- src/common/file.cpp | 32 ++++++------ src/common/fileconf.cpp | 46 ++++++++++++------ src/common/intl.cpp | 105 +++++++++++++++++++++------------------- src/common/log.cpp | 71 ++++++++++++++++----------- src/common/textfile.cpp | 4 +- 6 files changed, 149 insertions(+), 113 deletions(-) diff --git a/src/common/config.cpp b/src/common/config.cpp index 629a359f91..667d25e5fe 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -200,7 +200,7 @@ wxString ExpandEnvVars(const wxString& str) // check the closing bracket if ( bracket != Bracket_None ) { if ( m == str.Len() || str[m] != (char)bracket ) { - wxLogWarning("missing '%c' at position %d in '%s'.", + wxLogWarning(_("missing '%c' at position %d in '%s'."), (char)bracket, m + 1, str.c_str()); } else { @@ -238,7 +238,7 @@ void SplitPath(wxArrayString& aParts, const char *sz) else if ( strCurrent == ".." ) { // go up one level if ( aParts.IsEmpty() ) - wxLogWarning("'%s' has extra '..', ignored.", sz); + wxLogWarning(_("'%s' has extra '..', ignored."), sz); else aParts.Remove(aParts.Count() - 1); diff --git a/src/common/file.cpp b/src/common/file.cpp index d4a0e13551..f2f047c345 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -146,7 +146,7 @@ bool wxFile::Create(const char *szFileName, bool bOverwrite) int fd = open(szFileName, O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL)); if ( fd == -1 ) { - wxLogSysError("can't create file '%s'", szFileName); + wxLogSysError(_("can't create file '%s'"), szFileName); return FALSE; } else { @@ -181,7 +181,7 @@ bool wxFile::Open(const char *szFileName, OpenMode mode) int fd = open(szFileName, flags, S_IREAD | S_IWRITE); if ( fd == -1 ) { - wxLogSysError("can't open file '%s'", szFileName); + wxLogSysError(_("can't open file '%s'"), szFileName); return FALSE; } else { @@ -195,7 +195,7 @@ bool wxFile::Close() { if ( IsOpened() ) { if ( close(m_fd) == -1 ) { - wxLogSysError("can't close file descriptor %d", m_fd); + wxLogSysError(_("can't close file descriptor %d"), m_fd); m_fd = fd_invalid; return FALSE; } @@ -217,7 +217,7 @@ off_t wxFile::Read(void *pBuf, off_t nCount) int iRc = ::read(m_fd, pBuf, nCount); if ( iRc == -1 ) { - wxLogSysError("can't read from file descriptor %d", m_fd); + wxLogSysError(_("can't read from file descriptor %d"), m_fd); return ofsInvalid; } else @@ -231,22 +231,22 @@ uint wxFile::Write(const void *pBuf, uint nCount) int iRc = ::write(m_fd, pBuf, nCount); if ( iRc == -1 ) { - wxLogSysError("can't write to file descriptor %d", m_fd); + wxLogSysError(_("can't write to file descriptor %d"), m_fd); m_error = TRUE; return 0; } else - return iRc; + return (uint)iRc; } // flush bool wxFile::Flush() { if ( IsOpened() ) { - // @@@ fsync() is not ANSI (BSDish) +// @@@ fsync() is not ANSI (BSDish) // if ( fsync(m_fd) == -1 ) { // TODO if (TRUE) { - wxLogSysError("can't flush file descriptor %d", m_fd); + wxLogSysError(_("can't flush file descriptor %d"), m_fd); return FALSE; } } @@ -283,7 +283,7 @@ off_t wxFile::Seek(off_t ofs, wxSeekMode mode) int iRc = lseek(m_fd, ofs, flag); if ( iRc == -1 ) { - wxLogSysError("can't seek on file descriptor %d", m_fd); + wxLogSysError(_("can't seek on file descriptor %d"), m_fd); return ofsInvalid; } else @@ -297,7 +297,7 @@ off_t wxFile::Tell() const int iRc = tell(m_fd); if ( iRc == -1 ) { - wxLogSysError("can't get seek position on file descriptor %d", m_fd); + wxLogSysError(_("can't get seek position on file descriptor %d"), m_fd); return ofsInvalid; } else @@ -330,7 +330,7 @@ off_t wxFile::Length() const #endif //_MSC_VER if ( iRc == -1 ) { - wxLogSysError("can't find length of file on file descriptor %d", m_fd); + wxLogSysError(_("can't find length of file on file descriptor %d"), m_fd); return ofsInvalid; } else @@ -364,8 +364,8 @@ bool wxFile::Eof() const return FALSE; case -1: - wxLogSysError("can't determine if the end of file is reached on " - "descriptor %d", m_fd); + wxLogSysError(_("can't determine if the end of file is reached on " + "descriptor %d"), m_fd); break; default: @@ -427,12 +427,12 @@ bool wxTempFile::Commit() m_file.Close(); if ( wxFile::Exists(m_strName) && remove(m_strName) != 0 ) { - wxLogSysError("can't remove file '%s'", m_strName.c_str()); + wxLogSysError(_("can't remove file '%s'"), m_strName.c_str()); return FALSE; } if ( rename(m_strTemp, m_strName) != 0 ) { - wxLogSysError("can't commit changes to file '%s'", m_strName.c_str()); + wxLogSysError(_("can't commit changes to file '%s'"), m_strName.c_str()); return FALSE; } @@ -443,5 +443,5 @@ void wxTempFile::Discard() { m_file.Close(); if ( remove(m_strTemp) != 0 ) - wxLogSysError("can't remove temporary file '%s'", m_strTemp.c_str()); + wxLogSysError(_("can't remove temporary file '%s'"), m_strTemp.c_str()); } diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index f25cb997dc..a3f3df3f2c 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -107,7 +107,7 @@ wxString wxFileConfig::GetLocalFileName(const char *szFile) const char *szHome = getenv("HOME"); if ( szHome == NULL ) { // we're homeless... - wxLogWarning("can't find user's HOME, using current directory."); + wxLogWarning(_("can't find user's HOME, using current directory.")); szHome = "."; } str << szHome << "/." << szFile; @@ -165,7 +165,7 @@ wxFileConfig::wxFileConfig(const wxString& strLocal, const wxString& strGlobal) SetRootPath(); } else - wxLogWarning("Can't open global configuration file '%s'.", + wxLogWarning(_("can't open global configuration file '%s'."), strGlobal.c_str()); } } @@ -178,7 +178,7 @@ wxFileConfig::wxFileConfig(const wxString& strLocal, const wxString& strGlobal) SetRootPath(); } else - wxLogWarning("Can't open user configuration file '%s'.", + wxLogWarning(_("can't open user configuration file '%s'."), strLocal.c_str()); } } @@ -227,7 +227,7 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal) } if ( *pEnd != ']' ) { - wxLogError("file '%s': unexpected character %c at line %d.", + wxLogError(_("file '%s': unexpected character %c at line %d."), file.GetName(), *pEnd, n + 1); continue; // skip this line } @@ -258,7 +258,8 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal) break; default: - wxLogWarning("file '%s', line %d: '%s' ignored after group header.", + wxLogWarning(_("file '%s', line %d: '%s' " + "ignored after group header."), file.GetName(), n + 1, pEnd); bCont = FALSE; } @@ -276,7 +277,8 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal) pEnd++; if ( *pEnd++ != '=' ) { - wxLogError("file '%s', line %d: '=' expected.", file.GetName(), n + 1); + wxLogError(_("file '%s', line %d: '=' expected."), + file.GetName(), n + 1); } else { ConfigEntry *pEntry = m_pCurrentGroup->FindEntry(strKey); @@ -291,7 +293,8 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal) else { if ( bLocal && pEntry->IsImmutable() ) { // immutable keys can't be changed by user - wxLogWarning("file '%s', line %d: value for immutable key '%s' ignored.", + wxLogWarning(_("file '%s', line %d: value for " + "immutable key '%s' ignored."), file.GetName(), n + 1, strKey.c_str()); continue; } @@ -301,7 +304,8 @@ void wxFileConfig::Parse(wxTextFile& file, bool bLocal) // (c) key from global file now found in local one // which is exactly what we want. else if ( !bLocal || pEntry->IsLocal() ) { - wxLogWarning("file '%s', line %d: key '%s' was first found at line %d.", + wxLogWarning(_("file '%s', line %d: key '%s' was first " + "found at line %d."), file.GetName(), n + 1, strKey.c_str(), pEntry->Line()); if ( bLocal ) @@ -498,14 +502,14 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */) wxTempFile file(m_strLocalFile); if ( !file.IsOpened() ) { - wxLogError("Can't open user configuration file."); + wxLogError(_("can't open user configuration file.")); return FALSE; } // write all strings to file for ( LineList *p = m_linesHead; p != NULL; p = p->Next() ) { if ( !file.Write(p->Text() + wxTextFile::GetEOL()) ) { - wxLogError("Can't write user configuration file."); + wxLogError(_("can't write user configuration file.")); return FALSE; } } @@ -550,11 +554,11 @@ bool wxFileConfig::DeleteAll() Init(); if ( remove(szFile) == -1 ) - wxLogSysError("Can't delete user configuration file '%s'", szFile); + wxLogSysError(_("can't delete user configuration file '%s'"), szFile); szFile = m_strGlobalFile; if ( remove(szFile) ) - wxLogSysError("Can't delete system configuration file '%s'", szFile); + wxLogSysError(_("can't delete system configuration file '%s'"), szFile); return TRUE; } @@ -935,7 +939,7 @@ wxFileConfig::ConfigEntry::ConfigEntry(wxFileConfig::ConfigGroup *pParent, void wxFileConfig::ConfigEntry::SetLine(LineList *pLine) { if ( m_pLine != NULL ) { - wxLogWarning("Entry '%s' appears more than once in group '%s'", + wxLogWarning(_("entry '%s' appears more than once in group '%s'"), Name().c_str(), m_pParent->GetFullName().c_str()); } @@ -948,7 +952,7 @@ void wxFileConfig::ConfigEntry::SetLine(LineList *pLine) void wxFileConfig::ConfigEntry::SetValue(const wxString& strValue, bool bUser) { if ( bUser && IsImmutable() ) { - wxLogWarning("Attempt to change immutable key '%s' ignored.", + wxLogWarning(_("attempt to change immutable key '%s' ignored."), Name().c_str()); return; } @@ -1034,6 +1038,10 @@ wxString FilterIn(const wxString& str) strResult += '\n'; break; + case 'r': + strResult += '\r'; + break; + case 't': strResult += '\t'; break; @@ -1050,8 +1058,10 @@ wxString FilterIn(const wxString& str) else { if ( str[n] != '"' || !bQuoted ) strResult += str[n]; - else if ( n != str.Len() - 1 ) - wxLogWarning("unexpected \" at position %d in '%s'.", n, str.c_str()); + else if ( n != str.Len() - 1 ) { + wxLogWarning(_("unexpected \" at position %d in '%s'."), + n, str.c_str()); + } //else: it's the last quote of a quoted string, ok } } @@ -1078,6 +1088,10 @@ wxString FilterOut(const wxString& str) c = 'n'; break; + case '\r': + c = 'r'; + break; + case '\t': c = 't'; break; diff --git a/src/common/intl.cpp b/src/common/intl.cpp index b5520e58b7..eb52e900b9 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -10,7 +10,7 @@ ///////////////////////////////////////////////////////////////////////////// // ============================================================================ -// declaration +// declarations // ============================================================================ // ---------------------------------------------------------------------------- @@ -28,17 +28,19 @@ #pragma hdrstop #endif -// standard headers -#include - // wxWindows -#include "wx/defs.h" -#include "wx/string.h" +#ifndef WX_PRECOMP + #include "wx/defs.h" + #include "wx/string.h" +#endif //WX_PRECOMP + #include "wx/intl.h" #include "wx/file.h" #include "wx/log.h" #include "wx/utils.h" +// standard headers +#include #include // ---------------------------------------------------------------------------- @@ -53,23 +55,23 @@ const uint32 MSGCATALOG_MAGIC_SW = 0xde120495; #define MSGCATALOG_EXTENSION ".mo" // ---------------------------------------------------------------------------- -// global functions +// global functions (private to this module) // ---------------------------------------------------------------------------- // suppress further error messages about missing translations // (if you don't have one catalog file, you wouldn't like to see the // error message for each string in it, so normally it's given only // once) -void wxSuppressTransErrors(); +static void wxSuppressTransErrors(); // restore the logging -void wxRestoreTransErrors(); +static void wxRestoreTransErrors(); // get the current state -bool wxIsLoggingTransErrors(); +static bool wxIsLoggingTransErrors(); -// get the current locale object (## may be NULL!) -extern wxLocale *wxSetLocale(wxLocale *pLocale); +// get the current locale object (@@ may be NULL!) +static wxLocale *wxSetLocale(wxLocale *pLocale); // ---------------------------------------------------------------------------- // wxMsgCatalog corresponds to one disk-file message catalog. @@ -197,6 +199,8 @@ wxMsgCatalog::~wxMsgCatalog() DELETEA(m_pszName); } +// a helper class which suppresses all translation error messages +// from the moment of it's creation until it's destruction class NoTransErr { public: @@ -207,15 +211,15 @@ class NoTransErr // open disk file and read in it's contents bool wxMsgCatalog::Load(const char *szDirPrefix, const char *szName) { - // search order (assume language 'foo') is - // 1) $LC_PATH/foo/LC_MESSAGES (if LC_PATH set) - // 2) ./foo/LC_MESSAGES - // 3) ./foo + // search order (assume language 'lang') is + // 1) $LC_PATH/lang/LC_MESSAGES (if LC_PATH set) + // 2) ./lang/LC_MESSAGES + // 3) ./lang // 4) . (Added by JACS) // // under UNIX we search also in: - // 5) /usr/share/locale/foo/LC_MESSAGES (Linux) - // 6) /usr/lib/locale/foo/LC_MESSAGES (Solaris) + // 5) /usr/share/locale/lang/LC_MESSAGES (Linux) + // 6) /usr/lib/locale/lang/LC_MESSAGES (Solaris) #define MSG_PATH FILE_SEP_PATH + "LC_MESSAGES" PATH_SEP wxString strPath(""); @@ -225,12 +229,12 @@ bool wxMsgCatalog::Load(const char *szDirPrefix, const char *szName) // NB: '<<' is unneeded between too literal strings: // they are concatenated at compile time - strPath += "./" + wxString(szDirPrefix) + MSG_PATH // (2) - + "./" + szDirPrefix + FILE_SEP_PATH + PATH_SEP // (3) - + "." + PATH_SEP + strPath << "./" << wxString(szDirPrefix) + MSG_PATH // (2) + << "./" << szDirPrefix << FILE_SEP_PATH << PATH_SEP // (3) + << "." << PATH_SEP // (4) #ifdef __UNIX__ - "/usr/share/locale/" + szDirPrefix + MSG_PATH // (5) - "/usr/lib/locale/" + szDirPrefix + MSG_PATH // (6) + "/usr/share/locale/" << szDirPrefix << MSG_PATH // (5) + "/usr/lib/locale/" << szDirPrefix << MSG_PATH // (6) #endif //UNIX ; @@ -243,38 +247,41 @@ bool wxMsgCatalog::Load(const char *szDirPrefix, const char *szName) // (we're using an object because we have several return paths) NoTransErr noTransErr; - wxLogVerbose("looking for catalog '%s' in path '%s'.", - szName, strPath.c_str()); + wxLogVerbose(_("looking for catalog '%s' in path '%s'..."), + szName, strPath.c_str()); wxString strFullName; if ( !wxFindFileInPath(&strFullName, strPath, strFile) ) { - wxLogWarning("catalog file for domain '%s' not found.", szName); + wxLogWarning(_("catalog file for domain '%s' not found."), szName); return FALSE; } // open file - wxLogVerbose("using catalog '%s' from '%s'.", - szName, strFullName.c_str()); + wxLogVerbose(_("catalog '%s' found in '%s'."), szName, strFullName.c_str()); + // declare these vars here because we're using goto further down + bool bValid; + off_t nSize; + wxFile fileMsg(strFullName); if ( !fileMsg.IsOpened() ) - return FALSE; + goto error; // get the file size - off_t nSize = fileMsg.Length(); + nSize = fileMsg.Length(); if ( nSize == ofsInvalid ) - return FALSE; + goto error; // read the whole file in memory m_pData = new uint8[nSize]; if ( fileMsg.Read(m_pData, nSize) != nSize ) { DELETEA(m_pData); m_pData = NULL; - return FALSE; + goto error; } // examine header - bool bValid = (size_t)nSize > sizeof(wxMsgCatalogHeader); + bValid = (size_t)nSize > sizeof(wxMsgCatalogHeader); wxMsgCatalogHeader *pHeader; if ( bValid ) { @@ -289,7 +296,8 @@ bool wxMsgCatalog::Load(const char *szDirPrefix, const char *szName) if ( !bValid ) { // it's either too short or has incorrect magic number - wxLogWarning("'%s' is not a valid message catalog.", strFullName.c_str()); + wxLogWarning(_("'%s' is not a valid message catalog."), + strFullName.c_str()); DELETEA(m_pData); m_pData = NULL; @@ -298,10 +306,8 @@ bool wxMsgCatalog::Load(const char *szDirPrefix, const char *szName) // initialize m_numStrings = Swap(pHeader->numStrings); - m_pOrigTable = (wxMsgTableEntry *)(m_pData + - Swap(pHeader->ofsOrigTable)); - m_pTransTable = (wxMsgTableEntry *)(m_pData + - Swap(pHeader->ofsTransTable)); + m_pOrigTable = (wxMsgTableEntry *)(m_pData + Swap(pHeader->ofsOrigTable)); + m_pTransTable = (wxMsgTableEntry *)(m_pData + Swap(pHeader->ofsTransTable)); m_nHashSize = Swap(pHeader->nHashSize); m_pHashTable = (uint32 *)(m_pData + Swap(pHeader->ofsHashTable)); @@ -311,6 +317,11 @@ bool wxMsgCatalog::Load(const char *szDirPrefix, const char *szName) // everything is fine return TRUE; + +error: + wxLogError(_("error opening message catalog '%s', not loaded."), + strFullName.c_str()); + return FALSE; } // search for a string @@ -375,12 +386,12 @@ wxLocale::wxLocale(const char *szName, szLocale = szName; m_pszOldLocale = setlocale(LC_ALL, szLocale); if ( m_pszOldLocale == NULL ) - wxLogError("locale '%s' can not be set.", szLocale); + wxLogError(_("locale '%s' can not be set."), szLocale); // the short name will be used to look for catalog files as well, // so we need something here if ( m_strShort.IsEmpty() ) { - // #### I don't know how these 2 letter abbreviations are formed, + // @@@@ I don't know how these 2 letter abbreviations are formed, // this wild guess is almost surely wrong m_strShort = wxToLower(szLocale[0]) + wxToLower(szLocale[1]); } @@ -442,11 +453,12 @@ const char *wxLocale::GetString(const char *szOrigString, wxSuppressTransErrors(); if ( szDomain != NULL ) - wxLogWarning("string '%s' not found in domain '%s' for locale '%s'.", - szOrigString, szDomain, m_strLocale.c_str()); + wxLogWarning(_("string '%s' not found in domain '%s'" + " for locale '%s'."), + szOrigString, szDomain, m_strLocale.c_str()); else - wxLogWarning("string '%s' not found in locale '%s'.", - szOrigString, m_strLocale.c_str()); + wxLogWarning(_("string '%s' not found in locale '%s'."), + szOrigString, m_strLocale.c_str()); } return szOrigString; @@ -525,11 +537,6 @@ bool wxIsLoggingTransErrors() // the current locale object wxLocale *g_pLocale = NULL; -wxLocale *wxGetLocale() -{ - return g_pLocale; -} - wxLocale *wxSetLocale(wxLocale *pLocale) { wxLocale *pOld = g_pLocale; diff --git a/src/common/log.cpp b/src/common/log.cpp index 62a70119a0..08436becec 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -83,12 +83,12 @@ static char s_szBuf[LOG_BUFFER_SIZE]; // generic log function -void wxLogGeneric(wxLogLevel level, wxTString strFormat, ...) +void wxLogGeneric(wxLogLevel level, const char *szFormat, ...) { if ( wxLog::GetActiveTarget() != NULL ) { va_list argptr; - va_start(argptr, strFormat); - vsprintf(s_szBuf, strFormat, argptr); + va_start(argptr, szFormat); + vsprintf(s_szBuf, szFormat, argptr); va_end(argptr); wxLog::OnLog(level, s_szBuf); @@ -96,12 +96,12 @@ void wxLogGeneric(wxLogLevel level, wxTString strFormat, ...) } #define IMPLEMENT_LOG_FUNCTION(level) \ - void wxLog##level(wxTString strFormat, ...) \ + void wxLog##level(const char *szFormat, ...) \ { \ if ( wxLog::GetActiveTarget() != NULL ) { \ va_list argptr; \ - va_start(argptr, strFormat); \ - vsprintf(s_szBuf, strFormat, argptr); \ + va_start(argptr, szFormat); \ + vsprintf(s_szBuf, szFormat, argptr); \ va_end(argptr); \ \ wxLog::OnLog(wxLOG_##level, s_szBuf); \ @@ -116,13 +116,13 @@ IMPLEMENT_LOG_FUNCTION(Info) IMPLEMENT_LOG_FUNCTION(Status) // same as info, but only if 'verbose' mode is on -void wxLogVerbose(wxTString strFormat, ...) +void wxLogVerbose(const char *szFormat, ...) { wxLog *pLog = wxLog::GetActiveTarget(); if ( pLog != NULL && pLog->GetVerbose() ) { va_list argptr; - va_start(argptr, strFormat); - vsprintf(s_szBuf, strFormat, argptr); + va_start(argptr, szFormat); + vsprintf(s_szBuf, szFormat, argptr); va_end(argptr); wxLog::OnLog(wxLOG_Info, s_szBuf); @@ -181,21 +181,21 @@ void wxLogSysErrorHelper(long lErrCode) wxLog::OnLog(wxLOG_Error, s_szBuf); } -void WXDLLEXPORT wxLogSysError(wxTString strFormat, ...) +void WXDLLEXPORT wxLogSysError(const char *szFormat, ...) { va_list argptr; - va_start(argptr, strFormat); - vsprintf(s_szBuf, strFormat, argptr); + va_start(argptr, szFormat); + vsprintf(s_szBuf, szFormat, argptr); va_end(argptr); wxLogSysErrorHelper(wxSysErrorCode()); } -void WXDLLEXPORT wxLogSysError(long lErrCode, wxTString strFormat, ...) +void WXDLLEXPORT wxLogSysError(long lErrCode, const char *szFormat, ...) { va_list argptr; - va_start(argptr, strFormat); - vsprintf(s_szBuf, strFormat, argptr); + va_start(argptr, szFormat); + vsprintf(s_szBuf, szFormat, argptr); va_end(argptr); wxLogSysErrorHelper(lErrCode); @@ -297,7 +297,7 @@ void wxLog::DoLog(wxLogLevel level, const char *szString) // (don't prepend "Debug" here: it will go to debug window anyhow) ::OutputDebugString(str + szString + "\n\r"); #endif //Win32 - DoLogString(str << (level == wxLOG_Trace ? "Trace" : "Debug") + DoLogString(str << (level == wxLOG_Trace ? _("Trace") : _("Debug")) << ": " << szString); #endif @@ -454,8 +454,8 @@ void wxLogGui::DoLog(wxLogLevel level, const char *szString) OutputDebugString("\n\r"); #else //!WIN32 // send them to stderr - fprintf(stderr, level == wxLOG_Trace ? "Trace: %s\n" - : "Debug: %s\n", szString); + fprintf(stderr, "%s: %s\n", + level == wxLOG_Trace ? _("Trace") : _("Debug"), szString); fflush(stderr); #endif // WIN32 #endif @@ -463,7 +463,7 @@ void wxLogGui::DoLog(wxLogLevel level, const char *szString) case wxLOG_FatalError: // show this one immediately - wxMessageBox(szString, "Fatal error", wxICON_HAND); + wxMessageBox(szString, _("Fatal error"), wxICON_HAND); break; case wxLOG_Error: @@ -633,7 +633,7 @@ void wxLogFrame::OnSave(wxCommandEvent& event) bOk = file.Close(); if ( !bOk ) { - wxLogError("Can't save log contents to file."); + wxLogError(_("Can't save log contents to file.")); return; } } @@ -643,10 +643,10 @@ void wxLogFrame::OnClear(wxCommandEvent& event) m_pTextCtrl->Clear(); } -wxLogWindow::wxLogWindow(const wxTString& strTitle, bool bShow) +wxLogWindow::wxLogWindow(const char *szTitle, bool bShow) { m_pOldLog = wxLog::GetActiveTarget(); - m_pLogFrame = new wxLogFrame(strTitle); + m_pLogFrame = new wxLogFrame(szTitle); if ( bShow ) m_pLogFrame->Show(TRUE); @@ -811,11 +811,28 @@ const char *wxSysErrorMsg(unsigned long nErrCode) #ifdef __WXDEBUG__ +void Trap() +{ + #ifdef __WXMSW__ + DebugBreak(); + #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 s_bNoAsserts = FALSE; + 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); @@ -838,11 +855,7 @@ void wxOnAssert(const char *szFile, int nLine, const char *szMsg) switch ( wxMessageBox(szBuf, _("Debug"), wxYES_NO | wxCANCEL | wxICON_STOP ) ) { case wxYES: - #ifdef __WXMSW__ - DebugBreak(); - #else // Unix - raise(SIGTRAP); - #endif // Win/Unix + Trap(); break; case wxCANCEL: @@ -852,6 +865,8 @@ void wxOnAssert(const char *szFile, int nLine, const char *szMsg) //case wxNO: nothing to do } } + + s_bInAssert = FALSE; } #endif //WXDEBUG diff --git a/src/common/textfile.cpp b/src/common/textfile.cpp index eb9bae9f39..678ddcc688 100644 --- a/src/common/textfile.cpp +++ b/src/common/textfile.cpp @@ -131,7 +131,7 @@ wxTextFile::Type wxTextFile::GuessType() const // interpret the results (@@ far from being even 50% fool proof) if ( nDos + nUnix + nMac == 0 ) { // no newlines at all - wxLogWarning("'%s' is probably a binary file.", m_strFile.c_str()); + wxLogWarning(_("'%s' is probably a binary file."), m_strFile.c_str()); } else { #define GREATER_OF(t1, t2) n##t1 == n##t2 ? typeDefault \ @@ -224,7 +224,7 @@ bool wxTextFile::Write(Type typeNew) wxTempFile fileTmp(m_strFile); if ( !fileTmp.IsOpened() ) { - wxLogError("can't write file '%s' to disk.", m_strFile.c_str()); + wxLogError(_("can't write file '%s' to disk."), m_strFile.c_str()); return FALSE; } -- 2.45.2