X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/66fbdb15a49c82e631b3ed122409bed9c67c82c6..00421206821da3373ddc075d63149826b3be38af:/src/common/wxchar.cpp?ds=sidebyside diff --git a/src/common/wxchar.cpp b/src/common/wxchar.cpp index a8cde061fb..f985d439d1 100644 --- a/src/common/wxchar.cpp +++ b/src/common/wxchar.cpp @@ -39,9 +39,14 @@ #include "wx/hash.h" #endif +#if wxUSE_WCHAR_T size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n) { if (buf) { + if (!n || !*psz) { + if (n) *buf = _T('\0'); + return 0; + } return mbstowcs(buf, psz, n); } @@ -60,6 +65,11 @@ size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n) size_t wxWC2MB(char *buf, const wchar_t *pwz, size_t n) { if (buf) { + if (!n || !*pwz) { + // glibc2.1 chokes on null input + if (n) *buf = '\0'; + return 0; + } return wcstombs(buf, pwz, n); } @@ -74,6 +84,7 @@ size_t wxWC2MB(char *buf, const wchar_t *pwz, size_t n) return wcstombs((char *) NULL, pwz, 0); #endif // GNU } +#endif #ifndef wxStrdup wxChar * WXDLLEXPORT wxStrdup(const wxChar *psz) @@ -85,6 +96,18 @@ wxChar * WXDLLEXPORT wxStrdup(const wxChar *psz) } #endif +#ifndef wxStricmp +int WXDLLEXPORT wxStricmp(const wxChar *psz1, const wxChar *psz2) +{ + register wxChar c1, c2; + do { + c1 = wxTolower(*psz1++); + c2 = wxTolower(*psz2++); + } while ( c1 && (c1 == c2) ); + return c1 - c2; +} +#endif + #ifndef wxStrtok wxChar * WXDLLEXPORT wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_ptr) {