added wxS(); use it in a couple of places

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50987 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-01-02 16:31:38 +00:00
parent 038c03337f
commit a05166568c
4 changed files with 124 additions and 96 deletions

View File

@@ -225,6 +225,7 @@ the corresponding topic.
\helpref{wxRemoveFile}{wxremovefile}\\ \helpref{wxRemoveFile}{wxremovefile}\\
\helpref{wxRenameFile}{wxrenamefile}\\ \helpref{wxRenameFile}{wxrenamefile}\\
\helpref{wxRmdir}{wxrmdir}\\ \helpref{wxRmdir}{wxrmdir}\\
\helpref{wxS}{wxs}\\
\helpref{wxSafeShowMessage}{wxsafeshowmessage}\\ \helpref{wxSafeShowMessage}{wxsafeshowmessage}\\
\helpref{wxSafeYield}{wxsafeyield}\\ \helpref{wxSafeYield}{wxsafeyield}\\
\helpref{wxSetClipboardData}{wxsetclipboarddata}\\ \helpref{wxSetClipboardData}{wxsetclipboarddata}\\
@@ -1696,6 +1697,25 @@ Returns \true if the pointer is either {\tt NULL} or points to an empty
string, \false otherwise. string, \false otherwise.
\membersection{wxS}\label{wxs}
\func{wxStringCharType}{wxS}{\param{char }{ch}}
\func{const wxStringCharType *}{wxS}{\param{const char *}{s}}
wxS is macro which can be used with character and string literals to either
convert them to wide characters or strings in \texttt{wchar\_t}-based Unicode
builds or keep them unchanged in UTF-8 builds. The use of this macro is
optional as the translation will always be done at run-time even if there is a
mismatch between the kind of the literal used and wxStringCharType used in the
current build, but using it can be beneficial in performance-sensitive code to
do the conversion at compile-time instead.
\wxheading{See also}
\helpref{wxT}{wxt}
\membersection{::wxStrcmp}\label{wxstrcmp} \membersection{::wxStrcmp}\label{wxstrcmp}
\func{int}{wxStrcmp}{\param{const char *}{p1}, \param{const char *}{p2}} \func{int}{wxStrcmp}{\param{const char *}{p1}, \param{const char *}{p2}}

View File

@@ -214,11 +214,9 @@
#endif #endif
/* define char type used by wxString internal representation: */ /* define char type used by wxString internal representation: */
#if wxUSE_UNICODE_UTF8 #if wxUSE_UNICODE_WCHAR
typedef char wxStringCharType;
#elif wxUSE_UNICODE_WCHAR
typedef wchar_t wxStringCharType; typedef wchar_t wxStringCharType;
#else #else /* wxUSE_UNICODE_UTF8 || ANSI */
typedef char wxStringCharType; typedef char wxStringCharType;
#endif #endif
@@ -243,6 +241,18 @@
#endif /* ASCII/Unicode */ #endif /* ASCII/Unicode */
#endif /* !defined(_T) */ #endif /* !defined(_T) */
/*
wxS ("wx string") macro can be used to create literals using the same
representation as wxString does internally, i.e. wchar_t in Unicode build
under Windows or char in UTF-8-based Unicode builds and (deprecated) ANSI
builds everywhere (see wxStringCharType definition above).
*/
#if wxUSE_UNICODE_WCHAR
#define wxS(x) wxCONCAT_HELPER(L, x)
#else /* wxUSE_UNICODE_UTF8 || ANSI */
#define wxS(x) x
#endif
/* although global macros with such names are normally bad, we want to have */ /* although global macros with such names are normally bad, we want to have */
/* another name for _T() which should be used to avoid confusion between */ /* another name for _T() which should be used to avoid confusion between */
/* _T() and _() in wxWidgets sources */ /* _T() and _() in wxWidgets sources */

View File

