[Libreoffice-commits] core.git: desktop/win32

Mike Kaganski mike.kaganski at collabora.com
Fri Sep 15 04:19:43 UTC 2017


 desktop/win32/source/applauncher/launcher.cxx |   52 +++++++++++---------------
 desktop/win32/source/applauncher/launcher.hxx |   18 ---------
 desktop/win32/source/applauncher/sbase.cxx    |    2 -
 desktop/win32/source/applauncher/scalc.cxx    |    2 -
 desktop/win32/source/applauncher/sdraw.cxx    |    2 -
 desktop/win32/source/applauncher/simpress.cxx |    2 -
 desktop/win32/source/applauncher/smath.cxx    |    2 -
 desktop/win32/source/applauncher/sweb.cxx     |    2 -
 desktop/win32/source/applauncher/swriter.cxx  |    2 -
 9 files changed, 30 insertions(+), 54 deletions(-)

New commits:
commit 4830592796cdc42ca1f111840b5cc31a220b50d7
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Thu Sep 14 19:32:30 2017 +0300

    applauncher: don't use 8-bit string functions
    
    Change-Id: I44e9641fb800a7a0203b689b035adbe27c4efee1
    Reviewed-on: https://gerrit.libreoffice.org/42301
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/desktop/win32/source/applauncher/launcher.cxx b/desktop/win32/source/applauncher/launcher.cxx
index beb05f56d90a..d3114aa2d804 100644
--- a/desktop/win32/source/applauncher/launcher.cxx
+++ b/desktop/win32/source/applauncher/launcher.cxx
@@ -19,50 +19,42 @@
 
 #include "launcher.hxx"
 
-#include <shellapi.h>
-
 #include <stdlib.h>
 #include <malloc.h>
 
