From 941a4e6260eef03d6452b6eeb8f4c6f2de972b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 22 Aug 2007 19:06:31 +0000 Subject: [PATCH] replace wxStringToIntType with a macro to make Watcom compile the code git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48342 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/string.cpp | 47 ++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/src/common/string.cpp b/src/common/string.cpp index 76bd308623..a791562d7e 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -1391,49 +1391,46 @@ int wxString::Find(wxUniChar ch, bool bFromEnd) const // it out. Note that number extraction works correctly on UTF-8 strings, so // we can use wxStringCharType and wx_str() for maximum efficiency. -template -bool wxStringToIntType(const wxStringCharType *start, - T *val, - int base, - T (*func)(const wxStringCharType*, wxStringCharType**, int)) -{ - wxCHECK_MSG( val, false, _T("NULL output pointer") ); - wxASSERT_MSG( !base || (base > 1 && base <= 36), _T("invalid base") ); - #ifndef __WXWINCE__ - errno = 0; + #define DO_IF_NOT_WINCE(x) x +#else + #define DO_IF_NOT_WINCE(x) #endif - wxStringCharType *end; - *val = (*func)(start, &end, base); - - // 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 - return !*end && (end != start) -#ifndef __WXWINCE__ - && (errno != ERANGE) -#endif - ; -} +#define WX_STRING_TO_INT_TYPE(val, base, func) \ + wxCHECK_MSG( val, false, _T("NULL output pointer") ); \ + wxASSERT_MSG( !base || (base > 1 && base <= 36), _T("invalid base") ); \ + \ + DO_IF_NOT_WINCE( errno = 0; ) \ + \ + const wxStringCharType *start = wx_str(); \ + wxStringCharType *end; \ + *val = func(start, &end, base); \ + \ + /* 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: */ \ + return !*end && (end != start) \ + DO_IF_NOT_WINCE( && (errno != ERANGE) ) bool wxString::ToLong(long *val, int base) const { - return wxStringToIntType(wx_str(), val, base, wxStrtol); + WX_STRING_TO_INT_TYPE(val, base, wxStrtol); } bool wxString::ToULong(unsigned long *val, int base) const { - return wxStringToIntType(wx_str(), val, base, wxStrtoul); + WX_STRING_TO_INT_TYPE(val, base, wxStrtoul); } bool wxString::ToLongLong(wxLongLong_t *val, int base) const { - return wxStringToIntType(wx_str(), val, base, wxStrtoll); + WX_STRING_TO_INT_TYPE(val, base, wxStrtoll); } bool wxString::ToULongLong(wxULongLong_t *val, int base) const { - return wxStringToIntType(wx_str(), val, base, wxStrtoull); + WX_STRING_TO_INT_TYPE(val, base, wxStrtoull); } bool wxString::ToDouble(double *val) const