]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/win32/compat/compat.cpp
Correct a minor build problem with wx-console.
[bacula/bacula] / bacula / src / win32 / compat / compat.cpp
index 7d6d1c4c179f94fb417977d236cc9ac424e02c8e..96c21319601df516948bf35a5e43098ab0e8d7ed 100644 (file)
@@ -935,10 +935,10 @@ win32_fputs(const char *string, FILE *stream)
       this works under nt and 98 (95 and me not tested)
    */
 
-   if (p_MultiByteToWideChar && (stream == stdout)) {
+   if (p_MultiByteToWideChar && (stream == stdout) && p_cwprintf) {
       WCHAR szBuf[MAX_PATH_UNICODE];
       UTF8_2_wchar(szBuf, string, MAX_PATH_UNICODE);
-      return _cwprintf (szBuf);
+      return p_cwprintf (szBuf);
    }
 
    return fputs(string, stream);
@@ -951,33 +951,24 @@ win32_cgets (char* buffer, int len)
       from the win32 console */
 
    /* nt and unicode conversion */
-   if ((g_platform_id == VER_PLATFORM_WIN32_NT) && p_WideCharToMultiByte) {      
+   if ((g_platform_id == VER_PLATFORM_WIN32_NT) && p_WideCharToMultiByte && p_cgetws) {      
       WCHAR szBuf[260];
       szBuf[0] = min (255, len); /* max len, must be smaller than buffer */
-      if (!_cgetws (szBuf))
-         return NULL;
-
-      if (wchar_2_UTF8(buffer, &szBuf[2], len))
+      if (p_cgetws(szBuf) && wchar_2_UTF8(buffer, &szBuf[2], len))
          return buffer;
-      else
-         return NULL;
    }
 
    /* win 9x and unicode conversion */
    if ((g_platform_id == VER_PLATFORM_WIN32_WINDOWS) && p_WideCharToMultiByte && p_MultiByteToWideChar) {
       char szBuf[260];
-      szBuf[0] = min (255, len); /* max len, must be smaller than buffer */
-      if (!_cgets (szBuf))
-         return NULL;
-
-      /* back and forth to get UTF-8 from ANSI */
-      WCHAR wszBuf[260];
-      p_MultiByteToWideChar(CP_OEMCP, 0, &szBuf[2], -1, wszBuf,260);
+      szBuf[0] = min(255, len); /* max len, must be smaller than buffer */
+      if (_cgets(szBuf)) {  
+         WCHAR wszBuf[260];
+         p_MultiByteToWideChar(CP_OEMCP, 0, &szBuf[2], -1, wszBuf,260);
 
-      if (wchar_2_UTF8(buffer, wszBuf, len))
-         return buffer;
-      else
-         return NULL;
+         if (wchar_2_UTF8(buffer, wszBuf, len))
+            return buffer;
+      }
    }
 
    /* fallback */