For Android (wxQT), add private wcstol, wcstoul and wcstod
These functions are needed by wxString::ToLong wxString::ToDouble etc.. They do exist in the android library, but do not work corretly. This change implements them using strtol strtoul and strtod For more info see discussion in wx-dev list: https://groups.google.com/d/msg/wx-dev/71qtIFcujgM/TRCfCjGHUhEJ Thanks @seandepagnier (modified a bit the comments) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78472 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
24c0401e81
commit
744ea8a618
@ -197,9 +197,21 @@ WXDLLIMPEXP_BASE void *calloc( size_t num, size_t size );
|
||||
#define wxCRT_StrtodA strtod
|
||||
#define wxCRT_StrtolA strtol
|
||||
#define wxCRT_StrtoulA strtoul
|
||||
|
||||
#ifdef __ANDROID__ // these functions are broken on android
|
||||
|
||||
extern double android_wcstod(const wchar_t *nptr, wchar_t **endptr);
|
||||
extern long android_wcstol(const wchar_t *nptr, wchar_t **endptr, int base);
|
||||
extern unsigned long android_wcstoul(const wchar_t *nptr, wchar_t **endptr, int base);
|
||||
|
||||
#define wxCRT_StrtodW android_wcstod
|
||||
#define wxCRT_StrtolW android_wcstol
|
||||
#define wxCRT_StrtoulW android_wcstoul
|
||||
#else
|
||||
#define wxCRT_StrtodW wcstod
|
||||
#define wxCRT_StrtolW wcstol
|
||||
#define wxCRT_StrtoulW wcstoul
|
||||
#endif
|
||||
|
||||
#ifdef __VISUALC__
|
||||
#define wxCRT_StrtollA _strtoi64
|
||||
|
@ -1268,3 +1268,49 @@ int wxVsscanf(const wxCStrData& str, const char *format, va_list ap)
|
||||
int wxVsscanf(const wxCStrData& str, const wchar_t *format, va_list ap)
|
||||
{ return wxCRT_VsscanfW(str.AsWCharBuf(), format, ap); }
|
||||
#endif // HAVE_NO_VSSCANF
|
||||
|
||||
// ============================================================================
|
||||
// ANDROID specific private implementations (due stubs/missing support in NDK)
|
||||
// ============================================================================
|
||||
|
||||
// On android, most wchar_t functions are broken, so instead we must
|
||||
// convert a byte at a time
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#define ANDROID_WCSTO_START \
|
||||
int len = wcslen(nptr) + 1; \
|
||||
char dst[len]; \
|
||||
for(int i=0; i<len; i++) \
|
||||
dst[i] = wctob(nptr[i]); \
|
||||
char *dstendp;
|
||||
|
||||
#define ANDROID_WCSTO_END \
|
||||
if(endptr) { \
|
||||
if(dstendp) \
|
||||
*endptr = (wchar_t*)(nptr + (dstendp - dst) * sizeof(wchar_t)); \
|
||||
else \
|
||||
*endptr = NULL; \
|
||||
} \
|
||||
return d;
|
||||
|
||||
long android_wcstol(const wchar_t *nptr, wchar_t **endptr, int base)
|
||||
{
|
||||
ANDROID_WCSTO_START
|
||||
long d = strtol(dst, &dstendp, base);
|
||||
ANDROID_WCSTO_END
|
||||
}
|
||||
|
||||
unsigned long android_wcstoul(const wchar_t *nptr, wchar_t **endptr, int base)
|
||||
{
|
||||
ANDROID_WCSTO_START
|
||||
unsigned long d = strtoul(dst, &dstendp, base);
|
||||
ANDROID_WCSTO_END
|
||||
}
|
||||
|
||||
double android_wcstod(const wchar_t *nptr, wchar_t **endptr)
|
||||
{
|
||||
ANDROID_WCSTO_START
|
||||
double d = strtod(dst, &dstendp);
|
||||
ANDROID_WCSTO_END
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user