removed code for compatibility with OS X <= 10.2, 10.3 is the minimum since wx-2.8
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46493 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -142,52 +142,33 @@ WXDLLIMPEXP_BASE void *calloc( size_t num, size_t size );
|
|||||||
#define wxCRT_StrstrA strstr
|
#define wxCRT_StrstrA strstr
|
||||||
#define wxCRT_StrxfrmA strxfrm
|
#define wxCRT_StrxfrmA strxfrm
|
||||||
|
|
||||||
/*
|
#define wxCRT_StrcatW wcscat
|
||||||
The system C library on Mac OS X 10.2 and below does not support unicode: in
|
#define wxCRT_StrchrW wcschr
|
||||||
other words all wide-character functions such as towupper et al. do simply
|
#define wxCRT_StrcmpW wcscmp
|
||||||
not exist so we need to provide our own in that context, except for the
|
#define wxCRT_StrcollW wcscoll
|
||||||
wchar_t definition/typedef itself.
|
#define wxCRT_StrcpyW wcscpy
|
||||||
|
#define wxCRT_StrcspnW wcscspn
|
||||||
|
#define wxCRT_StrncatW wcsncat
|
||||||
|
#define wxCRT_StrncmpW wcsncmp
|
||||||
|
#define wxCRT_StrncpyW wcsncpy
|
||||||
|
#define wxCRT_StrpbrkW wcspbrk
|
||||||
|
#define wxCRT_StrrchrW wcsrchr
|
||||||
|
#define wxCRT_StrspnW wcsspn
|
||||||
|
#define wxCRT_StrstrW wcsstr
|
||||||
|
#define wxCRT_StrxfrmW wcsxfrm
|
||||||
|
|
||||||
We need to do this for both project builder and CodeWarrior as the latter
|
/* Almost all compiler have strdup(), but not quite all: CodeWarrior under
|
||||||
uses the system C library in Mach builds for wide character support, which
|
Mac and VC++ for Windows CE don't provide it; additionally, gcc under
|
||||||
as mentioned does not exist on 10.2 and below.
|
Mac and OpenVMS do not have wcsdup: */
|
||||||
*/
|
#if defined(__VISUALC__) && __VISUALC__ >= 1400
|
||||||
#if defined(__DARWIN__) && (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_2)
|
#define wxCRT_StrdupA _strdup
|
||||||
#define wxHAS_NO_WCS_FUNCTIONS
|
#elif !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
|
||||||
|
#define wxCRT_StrdupA strdup
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(__WINDOWS__)
|
||||||
#ifndef wxHAS_NO_WCS_FUNCTIONS
|
#define wxCRT_StrdupW _wcsdup
|
||||||
#define wxCRT_StrcatW wcscat
|
#elif !defined(__DARWIN__) && !defined( __VMS )
|
||||||
#define wxCRT_StrchrW wcschr
|
#define wxCRT_StrdupW wcsdup
|
||||||
#define wxCRT_StrcmpW wcscmp
|
|
||||||
#define wxCRT_StrcollW wcscoll
|
|
||||||
#define wxCRT_StrcpyW wcscpy
|
|
||||||
#define wxCRT_StrcspnW wcscspn
|
|
||||||
#define wxCRT_StrncatW wcsncat
|
|
||||||
#define wxCRT_StrncmpW wcsncmp
|
|
||||||
#define wxCRT_StrncpyW wcsncpy
|
|
||||||
#define wxCRT_StrpbrkW wcspbrk
|
|
||||||
#define wxCRT_StrrchrW wcsrchr
|
|
||||||
#define wxCRT_StrspnW wcsspn
|
|
||||||
#define wxCRT_StrstrW wcsstr
|
|
||||||
#define wxCRT_StrxfrmW wcsxfrm
|
|
||||||
|
|
||||||
/* Almost all compiler have strdup(), but not quite all: CodeWarrior under
|
|
||||||
Mac and VC++ for Windows CE don't provide it; additionally, gcc under
|
|
||||||
Mac and OpenVMS do not have wcsdup: */
|
|
||||||
#if defined(__VISUALC__) && __VISUALC__ >= 1400
|
|
||||||
#define wxCRT_StrdupA _strdup
|
|
||||||
#elif !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
|
|
||||||
#define wxCRT_StrdupA strdup
|
|
||||||
#endif
|
|
||||||
#if defined(__WINDOWS__)
|
|
||||||
#define wxCRT_StrdupW _wcsdup
|
|
||||||
#elif !defined(__DARWIN__) && !defined( __VMS )
|
|
||||||
#define wxCRT_StrdupW wcsdup
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define wxCRT_StrdupA strdup
|
|
||||||
/* the rest is implemented in our code */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef wxHAVE_TCHAR_SUPPORT
|
#ifdef wxHAVE_TCHAR_SUPPORT
|
||||||
@@ -454,23 +435,21 @@ WXDLLIMPEXP_BASE wchar_t *wxCRT_StrtokW(wchar_t *psz, const wchar_t *delim, wcha
|
|||||||
#define wxCRT_FgetcA fgetc
|
#define wxCRT_FgetcA fgetc
|
||||||
#define wxCRT_UngetcA ungetc
|
#define wxCRT_UngetcA ungetc
|
||||||
|
|
||||||
#ifndef wxHAS_NO_WCS_FUNCTIONS
|
#ifdef wxHAVE_TCHAR_SUPPORT
|
||||||
#ifdef wxHAVE_TCHAR_SUPPORT
|
#define wxCRT_PutsW _putws
|
||||||
#define wxCRT_PutsW _putws
|
#define wxCRT_FputsW fputws
|
||||||
#define wxCRT_FputsW fputws
|
#define wxCRT_FputcW fputwc
|
||||||
#define wxCRT_FputcW fputwc
|
#endif
|
||||||
#endif
|
#ifdef HAVE_FPUTWS
|
||||||
#ifdef HAVE_FPUTWS
|
#define wxCRT_FputsW fputws
|
||||||
#define wxCRT_FputsW fputws
|
#endif
|
||||||
#endif
|
#ifdef HAVE_PUTWS
|
||||||
#ifdef HAVE_PUTWS
|
#define wxCRT_PutsW putws
|
||||||
#define wxCRT_PutsW putws
|
#endif
|
||||||
#endif
|
#ifdef HAVE_FPUTWC
|
||||||
#ifdef HAVE_FPUTWC
|
#define wxCRT_FputcW fputwc
|
||||||
#define wxCRT_FputcW fputwc
|
#endif
|
||||||
#endif
|
#define wxCRT_FgetsW fgetws
|
||||||
#define wxCRT_FgetsW fgetws
|
|
||||||
#endif // !wxHAS_NO_WCS_FUNCTIONS
|
|
||||||
|
|
||||||
#ifndef wxCRT_PutsW
|
#ifndef wxCRT_PutsW
|
||||||
WXDLLIMPEXP_BASE int wxCRT_PutsW(const wchar_t *ws);
|
WXDLLIMPEXP_BASE int wxCRT_PutsW(const wchar_t *ws);
|
||||||
@@ -601,66 +580,41 @@ WXDLLIMPEXP_BASE size_t wxCRT_StrftimeW(wchar_t *s, size_t max,
|
|||||||
ctype.h
|
ctype.h
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifdef wxHAS_NO_WCS_FUNCTIONS
|
|
||||||
#define wxNEED_WX_CTYPE_H
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __WATCOMC__
|
#ifdef __WATCOMC__
|
||||||
#define WXWCHAR_T_CAST(c) (wint_t)(c)
|
#define WXWCHAR_T_CAST(c) (wint_t)(c)
|
||||||
#else
|
#else
|
||||||
#define WXWCHAR_T_CAST(c) c
|
#define WXWCHAR_T_CAST(c) c
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef wxNEED_WX_CTYPE_H
|
#define wxCRT_IsalnumW(c) iswalnum(WXWCHAR_T_CAST(c))
|
||||||
|
#define wxCRT_IsalphaW(c) iswalpha(WXWCHAR_T_CAST(c))
|
||||||
|
#define wxCRT_IscntrlW(c) iswcntrl(WXWCHAR_T_CAST(c))
|
||||||
|
#define wxCRT_IsdigitW(c) iswdigit(WXWCHAR_T_CAST(c))
|
||||||
|
#define wxCRT_IsgraphW(c) iswgraph(WXWCHAR_T_CAST(c))
|
||||||
|
#define wxCRT_IslowerW(c) iswlower(WXWCHAR_T_CAST(c))
|
||||||
|
#define wxCRT_IsprintW(c) iswprint(WXWCHAR_T_CAST(c))
|
||||||
|
#define wxCRT_IspunctW(c) iswpunct(WXWCHAR_T_CAST(c))
|
||||||
|
#define wxCRT_IsspaceW(c) iswspace(WXWCHAR_T_CAST(c))
|
||||||
|
#define wxCRT_IsupperW(c) iswupper(WXWCHAR_T_CAST(c))
|
||||||
|
#define wxCRT_IsxdigitW(c) iswxdigit(WXWCHAR_T_CAST(c))
|
||||||
|
|
||||||
/* RN: Used only under OSX <= 10.2 currently */
|
#ifdef __GLIBC__
|
||||||
WXDLLIMPEXP_BASE int wxCRT_IsalnumW(wchar_t ch);
|
#if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
|
||||||
WXDLLIMPEXP_BASE int wxCRT_IsalphaW(wchar_t ch);
|
/* /usr/include/wctype.h incorrectly declares translations */
|
||||||
WXDLLIMPEXP_BASE int wxCRT_IscntrlW(wchar_t ch);
|
/* tables which provokes tons of compile-time warnings -- try */
|
||||||
WXDLLIMPEXP_BASE int wxCRT_IsdigitW(wchar_t ch);
|
/* to correct this */
|
||||||
WXDLLIMPEXP_BASE int wxCRT_IsgraphW(wchar_t ch);
|
#define wxCRT_TolowerW(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
|
||||||
WXDLLIMPEXP_BASE int wxCRT_IslowerW(wchar_t ch);
|
#define wxCRT_ToupperW(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
|
||||||
WXDLLIMPEXP_BASE int wxCRT_IsprintW(wchar_t ch);
|
#else /* !glibc 2.0 */
|
||||||
WXDLLIMPEXP_BASE int wxCRT_IspunctW(wchar_t ch);
|
#define wxCRT_TolowerW towlower
|
||||||
WXDLLIMPEXP_BASE int wxCRT_IsspaceW(wchar_t ch);
|
#define wxCRT_ToupperW towupper
|
||||||
WXDLLIMPEXP_BASE int wxCRT_IsupperW(wchar_t ch);
|
#endif
|
||||||
WXDLLIMPEXP_BASE int wxCRT_IsxdigitW(wchar_t ch);
|
#else // !__GLIBC__
|
||||||
/* extern "C" because needed by regex code */
|
/* There is a bug in VC6 C RTL: toxxx() functions dosn't do anything
|
||||||
WXDLLIMPEXP_BASE extern "C" int wxCRT_TolowerW(wchar_t ch);
|
with signed chars < 0, so "fix" it here. */
|
||||||
WXDLLIMPEXP_BASE extern "C" int wxCRT_ToupperW(wchar_t ch);
|
#define wxCRT_TolowerW(c) towlower((wxUChar)(wxChar)(c))
|
||||||
|
#define wxCRT_ToupperW(c) towupper((wxUChar)(wxChar)(c))
|
||||||
#else // !defined(wxNEED_WX_CTYPE_H)
|
#endif // __GLIBC__/!__GLIBC__
|
||||||
|
|
||||||
#define wxCRT_IsalnumW(c) iswalnum(WXWCHAR_T_CAST(c))
|
|
||||||
#define wxCRT_IsalphaW(c) iswalpha(WXWCHAR_T_CAST(c))
|
|
||||||
#define wxCRT_IscntrlW(c) iswcntrl(WXWCHAR_T_CAST(c))
|
|
||||||
#define wxCRT_IsdigitW(c) iswdigit(WXWCHAR_T_CAST(c))
|
|
||||||
#define wxCRT_IsgraphW(c) iswgraph(WXWCHAR_T_CAST(c))
|
|
||||||
#define wxCRT_IslowerW(c) iswlower(WXWCHAR_T_CAST(c))
|
|
||||||
#define wxCRT_IsprintW(c) iswprint(WXWCHAR_T_CAST(c))
|
|
||||||
#define wxCRT_IspunctW(c) iswpunct(WXWCHAR_T_CAST(c))
|
|
||||||
#define wxCRT_IsspaceW(c) iswspace(WXWCHAR_T_CAST(c))
|
|
||||||
#define wxCRT_IsupperW(c) iswupper(WXWCHAR_T_CAST(c))
|
|
||||||
#define wxCRT_IsxdigitW(c) iswxdigit(WXWCHAR_T_CAST(c))
|
|
||||||
|
|
||||||
#ifdef __GLIBC__
|
|
||||||
#if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
|
|
||||||
/* /usr/include/wctype.h incorrectly declares translations */
|
|
||||||
/* tables which provokes tons of compile-time warnings -- try */
|
|
||||||
/* to correct this */
|
|
||||||
#define wxCRT_TolowerW(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
|
|
||||||
#define wxCRT_ToupperW(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
|
|
||||||
#else /* !glibc 2.0 */
|
|
||||||
#define wxCRT_TolowerW towlower
|
|
||||||
#define wxCRT_ToupperW towupper
|
|
||||||
#endif
|
|
||||||
#else // !__GLIBC__
|
|
||||||
/* There is a bug in VC6 C RTL: toxxx() functions dosn't do anything
|
|
||||||
with signed chars < 0, so "fix" it here. */
|
|
||||||
#define wxCRT_TolowerW(c) towlower((wxUChar)(wxChar)(c))
|
|
||||||
#define wxCRT_ToupperW(c) towupper((wxUChar)(wxChar)(c))
|
|
||||||
#endif // __GLIBC__/!__GLIBC__
|
|
||||||
#endif // !defined(wxNEED_WX_CTYPE_H)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -43,13 +43,6 @@
|
|||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__WIN32__) && defined(wxNEED_WX_CTYPE_H)
|
|
||||||
#include <windef.h>
|
|
||||||
#include <winbase.h>
|
|
||||||
#include <winnls.h>
|
|
||||||
#include <winnt.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __WXWINCE__
|
#ifdef __WXWINCE__
|
||||||
// there is no errno.h under CE apparently
|
// there is no errno.h under CE apparently
|
||||||
#define wxSET_ERRNO(value)
|
#define wxSET_ERRNO(value)
|
||||||
@@ -933,29 +926,6 @@ int wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argpt
|
|||||||
// ctype.h stuff (currently unused)
|
// ctype.h stuff (currently unused)
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__WIN32__) && defined(wxNEED_WX_CTYPE_H)
|
|
||||||
static inline WORD wxMSW_ctype(wchar_t ch)
|
|
||||||
{
|
|
||||||
WORD ret;
|
|
||||||
GetStringTypeEx(LOCALE_USER_DEFAULT, CT_CTYPE1, &ch, 1, &ret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxCRT_IsalnumW(wchar_t ch) { return IsCharAlphaNumeric(ch); }
|
|
||||||
int wxCRT_IsalphaW(wchar_t ch) { return IsCharAlpha(ch); }
|
|
||||||
int wxCRT_IscntrlW(wchar_t ch) { return wxMSW_ctype(ch) & C1_CNTRL; }
|
|
||||||
int wxCRT_IsdigitW(wchar_t ch) { return wxMSW_ctype(ch) & C1_DIGIT; }
|
|
||||||
int wxCRT_IsgraphW(wchar_t ch) { return wxMSW_ctype(ch) & (C1_DIGIT|C1_PUNCT|C1_ALPHA); }
|
|
||||||
int wxCRT_IslowerW(wchar_t ch) { return IsCharLower(ch); }
|
|
||||||
int wxCRT_IsprintW(wchar_t ch) { return wxMSW_ctype(ch) & (C1_DIGIT|C1_SPACE|C1_PUNCT|C1_ALPHA); }
|
|
||||||
int wxCRT_IspunctW(wchar_t ch) { return wxMSW_ctype(ch) & C1_PUNCT; }
|
|
||||||
int wxCRT_IsspaceW(wchar_t ch) { return wxMSW_ctype(ch) & C1_SPACE; }
|
|
||||||
int wxCRT_IsupperW(wchar_t ch) { return IsCharUpper(ch); }
|
|
||||||
int wxCRT_IsxdigitW(wchar_t ch) { return wxMSW_ctype(ch) & C1_XDIGIT; }
|
|
||||||
int wxCRT_Tolower(wchar_t ch) { return (wchar_t)CharLower((LPTSTR)(ch)); }
|
|
||||||
int wxCRT_Toupper(wchar_t ch) { return (wchar_t)CharUpper((LPTSTR)(ch)); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef wxNEED_WX_MBSTOWCS
|
#ifdef wxNEED_WX_MBSTOWCS
|
||||||
|
|
||||||
WXDLLEXPORT size_t wxMbstowcs (wchar_t * out, const char * in, size_t outlen)
|
WXDLLEXPORT size_t wxMbstowcs (wchar_t * out, const char * in, size_t outlen)
|
||||||
@@ -1004,39 +974,6 @@ WXDLLEXPORT size_t wxWcstombs (char * out, const wchar_t * in, size_t outlen)
|
|||||||
|
|
||||||
#endif // wxNEED_WX_MBSTOWCS
|
#endif // wxNEED_WX_MBSTOWCS
|
||||||
|
|
||||||
#if defined(wxNEED_WX_CTYPE_H)
|
|
||||||
|
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
|
||||||
|
|
||||||
#define cfalnumset CFCharacterSetGetPredefined(kCFCharacterSetAlphaNumeric)
|
|
||||||
#define cfalphaset CFCharacterSetGetPredefined(kCFCharacterSetLetter)
|
|
||||||
#define cfcntrlset CFCharacterSetGetPredefined(kCFCharacterSetControl)
|
|
||||||
#define cfdigitset CFCharacterSetGetPredefined(kCFCharacterSetDecimalDigit)
|
|
||||||
//CFCharacterSetRef cfgraphset = kCFCharacterSetControl && !' '
|
|
||||||
#define cflowerset CFCharacterSetGetPredefined(kCFCharacterSetLowercaseLetter)
|
|
||||||
//CFCharacterSetRef cfprintset = !kCFCharacterSetControl
|
|
||||||
#define cfpunctset CFCharacterSetGetPredefined(kCFCharacterSetPunctuation)
|
|
||||||
#define cfspaceset CFCharacterSetGetPredefined(kCFCharacterSetWhitespaceAndNewline)
|
|
||||||
#define cfupperset CFCharacterSetGetPredefined(kCFCharacterSetUppercaseLetter)
|
|
||||||
|
|
||||||
int wxCRT_IsalnumW(wchar_t ch) { return CFCharacterSetIsCharacterMember(cfalnumset, ch); }
|
|
||||||
int wxCRT_IsalphaW(wchar_t ch) { return CFCharacterSetIsCharacterMember(cfalphaset, ch); }
|
|
||||||
int wxCRT_IscntrlW(wchar_t ch) { return CFCharacterSetIsCharacterMember(cfcntrlset, ch); }
|
|
||||||
int wxCRT_IsdigitW(wchar_t ch) { return CFCharacterSetIsCharacterMember(cfdigitset, ch); }
|
|
||||||
int wxCRT_IsgraphW(wchar_t ch) { return !CFCharacterSetIsCharacterMember(cfcntrlset, ch) && ch != ' '; }
|
|
||||||
int wxCRT_IslowerW(wchar_t ch) { return CFCharacterSetIsCharacterMember(cflowerset, ch); }
|
|
||||||
int wxCRT_IsprintW(wchar_t ch) { return !CFCharacterSetIsCharacterMember(cfcntrlset, ch); }
|
|
||||||
int wxCRT_IspunctW(wchar_t ch) { return CFCharacterSetIsCharacterMember(cfpunctset, ch); }
|
|
||||||
int wxCRT_IsspaceW(wchar_t ch) { return CFCharacterSetIsCharacterMember(cfspaceset, ch); }
|
|
||||||
int wxCRT_IsupperW(wchar_t ch) { return CFCharacterSetIsCharacterMember(cfupperset, ch); }
|
|
||||||
int wxCRT_IsxdigitW(wchar_t ch) { return wxCRT_IsdigitW(ch) || (ch>='a' && ch<='f') || (ch>='A' && ch<='F'); }
|
|
||||||
|
|
||||||
// FIXME: these are broken!
|
|
||||||
extern "C" int wxCRT_TolowerW(wchar_t ch) { return (wchar_t)tolower((char)(ch)); }
|
|
||||||
extern "C" int wxCRT_ToupperW(wchar_t ch) { return (wchar_t)toupper((char)(ch)); }
|
|
||||||
|
|
||||||
#endif // wxNEED_WX_CTYPE_H
|
|
||||||
|
|
||||||
#ifndef wxCRT_StrdupA
|
#ifndef wxCRT_StrdupA
|
||||||
WXDLLEXPORT char *wxCRT_StrdupA(const char *s)
|
WXDLLEXPORT char *wxCRT_StrdupA(const char *s)
|
||||||
{
|
{
|
||||||
@@ -1110,51 +1047,10 @@ int WXDLLEXPORT wxCRT_StrnicmpW(const wchar_t *s1, const wchar_t *s2, size_t n)
|
|||||||
// string.h functions
|
// string.h functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifndef wxCRT_StrcatW
|
// this (and wxCRT_StrncmpW below) are extern "C" because they are needed
|
||||||
WXDLLEXPORT wchar_t *wxCRT_StrcatW(wchar_t *dest, const wchar_t *src)
|
// by regex code, the rest isn't needed, so it's not declared as extern "C"
|
||||||
{
|
#ifndef wxCRT_StrlenW
|
||||||
wchar_t *ret = dest;
|
extern "C" WXDLLEXPORT size_t wxCRT_StrlenW(const wchar_t *s)
|
||||||
while (*dest) dest++;
|
|
||||||
while ((*dest++ = *src++));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef wxCRT_StrchrW
|
|
||||||
WXDLLEXPORT const wchar_t *wxCRT_StrchrW(const wchar_t *s, wchar_t c)
|
|
||||||
{
|
|
||||||
// be careful here as the terminating NUL makes part of the string
|
|
||||||
while ( *s != c )
|
|
||||||
{
|
|
||||||
if ( !*s++ )
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef wxCRT_StrcmpW
|
|
||||||
WXDLLEXPORT int wxCRT_StrcmpW(const wchar_t *s1, const wchar_t *s2)
|
|
||||||
{
|
|
||||||
while ((*s1 == *s2) && *s1) s1++, s2++;
|
|
||||||
if ((wxUChar)*s1 < (wxUChar)*s2) return -1;
|
|
||||||
if ((wxUChar)*s1 > (wxUChar)*s2) return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef wxCRT_StrcpyW
|
|
||||||
WXDLLEXPORT wchar_t * wxCRT_StrcpyW(wchar_t *dest, const wchar_t *src)
|
|
||||||
{
|
|
||||||
wchar_t *ret = dest;
|
|
||||||
while ((*dest++ = *src++));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
static inline size_t wxCRT_DoStrlen(const T *s)
|
|
||||||
{
|
{
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
while ( *s++ )
|
while ( *s++ )
|
||||||
@@ -1162,175 +1058,11 @@ static inline size_t wxCRT_DoStrlen(const T *s)
|
|||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
// these two (and wxCRT_StrncmpW below) are extern "C" because they are needed
|
|
||||||
// by regex code, the rest isn't needed, so it's not declared as extern "C"
|
|
||||||
#ifndef wxCRT_StrlenA
|
|
||||||
WXDLLEXPORT size_t wxCRT_StrlenA(const char *s)
|
|
||||||
{ return wxCRT_DoStrlen(s); }
|
|
||||||
#endif
|
|
||||||
#ifndef wxCRT_StrlenW
|
|
||||||
extern "C" WXDLLEXPORT size_t wxCRT_StrlenW(const wchar_t *s)
|
|
||||||
{ return wxCRT_DoStrlen(s); }
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef wxCRT_StrncatW
|
// ----------------------------------------------------------------------------
|
||||||
WXDLLEXPORT wchar_t * wxCRT_StrncatW(wchar_t *dest, const wchar_t *src, size_t n)
|
// stdlib.h functions
|
||||||
{
|
// ----------------------------------------------------------------------------
|
||||||
wchar_t *ret = dest;
|
|
||||||
while (*dest) dest++;
|
|
||||||
while (n && (*dest++ = *src++)) n--;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef wxCRT_StrncmpW
|
|
||||||
extern "C"
|
|
||||||
WXDLLEXPORT int wxCRT_StrncmpW(const wchar_t *s1, const wchar_t *s2, size_t n)
|
|
||||||
{
|
|
||||||
while (n && (*s1 == *s2) && *s1) n--, s1++, s2++;
|
|
||||||
if (n) {
|
|
||||||
if ((wxUChar)*s1 < (wxUChar)*s2) return -1;
|
|
||||||
if ((wxUChar)*s1 > (wxUChar)*s2) return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef wxCRT_StrncpyW
|
|
||||||
WXDLLEXPORT wchar_t * wxCRT_StrncpyW(wchar_t *dest, const wchar_t *src, size_t n)
|
|
||||||
{
|
|
||||||
wchar_t *ret = dest;
|
|
||||||
while (n && (*dest++ = *src++)) n--;
|
|
||||||
while (n) *dest++=0, n--; // the docs specify padding with zeroes
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef wxCRT_StrpbrkW
|
|
||||||
WXDLLEXPORT const wchar_t * wxCRT_StrpbrkW(const wchar_t *s, const wchar_t *accept)
|
|
||||||
{
|
|
||||||
while (*s && !wxCRT_Strchr(accept, *s))
|
|
||||||
s++;
|
|
||||||
|
|
||||||
return *s ? s : NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef wxCRT_StrrchrW
|
|
||||||
WXDLLEXPORT const wchar_t * wxCRT_StrrchrW(const wchar_t *s, wchar_t c)
|
|
||||||
{
|
|
||||||
const wchar_t *ret = NULL;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if ( *s == c )
|
|
||||||
ret = s;
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
while ( *s );
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef wxCRT_StrspnW
|
|
||||||
WXDLLEXPORT size_t wxCRT_StrspnW(const wchar_t *s, const wchar_t *accept)
|
|
||||||
{
|
|
||||||
size_t len = 0;
|
|
||||||
while (wxCRT_Strchr(accept, *s++)) len++;
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef wxCRT_StrstrW
|
|
||||||
WXDLLEXPORT const wchar_t *wxCRT_StrstrW(const wchar_t *haystack, const wchar_t *needle)
|
|
||||||
{
|
|
||||||
wxASSERT_MSG( needle != NULL, _T("NULL argument in wxCRT_Strstr") );
|
|
||||||
|
|
||||||
// VZ: this is not exactly the most efficient string search algorithm...
|
|
||||||
|
|
||||||
const size_t len = wxStrlen(needle);
|
|
||||||
|
|
||||||
while ( const wchar_t *fnd = wxCRT_Strchr(haystack, *needle) )
|
|
||||||
{
|
|
||||||
if ( !wxCRT_Strncmp(fnd, needle, len) )
|
|
||||||
return fnd;
|
|
||||||
|
|
||||||
haystack = fnd + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef wxCRT_StrtodW
|
|
||||||
WXDLLEXPORT double wxCRT_StrtodW(const wchar_t *nptr, wchar_t **endptr)
|
|
||||||
{
|
|
||||||
const wchar_t *start = nptr;
|
|
||||||
|
|
||||||
// FIXME: only correct for C locale
|
|
||||||
while (wxIsspace(*nptr)) nptr++;
|
|
||||||
if (*nptr == wxT('+') || *nptr == wxT('-')) nptr++;
|
|
||||||
while (wxIsdigit(*nptr)) nptr++;
|
|
||||||
if (*nptr == wxT('.')) {
|
|
||||||
nptr++;
|
|
||||||
while (wxIsdigit(*nptr)) nptr++;
|
|
||||||
}
|
|
||||||
if (*nptr == wxT('E') || *nptr == wxT('e')) {
|
|
||||||
nptr++;
|
|
||||||
if (*nptr == wxT('+') || *nptr == wxT('-')) nptr++;
|
|
||||||
while (wxIsdigit(*nptr)) nptr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString data(nptr, nptr-start);
|
|
||||||
wxWX2MBbuf dat = data.mb_str(wxConvLibc);
|
|
||||||
char *rdat = wxMBSTRINGCAST dat;
|
|
||||||
double ret = strtod(dat, &rdat);
|
|
||||||
|
|
||||||
if (endptr) *endptr = (wchar_t *)(start + (rdat - (const char *)dat));
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif // !wxCRT_StrtodW
|
|
||||||
|
|
||||||
#ifndef wxCRT_StrtolW
|
|
||||||
WXDLLEXPORT long int wxCRT_StrtolW(const wchar_t *nptr, wchar_t **endptr, int base)
|
|
||||||
{
|
|
||||||
const wchar_t *start = nptr;
|
|
||||||
|
|
||||||
// FIXME: only correct for C locale
|
|
||||||
while (wxIsspace(*nptr)) nptr++;
|
|
||||||
if (*nptr == wxT('+') || *nptr == wxT('-')) nptr++;
|
|
||||||
if (((base == 0) || (base == 16)) &&
|
|
||||||
(nptr[0] == wxT('0') && nptr[1] == wxT('x'))) {
|
|
||||||
nptr += 2;
|
|
||||||
base = 16;
|
|
||||||
}
|
|
||||||
else if ((base == 0) && (nptr[0] == wxT('0'))) base = 8;
|
|
||||||
else if (base == 0) base = 10;
|
|
||||||
|
|
||||||
while ((wxIsdigit(*nptr) && (*nptr - wxT('0') < base)) ||
|
|
||||||
(wxIsalpha(*nptr) && (wxToupper(*nptr) - wxT('A') + 10 < base))) nptr++;
|
|
||||||
|
|
||||||
wxString data(start, nptr-start);
|
|
||||||
wxWX2MBbuf dat = data.mb_str(wxConvLibc);
|
|
||||||
char *rdat = wxMBSTRINGCAST dat;
|
|
||||||
long int ret = strtol(dat, &rdat, base);
|
|
||||||
|
|
||||||
if (endptr) *endptr = (wchar_t *)(start + (rdat - (const char *)dat));
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif // !wxCRT_StrtolW
|
|
||||||
|
|
||||||
#ifndef wxCRT_StrtoulW
|
|
||||||
WXDLLEXPORT unsigned long int wxCRT_StrtoulW(const wchar_t *nptr, wchar_t **endptr, int base)
|
|
||||||
{
|
|
||||||
return (unsigned long int) wxCRT_StrtolW(nptr, endptr, base);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef wxCRT_GetenvW
|
#ifndef wxCRT_GetenvW
|
||||||
wchar_t* WXDLLEXPORT wxCRT_GetenvW(const wchar_t *name)
|
wchar_t* WXDLLEXPORT wxCRT_GetenvW(const wchar_t *name)
|
||||||
|
Reference in New Issue
Block a user