Use o3tl::{get,set}Environment instead of resp. osl_* functions

Simplifies the code, and avoids OUString internals access.
Also replace some getenv calls.

Change-Id: I5f7dc492fe87ea1fbaad6a61bc54e21f0f0c5aef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187974
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2025-07-17 07:03:19 +02:00
parent bddeb8996a
commit 3a4961af43
29 changed files with 83 additions and 117 deletions
+2 -3
View File
@@ -39,6 +39,7 @@
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/factory.hxx>
#include <o3tl/environment.hxx>
#include <o3tl/safeint.hxx>
#include <osl/file.hxx>
#include <osl/module.hxx>
@@ -1827,9 +1828,7 @@ void cppuhelper::ServiceManager::preloadImplementations() {
OUStringBuffer aMissingMsg;
/// Allow external callers & testers to disable certain components
if (OUString aDisable;
osl_getEnvironment(u"UNODISABLELIBRARY"_ustr.pData, &aDisable.pData) == osl_Process_E_None
&& !aDisable.isEmpty())
if (OUString aDisable = o3tl::getEnvironment(u"UNODISABLELIBRARY"_ustr); !aDisable.isEmpty())
{
for (sal_Int32 i = 0; i >= 0; )
{
+3 -3
View File
@@ -34,6 +34,7 @@
#include <com/sun/star/registry/XRegistryKey.hpp>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/shlib.hxx>
#include <o3tl/environment.hxx>
#include <o3tl/string_view.hxx>
#include <osl/module.hxx>
#include <osl/process.h>
@@ -52,9 +53,8 @@ css::uno::Environment cppuhelper::detail::getEnvironment(
{
OUString n(name);
if (!implementation.empty()) {
OUString imps;
if (osl_getEnvironment(u"UNO_ENV_LOG"_ustr.pData, &imps.pData) == osl_Process_E_None
&& !imps.isEmpty()) {
OUString imps = o3tl::getEnvironment(u"UNO_ENV_LOG"_ustr);
if (!imps.isEmpty()) {
for (sal_Int32 i = 0; i != -1;) {
std::u16string_view imp(o3tl::getToken(imps, 0, ';', i));
if (implementation == imp)