From 89745e83f3f8bff8fb67d6516aea87f087e10398 Mon Sep 17 00:00:00 2001 From: ARATA Mizuki Date: Mon, 29 Feb 2016 18:07:07 +0900 Subject: [PATCH 1/7] Fix signatures of wxStringBuffer / wxStringBufferLength constructors in interface/wx/string.h There were extra 'const's in the interface file. --- interface/wx/string.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/wx/string.h b/interface/wx/string.h index fbd4e455c3..0b12290ab9 100644 --- a/interface/wx/string.h +++ b/interface/wx/string.h @@ -1953,7 +1953,7 @@ public: Basically, this is equivalent to calling wxString::GetWriteBuf and saving the result. */ - wxStringBufferLength(const wxString& str, size_t len); + wxStringBufferLength(wxString& str, size_t len); /** Restores the string passed to the constructor to the usable state by calling @@ -2014,7 +2014,7 @@ public: Basically, this is equivalent to calling wxString::GetWriteBuf() and saving the result. */ - wxStringBuffer(const wxString& str, size_t len); + wxStringBuffer(wxString& str, size_t len); /** Restores the string passed to the constructor to the usable state by calling From daf944909ce9d12bf786bcb2752c5edf03ef7c36 Mon Sep 17 00:00:00 2001 From: ARATA Mizuki Date: Mon, 22 Feb 2016 03:19:49 +0900 Subject: [PATCH 2/7] Use wxChar16 instead of wxDecodeSurrogate_t for UTF-16 unit type in wxDecodeSurrogate --- src/common/strconv.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 867d663f99..480d16251a 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -122,18 +122,12 @@ static size_t decode_utf16(const wxUint16* input, wxUint32& output) } } -#ifdef WC_UTF16 - typedef wchar_t wxDecodeSurrogate_t; -#else // !WC_UTF16 - typedef wxUint16 wxDecodeSurrogate_t; -#endif // WC_UTF16/!WC_UTF16 - // returns the next UTF-32 character from the wchar_t buffer and advances the // pointer to the character after this one // // if an invalid character is found, *pSrc is set to NULL, the caller must // check for this -static wxUint32 wxDecodeSurrogate(const wxDecodeSurrogate_t **pSrc) +static wxUint32 wxDecodeSurrogate(const wxChar16 **pSrc) { wxUint32 out; const size_t From 86dd0cd2a2645d2ddfdc88604a7977c18dbde65d Mon Sep 17 00:00:00 2001 From: ARATA Mizuki Date: Wed, 17 Feb 2016 23:40:07 +0900 Subject: [PATCH 3/7] Fix constness of some member functions of wxUString --- include/wx/ustring.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/wx/ustring.h b/include/wx/ustring.h index 25934f6dc4..7790ac1656 100644 --- a/include/wx/ustring.h +++ b/include/wx/ustring.h @@ -134,9 +134,9 @@ public: return utf16_str(); } #else - wchar_t *wc_str() const + const wchar_t *wc_str() const { - return (wchar_t*) c_str(); + return c_str(); } #endif @@ -154,18 +154,18 @@ public: } #if wxUSE_UNICODE_UTF8 - wxScopedCharBuffer wx_str() + wxScopedCharBuffer wx_str() const { return utf8_str(); } #else #if SIZEOF_WCHAR_T == 2 - wxScopedWCharBuffer wx_str() + wxScopedWCharBuffer wx_str() const { return utf16_str(); } #else - const wchar_t* wx_str() + const wchar_t* wx_str() const { return c_str(); } From 381ab333b960b94e8eb7ac9562684ca26989746e Mon Sep 17 00:00:00 2001 From: ARATA Mizuki Date: Wed, 17 Feb 2016 23:41:13 +0900 Subject: [PATCH 4/7] Get rid of a use of WXSTRINGCAST from src/msw/metafile.cpp WXSTRINGCAST is a const-removing cast and should be avoided unless necessary. Here, wxString::c_str() is sufficient because GetTextExtentPoint32 takes a const pointer. --- src/msw/metafile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/msw/metafile.cpp b/src/msw/metafile.cpp index 7c3d177b66..5f88acdadd 100644 --- a/src/msw/metafile.cpp +++ b/src/msw/metafile.cpp @@ -236,7 +236,7 @@ void wxMetafileDCImpl::DoGetTextExtent(const wxString& string, SIZE sizeRect; TEXTMETRIC tm; - ::GetTextExtentPoint32(dc, WXSTRINGCAST string, wxStrlen(WXSTRINGCAST string), &sizeRect); + ::GetTextExtentPoint32(dc, string.c_str(), string.length(), &sizeRect); ::GetTextMetrics(dc, &tm); if ( x ) From a2b5309f61b0e89109d4740349eb5142ff8999fb Mon Sep 17 00:00:00 2001 From: ARATA Mizuki Date: Wed, 17 Feb 2016 23:46:52 +0900 Subject: [PATCH 5/7] Get rid of some Win16 code from wxSetWorkingDirectory --- src/common/filefn.cpp | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index a8f80c880d..26bdb9986f 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -1390,31 +1390,7 @@ bool wxSetWorkingDirectory(const wxString& d) #if defined(__UNIX__) || defined(__WXMAC__) success = (chdir(wxFNSTRINGCAST d.fn_str()) == 0); #elif defined(__WINDOWS__) - -#ifdef __WIN32__ success = (SetCurrentDirectory(d.t_str()) != 0); -#else - // Must change drive, too. - bool isDriveSpec = ((strlen(d) > 1) && (d[1] == ':')); - if (isDriveSpec) - { - wxChar firstChar = d[0]; - - // To upper case - if (firstChar > 90) - firstChar = firstChar - 32; - - // To a drive number - unsigned int driveNo = firstChar - 64; - if (driveNo > 0) - { - unsigned int noDrives; - _dos_setdrive(driveNo, &noDrives); - } - } - success = (chdir(WXSTRINGCAST d) == 0); -#endif - #endif if ( !success ) { From 45ff4e6b218f03c7303b3ad79967f2bccffa9cc9 Mon Sep 17 00:00:00 2001 From: ARATA Mizuki Date: Wed, 17 Feb 2016 23:58:06 +0900 Subject: [PATCH 6/7] Get rid of a use of wxFNSTRINGCAST Since chdir() takes a const pointer, the const-removing cast is not needed. --- src/common/filefn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 26bdb9986f..a5fc4e6265 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -1388,7 +1388,7 @@ bool wxSetWorkingDirectory(const wxString& d) { bool success = false; #if defined(__UNIX__) || defined(__WXMAC__) - success = (chdir(wxFNSTRINGCAST d.fn_str()) == 0); + success = (chdir(d.fn_str()) == 0); #elif defined(__WINDOWS__) success = (SetCurrentDirectory(d.t_str()) != 0); #endif From a17a3994ecac1b06f35af547edd920d9fb08f225 Mon Sep 17 00:00:00 2001 From: ARATA Mizuki Date: Thu, 18 Feb 2016 00:29:06 +0900 Subject: [PATCH 7/7] Get rid of a use of wxMBSTRINGCAST wxMBSTRINGCAST is a const-removing cast and therefore should be avoided unless necessary. Here, the cast was used to convert wxWX2MBbuf to const char *, which does not involve removing const-ness. --- src/common/ftp.cpp | 2 +- src/generic/dcpsg.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/ftp.cpp b/src/common/ftp.cpp index 4dca4bddc2..e253956890 100644 --- a/src/common/ftp.cpp +++ b/src/common/ftp.cpp @@ -237,7 +237,7 @@ char wxFTP::SendCommand(const wxString& command) wxString tmp_str = command + wxT("\r\n"); const wxWX2MBbuf tmp_buf = tmp_str.mb_str(); - if ( Write(wxMBSTRINGCAST tmp_buf, strlen(tmp_buf)).Error()) + if ( Write(static_cast(tmp_buf), strlen(tmp_buf)).Error()) { m_lastError = wxPROTO_NETERR; return 0; diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index 32b6830eca..1754ac83a9 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -2336,7 +2336,7 @@ void wxPostScriptDCImpl::DoGetTextExtent(const wxString& string, long sum=0; float height=fontSize; /* by default */ - unsigned char *p=(unsigned char *)wxMBSTRINGCAST strbuf; + const unsigned char *p=reinterpret_cast(static_cast(strbuf)); if(!p) { // String couldn't be converted which used to SEGV as reported here: