]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wxcrt.cpp
remove references to contrib (patch from Francesco)
[wxWidgets.git] / src / common / wxcrt.cpp
index a967694a346a659a6d675be44aa80570b174bdea..6d5c08774d341b599fa56c2c73e18dc284459e41 100644 (file)
@@ -548,8 +548,11 @@ int wxDoSnprintfUtf8(wchar_t *str, size_t size, const char *format, ...)
 
 #if wxUSE_UNICODE
 
+namespace
+{
+
 #if !wxUSE_UTF8_LOCALE_ONLY
-int wxInternalConvertStringToBuf(const wxString& s, char *out, size_t outsize)
+int ConvertStringToBuf(const wxString& s, char *out, size_t outsize)
 {
     const wxWX2WCbuf buf = s.wc_str();
 
@@ -562,17 +565,25 @@ int wxInternalConvertStringToBuf(const wxString& s, char *out, size_t outsize)
 #endif // !wxUSE_UTF8_LOCALE_ONLY
 
 #if wxUSE_UNICODE_UTF8
-int wxInternalConvertStringToBuf(const wxString& s, wchar_t *out, size_t outsize)
+int ConvertStringToBuf(const wxString& s, wchar_t *out, size_t outsize)
 {
     const wxWX2WCbuf buf(s.wc_str());
-    size_t len = wxWcslen(buf);
+    size_t len = s.length(); // same as buf length for wchar_t*
     if ( outsize > len )
+    {
         memcpy(out, buf, (len+1) * sizeof(wchar_t));
-    // else: not enough space
+    }
+    else // not enough space
+    {
+        memcpy(out, buf, (outsize-1) * sizeof(wchar_t));
+        out[outsize-1] = 0;
+    }
     return len;
 }
 #endif // wxUSE_UNICODE_UTF8
 
+} // anonymous namespace
+
 template<typename T>
 static size_t PrintfViaString(T *out, size_t outsize,
                               const wxString& format, va_list argptr)
@@ -580,18 +591,18 @@ static size_t PrintfViaString(T *out, size_t outsize,
     wxString s;
     s.PrintfV(format, argptr);
 
-    return wxInternalConvertStringToBuf(s, out, outsize);
+    return ConvertStringToBuf(s, out, outsize);
 }
 #endif // wxUSE_UNICODE
 
 int wxVsprintf(char *str, const wxString& format, va_list argptr)
 {
 #if wxUSE_UTF8_LOCALE_ONLY
-    return vsprintf(str, format.wx_str(), argptr);
+    return wxCRT_VsprintfA(str, format.wx_str(), argptr);
 #else
     #if wxUSE_UNICODE_UTF8
     if ( wxLocaleIsUtf8 )
-        return vsprintf(str, format.wx_str(), argptr);
+        return wxCRT_VsprintfA(str, format.wx_str(), argptr);
     else
     #endif
     #if wxUSE_UNICODE
@@ -861,6 +872,7 @@ wxCRT_StrftimeW(wchar_t *s, size_t maxsize, const wchar_t *fmt, const struct tm
 
 #endif // wxUSE_WCHAR_T
 
+#ifdef wxLongLong_t
 template<typename T>
 static wxULongLong_t
 wxCRT_StrtoullBase(const T* nptr, T** endptr, int base, T* sign)
@@ -1014,6 +1026,8 @@ wxULongLong_t wxCRT_StrtoullW(const wchar_t* nptr, wchar_t** endptr, int base)
     { return wxCRT_DoStrtoull(nptr, endptr, base); }
 #endif
 
+#endif // wxLongLong_t
+
 // ----------------------------------------------------------------------------
 // functions which we may need even if !wxUSE_WCHAR_T
 // ----------------------------------------------------------------------------
@@ -1092,22 +1106,6 @@ int wxCRT_RemoveW(const wchar_t *path)
 }
 #endif
 
-#ifndef wxCRT_TmpnamW
-wchar_t *wxCRT_TmpnamW(wchar_t *s)
-{
-    // tmpnam_r() returns NULL if s=NULL, do the same
-    wxCHECK_MSG( s, NULL, "wxTmpnam must be called with a buffer" );
-
-#ifndef L_tmpnam
-    #define L_tmpnam 1024
-#endif
-    wxCharBuffer buf(L_tmpnam);
-    tmpnam(buf.data());
-
-    wxConvLibc.ToWChar(s, L_tmpnam+1, buf.data());
-    return s;
-}
-#endif // !wxCRT_TmpnamW
 
 
 // ============================================================================