From e9528e32da775303f40a2c78b88cdce3c048c782 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 8 May 2007 20:05:16 +0000 Subject: [PATCH] compilation fixes for wxUSE_WCHAR_T==0 (this is the case for DJGPP which is used for wxMGL compilation) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@45893 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/chkconf.h | 12 ++++++++++++ include/wx/convauto.h | 9 ++++++++- include/wx/gtk/private.h | 8 +++++++- include/wx/strconv.h | 7 +++++-- src/common/intl.cpp | 4 +++- src/gtk/app.cpp | 3 +++ src/unix/mimetype.cpp | 7 ++++++- 7 files changed, 44 insertions(+), 6 deletions(-) diff --git a/include/wx/chkconf.h b/include/wx/chkconf.h index e4d8d71527..fd3d2abf96 100644 --- a/include/wx/chkconf.h +++ b/include/wx/chkconf.h @@ -1197,6 +1197,18 @@ # endif #endif /* wxUSE_ZIPSTREAM */ +#if wxUSE_TARSTREAM + /* wxTar doesn't currently compile without wchar_t */ +# if !wxUSE_WCHAR_T +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxTar requires wchar_t" +# else +# undef wxUSE_TARSTREAM +# define wxUSE_TARSTREAM 0 +# endif +# endif +#endif /* wxUSE_TARSTREAM */ + #if wxUSE_TARSTREAM # if !wxUSE_ARCHIVE_STREAMS # ifdef wxABORT_ON_CONFIG_ERROR diff --git a/include/wx/convauto.h b/include/wx/convauto.h index fcd26532e9..9545883ea5 100644 --- a/include/wx/convauto.h +++ b/include/wx/convauto.h @@ -95,7 +95,14 @@ private: DECLARE_NO_ASSIGN_CLASS(wxConvAuto) }; -#endif // wxUSE_WCHAR_T +#else // !wxUSE_WCHAR_T + +// it doesn't matter how we define it in this case as it's unused anyhow, but +// do define it to allow the code using wxConvAuto() as default argument (this +// is done in many places) to compile +typedef wxMBConv wxConvAuto; + +#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T #endif // _WX_CONVAUTO_H_ diff --git a/include/wx/gtk/private.h b/include/wx/gtk/private.h index 7352f87369..8fdd3f4261 100644 --- a/include/wx/gtk/private.h +++ b/include/wx/gtk/private.h @@ -29,7 +29,7 @@ #define wxGTK_CONV_FONT(s, font) wxGTK_CONV((s)) #define wxGTK_CONV_SYS(s) wxGTK_CONV((s)) #define wxGTK_CONV_BACK(s) wxConvUTF8.cMB2WX((s)) -#else +#elif wxUSE_WCHAR_T #include "wx/font.h" // convert the text in given encoding to UTF-8 used by wxGTK @@ -49,6 +49,12 @@ #define wxGTK_CONV(s) wxGTK_CONV_FONT((s), m_font) #define wxGTK_CONV_SYS(s) wxConvertToGTK((s)) #define wxGTK_CONV_BACK(s) wxConvLocal.cWC2WX(wxConvUTF8.cMB2WC((s))) +#else // we're limited to ASCII + #define wxGTK_CONV_ENC(s, enc) (s) + #define wxGTK_CONV_FONT(s, font) (s) + #define wxGTK_CONV(s) (s) + #define wxGTK_CONV_SYS(s) (s) + #define wxGTK_CONV_BACK(s) (wxString(s)) #endif // Some deprecated GTK+ prototypes we still use often diff --git a/include/wx/strconv.h b/include/wx/strconv.h index 39ce201c80..a055d0de36 100644 --- a/include/wx/strconv.h +++ b/include/wx/strconv.h @@ -500,9 +500,13 @@ class WXDLLIMPEXP_BASE wxMBConv public: const char* cMB2WX(const char *psz) const { return psz; } const char* cWX2MB(const char *psz) const { return psz; } + wxMBConv *Clone() const { return NULL; } }; #define wxConvFile wxConvLocal +#define wxConvUI wxConvCurrent + +typedef wxMBConv wxCSConv; extern WXDLLIMPEXP_DATA_BASE(wxMBConv) wxConvLibc, wxConvLocal, @@ -513,8 +517,7 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvCurrent; #define wxFNCONV(name) name #define wxFNSTRINGCAST WXSTRINGCAST -#endif - // wxUSE_WCHAR_T +#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T // ---------------------------------------------------------------------------- // macros for the most common conversions diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 95eb80b3e1..22b8af9da4 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -1304,7 +1304,7 @@ void wxMsgCatalogFile::FillHash(wxMessagesHash& hash, : new wxCSConv(msgIdCharset); #elif wxUSE_FONTMAP - wxASSERT_MSG( msgIdCharset == NULL, + wxASSERT_MSG( msgIdCharset.empty(), _T("non-ASCII msgid languages only supported if wxUSE_WCHAR_T=1") ); wxEncodingConverter converter; @@ -1430,6 +1430,7 @@ bool wxMsgCatalog::Load(const wxChar *szDirPrefix, const wxChar *szName, file.FillHash(m_messages, msgIdCharset, bConvertEncoding); +#if wxUSE_WCHAR_T // we should use a conversion compatible with the message catalog encoding // in the GUI if we don't convert the strings to the current conversion but // as the encoding is global, only change it once, otherwise we could get @@ -1445,6 +1446,7 @@ bool wxMsgCatalog::Load(const wxChar *szDirPrefix, const wxChar *szName, wxConvUI = m_conv = new wxCSConv(file.GetCharset()); } +#endif // wxUSE_WCHAR_T return true; } diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index 010ee269a7..444706b32f 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -448,8 +448,11 @@ bool wxApp::Initialize(int& argc, wxChar **argv) if (encName.empty()) encName = _T("UTF-8"); #endif // wxUSE_INTL + +#if wxUSE_WCHAR_T static wxConvBrokenFileNames fileconv(encName); wxConvFileName = &fileconv; +#endif // wxUSE_WCHAR_T #if wxUSE_UNICODE // gtk_init() wants UTF-8, not wchar_t, so convert diff --git a/src/unix/mimetype.cpp b/src/unix/mimetype.cpp index 9aa4adaf07..ff93a23cbf 100644 --- a/src/unix/mimetype.cpp +++ b/src/unix/mimetype.cpp @@ -152,7 +152,12 @@ protected: virtual bool OnRead(const wxMBConv& WXUNUSED(conv)) { return wxTextFile::OnRead( - wxMBConvUTF8(wxMBConvUTF8::MAP_INVALID_UTF8_TO_PUA)); +#if wxUSE_WCHAR_T + wxMBConvUTF8(wxMBConvUTF8::MAP_INVALID_UTF8_TO_PUA) +#else + wxMBConv() +#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T + ); } };