desktop/source/app/updater.cxx                 |    3 ++-
 onlineupdate/Executable_mar.mk                 |    2 ++
 onlineupdate/Executable_test_updater_dialog.mk |    4 ++++
 onlineupdate/Executable_update_service.mk      |    4 ++++
 onlineupdate/Executable_updater.mk             |   10 ++++++++++
 onlineupdate/StaticLibrary_libmar.mk           |    2 ++
 onlineupdate/StaticLibrary_libmarverify.mk     |    2 ++
 onlineupdate/StaticLibrary_updatehelper.mk     |    6 ++++++
 onlineupdate/source/update/updater/updater.cxx |    2 +-
 9 files changed, 33 insertions(+), 2 deletions(-)

New commits:
commit 13595f6220095d120e13ccb6fbfac1de4c803fe7
Author:     Stephan Bergmann <[email protected]>
AuthorDate: Fri Dec 8 08:30:18 2023 +0100
Commit:     Stephan Bergmann <[email protected]>
CommitDate: Fri Dec 8 09:49:41 2023 +0100

    Fix --enable-online-update-mar on Windows
    
    The code had apparently rotten a bit,
    
    * a wchar_t vs. char16_t confusion in desktop/source/app/updater.cxx
    
    * code broken by 926e4e469d0285ee72f8da80f00370b4b3120417 "Rename online 
updater
      functions and strcmp relpath" in
      onlineupdate/source/update/updater/updater.cxx
    
    * -DUNICODE missing in some places (so that plain Windows functions resolve 
to
      the ...W variant), which had been set centrally in the past IIRC
    
    * silencing some warnings like "C4267: 'initializing': conversion from 
'size_t'
      to 'int', possible loss of data" (where silencing is the right thing to 
do for
      effectively extern code); no sure why those apparently didn't hit in the 
past,
      maybe it is all warnings that compilers only started to emit in recent 
years,
      or only for recent -std:c++... modes
    
    * silencing some "Conversion from string literal loses const qualifier" 
errors
      with -Zc:strictStrings-; these hit at least with recent VS 2022 Preview 
and
      --with-latest-c++, where -Zc:strictStrings is apparently now on by default
    
    Change-Id: I7fe46f5aa2b42fc9c03f24f7f0236512b4d3b936
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160451
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <[email protected]>

diff --git a/desktop/source/app/updater.cxx b/desktop/source/app/updater.cxx
index 0cd95da8d4e7..bdd232be8560 100644
--- a/desktop/source/app/updater.cxx
+++ b/desktop/source/app/updater.cxx
@@ -28,6 +28,7 @@
 #include <rtl/ustring.hxx>
 #include <unotools/tempfile.hxx>
 #include <unotools/configmgr.hxx>
+#include <o3tl/char16_t2wchar_t.hxx>
 #include <osl/file.hxx>
 #include <rtl/process.h>
 #include <sal/log.hxx>
@@ -316,7 +317,7 @@ bool update()
         SAL_WARN("desktop.updater", "Updater executable path: " << 
aUpdaterPath);
         for (size_t i = 0; i < 8 + rtl_getAppCommandArgCount(); ++i)
         {
-            SAL_WARN("desktop.updater", pArgs[i]);
+            SAL_WARN("desktop.updater", OUString(o3tl::toU(pArgs[i])));
         }
         bSuccess = false;
     }
diff --git a/onlineupdate/Executable_mar.mk b/onlineupdate/Executable_mar.mk
index 5352f4ac2761..45a182323873 100644
--- a/onlineupdate/Executable_mar.mk
+++ b/onlineupdate/Executable_mar.mk
@@ -46,4 +46,6 @@ $(eval $(call gb_Executable_add_cobjects,mar,\
        onlineupdate/source/libmar/tool/mar \
 ))
 
+$(eval $(call gb_Executable_set_warnings_not_errors,mar))
+
 # vim:set shiftwidth=4 tabstop=4 noexpandtab: */
diff --git a/onlineupdate/Executable_test_updater_dialog.mk 
b/onlineupdate/Executable_test_updater_dialog.mk
index a2988d0079d6..1f95c21e20d1 100644
--- a/onlineupdate/Executable_test_updater_dialog.mk
+++ b/onlineupdate/Executable_test_updater_dialog.mk
@@ -60,4 +60,8 @@ $(eval $(call 
gb_Executable_add_exception_objects,test_updater_dialog,\
        onlineupdate/workben/test_dialog \
 ))
 
+ifeq ($(OS),WNT)
+$(eval $(call gb_Executable_add_defs,test_updater_dialog,-DUNICODE))
+endif
+
 # vim:set shiftwidth=4 tabstop=4 noexpandtab: */
