X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b0655a87f40073577bdb8ba4378e5e683a163d44..93dfff5ae6ff29195c441e3cd3b4637656e1f76f:/src/common/wxchar.cpp diff --git a/src/common/wxchar.cpp b/src/common/wxchar.cpp index 23bc691780..ca5419f957 100644 --- a/src/common/wxchar.cpp +++ b/src/common/wxchar.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #ifndef WX_PRECOMP #include "wx/defs.h" @@ -234,6 +235,16 @@ WXDLLEXPORT wxChar * wxStrncat(wxChar *dest, const wxChar *src, size_t n) return ret; } +WXDLLEXPORT int wxStrncmp(const wxChar *s1, const wxChar *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; +} + WXDLLEXPORT wxChar * wxStrncpy(wxChar *dest, const wxChar *src, size_t n) { wxChar *ret = dest; @@ -333,6 +344,16 @@ WXDLLEXPORT long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base) #endif #ifdef wxNEED_WX_STDIO_H +WXDLLEXPORT FILE * wxFopen(const wxChar *path, const wxChar *mode) +{ + return fopen(wxConvFile.cWX2MB(path), wxConvLibc.cWX2MB(mode)); +} + +WXDLLEXPORT FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream) +{ + return freopen(wxConvFile.cWX2MB(path), wxConvLibc.cWX2MB(mode), stream); +} + int WXDLLEXPORT wxPrintf(const wxChar *fmt, ...) { va_list argptr; @@ -455,3 +476,21 @@ int WXDLLEXPORT wxSystem(const wxChar *psz) } #endif + +#ifdef wxNEED_WX_TIME_H +WXDLLEXPORT size_t wxStrftime(wxChar *s, size_t max, const wxChar *fmt, const struct tm *tm) +{ + if (!max) return 0; + char *buf = (char *)malloc(max); + size_t ret = strftime(buf, max, wxConvLibc.cWX2MB(fmt), tm); + if (ret) { + wxStrcpy(s, wxConvLibc.cMB2WX(buf)); + free(buf); + return wxStrlen(s); + } else { + free(buf); + *s = 0; + return 0; + } +} +#endif