diff options
Diffstat (limited to 'desktop/source/deployment/misc/dp_platform.cxx')
-rw-r--r-- | desktop/source/deployment/misc/dp_platform.cxx | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/desktop/source/deployment/misc/dp_platform.cxx b/desktop/source/deployment/misc/dp_platform.cxx index 79fb78c0b9ba..aeab3e567051 100644 --- a/desktop/source/deployment/misc/dp_platform.cxx +++ b/desktop/source/deployment/misc/dp_platform.cxx @@ -20,9 +20,9 @@ #include <dp_platform.hxx> #include <rtl/ustring.hxx> -#include <rtl/instance.hxx> #include <rtl/bootstrap.hxx> #include <osl/diagnose.h> +#include <o3tl/string_view.hxx> constexpr OUStringLiteral PLATFORM_ALL = u"all"; @@ -31,36 +31,39 @@ namespace dp_misc { namespace { - struct StrOperatingSystem : - public rtl::StaticWithInit<OUString, StrOperatingSystem> { - OUString operator () () { + const OUString & StrOperatingSystem() + { + static const OUString theOS = []() + { OUString os( "$_OS" ); ::rtl::Bootstrap::expandMacros( os ); return os; - } + }(); + return theOS; }; - struct StrCPU : - public rtl::StaticWithInit<OUString, StrCPU> { - OUString operator () () { + const OUString & StrCPU() + { + static const OUString theCPU = []() + { OUString arch( "$_ARCH" ); ::rtl::Bootstrap::expandMacros( arch ); return arch; - } + }(); + return theCPU; }; - struct StrPlatform : public rtl::StaticWithInit< - OUString, StrPlatform> { - OUString operator () () { - return StrOperatingSystem::get() + "_" + StrCPU::get(); - } + const OUString & StrPlatform() + { + static const OUString thePlatform = StrOperatingSystem() + "_" + StrCPU(); + return thePlatform; }; bool checkOSandCPU(std::u16string_view os, std::u16string_view cpu) { - return (os == StrOperatingSystem::get()) - && (cpu == StrCPU::get()); + return (os == StrOperatingSystem()) + && (cpu == StrCPU()); } bool isPlatformSupported( std::u16string_view token ) @@ -80,8 +83,6 @@ namespace ret = checkOSandCPU(u"Solaris", u"SPARC64"); else if (token == u"solaris_x86") ret = checkOSandCPU(u"Solaris", u"x86"); - else if (token == u"aix_powerpc") - ret = checkOSandCPU(u"AIX", u"PowerPC"); else if (token == u"macosx_aarch64") ret = checkOSandCPU(u"MacOSX", u"AARCH64"); else if (token == u"macosx_x86_64") @@ -116,8 +117,6 @@ namespace ret = checkOSandCPU(u"Linux", u"IA64"); else if (token == u"linux_m68k") ret = checkOSandCPU(u"Linux", u"M68K"); - else if (token == u"linux_s390") - ret = checkOSandCPU(u"Linux", u"S390"); else if (token == u"linux_s390x") ret = checkOSandCPU(u"Linux", u"S390x"); else if (token == u"linux_hppa") @@ -126,6 +125,10 @@ namespace ret = checkOSandCPU(u"Linux", u"ALPHA"); else if (token == u"linux_aarch64") ret = checkOSandCPU(u"Linux", u"AARCH64"); + else if (token == u"linux_riscv64") + ret = checkOSandCPU(u"Linux", u"RISCV64"); + else if (token == u"linux_loongarch64") + ret = checkOSandCPU(u"Linux", u"LOONGARCH64"); else if (token == u"freebsd_x86") ret = checkOSandCPU(u"FreeBSD", u"x86"); else if (token == u"freebsd_x86_64") @@ -164,20 +167,20 @@ namespace OUString const & getPlatformString() { - return StrPlatform::get(); + return StrPlatform(); } -bool platform_fits( OUString const & platform_string ) +bool platform_fits( std::u16string_view platform_string ) { sal_Int32 index = 0; for (;;) { - const OUString token( - platform_string.getToken( 0, ',', index ).trim() ); + const std::u16string_view token( + o3tl::trim(o3tl::getToken(platform_string, 0, ',', index )) ); // check if this platform: - if (token.equalsIgnoreAsciiCase( StrPlatform::get() ) || - (token.indexOf( '_' ) < 0 && /* check OS part only */ - token.equalsIgnoreAsciiCase( StrOperatingSystem::get() ))) + if (o3tl::equalsIgnoreAsciiCase( token, StrPlatform() ) || + (token.find( '_' ) == std::u16string_view::npos && /* check OS part only */ + o3tl::equalsIgnoreAsciiCase( token, StrOperatingSystem() ))) { return true; } |