-extern "C" int APIENTRY _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
+extern "C" int APIENTRY wWinMain( HINSTANCE, HINSTANCE, LPWSTR, int )
 {
     // Retrieve startup info
 
-    STARTUPINFO aStartupInfo;
+    STARTUPINFOW aStartupInfo;
 
     ZeroMemory( &aStartupInfo, sizeof(aStartupInfo) );
     aStartupInfo.cb = sizeof( aStartupInfo );
-    GetStartupInfo( &aStartupInfo );
+    GetStartupInfoW( &aStartupInfo );
 
     // Retrieve command line
 
-    LPTSTR  lpCommandLine = GetCommandLine();
-
-    {
-        lpCommandLine = static_cast<LPTSTR>(_alloca( sizeof(_TCHAR) * (_tcslen(lpCommandLine) + _tcslen(APPLICATION_SWITCH) + 2) ));
-
-        _tcscpy( lpCommandLine, GetCommandLine() );
-        _tcscat( lpCommandLine, _T(" ") );
-        _tcscat( lpCommandLine, APPLICATION_SWITCH );
-    }
+    LPWSTR lpCommandLine = static_cast<LPWSTR>(_alloca( sizeof(WCHAR) * (wcslen(GetCommandLineW()) + wcslen(APPLICATION_SWITCH) + 2) ));
 
+    wcscpy( lpCommandLine, GetCommandLineW() );
+    wcscat( lpCommandLine, L" " );
+    wcscat( lpCommandLine, APPLICATION_SWITCH );
 
     // Calculate application name
 
-    TCHAR   szApplicationName[MAX_PATH];
-    TCHAR   szDrive[MAX_PATH];
-    TCHAR   szDir[MAX_PATH];
-    TCHAR   szFileName[MAX_PATH];
-    TCHAR   szExt[MAX_PATH];
-
-    GetModuleFileName( nullptr, szApplicationName, MAX_PATH );
-    _tsplitpath( szApplicationName, szDrive, szDir, szFileName, szExt );
-    _tmakepath( szApplicationName, szDrive, szDir, _T("soffice"), _T(".exe") );
+    WCHAR szApplicationName[MAX_PATH];
+    WCHAR szDrive[MAX_PATH];
+    WCHAR szDir[MAX_PATH];
+    WCHAR szFileName[MAX_PATH];
+    WCHAR szExt[MAX_PATH];
 
+    GetModuleFileNameW( nullptr, szApplicationName, MAX_PATH );
+    _wsplitpath( szApplicationName, szDrive, szDir, szFileName, szExt );
+    _wmakepath( szApplicationName, szDrive, szDir, L"soffice", L".exe" );
 
     PROCESS_INFORMATION aProcessInfo;
 
-    BOOL    fSuccess = CreateProcess(
+    BOOL fSuccess = CreateProcessW(
         szApplicationName,
         lpCommandLine,
         nullptr,
@@ -87,28 +79,28 @@ extern "C" int APIENTRY _tWinMain( HINSTANCE, HINSTANCE, LPTSTR, int )
         return 0;
     }
 
-    DWORD   dwError = GetLastError();
+    DWORD dwError = GetLastError();
 
-    LPVOID lpMsgBuf;
+    LPWSTR lpMsgBuf;
 
-    FormatMessage(
+    FormatMessageW(
         FORMAT_MESSAGE_ALLOCATE_BUFFER |
         FORMAT_MESSAGE_FROM_SYSTEM,
         nullptr,
         dwError,
         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
-        reinterpret_cast<LPTSTR>(&lpMsgBuf),
+        reinterpret_cast<LPWSTR>(&lpMsgBuf),
         0,
         nullptr
     );
 
     // Display the string.
-    MessageBox( nullptr, static_cast<LPCTSTR>(lpMsgBuf), nullptr, MB_OK | MB_ICONERROR );
+    MessageBoxW( nullptr, lpMsgBuf, nullptr, MB_OK | MB_ICONERROR );
 
     // Free the buffer.
     LocalFree( lpMsgBuf );
 
-    return GetLastError();
+    return dwError;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/win32/source/applauncher/launcher.hxx b/desktop/win32/source/applauncher/launcher.hxx
index bfc5e588455c..fdd651042481 100644
--- a/desktop/win32/source/applauncher/launcher.hxx
+++ b/desktop/win32/source/applauncher/launcher.hxx
@@ -20,23 +20,7 @@
 #pragma once
 
 #include <windows.h>
-#include <winbase.h>
-#include <windef.h>
-#include <shlwapi.h>
 
-#ifndef _INC_TCHAR
-#   ifdef UNICODE
-#       define _UNICODE
-#   endif
-#   include <tchar.h>
-#endif
-
-#ifdef UNICODE
-#   define GetArgv( pArgc )         CommandLineToArgvW( GetCommandLine(), pArgc )
-#else
-#   define GetArgv( pArgc )         (*pArgc = __argc, __argv)
-#endif
-
-extern _TCHAR APPLICATION_SWITCH[];
+extern WCHAR APPLICATION_SWITCH[];
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/win32/source/applauncher/sbase.cxx b/desktop/win32/source/applauncher/sbase.cxx
index e6123a66b14f..a8e832a5b1b2 100644
--- a/desktop/win32/source/applauncher/sbase.cxx
+++ b/desktop/win32/source/applauncher/sbase.cxx
@@ -19,6 +19,6 @@
 
 #include "launcher.hxx"
 
-_TCHAR APPLICATION_SWITCH[] = _T( "--base" );
+WCHAR APPLICATION_SWITCH[] = L"--base";
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/win32/source/applauncher/scalc.cxx b/desktop/win32/source/applauncher/scalc.cxx
index 4d1112437bf2..27df4211931d 100644
--- a/desktop/win32/source/applauncher/scalc.cxx
+++ b/desktop/win32/source/applauncher/scalc.cxx
@@ -19,6 +19,6 @@
 
 #include "launcher.hxx"
 
-_TCHAR APPLICATION_SWITCH[] = _T( "--calc" );
+WCHAR APPLICATION_SWITCH[] = L"--calc";
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/win32/source/applauncher/sdraw.cxx b/desktop/win32/source/applauncher/sdraw.cxx
index 57112523f698..3cfb7e425c6a 100644
--- a/desktop/win32/source/applauncher/sdraw.cxx
+++ b/desktop/win32/source/applauncher/sdraw.cxx
@@ -19,6 +19,6 @@
 
 #include "launcher.hxx"
 
-_TCHAR APPLICATION_SWITCH[] = _T( "--draw" );
+WCHAR APPLICATION_SWITCH[] = L"--draw";
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/win32/source/applauncher/simpress.cxx b/desktop/win32/source/applauncher/simpress.cxx
index 53a0dccdc0cd..c3b73bf408e2 100644
--- a/desktop/win32/source/applauncher/simpress.cxx
+++ b/desktop/win32/source/applauncher/simpress.cxx
@@ -19,6 +19,6 @@
 
 #include "launcher.hxx"
 
-_TCHAR APPLICATION_SWITCH[] = _T( "--impress" );
+WCHAR APPLICATION_SWITCH[] = L"--impress";
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/win32/source/applauncher/smath.cxx b/desktop/win32/source/applauncher/smath.cxx
index e71c84ba4fe5..ae441b2e4f4d 100644
--- a/desktop/win32/source/applauncher/smath.cxx
+++ b/desktop/win32/source/applauncher/smath.cxx
@@ -19,6 +19,6 @@
 
 #include "launcher.hxx"
 
-_TCHAR APPLICATION_SWITCH[] = _T( "--math" );
+WCHAR APPLICATION_SWITCH[] = L"--math";
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/win32/source/applauncher/sweb.cxx b/desktop/win32/source/applauncher/sweb.cxx
index 3824ece6f2ae..69aeda135e66 100644
--- a/desktop/win32/source/applauncher/sweb.cxx
+++ b/desktop/win32/source/applauncher/sweb.cxx
@@ -19,6 +19,6 @@
 
 #include "launcher.hxx"
 
-_TCHAR APPLICATION_SWITCH[] = _T( "--web" );
+WCHAR APPLICATION_SWITCH[] = L"--web";
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/desktop/win32/source/applauncher/swriter.cxx b/desktop/win32/source/applauncher/swriter.cxx
index 013ce9ec10ae..fc470d3ac102 100644
--- a/desktop/win32/source/applauncher/swriter.cxx
+++ b/desktop/win32/source/applauncher/swriter.cxx
@@ -19,6 +19,6 @@
 
 #include "launcher.hxx"
 
-_TCHAR APPLICATION_SWITCH[] = _T( "--writer" );
+WCHAR APPLICATION_SWITCH[] = L"--writer";
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list