diff --git a/onlineupdate/Executable_update_service.mk 
b/onlineupdate/Executable_update_service.mk
index edd02f6ecf96..2cbea4a63d71 100644
--- a/onlineupdate/Executable_update_service.mk
+++ b/onlineupdate/Executable_update_service.mk
@@ -55,4 +55,8 @@ $(eval $(call 
gb_Executable_add_exception_objects,update_service,\
        onlineupdate/source/service/workmonitor \
 ))
 
+$(eval $(call gb_Executable_add_cxxflags,update_service,-Zc:strictStrings-))
+
+$(eval $(call gb_Executable_add_defs,update_service,-DUNICODE))
+
 # vim:set shiftwidth=4 tabstop=4 noexpandtab: */
diff --git a/onlineupdate/Executable_updater.mk 
b/onlineupdate/Executable_updater.mk
index ab15a94e4c60..03df54a83e03 100644
--- a/onlineupdate/Executable_updater.mk
+++ b/onlineupdate/Executable_updater.mk
@@ -82,4 +82,14 @@ $(eval $(call gb_Executable_add_exception_objects,updater,\
                onlineupdate/source/update/updater/win_dirent )\
 ))
 
+$(eval $(call gb_Executable_set_warnings_not_errors,updater))
+
+ifeq ($(OS),WNT)
+
+$(eval $(call gb_Executable_add_cxxflags,updater,-Zc:strictStrings-))
+
+$(eval $(call gb_Executable_add_defs,updater,-DUNICODE))
+
+endif
+
 # vim:set shiftwidth=4 tabstop=4 noexpandtab: */
diff --git a/onlineupdate/StaticLibrary_libmar.mk 
b/onlineupdate/StaticLibrary_libmar.mk
index 9b82e726a21d..37303d71e3b0 100644
--- a/onlineupdate/StaticLibrary_libmar.mk
+++ b/onlineupdate/StaticLibrary_libmar.mk
@@ -24,4 +24,6 @@ $(eval $(call gb_StaticLibrary_use_static_libraries,\
        libmarverify \
 ))
 
+$(eval $(call gb_StaticLibrary_set_warnings_not_errors,libmar))
+
 # vim:set shiftwidth=4 tabstop=4 noexpandtab: */
diff --git a/onlineupdate/StaticLibrary_libmarverify.mk 
b/onlineupdate/StaticLibrary_libmarverify.mk
index 41ac492a7b63..62e13b686a33 100644
--- a/onlineupdate/StaticLibrary_libmarverify.mk
+++ b/onlineupdate/StaticLibrary_libmarverify.mk
@@ -29,4 +29,6 @@ $(eval $(call gb_StaticLibrary_add_cobjects,libmarverify,\
        onlineupdate/source/libmar/verify/cryptox \
 ))
 
+$(eval $(call gb_StaticLibrary_set_warnings_not_errors,libmarverify))
+
 # vim:set shiftwidth=4 tabstop=4 noexpandtab: */
diff --git a/onlineupdate/StaticLibrary_updatehelper.mk 
b/onlineupdate/StaticLibrary_updatehelper.mk
index 1c3654cbc864..f040017ec9e3 100644
--- a/onlineupdate/StaticLibrary_updatehelper.mk
+++ b/onlineupdate/StaticLibrary_updatehelper.mk
@@ -28,4 +28,10 @@ $(eval $(call 
gb_StaticLibrary_add_exception_objects,updatehelper,\
        onlineupdate/source/update/common/updatelogging \
 ))
 
+$(eval $(call gb_StaticLibrary_set_warnings_not_errors,updatehelper))
+
+ifeq ($(OS),WNT)
+$(eval $(call gb_StaticLibrary_add_cxxflags,updatehelper,-Zc:strictStrings-))
+endif
+
 # vim:set shiftwidth=4 tabstop=4 noexpandtab: */
diff --git a/onlineupdate/source/update/updater/updater.cxx 
b/onlineupdate/source/update/updater/updater.cxx
index 467f0b67cd1f..321d43a53936 100644
--- a/onlineupdate/source/update/updater/updater.cxx
+++ b/onlineupdate/source/update/updater/updater.cxx
@@ -386,7 +386,7 @@ get_relative_offset(const NS_tchar *abs_path)
     size_t len = NS_tstrlen(prefix);
     if (NS_tstrlen(abs_path) <= len)
         return abs_path;
-    if (0 != strncmp(abs_path, prefix, len))
+    if (0 != NS_tstrncmp(abs_path, prefix, len))
         return abs_path;
     return abs_path + len + 1;
 }

Reply via email to