#endif
#if defined(__MWERKS__) && __MSL__ >= 0x6000
+namespace std {}
using namespace std ;
#endif
}
else
{
- val = wxT("");
+ val = wxEmptyString;
len = 0;
}
}
#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)
{
int vswscanf(const wxChar *ws, const wxChar *format, va_list argptr)
{
- wxFAIL_MSG( _T("TODO") );
+ // 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.
- return -1;
+ 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)
WXDLLEXPORT int wxToupper(wxChar ch) { return (wxChar)CharUpper((LPTSTR)(ch)); }
#endif
-#if wxUSE_UNICODE && __DARWIN__ && ( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 )
+#if defined(__DARWIN__) && ( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 )
WXDLLEXPORT size_t wxInternalMbstowcs (wchar_t * out, const char * in, size_t outlen)
{
outsize++;
return outsize;
}
-
+
const char* origin = in;
-
+
while (outlen-- && *in)
{
*out++ = (wchar_t) *in++;
}
-
+
*out = '\0';
-
+
return in - origin;
}
outsize++;
return outsize;
}
-
+
const wchar_t* origin = in;
-
+
while (outlen-- && *in)
{
*out++ = (char) *in++;
}
-
+
*out = '\0';
-
+
return in - origin;
}
-
+
#if defined(wxNEED_WX_CTYPE_H)
#include <CoreFoundation/CoreFoundation.h>
-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); }
WXDLLEXPORT int wxIsxdigit(wxChar ch) { return wxIsdigit(ch) || (ch>='a' && ch<='f') || (ch>='A' && ch<='F'); }
WXDLLEXPORT int wxTolower(wxChar ch) { return (wxChar)tolower((char)(ch)); }
WXDLLEXPORT int wxToupper(wxChar ch) { return (wxChar)toupper((char)(ch)); }
-#endif
-#endif
+#endif // wxNEED_WX_CTYPE_H
+
+#endif // defined(__DARWIN__) and OSX <= 10.2
#ifndef wxStrdupA
}
#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;
size_t n = 0;
while ( *s++ )
n++;
-
+
return n;
}
return NULL;
}
+#ifdef __cplusplus
+}
+#endif
+
WXDLLEXPORT double wxStrtod(const wxChar *nptr, wxChar **endptr)
{
const wxChar *start = nptr;
#endif // wxNEED_WX_STDLIB_H
#ifdef wxNEED_WX_TIME_H
-WXDLLEXPORT size_t wxStrftime(wxChar *s, size_t max, const wxChar *fmt, const struct tm *tm)
+WXDLLEXPORT size_t
+wxStrftime(wxChar *s, size_t maxsize, const wxChar *fmt, const struct tm *tm)
{
- if (!max) return 0;
+ if ( !maxsize )
+ return 0;
- char *buf = (char *)malloc(max);
- size_t ret = strftime(buf, max, wxConvLocal.cWX2MB(fmt), tm);
- if (ret)
- {
- wxStrcpy(s, wxConvLocal.cMB2WX(buf));
- free(buf);
- return wxStrlen(s);
- }
- else
- {
- free(buf);
- *s = 0;
+ wxCharBuffer buf(maxsize);
+
+ wxCharBuffer bufFmt(wxConvLocal.cWX2MB(fmt));
+ if ( !bufFmt )
return 0;
- }
+
+ size_t ret = strftime(buf.data(), maxsize, bufFmt, tm);
+ if ( !ret )
+ return 0;
+
+ wxWCharBuffer wbuf = wxConvLocal.cMB2WX(buf);
+ if ( !wbuf )
+ return 0;
+
+ wxStrncpy(s, wbuf, maxsize);
+ return wxStrlen(s);
}
#endif // wxNEED_WX_TIME_H