X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8a9c20b016d88b85db8a1f564a2249057db0ca77..93c2f401e9955dc37df1f8dbfea7881c676b8ddb:/src/common/wxchar.cpp?ds=inline diff --git a/src/common/wxchar.cpp b/src/common/wxchar.cpp index e955415642..9db633db07 100644 --- a/src/common/wxchar.cpp +++ b/src/common/wxchar.cpp @@ -53,6 +53,7 @@ #endif #if defined(__MWERKS__) && __MSL__ >= 0x6000 +namespace std {} using namespace std ; #endif @@ -613,6 +614,22 @@ int wxFputs(const wchar_t *ws, FILE *stream) } #endif // wxNEED_FPUTS +#ifdef wxNEED_PUTS +int wxPuts(const wxChar *ws) +{ + int rc = wxFputs(ws, stdout); + if ( rc != -1 ) + { + if ( wxFputs(L"\n", stdout) == -1 ) + return -1; + + rc++; + } + + return rc; +} +#endif // wxNEED_PUTS + #ifdef wxNEED_PUTC int /* not wint_t */ wxPutc(wchar_t wc, FILE *stream) { @@ -637,9 +654,19 @@ int vwscanf(const wxChar *format, va_list argptr) int vswscanf(const wxChar *ws, const wxChar *format, va_list argptr) { - wxFAIL_MSG( _T("TODO") ); - - return -1; + // The best we can do without proper Unicode support in glibc is to + // convert the strings into MB representation and run ANSI version + // of the function. This doesn't work with %c and %s because of difference + // in size of char and wchar_t, though. + + wxCHECK_MSG( wxStrstr(format, _T("%s")) == NULL, -1, + _T("incomplete vswscanf implementation doesn't allow %s") ); + wxCHECK_MSG( wxStrstr(format, _T("%c")) == NULL, -1, + _T("incomplete vswscanf implementation doesn't allow %c") ); + + va_list argcopy; + wxVaCopy(argcopy, argptr); + return vsscanf(wxConvLibc.cWX2MB(ws), wxConvLibc.cWX2MB(format), argcopy); } int vfwscanf(FILE *stream, const wxChar *format, va_list argptr) @@ -1093,16 +1120,16 @@ WXDLLEXPORT size_t wxInternalWcstombs (char * out, const wchar_t * in, size_t ou #include -CFCharacterSetRef cfalnumset = CFCharacterSetGetPredefined(kCFCharacterSetAlphaNumeric); -CFCharacterSetRef cfalphaset = CFCharacterSetGetPredefined(kCFCharacterSetLetter); -CFCharacterSetRef cfcntrlset = CFCharacterSetGetPredefined(kCFCharacterSetControl); -CFCharacterSetRef cfdigitset = CFCharacterSetGetPredefined(kCFCharacterSetDecimalDigit); +#define cfalnumset CFCharacterSetGetPredefined(kCFCharacterSetAlphaNumeric) +#define cfalphaset CFCharacterSetGetPredefined(kCFCharacterSetLetter) +#define cfcntrlset CFCharacterSetGetPredefined(kCFCharacterSetControl) +#define cfdigitset CFCharacterSetGetPredefined(kCFCharacterSetDecimalDigit) //CFCharacterSetRef cfgraphset = kCFCharacterSetControl && !' ' -CFCharacterSetRef cflowerset = CFCharacterSetGetPredefined(kCFCharacterSetLowercaseLetter); +#define cflowerset CFCharacterSetGetPredefined(kCFCharacterSetLowercaseLetter) //CFCharacterSetRef cfprintset = !kCFCharacterSetControl -CFCharacterSetRef cfpunctset = CFCharacterSetGetPredefined(kCFCharacterSetPunctuation); -CFCharacterSetRef cfspaceset = CFCharacterSetGetPredefined(kCFCharacterSetWhitespaceAndNewline); -CFCharacterSetRef cfupperset = CFCharacterSetGetPredefined(kCFCharacterSetUppercaseLetter); +#define cfpunctset CFCharacterSetGetPredefined(kCFCharacterSetPunctuation) +#define cfspaceset CFCharacterSetGetPredefined(kCFCharacterSetWhitespaceAndNewline) +#define cfupperset CFCharacterSetGetPredefined(kCFCharacterSetUppercaseLetter) WXDLLEXPORT int wxIsalnum(wxChar ch) { return CFCharacterSetIsCharacterMember(cfalnumset, ch); } WXDLLEXPORT int wxIsalpha(wxChar ch) { return CFCharacterSetIsCharacterMember(cfalphaset, ch); } @@ -1178,11 +1205,28 @@ WXDLLEXPORT wxWCharBuffer wxSetlocale(int category, const wxChar *locale) } #endif +#if wxUSE_WCHAR_T && !defined(HAVE_WCSLEN) +WXDLLEXPORT size_t wxWcslen(const wchar_t *s) +{ + size_t n = 0; + while ( *s++ ) + n++; + + return n; +} +#endif + // ---------------------------------------------------------------------------- // string.h functions // ---------------------------------------------------------------------------- #ifdef wxNEED_WX_STRING_H + +// RN: These need to be c externed for the regex lib +#ifdef __cplusplus +extern "C" { +#endif + WXDLLEXPORT wxChar * wxStrcat(wxChar *dest, const wxChar *src) { wxChar *ret = dest; @@ -1302,6 +1346,10 @@ WXDLLEXPORT const wxChar *wxStrstr(const wxChar *haystack, const wxChar *needle) return NULL; } +#ifdef __cplusplus +} +#endif + WXDLLEXPORT double wxStrtod(const wxChar *nptr, wxChar **endptr) { const wxChar *start = nptr;