[Libreoffice-commits] core.git: setup_native/source

skswales stuart.swales.croftnuisk at gmail.com
Tue May 24 20:27:46 UTC 2016


 setup_native/source/win32/customactions/tools/checkversion.cxx |   31 +++++-----
 setup_native/source/win32/customactions/tools/seterror.cxx     |   23 +++----
 2 files changed, 28 insertions(+), 26 deletions(-)

New commits:
commit 163dcad72e03e214d842e74d1f71ed025cbdd870
Author: skswales <stuart.swales.croftnuisk at gmail.com>
Date:   Tue May 10 17:58:20 2016 +0100

    Work towards tdf#72606
    
    EasyHack _tstring/TCHAR elimination
    
    These were already compiled UNICODE - changes for clarity and consistency
    
    Change-Id: I846063ddf37af80b3a8787b45d97215e1770c0f3
    Reviewed-on: https://gerrit.libreoffice.org/24859
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/setup_native/source/win32/customactions/tools/checkversion.cxx b/setup_native/source/win32/customactions/tools/checkversion.cxx
index 49ae455..2b7cc13 100644
--- a/setup_native/source/win32/customactions/tools/checkversion.cxx
+++ b/setup_native/source/win32/customactions/tools/checkversion.cxx
@@ -18,6 +18,7 @@
  */
 
 #define UNICODE
+#define _UNICODE
 
 #ifdef _MSC_VER
 #pragma warning(push,1) // disable warnings within system headers
@@ -31,21 +32,21 @@
 #include <string.h>
 #include <malloc.h>
 #include <stdio.h>
-#include "strsafe.h"
+#include <strsafe.h>
 
