Use osl_getEnvironment instead of getenv
Avoids conversion to OUString; and is Unicode-safe on Windows. Change-Id: I39fc7af8822850a187efb108e5f862a9863152fa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183506 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
@@ -1038,11 +1038,11 @@ void addJavaInfosFromPath(
|
|||||||
{
|
{
|
||||||
#if !defined JVM_ONE_PATH_CHECK
|
#if !defined JVM_ONE_PATH_CHECK
|
||||||
// Get Java from PATH environment variable
|
// Get Java from PATH environment variable
|
||||||
char *szPath= getenv("PATH");
|
OUString usAllPath;
|
||||||
if(!szPath)
|
if (osl_getEnvironment(u"PATH"_ustr.pData, &usAllPath.pData) != osl_Process_E_None
|
||||||
|
|| usAllPath.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
OUString usAllPath(szPath, strlen(szPath), osl_getThreadTextEncoding());
|
|
||||||
sal_Int32 nIndex = 0;
|
sal_Int32 nIndex = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@@ -1092,10 +1092,10 @@ void addJavaInfoFromJavaHome(
|
|||||||
// variable. We set it in our build environment for build-time programs, though,
|
// variable. We set it in our build environment for build-time programs, though,
|
||||||
// so it is set when running unit tests that involve Java functionality. (Which affects
|
// so it is set when running unit tests that involve Java functionality. (Which affects
|
||||||
// at least CppunitTest_dbaccess_dialog_save, too, and not only the JunitTest ones.)
|
// at least CppunitTest_dbaccess_dialog_save, too, and not only the JunitTest ones.)
|
||||||
char *szJavaHome= getenv("JAVA_HOME");
|
OUString sHome;
|
||||||
if(szJavaHome)
|
if (osl_getEnvironment(u"JAVA_HOME"_ustr.pData, &sHome.pData) == osl_Process_E_None
|
||||||
|
&& !sHome.isEmpty())
|
||||||
{
|
{
|
||||||
OUString sHome(szJavaHome, strlen(szJavaHome), osl_getThreadTextEncoding());
|
|
||||||
OUString sHomeUrl;
|
OUString sHomeUrl;
|
||||||
if(File::getFileURLFromSystemPath(sHome, sHomeUrl) == File::E_None)
|
if(File::getFileURLFromSystemPath(sHome, sHomeUrl) == File::E_None)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user