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