Output the extracted number from wxString::ToXXX() even if it returns false.
After the changes in r50710 wxString numeric conversion functions didn't update their output parameter any more if the conversion failed because not entire string was converted. This was incompatible with the old behaviour which some existing code did rely on, so restore it and now always return the number which was extracted from the beginning of the string if we found anything at all, even if the function returns false. Add unit test for the correct behaviour and updated the documentation. Closes #11126. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61786 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1632,14 +1632,14 @@ int wxString::Find(wxUniChar ch, bool bFromEnd) const
|
||||
const wxStringCharType *start = wx_str(); \
|
||||
wxStringCharType *end;
|
||||
|
||||
// notice that we return false without modifying the output parameter at all if
|
||||
// nothing could be parsed but we do modify it and return false then if we did
|
||||
// parse something successfully but not the entire string
|
||||
#define WX_STRING_TO_X_TYPE_END \
|
||||
/* return true only if scan was stopped by the terminating NUL and */ \
|
||||
/* if the string was not empty to start with and no under/overflow */ \
|
||||
/* occurred: */ \
|
||||
if ( *end || end == start DO_IF_NOT_WINCE(|| errno == ERANGE) ) \
|
||||
if ( end == start DO_IF_NOT_WINCE(|| errno == ERANGE) ) \
|
||||
return false; \
|
||||
*pVal = val; \
|
||||
return true;
|
||||
return !*end;
|
||||
|
||||
bool wxString::ToLong(long *pVal, int base) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user