added wxSafeConvertMB2WX/WX2MB() and use them when interfacing with C functions which crash if we pass them NULL pointers [backport from HEAD]
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@44772 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -523,10 +523,27 @@ extern WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvCurrent;
|
||||
#if wxUSE_UNICODE
|
||||
#define wxConvertWX2MB(s) wxConvCurrent->cWX2MB(s)
|
||||
#define wxConvertMB2WX(s) wxConvCurrent->cMB2WX(s)
|
||||
|
||||
#if wxABI_VERSION >= 20802
|
||||
// these functions should be used when the conversions really, really have
|
||||
// to succeed (usually because we pass their results to a standard C
|
||||
// function which would crash if we passed NULL to it), so these functions
|
||||
// always return a valid pointer if their argument is non-NULL
|
||||
|
||||
// this function safety is achieved by trying wxConvLibc first, wxConvUTF8
|
||||
// next if it fails and, finally, wxConvISO8859_1 which always succeeds
|
||||
extern WXDLLIMPEXP_BASE wxWCharBuffer wxSafeConvertMB2WX(const char *s);
|
||||
|
||||
// this function uses wxConvLibc and wxConvUTF8(MAP_INVALID_UTF8_TO_OCTAL)
|
||||
// if it fails
|
||||
extern WXDLLIMPEXP_BASE wxCharBuffer wxSafeConvertWX2MB(const wchar_t *ws);
|
||||
#endif // wxABI 2.8.2+
|
||||
#else // ANSI
|
||||
// no conversions to do
|
||||
#define wxConvertWX2MB(s) (s)
|
||||
#define wxConvertMB2WX(s) (s)
|
||||
#define wxSafeConvertMB2WX(s) (s)
|
||||
#define wxSafeConvertWX2MB(s) (s)
|
||||
#endif // Unicode/ANSI
|
||||
|
||||
#endif // _WX_STRCONV_H_
|
||||
|
Reference in New Issue
Block a user