Add wxNO_UNSAFE_WXSTRING_CONV2 macro

The macro disallows implicit conversions between wxString and const
char*
This commit is contained in:
Arrigo Marchiori
2019-10-21 11:05:58 +02:00
committed by Vadim Zeitlin
parent 15a4375f93
commit 65cbf40b7e
16 changed files with 502 additions and 33 deletions

View File

@@ -280,14 +280,14 @@ WX_DEFINE_VARARG_FUNC_SANS_N0(int, wxPrintf, 1, (const wxFormatString&),
wxCRT_PrintfNative, wxCRT_PrintfA)
inline int wxPrintf(const wxFormatString& s)
{
return wxPrintf("%s", s.InputAsString());
return wxPrintf(wxASCII_STR("%s"), s.InputAsString());
}
WX_DEFINE_VARARG_FUNC_SANS_N0(int, wxFprintf, 2, (FILE*, const wxFormatString&),
wxCRT_FprintfNative, wxCRT_FprintfA)
inline int wxFprintf(FILE *f, const wxFormatString& s)
{
return wxFprintf(f, "%s", s.InputAsString());
return wxFprintf(f, wxASCII_STR("%s"), s.InputAsString());
}
// va_list versions of printf functions simply forward to the respective
@@ -440,12 +440,16 @@ WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxScopedCharBuffer& str, const char *form
wxCRT_SscanfA, (str.data(), format))
WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxScopedWCharBuffer& str, const wchar_t *format),
wxCRT_SscanfW, (str.data(), wxScanfConvertFormatW(format)))
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxString& str, const char *format),
wxCRT_SscanfA, (str.mb_str(), format))
#endif
WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxString& str, const wchar_t *format),
wxCRT_SscanfW, (str.wc_str(), wxScanfConvertFormatW(format)))
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxCStrData& str, const char *format),
wxCRT_SscanfA, (str.AsCharBuf(), format))
#endif
WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxCStrData& str, const wchar_t *format),
wxCRT_SscanfW, (str.AsWCharBuf(), wxScanfConvertFormatW(format)))