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 <stephan.bergmann@allotropia.de>
diff --git a/desktop/source/app/updater.cxx b/desktop/source/app/updater.cxx
index 0cd95da..bdd232b 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 5352f4a..45a1823 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 a2988d0..1f95c21 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 edd02f6..2cbea4a 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 ab15a94..03df54a 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 9b82e72..37303d7 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 41ac492..62e13b6 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 1c3654cb..f040017 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 467f0b6..321d43a 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;
}