}
else
{
- val = wxT("");
+ val = wxEmptyString;
len = 0;
}
// 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);
WXDLLEXPORT int wxToupper(wxChar ch) { return (wxChar)CharUpper((LPTSTR)(ch)); }
#endif
-#if defined(__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>
size_t n = 0;
while ( *s++ )
n++;
-
+
return n;
}
#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