@@ -103,7 +103,7 @@ static const size_t LEN_LANG = 2;
static const size_t LEN_SUBLANG = 2; static const size_t LEN_SUBLANG = 2;
static const size_t LEN_FULL = LEN_LANG + 1 + LEN_SUBLANG; // 1 for '_' static const size_t LEN_FULL = LEN_LANG + 1 + LEN_SUBLANG; // 1 for '_'
#define TRACE_I18N _T("i18n") #define TRACE_I18N wxS("i18n")
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// global functions // global functions
@@ -1074,7 +1074,7 @@ static wxString GetFullSearchPath(const wxString& lang)
#ifdef __UNIX__ #ifdef __UNIX__
// LC_PATH is a standard env var containing the search path for the .mo // LC_PATH is a standard env var containing the search path for the .mo
// files // files
const wxChar *pszLcPath = wxGetenv(wxT("LC_PATH")); const char *pszLcPath = wxGetenv("LC_PATH");
if ( pszLcPath ) if ( pszLcPath )
{ {
const wxString lcp = GetMsgCatalogSubdirs(pszLcPath, lang); const wxString lcp = GetMsgCatalogSubdirs(pszLcPath, lang);
@@ -1086,7 +1086,7 @@ static wxString GetFullSearchPath(const wxString& lang)
wxString wxp = wxGetInstallPrefix(); wxString wxp = wxGetInstallPrefix();
if ( !wxp.empty() ) if ( !wxp.empty() )
{ {
wxp = GetMsgCatalogSubdirs(wxp + _T("/share/locale"), lang); wxp = GetMsgCatalogSubdirs(wxp + wxS("/share/locale"), lang);
if ( paths.Index(wxp) == wxNOT_FOUND ) if ( paths.Index(wxp) == wxNOT_FOUND )
paths.Add(wxp); paths.Add(wxp);
} }
@@ -1122,14 +1122,14 @@ bool wxMsgCatalogFile::Load(const wxString& szDirPrefix, const wxString& szName,
if ( encSys != wxFONTENCODING_SYSTEM ) if ( encSys != wxFONTENCODING_SYSTEM )
{ {
wxString fullname(szDirPrefix); wxString fullname(szDirPrefix);
fullname << _T('.') << wxFontMapperBase::GetEncodingName(encSys); fullname << wxS('.') << wxFontMapperBase::GetEncodingName(encSys);
searchPath << GetFullSearchPath(fullname) << wxPATH_SEP; searchPath << GetFullSearchPath(fullname) << wxPATH_SEP;
} }
#endif // wxUSE_FONTMAP #endif // wxUSE_FONTMAP
searchPath += GetFullSearchPath(szDirPrefix); searchPath += GetFullSearchPath(szDirPrefix);
size_t sublocaleIndex = szDirPrefix.find(wxT('_')); size_t sublocaleIndex = szDirPrefix.find(wxS('_'));
if ( sublocaleIndex != wxString::npos ) if ( sublocaleIndex != wxString::npos )
{ {
// also add just base locale name: for things like "fr_BE" (belgium // also add just base locale name: for things like "fr_BE" (belgium
@@ -1147,11 +1147,11 @@ bool wxMsgCatalogFile::Load(const wxString& szDirPrefix, const wxString& szName,
NoTransErr noTransErr; NoTransErr noTransErr;
wxLogVerbose(_("looking for catalog '%s' in path '%s'."), wxLogVerbose(_("looking for catalog '%s' in path '%s'."),
szName, searchPath.c_str()); szName, searchPath.c_str());
wxLogTrace(TRACE_I18N, _T("Looking for \"%s.mo\" in \"%s\""), wxLogTrace(TRACE_I18N, wxS("Looking for \"%s.mo\" in \"%s\""),
szName, searchPath.c_str()); szName, searchPath.c_str());
wxFileName fn(szName); wxFileName fn(szName);
fn.SetExt(_T("mo")); fn.SetExt(wxS("mo"));
wxString strFullName; wxString strFullName;
#if wxUSE_FILESYSTEM #if wxUSE_FILESYSTEM
@@ -1162,13 +1162,13 @@ bool wxMsgCatalogFile::Load(const wxString& szDirPrefix, const wxString& szName,
#endif // wxUSE_FILESYSTEM/!wxUSE_FILESYSTEM #endif // wxUSE_FILESYSTEM/!wxUSE_FILESYSTEM
{ {
wxLogVerbose(_("catalog file for domain '%s' not found."), szName); wxLogVerbose(_("catalog file for domain '%s' not found."), szName);
wxLogTrace(TRACE_I18N, _T("Catalog \"%s.mo\" not found"), szName); wxLogTrace(TRACE_I18N, wxS("Catalog \"%s.mo\" not found"), szName);
return false; return false;
} }
// open file and read its data // open file and read its data
wxLogVerbose(_("using catalog '%s' from '%s'."), szName, strFullName.c_str()); wxLogVerbose(_("using catalog '%s' from '%s'."), szName, strFullName.c_str());
wxLogTrace(TRACE_I18N, _T("Using catalog \"%s\"."), strFullName.c_str()); wxLogTrace(TRACE_I18N, wxS("Using catalog \"%s\"."), strFullName.c_str());
#if wxUSE_FILESYSTEM #if wxUSE_FILESYSTEM
wxFSFile * const fileMsg = fileSys.OpenFile(strFullName); wxFSFile * const fileMsg = fileSys.OpenFile(strFullName);
@@ -1196,7 +1196,7 @@ bool wxMsgCatalogFile::Load(const wxString& szDirPrefix, const wxString& szName,
return false; return false;
size_t nSize = wx_truncate_cast(size_t, lenFile); size_t nSize = wx_truncate_cast(size_t, lenFile);
wxASSERT_MSG( nSize == lenFile + size_t(0), _T("message catalog bigger than 4GB?") ); wxASSERT_MSG( nSize == lenFile + size_t(0), wxS("message catalog bigger than 4GB?") );
// read the whole file in memory // read the whole file in memory
if ( fileMsg.Read(m_data.GetWriteBuf(nSize), nSize) != lenFile ) if ( fileMsg.Read(m_data.GetWriteBuf(nSize), nSize) != lenFile )
@@ -1238,7 +1238,7 @@ bool wxMsgCatalogFile::Load(const wxString& szDirPrefix, const wxString& szName,
{ {
// Extract the charset: // Extract the charset:
wxString header = wxString::FromAscii(StringAtOfs(m_pTransTable, 0)); wxString header = wxString::FromAscii(StringAtOfs(m_pTransTable, 0));
int begin = header.Find(wxT("Content-Type: text/plain; charset=")); int begin = header.Find(wxS("Content-Type: text/plain; charset="));
if (begin != wxNOT_FOUND) if (begin != wxNOT_FOUND)
{ {
begin += 34; //strlen("Content-Type: text/plain; charset=") begin += 34; //strlen("Content-Type: text/plain; charset=")
@@ -1246,7 +1246,7 @@ bool wxMsgCatalogFile::Load(const wxString& szDirPrefix, const wxString& szName,
if (end != size_t(-1)) if (end != size_t(-1))
{ {
m_charset.assign(header, begin, end - begin); m_charset.assign(header, begin, end - begin);
if (m_charset == wxT("CHARSET")) if (m_charset == wxS("CHARSET"))
{ {
// "CHARSET" is not valid charset, but lazy translator // "CHARSET" is not valid charset, but lazy translator
m_charset.Clear(); m_charset.Clear();
@@ -1256,7 +1256,7 @@ bool wxMsgCatalogFile::Load(const wxString& szDirPrefix, const wxString& szName,
// else: incorrectly filled Content-Type header // else: incorrectly filled Content-Type header
// Extract plural forms: // Extract plural forms:
begin = header.Find(wxT("Plural-Forms:")); begin = header.Find(wxS("Plural-Forms:"));
if (begin != wxNOT_FOUND) if (begin != wxNOT_FOUND)
{ {
begin += 13; begin += 13;
@@ -1336,7 +1336,7 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash,
#elif wxUSE_FONTMAP #elif wxUSE_FONTMAP
wxASSERT_MSG( msgIdCharset.empty(), wxASSERT_MSG( msgIdCharset.empty(),
_T("non-ASCII msgid languages only supported if wxUSE_WCHAR_T=1") ); wxS("non-ASCII msgid languages only supported if wxUSE_WCHAR_T=1") );
wxEncodingConverter converter; wxEncodingConverter converter;
if ( convertEncoding ) if ( convertEncoding )
@@ -1550,7 +1550,7 @@ bool wxLocale::Init(const wxString& name,
bool bConvertEncoding) bool bConvertEncoding)
{ {
wxASSERT_MSG( !m_initialized, wxASSERT_MSG( !m_initialized,
_T("you can't call wxLocale::Init more than once") ); wxS("you can't call wxLocale::Init more than once") );
m_initialized = true; m_initialized = true;
m_strLocale = name; m_strLocale = name;
@@ -1566,7 +1566,7 @@ bool wxLocale::Init(const wxString& name,
szLocale = shortName; szLocale = shortName;
wxCHECK_MSG( !szLocale.empty(), false, wxCHECK_MSG( !szLocale.empty(), false,
_T("no locale to set in wxLocale::Init()") ); wxS("no locale to set in wxLocale::Init()") );
} }
#ifdef __WXWINCE__ #ifdef __WXWINCE__
@@ -1612,7 +1612,7 @@ bool wxLocale::Init(const wxString& name,
bool bOk = true; bool bOk = true;
if ( bLoadDefault ) if ( bLoadDefault )
{ {
bOk = AddCatalog(wxT("wxstd")); bOk = AddCatalog(wxS("wxstd"));
// there may be a catalog with toolkit specific overrides, it is not // there may be a catalog with toolkit specific overrides, it is not
// an error if this does not exist // an error if this does not exist
@@ -1621,7 +1621,7 @@ bool wxLocale::Init(const wxString& name,
wxString port(wxPlatformInfo::Get().GetPortIdName()); wxString port(wxPlatformInfo::Get().GetPortIdName());
if ( !port.empty() ) if ( !port.empty() )
{ {
AddCatalog(port.BeforeFirst(wxT('/')).MakeLower()); AddCatalog(port.BeforeFirst(wxS('/')).MakeLower());
} }
} }
} }
@@ -1642,21 +1642,21 @@ static const char *wxSetlocaleTryUTF8(int c, const wxString& lc)
{ {
wxString buf(lc); wxString buf(lc);
wxString buf2; wxString buf2;
buf2 = buf + wxT(".UTF-8"); buf2 = buf + wxS(".UTF-8");
l = wxSetlocale(c, buf2); l = wxSetlocale(c, buf2);
if ( !l ) if ( !l )
{ {
buf2 = buf + wxT(".utf-8"); buf2 = buf + wxS(".utf-8");
l = wxSetlocale(c, buf2); l = wxSetlocale(c, buf2);
} }
if ( !l ) if ( !l )
{ {
buf2 = buf + wxT(".UTF8"); buf2 = buf + wxS(".UTF8");
l = wxSetlocale(c, buf2); l = wxSetlocale(c, buf2);
} }
if ( !l ) if ( !l )
{ {
buf2 = buf + wxT(".utf8"); buf2 = buf + wxS(".utf8");
l = wxSetlocale(c, buf2); l = wxSetlocale(c, buf2);
} }
} }
@@ -1693,7 +1693,7 @@ bool wxLocale::Init(int language, int flags)
// Unknown language: // Unknown language:
if (info == NULL) if (info == NULL)
{ {
wxLogError(wxT("Unknown language %i."), lang); wxLogError(wxS("Unknown language %i."), lang);
return false; return false;
} }
@@ -1730,7 +1730,7 @@ bool wxLocale::Init(int language, int flags)
wxFontMapperBase::GetAllEncodingNames(wxFONTENCODING_UTF8); wxFontMapperBase::GetAllEncodingNames(wxFONTENCODING_UTF8);
while ( *names ) while ( *names )
{ {
retloc = wxSetlocale(LC_ALL, locale + _T('.') + *names++); retloc = wxSetlocale(LC_ALL, locale + wxS('.') + *names++);
if ( retloc ) if ( retloc )
break; break;
} }
@@ -1742,16 +1742,16 @@ bool wxLocale::Init(int language, int flags)
// Some C libraries (namely glibc) still use old ISO 639, // Some C libraries (namely glibc) still use old ISO 639,
// so will translate the abbrev for them // so will translate the abbrev for them
wxString localeAlt; wxString localeAlt;
if ( langOnly == wxT("he") ) if ( langOnly == wxS("he") )
localeAlt = wxT("iw") + locale.Mid(3); localeAlt = wxS("iw") + locale.Mid(3);
else if ( langOnly == wxT("id") ) else if ( langOnly == wxS("id") )
localeAlt = wxT("in") + locale.Mid(3); localeAlt = wxS("in") + locale.Mid(3);
else if ( langOnly == wxT("yi") ) else if ( langOnly == wxS("yi") )
localeAlt = wxT("ji") + locale.Mid(3); localeAlt = wxS("ji") + locale.Mid(3);
else if ( langOnly == wxT("nb") ) else if ( langOnly == wxS("nb") )
localeAlt = wxT("no_NO"); localeAlt = wxS("no_NO");
else if ( langOnly == wxT("nn") ) else if ( langOnly == wxS("nn") )
localeAlt = wxT("no_NY"); localeAlt = wxS("no_NY");
if ( !localeAlt.empty() ) if ( !localeAlt.empty() )
{ {
@@ -1794,7 +1794,7 @@ bool wxLocale::Init(int language, int flags)
{ {
if (info->WinLang == 0) if (info->WinLang == 0)
{ {
wxLogWarning(wxT("Locale '%s' not supported by OS."), name.c_str()); wxLogWarning(wxS("Locale '%s' not supported by OS."), name.c_str());
// retloc already set to "C" // retloc already set to "C"
} }
else else
@@ -1814,20 +1814,20 @@ bool wxLocale::Init(int language, int flags)
// because SetThreadLocale does not modify change the // because SetThreadLocale does not modify change the
// interpretation of setlocale(LC_ALL, "") call: // interpretation of setlocale(LC_ALL, "") call:
wxChar buffer[256]; wxChar buffer[256];
buffer[0] = wxT('\0'); buffer[0] = wxS('\0');
GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, buffer, 256); GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, buffer, 256);
locale << buffer; locale << buffer;
if (GetLocaleInfo(lcid, LOCALE_SENGCOUNTRY, buffer, 256) > 0) if (GetLocaleInfo(lcid, LOCALE_SENGCOUNTRY, buffer, 256) > 0)
locale << wxT("_") << buffer; locale << wxS("_") << buffer;
if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buffer, 256) > 0) if (GetLocaleInfo(lcid, LOCALE_IDEFAULTANSICODEPAGE, buffer, 256) > 0)
{ {
codepage = wxAtoi(buffer); codepage = wxAtoi(buffer);
if (codepage != 0) if (codepage != 0)
locale << wxT(".") << buffer; locale << wxS(".") << buffer;
} }
if (locale.empty()) if (locale.empty())
{ {
wxLogLastError(wxT("SetThreadLocale")); wxLogLastError(wxS("SetThreadLocale"));
ret = false; ret = false;
} }
else else
@@ -1859,7 +1859,7 @@ bool wxLocale::Init(int language, int flags)
wxChar buffer[16]; wxChar buffer[16];
if (GetLocaleInfo(LOCALE_USER_DEFAULT, if (GetLocaleInfo(LOCALE_USER_DEFAULT,
LOCALE_IDEFAULTANSICODEPAGE, buffer, 16) > 0 && LOCALE_IDEFAULTANSICODEPAGE, buffer, 16) > 0 &&
wxStrcmp(buffer, wxT("0")) == 0) wxStrcmp(buffer, wxS("0")) == 0)
{ {
retloc = "C"; retloc = "C";
} }
@@ -1944,15 +1944,15 @@ void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix)
str.reset(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleCountryCode))); str.reset(wxCFRetain((CFStringRef)CFLocaleGetValue(userLocaleRef, kCFLocaleCountryCode)));
langFull += str.AsString(); langFull += str.AsString();
#else #else
if (!wxGetEnv(wxT("LC_ALL"), &langFull) && if (!wxGetEnv(wxS("LC_ALL"), &langFull) &&
!wxGetEnv(wxT("LC_MESSAGES"), &langFull) && !wxGetEnv(wxS("LC_MESSAGES"), &langFull) &&
!wxGetEnv(wxT("LANG"), &langFull)) !wxGetEnv(wxS("LANG"), &langFull))
{ {
// no language specified, treat it as English // no language specified, treat it as English
return wxLANGUAGE_ENGLISH_US; return wxLANGUAGE_ENGLISH_US;
} }
if ( langFull == _T("C") || langFull == _T("POSIX") ) if ( langFull == wxS("C") || langFull == wxS("POSIX") )
{ {
// default C locale is English too // default C locale is English too
return wxLANGUAGE_ENGLISH_US; return wxLANGUAGE_ENGLISH_US;
@@ -1981,7 +1981,7 @@ void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix)
// //
// we don't use the modifiers neither but we probably should translate // we don't use the modifiers neither but we probably should translate
// "euro" into iso885915 // "euro" into iso885915
size_t posEndLang = langFull.find_first_of(_T("@.")); size_t posEndLang = langFull.find_first_of(wxS("@."));
if ( posEndLang != wxString::npos ) if ( posEndLang != wxString::npos )
{ {
langFull.Truncate(posEndLang); langFull.Truncate(posEndLang);
@@ -1994,7 +1994,7 @@ void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix)
// do we have just the language (or sublang too)? // do we have just the language (or sublang too)?
bool justLang = langFull.length() == LEN_LANG; bool justLang = langFull.length() == LEN_LANG;
if ( justLang || if ( justLang ||
(langFull.length() == LEN_FULL && langFull[LEN_LANG] == wxT('_')) ) (langFull.length() == LEN_FULL && langFull[LEN_LANG] == wxS('_')) )
{ {
// 0. Make sure the lang is according to latest ISO 639 // 0. Make sure the lang is according to latest ISO 639
// (this is necessary because glibc uses iw and in instead // (this is necessary because glibc uses iw and in instead
@@ -2004,18 +2004,18 @@ void wxLocale::AddCatalogLookupPathPrefix(const wxString& prefix)
wxString langOrig = ExtractLang(langFull); wxString langOrig = ExtractLang(langFull);
wxString lang; wxString lang;
if ( langOrig == wxT("iw")) if ( langOrig == wxS("iw"))
lang = _T("he"); lang = wxS("he");
else if (langOrig == wxT("in")) else if (langOrig == wxS("in"))
lang = wxT("id"); lang = wxS("id");
else if (langOrig == wxT("ji")) else if (langOrig == wxS("ji"))
lang = wxT("yi"); lang = wxS("yi");
else if (langOrig == wxT("no_NO")) else if (langOrig == wxS("no_NO"))
lang = wxT("nb_NO"); lang = wxS("nb_NO");
else if (langOrig == wxT("no_NY")) else if (langOrig == wxS("no_NY"))
lang = wxT("nn_NO"); lang = wxS("nn_NO");
else if (langOrig == wxT("no")) else if (langOrig == wxS("no"))
lang = wxT("nb_NO"); lang = wxS("nb_NO");
else else
lang = langOrig; lang = langOrig;
@@ -2115,7 +2115,7 @@ wxString wxLocale::GetSystemEncodingName()
#if defined(__WIN32__) && !defined(__WXMICROWIN__) #if defined(__WIN32__) && !defined(__WXMICROWIN__)
// FIXME: what is the error return value for GetACP()? // FIXME: what is the error return value for GetACP()?
UINT codepage = ::GetACP(); UINT codepage = ::GetACP();
encname.Printf(_T("windows-%u"), codepage); encname.Printf(wxS("windows-%u"), codepage);
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
// default is just empty string, this resolves to the default system // default is just empty string, this resolves to the default system
// encoding later // encoding later
@@ -2305,7 +2305,7 @@ const wxLanguageInfo *wxLocale::FindLanguageInfo(const wxString& locale)
break; break;
} }
if ( wxStricmp(locale, info->CanonicalName.BeforeFirst(_T('_'))) == 0 ) if ( wxStricmp(locale, info->CanonicalName.BeforeFirst(wxS('_'))) == 0 )
{ {
// a match -- but maybe we'll find an exact one later, so continue // a match -- but maybe we'll find an exact one later, so continue
// looking // looking
@@ -2397,11 +2397,9 @@ const wxString& wxLocale::GetString(const wxString& origString,
NoTransErr noTransErr; NoTransErr noTransErr;
wxLogTrace(TRACE_I18N, wxLogTrace(TRACE_I18N,
_T("string \"%s\"[%ld] not found in %slocale '%s'."), wxS("string \"%s\"[%ld] not found in %slocale '%s'."),
origString, (long)n, origString, (long)n,
domain.empty() wxString::Format(wxS("domain '%s' "), domain).c_str(),
? (const wxChar*)wxString::Format(_T("domain '%s' "), domain).c_str()
: _T(""),
m_strLocale.c_str()); m_strLocale.c_str());
} }
#endif // __WXDEBUG__ #endif // __WXDEBUG__
@@ -2471,7 +2469,7 @@ wxString wxLocale::GetHeaderValue(const wxString& header,
// Every header is separated by \n // Every header is separated by \n
size_t endLine = trans->find(wxT('\n'), found); size_t endLine = trans->find(wxS('\n'), found);
size_t len = (endLine == wxString::npos) ? size_t len = (endLine == wxString::npos) ?
wxString::npos : (endLine - found); wxString::npos : (endLine - found);
@@ -2498,7 +2496,7 @@ wxMsgCatalog *wxLocale::FindCatalog(const wxString& domain) const
bool wxLocale::IsAvailable(int lang) bool wxLocale::IsAvailable(int lang)
{ {
const wxLanguageInfo *info = wxLocale::GetLanguageInfo(lang); const wxLanguageInfo *info = wxLocale::GetLanguageInfo(lang);
wxCHECK_MSG( info, false, _T("invalid language") ); wxCHECK_MSG( info, false, wxS("invalid language") );
#if defined(__WIN32__) #if defined(__WIN32__)
if ( !info->WinLang ) if ( !info->WinLang )
@@ -2595,13 +2593,13 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat))
wxString str; wxString str;
wxChar buffer[256]; wxChar buffer[256];
size_t count; size_t count;
buffer[0] = wxT('\0'); buffer[0] = wxS('\0');
switch (index) switch (index)
{ {
case wxLOCALE_DECIMAL_POINT: case wxLOCALE_DECIMAL_POINT:
count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buffer, 256); count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, buffer, 256);
if (!count) if (!count)
str << wxT("."); str << wxS(".");
else else
str << buffer; str << buffer;
break; break;
@@ -2609,20 +2607,20 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory WXUNUSED(cat))
case wxSYS_LIST_SEPARATOR: case wxSYS_LIST_SEPARATOR:
count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLIST, buffer, 256); count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLIST, buffer, 256);
if (!count) if (!count)
str << wxT(","); str << wxS(",");
else else
str << buffer; str << buffer;
break; break;
case wxSYS_LEADING_ZERO: // 0 means no leading zero, 1 means leading zero case wxSYS_LEADING_ZERO: // 0 means no leading zero, 1 means leading zero
count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILZERO, buffer, 256); count = ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ILZERO, buffer, 256);
if (!count) if (!count)
str << wxT("0"); str << wxS("0");
else else
str << buffer; str << buffer;
break; break;
#endif #endif
default: default:
wxFAIL_MSG(wxT("Unknown System String !")); wxFAIL_MSG(wxS("Unknown System String !"));
} }
return str; return str;
} }
@@ -3236,9 +3234,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxLocaleModule, wxModule)
#define LNG(wxlang, canonical, winlang, winsublang, layout, desc) \ #define LNG(wxlang, canonical, winlang, winsublang, layout, desc) \
info.Language = wxlang; \ info.Language = wxlang; \
info.CanonicalName = wxT(canonical); \ info.CanonicalName = wxS(canonical); \
info.LayoutDirection = layout; \ info.LayoutDirection = layout; \
info.Description = wxT(desc); \ info.Description = wxS(desc); \
SETWINLANG(info, winlang, winsublang) \ SETWINLANG(info, winlang, winsublang) \
AddLanguage(info); AddLanguage(info);

View File

@@ -159,7 +159,7 @@ void wxSafeShowMessage(const wxString& title, const wxString& text)
#ifdef __WINDOWS__ #ifdef __WINDOWS__
::MessageBox(NULL, text.wx_str(), title.wx_str(), MB_OK | MB_ICONSTOP); ::MessageBox(NULL, text.wx_str(), title.wx_str(), MB_OK | MB_ICONSTOP);
#else #else
wxFprintf(stderr, _T("%s: %s\n"), title.c_str(), text.c_str()); wxFprintf(stderr, wxS("%s: %s\n"), title.c_str(), text.c_str());
fflush(stderr); fflush(stderr);
#endif #endif
} }
@@ -168,7 +168,7 @@ void wxSafeShowMessage(const wxString& title, const wxString& text)
// always terminate the program // always terminate the program
void wxVLogFatalError(const wxString& format, va_list argptr) void wxVLogFatalError(const wxString& format, va_list argptr)
{ {
wxSafeShowMessage(_T("Fatal Error"), wxString::FormatV(format, argptr)); wxSafeShowMessage(wxS("Fatal Error"), wxString::FormatV(format, argptr));
#ifdef __WXWINCE__ #ifdef __WXWINCE__
ExitThread(3); ExitThread(3);
@@ -279,7 +279,7 @@ void wxDoLogVerboseUtf8(const char *format, ...)
{ {
if ( wxLog::IsEnabled() && wxLog::IsAllowedTraceMask(mask) ) { if ( wxLog::IsEnabled() && wxLog::IsAllowedTraceMask(mask) ) {
wxString msg; wxString msg;
msg << _T("(") << mask << _T(") ") << wxString::FormatV(format, argptr); msg << wxS("(") << mask << wxS(") ") << wxString::FormatV(format, argptr);
wxLog::OnLog(wxLOG_Trace, msg, time(NULL)); wxLog::OnLog(wxLOG_Trace, msg, time(NULL));
} }
@@ -472,7 +472,7 @@ unsigned wxLog::LogLastRepetitionCountIfNeeded()
ms_prevCounter), ms_prevCounter),
ms_prevCounter); ms_prevCounter);
#else #else
msg.Printf(wxT("The previous message was repeated %lu times."), msg.Printf(wxS("The previous message was repeated %lu times."),
ms_prevCounter); ms_prevCounter);
#endif #endif
ms_prevCounter = 0; ms_prevCounter = 0;
@@ -627,7 +627,7 @@ void wxLog::TimeStamp(wxString *str)
ms_timestamp, wxLocaltime_r(&timeNow, &tm)); ms_timestamp, wxLocaltime_r(&timeNow, &tm));
str->Empty(); str->Empty();
*str << buf << wxT(": "); *str << buf << wxS(": ");
} }
#endif // wxUSE_DATETIME #endif // wxUSE_DATETIME
} }
@@ -673,8 +673,8 @@ void wxLog::DoLog(wxLogLevel level, const wxString& szString, time_t t)
case wxLOG_Debug: case wxLOG_Debug:
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
{ {
wxString msg = level == wxLOG_Trace ? wxT("Trace: ") wxString msg = level == wxLOG_Trace ? wxS("Trace: ")
: wxT("Debug: "); : wxS("Debug: ");
msg << szString; msg << szString;
LogString(msg, t); LogString(msg, t);
} }
@@ -692,7 +692,7 @@ void wxLog::DoLogString(const wxString& szString, time_t t)
DoLogString((const char*)szString.mb_str(), t); DoLogString((const char*)szString.mb_str(), t);
DoLogString((const wchar_t*)szString.wc_str(), t); DoLogString((const wchar_t*)szString.wc_str(), t);
#else #else
wxFAIL_MSG(wxT("DoLogString must be overriden if it's called.")); wxFAIL_MSG(wxS("DoLogString must be overriden if it's called."));
wxUnusedVar(szString); wxUnusedVar(szString);
wxUnusedVar(t); wxUnusedVar(t);
#endif #endif
@@ -722,7 +722,7 @@ void wxLogBuffer::Flush()
if ( !m_str.empty() ) if ( !m_str.empty() )
{ {
wxMessageOutputBest out; wxMessageOutputBest out;
out.Printf(_T("%s"), m_str.c_str()); out.Printf(wxS("%s"), m_str.c_str());
m_str.clear(); m_str.clear();
} }
} }
@@ -742,7 +742,7 @@ void wxLogBuffer::DoLog(wxLogLevel level, const wxString& szString, time_t t)
str += szString; str += szString;
wxMessageOutputDebug dbgout; wxMessageOutputDebug dbgout;
dbgout.Printf(_T("%s\n"), str.c_str()); dbgout.Printf(wxS("%s\n"), str.c_str());
} }
#endif // __WXDEBUG__ #endif // __WXDEBUG__
break; break;
@@ -754,7 +754,7 @@ void wxLogBuffer::DoLog(wxLogLevel level, const wxString& szString, time_t t)
void wxLogBuffer::DoLogString(const wxString& szString, time_t WXUNUSED(t)) void wxLogBuffer::DoLogString(const wxString& szString, time_t WXUNUSED(t))
{ {
m_str << szString << _T("\n"); m_str << szString << wxS("\n");
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -776,7 +776,7 @@ void wxLogStderr::DoLogString(const wxString& szString, time_t WXUNUSED(t))
str << szString; str << szString;
wxFputs(str, m_fp); wxFputs(str, m_fp);
wxFputc(_T('\n'), m_fp); wxFputc(wxS('\n'), m_fp);
fflush(m_fp); fflush(m_fp);
// under GUI systems such as Windows or Mac, programs usually don't have // under GUI systems such as Windows or Mac, programs usually don't have
@@ -789,7 +789,7 @@ void wxLogStderr::DoLogString(const wxString& szString, time_t WXUNUSED(t))
if ( traits && !traits->HasStderr() ) if ( traits && !traits->HasStderr() )
{ {
wxMessageOutputDebug dbgout; wxMessageOutputDebug dbgout;
dbgout.Printf(_T("%s\n"), str.c_str()); dbgout.Printf(wxS("%s\n"), str.c_str());
} }
} }
} }
@@ -924,7 +924,7 @@ wxLogLevel wxLog::ms_logLevel = wxLOG_Max; // log everything by defaul
size_t wxLog::ms_suspendCount = 0; size_t wxLog::ms_suspendCount = 0;
wxString wxLog::ms_timestamp(wxT("%X")); // time only, no date wxString wxLog::ms_timestamp(wxS("%X")); // time only, no date
wxTraceMask wxLog::ms_ulTraceMask = (wxTraceMask)0; wxTraceMask wxLog::ms_ulTraceMask = (wxTraceMask)0;
wxArrayString wxLog::ms_aTraceMasks; wxArrayString wxLog::ms_aTraceMasks;
@@ -1004,7 +1004,7 @@ const wxChar *wxSysErrorMsg(unsigned long nErrCode)
{ {
// if this happens, something is seriously wrong, so don't use _() here // if this happens, something is seriously wrong, so don't use _() here
// for safety // for safety
wxSprintf(s_szBuf, _T("unknown error %lx"), nErrCode); wxSprintf(s_szBuf, wxS("unknown error %lx"), nErrCode);
return s_szBuf; return s_szBuf;
} }
@@ -1015,7 +1015,7 @@ const wxChar *wxSysErrorMsg(unsigned long nErrCode)
if( lpMsgBuf != 0 ) if( lpMsgBuf != 0 )
{ {
wxStrncpy(s_szBuf, (const wxChar *)lpMsgBuf, WXSIZEOF(s_szBuf) - 1); wxStrncpy(s_szBuf, (const wxChar *)lpMsgBuf, WXSIZEOF(s_szBuf) - 1);
s_szBuf[WXSIZEOF(s_szBuf) - 1] = wxT('\0'); s_szBuf[WXSIZEOF(s_szBuf) - 1] = wxS('\0');
LocalFree(lpMsgBuf); LocalFree(lpMsgBuf);
@@ -1024,14 +1024,14 @@ const wxChar *wxSysErrorMsg(unsigned long nErrCode)
size_t len = wxStrlen(s_szBuf); size_t len = wxStrlen(s_szBuf);
if ( len > 0 ) { if ( len > 0 ) {
// truncate string // truncate string
if ( s_szBuf[len - 2] == wxT('\r') ) if ( s_szBuf[len - 2] == wxS('\r') )
s_szBuf[len - 2] = wxT('\0'); s_szBuf[len - 2] = wxS('\0');
} }
} }
else else
#endif // !__SMARTPHONE__ #endif // !__SMARTPHONE__
{ {
s_szBuf[0] = wxT('\0'); s_szBuf[0] = wxS('\0');
} }
return s_szBuf; return s_szBuf;