-#include <seterror.hxx>
+#include "seterror.hxx"
 
 
-BOOL GetMsiProp( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
+BOOL GetMsiPropW( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
 {
     DWORD sz = 0;
-       if ( MsiGetProperty( hMSI, pPropName, const_cast<wchar_t *>(L""), &sz ) == ERROR_MORE_DATA )
+       if ( MsiGetPropertyW( hMSI, pPropName, const_cast<wchar_t *>(L""), &sz ) == ERROR_MORE_DATA )
        {
            sz++;
            DWORD nbytes = sz * sizeof( wchar_t );
            wchar_t* buff = reinterpret_cast<wchar_t*>( malloc( nbytes ) );
            ZeroMemory( buff, nbytes );
-           MsiGetProperty( hMSI, pPropName, buff, &sz );
+           MsiGetPropertyW( hMSI, pPropName, buff, &sz );
            *ppValue = buff;
 
         return TRUE;
@@ -56,18 +57,18 @@ BOOL GetMsiProp( MSIHANDLE hMSI, const wchar_t* pPropName, wchar_t** ppValue )
 
 
 #ifdef DEBUG
-inline void OutputDebugStringFormat( LPCTSTR pFormat, ... )
+inline void OutputDebugStringFormatW( PCWSTR pFormat, ... )
 {
-    TCHAR    buffer[1024];
+    WCHAR    buffer[1024];
     va_list  args;
 
     va_start( args, pFormat );
-    StringCchVPrintf( buffer, sizeof(buffer), pFormat, args );
-    OutputDebugString( buffer );
+    StringCchVPrintfW( buffer, sizeof(buffer)/sizeof(buffer[0]), pFormat, args );
+    OutputDebugStringW( buffer );
     va_end(args);
 }
 #else
-static inline void OutputDebugStringFormat( LPCTSTR, ... )
+static inline void OutputDebugStringFormatW( PCWSTR, ... )
 {
 }
 #endif
@@ -75,21 +76,21 @@ static inline void OutputDebugStringFormat( LPCTSTR, ... )
 
 extern "C" UINT __stdcall CheckVersions( MSIHANDLE hMSI )
 {
-    // MessageBox(NULL, L"CheckVersions", L"Information", MB_OK | MB_ICONINFORMATION);
+    // MessageBoxW(NULL, L"CheckVersions", L"Information", MB_OK | MB_ICONINFORMATION);
 
     wchar_t* pVal = NULL;
 
-    if ( GetMsiProp( hMSI, L"NEWPRODUCTS", &pVal ) && pVal )
+    if ( GetMsiPropW( hMSI, L"NEWPRODUCTS", &pVal ) && pVal )
     {
-        OutputDebugStringFormat( TEXT("DEBUG: NEWPRODUCTS found [%s]"), pVal );
+        OutputDebugStringFormatW( L"DEBUG: NEWPRODUCTS found [%s]", pVal );
         if ( *pVal != 0 )
             SetMsiErrorCode( MSI_ERROR_NEW_VERSION_FOUND );
         free( pVal );
     }
     pVal = NULL;
-    if ( GetMsiProp( hMSI, L"OLDPRODUCTS", &pVal ) && pVal )
+    if ( GetMsiPropW( hMSI, L"OLDPRODUCTS", &pVal ) && pVal )
     {
-        OutputDebugStringFormat( TEXT("DEBUG: OLDPRODUCTS found [%s]"), pVal );
+        OutputDebugStringFormatW( L"DEBUG: OLDPRODUCTS found [%s]", pVal );
         if ( *pVal != 0 )
             SetMsiErrorCode( MSI_ERROR_OLD_VERSION_FOUND );
         free( pVal );
diff --git a/setup_native/source/win32/customactions/tools/seterror.cxx b/setup_native/source/win32/customactions/tools/seterror.cxx
index a9af467..aeb2ff5 100644
--- a/setup_native/source/win32/customactions/tools/seterror.cxx
+++ b/setup_native/source/win32/customactions/tools/seterror.cxx
@@ -18,6 +18,7 @@
  */
 
 #define UNICODE
+#define _UNICODE
 
 #ifdef _MSC_VER
 #pragma warning(push,1) // disable warnings within system headers
@@ -30,24 +31,24 @@
 #include <string.h>
 #include <malloc.h>
 #include <stdio.h>
-#include "strsafe.h"
+#include <strsafe.h>
 
-#include <seterror.hxx>
+#include "seterror.hxx"
 
 
 #ifdef DEBUG
-inline void OutputDebugStringFormat( LPCTSTR pFormat, ... )
+inline void OutputDebugStringFormatW( PCWSTR pFormat, ... )
 {
-    TCHAR    buffer[1024];
+    WCHAR    buffer[1024];
     va_list  args;
 
     va_start( args, pFormat );
-    StringCchVPrintf( buffer, sizeof(buffer), pFormat, args );
-    OutputDebugString( buffer );
+    StringCchVPrintfW( buffer, sizeof(buffer)/sizeof(buffer[0]), pFormat, args );
+    OutputDebugStringW( buffer );
     va_end(args);
 }
 #else
-static inline void OutputDebugStringFormat( LPCTSTR, ... )
+static inline void OutputDebugStringFormatW( PCWSTR, ... )
 {
 }
 #endif
@@ -55,19 +56,19 @@ static inline void OutputDebugStringFormat( LPCTSTR, ... )
 
 void SetMsiErrorCode( int nErrorCode )
 {
-    const TCHAR sMemMapName[] = TEXT( "Global\\MsiErrorObject" );
+    const WCHAR sMemMapName[] = L"Global\\MsiErrorObject";
 
     HANDLE hMapFile;
     int *pBuf;
 
-    hMapFile = OpenFileMapping(
+    hMapFile = OpenFileMappingW(
                     FILE_MAP_ALL_ACCESS,    // read/write access
                     FALSE,                  // do not inherit the name
                     sMemMapName );          // name of mapping object
 
     if ( hMapFile == NULL )                 // can not set error code
     {
-        OutputDebugStringFormat( TEXT("Could not open map file (%d).\n"), GetLastError() );
+        OutputDebugStringFormatW( L"Could not open map file (%d).\n", GetLastError() );
         return;
     }
 
@@ -82,7 +83,7 @@ void SetMsiErrorCode( int nErrorCode )
         UnmapViewOfFile( pBuf );
     }
     else
-        OutputDebugStringFormat( TEXT("Could not map view of file (%d).\n"), GetLastError() );
+        OutputDebugStringFormatW( L"Could not map view of file (%d).\n", GetLastError() );
 
     CloseHandle( hMapFile );
 }


More information about the Libreoffice-commits mailing list