From 8d94819c437fdf28c45e9f328e6c38fd1c639ddf Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Fri, 16 Apr 2010 10:43:18 +0000 Subject: [PATCH] Remove wxUSE_WCHAR_T checks. wxWidgets requires wchar_t for some time now; wx/chartype.h has a check to fail complation without it. Simplify code by removing now-dead code for the !wxUSE_WCHAR_T case. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63991 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/buffer.h | 2 - include/wx/chartype.h | 60 +++++++++++------------ include/wx/chkconf.h | 9 ---- include/wx/confbase.h | 4 -- include/wx/convauto.h | 4 -- include/wx/defs.h | 12 +++-- include/wx/encconv.h | 10 +--- include/wx/html/htmlpars.h | 8 ++- include/wx/propgrid/propgridiface.h | 6 --- include/wx/strconv.h | 29 ----------- include/wx/wxcrt.h | 30 ++++-------- interface/wx/encconv.h | 6 +-- samples/propgrid/propgrid.cpp | 1 - src/common/convauto.cpp | 4 -- src/common/encconv.cpp | 42 +++++----------- src/common/intl.cpp | 62 +++--------------------- src/common/strconv.cpp | 13 ----- src/common/wxcrt.cpp | 7 +-- src/dfb/window.cpp | 2 - src/gtk1/app.cpp | 1 - src/html/helpdata.cpp | 6 --- src/html/htmlpars.cpp | 14 ++---- src/html/m_layout.cpp | 2 +- src/msw/textctrl.cpp | 13 ----- src/propgrid/propgridiface.cpp | 2 - tests/benchmarks/htmlparser/htmlpars.cpp | 10 ++-- tests/benchmarks/htmlparser/htmlpars.h | 4 +- tests/mbconv/convautotest.cpp | 5 -- 28 files changed, 85 insertions(+), 283 deletions(-) diff --git a/include/wx/buffer.h b/include/wx/buffer.h index 4be2660b67..d9640e25c0 100644 --- a/include/wx/buffer.h +++ b/include/wx/buffer.h @@ -359,7 +359,6 @@ public: wxCharBuffer(const wxCStrData& cstr); }; -#if wxUSE_WCHAR_T WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxScopedCharTypeBuffer ) WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer ) @@ -379,7 +378,6 @@ public: wxWCharBuffer(const wxCStrData& cstr); }; -#endif // wxUSE_WCHAR_T // wxCharTypeBuffer implicitly convertible to T* template diff --git a/include/wx/chartype.h b/include/wx/chartype.h index 480d1b1e2d..88b1d5e624 100644 --- a/include/wx/chartype.h +++ b/include/wx/chartype.h @@ -59,37 +59,35 @@ #endif #endif -#if wxUSE_WCHAR_T - #ifdef HAVE_WCHAR_H - /* the current (as of Nov 2002) version of cygwin has a bug in its */ - /* wchar.h -- there is no extern "C" around the declarations in it */ - /* and this results in linking errors later; also, at least on some */ - /* Cygwin versions, wchar.h requires sys/types.h */ - #ifdef __CYGWIN__ - #include - #ifdef __cplusplus - extern "C" { - #endif - #endif /* Cygwin */ - - #include - - #if defined(__CYGWIN__) && defined(__cplusplus) - } - #endif /* Cygwin and C++ */ - - #elif defined(HAVE_WCSTR_H) - /* old compilers have relevant declarations here */ - #include - #elif defined(__FreeBSD__) || defined(__DARWIN__) || defined(__EMX__) - /* include stdlib.h for wchar_t */ - #include - #endif /* HAVE_WCHAR_H */ - - #ifdef HAVE_WIDEC_H - #include - #endif -#endif /* wxUSE_WCHAR_T */ +#ifdef HAVE_WCHAR_H + /* the current (as of Nov 2002) version of cygwin has a bug in its */ + /* wchar.h -- there is no extern "C" around the declarations in it */ + /* and this results in linking errors later; also, at least on some */ + /* Cygwin versions, wchar.h requires sys/types.h */ + #ifdef __CYGWIN__ + #include + #ifdef __cplusplus + extern "C" { + #endif + #endif /* Cygwin */ + + #include + + #if defined(__CYGWIN__) && defined(__cplusplus) + } + #endif /* Cygwin and C++ */ + +#elif defined(HAVE_WCSTR_H) + /* old compilers have relevant declarations here */ + #include +#elif defined(__FreeBSD__) || defined(__DARWIN__) || defined(__EMX__) + /* include stdlib.h for wchar_t */ + #include +#endif /* HAVE_WCHAR_H */ + +#ifdef HAVE_WIDEC_H + #include +#endif /* -------------------------------------------------------------------------- */ /* define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type */ diff --git a/include/wx/chkconf.h b/include/wx/chkconf.h index 38210b3e75..54c0c112fd 100644 --- a/include/wx/chkconf.h +++ b/include/wx/chkconf.h @@ -1313,15 +1313,6 @@ # endif #endif /* wxUSE_TEXTFILE */ -#if wxUSE_XML && !wxUSE_WCHAR_T -# ifdef wxABORT_ON_CONFIG_ERROR -# error "wxUSE_XML requires wxUSE_WCHAR_T" -# else -# undef wxUSE_XML -# define wxUSE_XML 0 -# endif -#endif /* wxUSE_XML */ - #if !wxUSE_DYNLIB_CLASS # if wxUSE_DYNAMIC_LOADER # ifdef wxABORT_ON_CONFIG_ERROR diff --git a/include/wx/confbase.h b/include/wx/confbase.h index e0ed69ff5e..9df8edcc0a 100644 --- a/include/wx/confbase.h +++ b/include/wx/confbase.h @@ -226,10 +226,8 @@ public: // template Read() would be used wxString Read(const wxString& key, const char* defVal) const { return Read(key, wxString(defVal)); } -#if wxUSE_WCHAR_T wxString Read(const wxString& key, const wchar_t* defVal) const { return Read(key, wxString(defVal)); } -#endif long ReadLong(const wxString& key, long defVal) const { long l; (void)Read(key, &l, defVal); return l; } @@ -273,10 +271,8 @@ public: { return Write(key, wxString(value)); } bool Write(const wxString& key, const unsigned char *value) { return Write(key, wxString(value)); } -#if wxUSE_WCHAR_T bool Write(const wxString& key, const wchar_t *value) { return Write(key, wxString(value)); } -#endif // we also have to provide specializations for other types which we want to diff --git a/include/wx/convauto.h b/include/wx/convauto.h index 4de2bee9e7..bc514cea3b 100644 --- a/include/wx/convauto.h +++ b/include/wx/convauto.h @@ -14,8 +14,6 @@ #include "wx/strconv.h" #include "wx/fontenc.h" -#if wxUSE_WCHAR_T - // ---------------------------------------------------------------------------- // wxConvAuto: uses BOM to automatically detect input encoding // ---------------------------------------------------------------------------- @@ -144,7 +142,5 @@ private: wxDECLARE_NO_ASSIGN_CLASS(wxConvAuto); }; -#endif // wxUSE_WCHAR_T - #endif // _WX_CONVAUTO_H_ diff --git a/include/wx/defs.h b/include/wx/defs.h index 7f43f5391a..b1e7f2062f 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -908,7 +908,7 @@ typedef wxUint16 wxWord; #if defined(__MACH__) && !defined(SIZEOF_WCHAR_T) #define SIZEOF_WCHAR_T 4 #endif - #if wxUSE_WCHAR_T && !defined(SIZEOF_WCHAR_T) + #if !defined(SIZEOF_WCHAR_T) /* also assume that sizeof(wchar_t) == 2 (under Unix the most */ /* common case is 4 but there configure would have defined */ /* SIZEOF_WCHAR_T for us) */ @@ -917,10 +917,14 @@ typedef wxUint16 wxWord; Wchar_tMustBeExactly2Bytes); #define SIZEOF_WCHAR_T 2 - #endif /* wxUSE_WCHAR_T */ + #endif /* !defined(SIZEOF_WCHAR_T) */ #endif #endif /* Win/!Win */ +#ifndef SIZEOF_WCHAR_T + #error "SIZEOF_WCHAR_T must be defined, but isn't" +#endif + /* also define C99-like sized MIN/MAX constants */ #define wxINT8_MIN CHAR_MIN #define wxINT8_MAX CHAR_MAX @@ -1248,14 +1252,14 @@ typedef double wxDouble; /* Define wxChar16 and wxChar32 */ -#if wxUSE_WCHAR_T && (!defined(SIZEOF_WCHAR_T) || (SIZEOF_WCHAR_T == 2)) +#if SIZEOF_WCHAR_T == 2 #define wxWCHAR_T_IS_WXCHAR16 typedef wchar_t wxChar16; #else typedef wxUint16 wxChar16; #endif -#if wxUSE_WCHAR_T && defined(SIZEOF_WCHAR_T) && (SIZEOF_WCHAR_T == 4) +#if SIZEOF_WCHAR_T == 4 #define wxWCHAR_T_IS_WXCHAR32 typedef wchar_t wxChar32; #else diff --git a/include/wx/encconv.h b/include/wx/encconv.h index 2c4bfa21e2..5447fb5980 100644 --- a/include/wx/encconv.h +++ b/include/wx/encconv.h @@ -57,7 +57,7 @@ class WXDLLIMPEXP_BASE wxEncodingConverter : public wxObject virtual ~wxEncodingConverter() { if (m_Table) delete[] m_Table; } // Initialize conversion. Both output or input encoding may - // be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1. + // be wxFONTENCODING_UNICODE. // // All subsequent calls to Convert() will interpret it's argument // as a string in input_enc encoding and will output string in @@ -91,12 +91,11 @@ class WXDLLIMPEXP_BASE wxEncodingConverter : public wxObject bool Convert(char* str) const { return Convert(str, str); } wxString Convert(const wxString& input) const; -#if wxUSE_WCHAR_T bool Convert(const char* input, wchar_t* output) const; bool Convert(const wchar_t* input, char* output) const; bool Convert(const wchar_t* input, wchar_t* output) const; bool Convert(wchar_t* str) const { return Convert(str, str); } -#endif + // Return equivalent(s) for given font that are used // under given platform. wxPLATFORM_CURRENT means the plaform // this binary was compiled for @@ -144,12 +143,7 @@ class WXDLLIMPEXP_BASE wxEncodingConverter : public wxObject } private: - -#if wxUSE_WCHAR_T wchar_t *m_Table; -#else - char *m_Table; -#endif bool m_UnicodeInput, m_UnicodeOutput; bool m_JustCopy; diff --git a/include/wx/html/htmlpars.h b/include/wx/html/htmlpars.h index f4df4344dd..e9fd5e013a 100644 --- a/include/wx/html/htmlpars.h +++ b/include/wx/html/htmlpars.h @@ -269,8 +269,12 @@ public: virtual ~wxHtmlEntitiesParser(); // Sets encoding of output string. - // Has no effect if wxUSE_WCHAR_T==0 or wxUSE_UNICODE==1 + // Has no effect if wxUSE_UNICODE==1 +#if wxUSE_UNICODE + void SetEncoding(wxFontEncoding WXUNUSED(encoding)) {} +#else void SetEncoding(wxFontEncoding encoding); +#endif // Parses entities in input and replaces them with respective characters // (with respect to output encoding) @@ -287,7 +291,7 @@ public: #endif protected: -#if wxUSE_WCHAR_T && !wxUSE_UNICODE +#if !wxUSE_UNICODE wxMBConv *m_conv; wxFontEncoding m_encoding; #endif diff --git a/include/wx/propgrid/propgridiface.h b/include/wx/propgrid/propgridiface.h index 7b4041b4ca..d68fa7abe8 100644 --- a/include/wx/propgrid/propgridiface.h +++ b/include/wx/propgrid/propgridiface.h @@ -64,13 +64,11 @@ public: m_ptr.charName = str; m_flags = IsCharPtr; } -#if wxUSE_WCHAR_T wxPGPropArgCls( const wchar_t* str ) { m_ptr.wcharName = str; m_flags = IsWCharPtr; } -#endif /** This constructor is required for NULL. */ wxPGPropArgCls( int ) { @@ -100,9 +98,7 @@ private: { wxPGProperty* property; const char* charName; -#if wxUSE_WCHAR_T const wchar_t* wcharName; -#endif const wxString* stringName; } m_ptr; unsigned char m_flags; @@ -1171,12 +1167,10 @@ public: wxVariant v(value); SetPropVal( id, v ); } -#if wxUSE_WCHAR_T void SetPropertyValue( wxPGPropArg id, const wchar_t* value ) { SetPropertyValueString( id, wxString(value) ); } -#endif void SetPropertyValue( wxPGPropArg id, const char* value ) { SetPropertyValueString( id, wxString(value) ); diff --git a/include/wx/strconv.h b/include/wx/strconv.h index 0847360a8f..25ce7a0fb6 100644 --- a/include/wx/strconv.h +++ b/include/wx/strconv.h @@ -29,8 +29,6 @@ #include #endif // ! __WXPALMOS5__ -#if wxUSE_WCHAR_T - class WXDLLIMPEXP_FWD_BASE wxString; // the error value returned by wxMBConv methods @@ -643,33 +641,6 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvUI; #define wxFNSTRINGCAST WXSTRINGCAST #endif -#else // !wxUSE_WCHAR_T - -// ---------------------------------------------------------------------------- -// stand-ins in absence of wchar_t -// ---------------------------------------------------------------------------- - -class WXDLLIMPEXP_BASE wxMBConv -{ -public: - const char* cMB2WX(const char *psz) const { return psz; } - const char* cWX2MB(const char *psz) const { return psz; } -}; - -#define wxConvFile wxConvLocal - -extern WXDLLIMPEXP_DATA_BASE(wxMBConv) wxConvLibc, - wxConvLocal, - wxConvISO8859_1, - wxConvUTF8; -extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvCurrent; - -#define wxFNCONV(name) name -#define wxFNSTRINGCAST WXSTRINGCAST - -#endif - // wxUSE_WCHAR_T - // ---------------------------------------------------------------------------- // macros for the most common conversions // ---------------------------------------------------------------------------- diff --git a/include/wx/wxcrt.h b/include/wx/wxcrt.h index aa398aea5f..f9e68ef71e 100644 --- a/include/wx/wxcrt.h +++ b/include/wx/wxcrt.h @@ -39,26 +39,16 @@ inline bool wxIsEmpty(const wxCStrData& s) { return s.AsString().empty(); } /* multibyte to wide char conversion functions and macros */ -#if wxUSE_WCHAR_T - /* multibyte<->widechar conversion */ - WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n); - WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n); - - #if wxUSE_UNICODE - #define wxMB2WX wxMB2WC - #define wxWX2MB wxWC2MB - #define wxWC2WX wxStrncpy - #define wxWX2WC wxStrncpy - #else - #define wxMB2WX wxStrncpy - #define wxWX2MB wxStrncpy - #define wxWC2WX wxWC2MB - #define wxWX2WC wxMB2WC - #endif -#else /* !wxUSE_UNICODE */ - /* No wxUSE_WCHAR_T: we have to do something (JACS) */ - #define wxMB2WC wxStrncpy - #define wxWC2MB wxStrncpy +/* multibyte<->widechar conversion */ +WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n); +WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n); + +#if wxUSE_UNICODE + #define wxMB2WX wxMB2WC + #define wxWX2MB wxWC2MB + #define wxWC2WX wxStrncpy + #define wxWX2WC wxStrncpy +#else #define wxMB2WX wxStrncpy #define wxWX2MB wxStrncpy #define wxWC2WX wxWC2MB diff --git a/interface/wx/encconv.h b/interface/wx/encconv.h index ceba036f84..857531c615 100644 --- a/interface/wx/encconv.h +++ b/interface/wx/encconv.h @@ -10,8 +10,7 @@ @class wxEncodingConverter This class is capable of converting strings between two 8-bit encodings/charsets. - It can also convert from/to Unicode (but only if you compiled wxWidgets - with @c wxUSE_WCHAR_T set to 1). + It can also convert from/to Unicode. Only a limited subset of encodings is supported by wxEncodingConverter: @c wxFONTENCODING_ISO8859_1..15, @c wxFONTENCODING_CP1250..1257 and @@ -64,9 +63,6 @@ public: considered a lossless operation. @note You must call Init() before using this method! - - @note wchar_t versions of the method are not available if wxWidgets was - compiled with @c wxUSE_WCHAR_T set to 0. */ bool Convert(const char* input, char* output) const; bool Convert(const wchar_t* input, wchar_t* output) const; diff --git a/samples/propgrid/propgrid.cpp b/samples/propgrid/propgrid.cpp index b546314ab4..34723fc3ea 100644 --- a/samples/propgrid/propgrid.cpp +++ b/samples/propgrid/propgrid.cpp @@ -1922,7 +1922,6 @@ void FormMain::PopulateWithLibraryConfig () ADD_WX_LIB_CONF_GROUP(wxT("Unicode Support")) ADD_WX_LIB_CONF( wxUSE_UNICODE ) ADD_WX_LIB_CONF( wxUSE_UNICODE_MSLU ) - ADD_WX_LIB_CONF( wxUSE_WCHAR_T ) ADD_WX_LIB_CONF_GROUP(wxT("Global Features")) ADD_WX_LIB_CONF( wxUSE_EXCEPTIONS ) diff --git a/src/common/convauto.cpp b/src/common/convauto.cpp index dde8af743e..8d8c24c0a3 100644 --- a/src/common/convauto.cpp +++ b/src/common/convauto.cpp @@ -23,8 +23,6 @@ #pragma hdrstop #endif -#if wxUSE_WCHAR_T - #ifndef WX_PRECOMP #include "wx/wx.h" #endif //WX_PRECOMP @@ -318,5 +316,3 @@ wxConvAuto::FromWChar(char *dst, size_t dstLen, return m_conv->FromWChar(dst, dstLen, src, srcLen); } - -#endif // wxUSE_WCHAR_T diff --git a/src/common/encconv.cpp b/src/common/encconv.cpp index 92c8b04362..a4b7143ff3 100644 --- a/src/common/encconv.cpp +++ b/src/common/encconv.cpp @@ -25,12 +25,6 @@ #include "unictabl.inc" #endif -#if wxUSE_WCHAR_T - typedef wchar_t tchar; -#else - typedef char tchar; -#endif - #ifdef __WXMAC__ #include "wx/osx/core/cfstring.h" #include @@ -124,10 +118,6 @@ bool wxEncodingConverter::Init(wxFontEncoding input_enc, wxFontEncoding output_e if (m_Table) {delete[] m_Table; m_Table = NULL;} -#if !wxUSE_WCHAR_T - if (input_enc == wxFONTENCODING_UNICODE || output_enc == wxFONTENCODING_UNICODE) return false; -#endif - if (input_enc == output_enc) {m_JustCopy = true; return true;} m_UnicodeOutput = (output_enc == wxFONTENCODING_UNICODE); @@ -137,18 +127,18 @@ bool wxEncodingConverter::Init(wxFontEncoding input_enc, wxFontEncoding output_e { if ((out_tbl = GetEncTable(output_enc)) == NULL) return false; - m_Table = new tchar[65536]; - for (i = 0; i < 128; i++) m_Table[i] = (tchar)i; // 7bit ASCII - for (i = 128; i < 65536; i++) m_Table[i] = (tchar)0; + m_Table = new wchar_t[65536]; + for (i = 0; i < 128; i++) m_Table[i] = (wchar_t)i; // 7bit ASCII + for (i = 128; i < 65536; i++) m_Table[i] = (wchar_t)0; if (method == wxCONVERT_SUBSTITUTE) { for (i = 0; i < encoding_unicode_fallback_count; i++) - m_Table[encoding_unicode_fallback[i].c] = (tchar) encoding_unicode_fallback[i].s; + m_Table[encoding_unicode_fallback[i].c] = (wchar_t) encoding_unicode_fallback[i].s; } for (i = 0; i < 128; i++) - m_Table[out_tbl[i]] = (tchar)(128 + i); + m_Table[out_tbl[i]] = (wchar_t)(128 + i); m_UnicodeInput = true; } @@ -160,12 +150,12 @@ bool wxEncodingConverter::Init(wxFontEncoding input_enc, wxFontEncoding output_e m_UnicodeInput = false; - m_Table = new tchar[256]; - for (i = 0; i < 128; i++) m_Table[i] = (tchar)i; // 7bit ASCII + m_Table = new wchar_t[256]; + for (i = 0; i < 128; i++) m_Table[i] = (wchar_t)i; // 7bit ASCII if (output_enc == wxFONTENCODING_UNICODE) { - for (i = 0; i < 128; i++) m_Table[128 + i] = (tchar)in_tbl[i]; + for (i = 0; i < 128; i++) m_Table[128 + i] = (wchar_t)in_tbl[i]; return true; } else // output !Unicode @@ -182,13 +172,9 @@ bool wxEncodingConverter::Init(wxFontEncoding input_enc, wxFontEncoding output_e item = (CharsetItem*) bsearch(&key, encoding_unicode_fallback, encoding_unicode_fallback_count, sizeof(CharsetItem), CompareCharsetItems); if (item) - m_Table[128 + i] = (tchar)item -> c; + m_Table[128 + i] = (wchar_t)item -> c; else -#if wxUSE_WCHAR_T m_Table[128 + i] = (wchar_t)(128 + i); -#else - m_Table[128 + i] = (char)(128 + i); -#endif } delete[] rev; @@ -199,11 +185,11 @@ bool wxEncodingConverter::Init(wxFontEncoding input_enc, wxFontEncoding output_e } -#define REPLACEMENT_CHAR ((tchar)'?') +#define REPLACEMENT_CHAR (L'?') -inline tchar GetTableValue(const tchar *table, tchar value, bool& repl) +inline wchar_t GetTableValue(const wchar_t *table, wchar_t value, bool& repl) { - tchar r = table[value]; + wchar_t r = table[value]; if (r == 0 && value != 0) { r = REPLACEMENT_CHAR; @@ -240,8 +226,6 @@ bool wxEncodingConverter::Convert(const char* input, char* output) const } -#if wxUSE_WCHAR_T - bool wxEncodingConverter::Convert(const char* input, wchar_t* output) const { wxASSERT_MSG(m_UnicodeOutput, wxT("You cannot convert to 8-bit if output is const wchar_t*!")); @@ -331,8 +315,6 @@ bool wxEncodingConverter::Convert(const wchar_t* input, wchar_t* output) const return !replaced; } -#endif // wxUSE_WCHAR_T - wxString wxEncodingConverter::Convert(const wxString& input) const { diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 0638da4e95..fa97d94990 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -65,7 +65,6 @@ #include "wx/filename.h" #include "wx/tokenzr.h" #include "wx/fontmap.h" -#include "wx/encconv.h" #include "wx/scopedptr.h" #include "wx/apptrait.h" #include "wx/stdpaths.h" @@ -1326,7 +1325,6 @@ bool wxMsgCatalogFile::FillHash(wxMessagesHash& hash, } #endif // wxUSE_UNICODE/wxUSE_FONTMAP -#if wxUSE_WCHAR_T // conversion to use to convert catalog strings to the GUI encoding wxMBConv *inputConv, *inputConvPtr = NULL; // same as inputConv but safely deleteable @@ -1353,43 +1351,6 @@ bool wxMsgCatalogFile::FillHash(wxMessagesHash& hash, ? NULL : new wxCSConv(msgIdCharset); -#elif wxUSE_FONTMAP - wxASSERT_MSG( msgIdCharset.empty(), - wxS("non-ASCII msgid languages only supported if wxUSE_WCHAR_T=1") ); - - wxEncodingConverter converter; - if ( convertEncoding ) - { - wxFontEncoding targetEnc = wxFONTENCODING_SYSTEM; - wxFontEncoding enc = wxFontMapperBase::Get()->CharsetToEncoding(m_charset, false); - if ( enc == wxFONTENCODING_SYSTEM ) - { - convertEncoding = false; // unknown encoding - } - else - { - targetEnc = wxLocale::GetSystemEncoding(); - if (targetEnc == wxFONTENCODING_SYSTEM) - { - wxFontEncodingArray a = wxEncodingConverter::GetPlatformEquivalents(enc); - if (a[0] == enc) - // no conversion needed, locale uses native encoding - convertEncoding = false; - if (a.GetCount() == 0) - // we don't know common equiv. under this platform - convertEncoding = false; - targetEnc = a[0]; - } - } - - if ( convertEncoding ) - { - converter.Init(enc, targetEnc); - } - } -#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T - (void)convertEncoding; // get rid of warnings about unused parameter - for (size_t32 i = 0; i < m_numStrings; i++) { const char *data = StringAtOfs(m_pOrigTable, i); @@ -1400,12 +1361,10 @@ bool wxMsgCatalogFile::FillHash(wxMessagesHash& hash, #if wxUSE_UNICODE msgid = wxString(data, *inputConv); #else // ASCII - #if wxUSE_WCHAR_T - if ( inputConv && sourceConv ) - msgid = wxString(inputConv->cMB2WC(data), *sourceConv); - else - #endif - msgid = data; + if ( inputConv && sourceConv ) + msgid = wxString(inputConv->cMB2WC(data), *sourceConv); + else + msgid = data; #endif // wxUSE_UNICODE data = StringAtOfs(m_pTransTable, i); @@ -1422,19 +1381,12 @@ bool wxMsgCatalogFile::FillHash(wxMessagesHash& hash, wxString msgstr; #if wxUSE_UNICODE msgstr = wxString(str, *inputConv); -#elif wxUSE_WCHAR_T +#else if ( inputConv ) msgstr = wxString(inputConv->cMB2WC(str), *wxConvUI); else msgstr = str; -#else // !wxUSE_WCHAR_T - #if wxUSE_FONTMAP - if ( bConvertEncoding ) - msgstr = wxString(converter.Convert(str)); - else - #endif - msgstr = str; -#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T +#endif // wxUSE_UNICODE/!wxUSE_UNICODE if ( !msgstr.empty() ) { @@ -1452,10 +1404,8 @@ bool wxMsgCatalogFile::FillHash(wxMessagesHash& hash, } } -#if wxUSE_WCHAR_T delete sourceConv; delete inputConvPtr; -#endif // wxUSE_WCHAR_T return true; } diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 599048e9e2..7e7136ae9e 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -28,8 +28,6 @@ #include "wx/strconv.h" -#if wxUSE_WCHAR_T - #ifndef __WXWINCE__ #include #endif @@ -3455,14 +3453,3 @@ WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvFileName = #else // !__DARWIN__ wxGet_wxConvLibcPtr(); #endif // __DARWIN__/!__DARWIN__ - -#else // !wxUSE_WCHAR_T - -// FIXME-UTF8: remove this, wxUSE_WCHAR_T is required now -// stand-ins in absence of wchar_t -WXDLLIMPEXP_DATA_BASE(wxMBConv) wxConvLibc, - wxConvISO8859_1, - wxConvLocal, - wxConvUTF8; - -#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T diff --git a/src/common/wxcrt.cpp b/src/common/wxcrt.cpp index db16fa9b18..55ad0812a8 100644 --- a/src/common/wxcrt.cpp +++ b/src/common/wxcrt.cpp @@ -81,7 +81,6 @@ using namespace std ; #include #endif -#if wxUSE_WCHAR_T WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n) { // assume that we have mbsrtowcs() too if we have wcsrtombs() @@ -141,7 +140,6 @@ WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *pwz, size_t n) return wxWcstombs(NULL, pwz, 0); #endif } -#endif // wxUSE_WCHAR_T char* wxSetlocale(int category, const char *locale) { @@ -735,7 +733,6 @@ int wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argpt } #endif // wxUSE_UNICODE -#if wxUSE_WCHAR_T // ---------------------------------------------------------------------------- // ctype.h stuff (currently unused) @@ -953,8 +950,6 @@ wxCRT_StrftimeW(wchar_t *s, size_t maxsize, const wchar_t *fmt, const struct tm } #endif // !wxCRT_StrftimeW -#endif // wxUSE_WCHAR_T - #ifdef wxLongLong_t template static wxULongLong_t @@ -1109,7 +1104,7 @@ wxULongLong_t wxCRT_StrtoullW(const wchar_t* nptr, wchar_t** endptr, int base) #endif // wxLongLong_t // ---------------------------------------------------------------------------- -// functions which we may need even if !wxUSE_WCHAR_T +// strtok() functions // ---------------------------------------------------------------------------- template diff --git a/src/dfb/window.cpp b/src/dfb/window.cpp index 6fed4e69f4..bfe64b16f0 100644 --- a/src/dfb/window.cpp +++ b/src/dfb/window.cpp @@ -967,13 +967,11 @@ static long GetUntraslatedKeyCode(DFBInputDeviceKeyIdentifier key_id, return key_symbol; else { -#if wxUSE_WCHAR_T wchar_t chr = key_symbol; wxCharBuffer buf(wxConvUI->cWC2MB(&chr, 1, NULL)); if ( buf ) return *buf; // may be 0 if failed else -#endif // wxUSE_WCHAR_T return 0; } #endif diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index 66fced32c3..5627fbe89a 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -531,7 +531,6 @@ bool wxApp::Initialize(int& argc, wxChar **argv) gtk_set_locale(); - // We should have the wxUSE_WCHAR_T test on the _outside_ if (!wxOKlibc()) wxConvCurrent = &wxConvLocal; diff --git a/src/html/helpdata.cpp b/src/html/helpdata.cpp index 63b2988e61..f67b1689c8 100644 --- a/src/html/helpdata.cpp +++ b/src/html/helpdata.cpp @@ -569,7 +569,6 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile, // Now store the contents range bookr->SetContentsRange(cont_start, m_contents.size()); -#if wxUSE_WCHAR_T // MS HTML Help files [written by MS HTML Help Workshop] are broken // in that the data are iso-8859-1 (including HTML entities), but must // be interpreted as being in language's windows charset. Correct the @@ -597,11 +596,6 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile, } #undef CORRECT_STR } -#else - wxUnusedVar(IndexOld); - wxUnusedVar(ContentsOld); - wxASSERT_MSG(encoding == wxFONTENCODING_SYSTEM, wxT("Help files need charset conversion, but wxUSE_WCHAR_T is 0")); -#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T m_bookRecords.Add(bookr); if (!m_index.empty()) diff --git a/src/html/htmlpars.cpp b/src/html/htmlpars.cpp index 0b43365821..3c312275a7 100644 --- a/src/html/htmlpars.cpp +++ b/src/html/htmlpars.cpp @@ -433,7 +433,7 @@ void wxHtmlTagHandler::ParseInnerSource(const wxString& source) IMPLEMENT_DYNAMIC_CLASS(wxHtmlEntitiesParser,wxObject) wxHtmlEntitiesParser::wxHtmlEntitiesParser() -#if wxUSE_WCHAR_T && !wxUSE_UNICODE +#if !wxUSE_UNICODE : m_conv(NULL), m_encoding(wxFONTENCODING_SYSTEM) #endif { @@ -441,14 +441,14 @@ wxHtmlEntitiesParser::wxHtmlEntitiesParser() wxHtmlEntitiesParser::~wxHtmlEntitiesParser() { -#if wxUSE_WCHAR_T && !wxUSE_UNICODE +#if !wxUSE_UNICODE delete m_conv; #endif } +#if !wxUSE_UNICODE void wxHtmlEntitiesParser::SetEncoding(wxFontEncoding encoding) { -#if wxUSE_WCHAR_T && !wxUSE_UNICODE if (encoding == m_encoding) return; @@ -459,10 +459,8 @@ void wxHtmlEntitiesParser::SetEncoding(wxFontEncoding encoding) m_conv = NULL; else m_conv = new wxCSConv(wxFontMapper::GetEncodingName(m_encoding)); -#else - (void) encoding; -#endif } +#endif // !wxUSE_UNICODE wxString wxHtmlEntitiesParser::Parse(const wxString& input) const { @@ -523,7 +521,6 @@ wxString wxHtmlEntitiesParser::Parse(const wxString& input) const #if !wxUSE_UNICODE wxChar wxHtmlEntitiesParser::GetCharForCode(unsigned code) const { -#if wxUSE_WCHAR_T char buf[2]; wchar_t wbuf[2]; wbuf[0] = (wchar_t)code; @@ -532,9 +529,6 @@ wxChar wxHtmlEntitiesParser::GetCharForCode(unsigned code) const if (conv->WC2MB(buf, wbuf, 2) == (size_t)-1) return '?'; return buf[0]; -#else - return (code < 256) ? (wxChar)code : '?'; -#endif } #endif diff --git a/src/html/m_layout.cpp b/src/html/m_layout.cpp index 02d38228cd..b373e85a9d 100644 --- a/src/html/m_layout.cpp +++ b/src/html/m_layout.cpp @@ -285,7 +285,7 @@ TAG_HANDLER_BEGIN(TITLE, "TITLE") if (winIface) { wxString title(tag.GetBeginIter(), tag.GetEndIter1()); -#if !wxUSE_UNICODE && wxUSE_WCHAR_T +#if !wxUSE_UNICODE const wxFontEncoding enc = m_WParser->GetInputEncoding(); if ( enc != wxFONTENCODING_DEFAULT ) { diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 8ffbfce0c1..d5e40992c3 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -1038,10 +1038,6 @@ wxTextCtrl::StreamIn(const wxString& value, wxLogLastError(wxT("EM_STREAMIN")); } -#if !wxUSE_WCHAR_T - free(wchBuf); -#endif // !wxUSE_WCHAR_T - return true; } @@ -1054,13 +1050,8 @@ wxTextCtrl::StreamOut(wxFontEncoding encoding, bool selectionOnly) const const int len = GetWindowTextLength(GetHwnd()); -#if wxUSE_WCHAR_T wxWCharBuffer wchBuf(len); wchar_t *wpc = wchBuf.data(); -#else - wchar_t *wchBuf = (wchar_t *)malloc((len + 1)*sizeof(wchar_t)); - wchar_t *wpc = wchBuf; -#endif wxStreamOutData data; data.wpc = wpc; @@ -1100,10 +1091,6 @@ wxTextCtrl::StreamOut(wxFontEncoding encoding, bool selectionOnly) const } } -#if !wxUSE_WCHAR_T - free(wchBuf); -#endif // !wxUSE_WCHAR_T - return out; } diff --git a/src/propgrid/propgridiface.cpp b/src/propgrid/propgridiface.cpp index d29e2f4498..9acbb60a0f 100644 --- a/src/propgrid/propgridiface.cpp +++ b/src/propgrid/propgridiface.cpp @@ -73,10 +73,8 @@ wxPGProperty* wxPGPropArgCls::GetPtr( wxPropertyGridInterface* iface ) const return iface->GetPropertyByNameA(*m_ptr.stringName); else if ( m_flags & IsCharPtr ) return iface->GetPropertyByNameA(m_ptr.charName); -#if wxUSE_WCHAR_T else if ( m_flags & IsWCharPtr ) return iface->GetPropertyByNameA(m_ptr.wcharName); -#endif return NULL; } diff --git a/tests/benchmarks/htmlparser/htmlpars.cpp b/tests/benchmarks/htmlparser/htmlpars.cpp index 7d7e5eaed5..3bc1dea94a 100644 --- a/tests/benchmarks/htmlparser/htmlpars.cpp +++ b/tests/benchmarks/htmlparser/htmlpars.cpp @@ -459,7 +459,7 @@ void wx28HtmlTagHandler::ParseInnerSource(const wxString& source) IMPLEMENT_DYNAMIC_CLASS(wx28HtmlEntitiesParser,wxObject) wx28HtmlEntitiesParser::wx28HtmlEntitiesParser() -#if wxUSE_WCHAR_T && !wxUSE_UNICODE +#if !wxUSE_UNICODE : m_conv(NULL), m_encoding(wxFONTENCODING_SYSTEM) #endif { @@ -467,14 +467,14 @@ wx28HtmlEntitiesParser::wx28HtmlEntitiesParser() wx28HtmlEntitiesParser::~wx28HtmlEntitiesParser() { -#if wxUSE_WCHAR_T && !wxUSE_UNICODE +#if !wxUSE_UNICODE delete m_conv; #endif } void wx28HtmlEntitiesParser::SetEncoding(wxFontEncoding encoding) { -#if wxUSE_WCHAR_T && !wxUSE_UNICODE +#if !wxUSE_UNICODE if (encoding == m_encoding) return; @@ -552,7 +552,6 @@ extern "C" int LINKAGEMODE wx28HtmlEntityCompare(const void *key, const void *it #if !wxUSE_UNICODE wxChar wx28HtmlEntitiesParser::GetCharForCode(unsigned code) { -#if wxUSE_WCHAR_T char buf[2]; wchar_t wbuf[2]; wbuf[0] = (wchar_t)code; @@ -561,9 +560,6 @@ wxChar wx28HtmlEntitiesParser::GetCharForCode(unsigned code) if (conv->WC2MB(buf, wbuf, 2) == (size_t)-1) return '?'; return buf[0]; -#else - return (code < 256) ? (wxChar)code : '?'; -#endif } #endif diff --git a/tests/benchmarks/htmlparser/htmlpars.h b/tests/benchmarks/htmlparser/htmlpars.h index 5618267231..db6637814a 100644 --- a/tests/benchmarks/htmlparser/htmlpars.h +++ b/tests/benchmarks/htmlparser/htmlpars.h @@ -250,7 +250,7 @@ public: virtual ~wx28HtmlEntitiesParser(); // Sets encoding of output string. - // Has no effect if wxUSE_WCHAR_T==0 or wxUSE_UNICODE==1 + // Has no effect if wxUSE_UNICODE==1 void SetEncoding(wxFontEncoding encoding); // Parses entities in input and replaces them with respective characters @@ -268,7 +268,7 @@ public: #endif protected: -#if wxUSE_WCHAR_T && !wxUSE_UNICODE +#if !wxUSE_UNICODE wxMBConv *m_conv; wxFontEncoding m_encoding; #endif diff --git a/tests/mbconv/convautotest.cpp b/tests/mbconv/convautotest.cpp index 0c6292f625..45fb79e0d5 100644 --- a/tests/mbconv/convautotest.cpp +++ b/tests/mbconv/convautotest.cpp @@ -17,8 +17,6 @@ #pragma hdrstop #endif -#if wxUSE_WCHAR_T - #include "wx/convauto.h" #include "wx/mstream.h" @@ -207,6 +205,3 @@ void ConvAutoTestCase::StreamUTF32BE() "\0\0\x03\xB2", 20, line1, line2); } - -#endif // wxUSE_WCHAR_T - -- 2.45.2