[Libreoffice-commits] core.git: sal/osl

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jan 15 19:58:17 UTC 2019


 sal/osl/unx/security.cxx |   28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

New commits:
commit 47834895ee8284b3e42c1436c1bb59c36fab5051
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Jan 15 16:13:40 2019 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Tue Jan 15 20:57:51 2019 +0100

    Use C++ OString/OUString classes here
    
    ...instead of underlying C structs
    
    Change-Id: I25f1de9a902e5d8ed459c9b1bfc8a8c855eefb2d
    Reviewed-on: https://gerrit.libreoffice.org/66394
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/sal/osl/unx/security.cxx b/sal/osl/unx/security.cxx
index 3ea5c96b7bdd..c440de1bf3e1 100644
--- a/sal/osl/unx/security.cxx
+++ b/sal/osl/unx/security.cxx
@@ -32,7 +32,7 @@
 #include "system.hxx"
 
 #include <osl/security.h>
-#include <rtl/bootstrap.h>
+#include <rtl/bootstrap.hxx>
 #include <sal/log.hxx>
 
 #include <osl/thread.h>
@@ -267,28 +267,18 @@ static bool osl_psz_getHomeDir(oslSecurity Security, sal_Char* pszDirectory, sal
 #ifdef ANDROID
 {
     sal_Bool bRet = sal_False;
-    rtl_uString *pName = 0, *pValue = 0;
+    OUString pValue;
 
-    rtl_uString_newFromAscii(&pName, "HOME");
-
-    if (rtl_bootstrap_get(pName, &pValue, NULL))
+    if (rtl::Bootstrap::get("HOME", pValue))
     {
-        rtl_String *pStrValue = 0;
-        if (pValue && pValue->length > 0)
+        auto const pStrValue = OUStringToOString(pValue, RTL_TEXTENCODING_UTF8);
+        if (!pStrValue.isEmpty())
         {
-            rtl_uString2String(&pStrValue, pValue->buffer,
-                               pValue->length, RTL_TEXTENCODING_UTF8,
-                               OUSTRING_TO_OSTRING_CVTFLAGS);
-            if (pStrValue && pStrValue->length > 0)
-            {
-                sal_Int32 nCopy = (sal_Int32)std::min<sal_uInt32>(nMax-1, pStrValue->length) ;
-                strncpy (pszDirectory, pStrValue->buffer, nCopy);
-                pszDirectory[nCopy] = '\0';
-                bRet = (std::size_t)pStrValue->length < nMax;
-            }
-            rtl_string_release(pStrValue);
+            sal_Int32 nCopy = (sal_Int32)std::min<sal_uInt32>(nMax-1, pStrValue.getLength()) ;
+            strncpy (pszDirectory, pStrValue.getStr(), nCopy);
+            pszDirectory[nCopy] = '\0';
+            bRet = (std::size_t)pStrValue.getLength() < nMax;
         }
-        rtl_uString_release(pName);
     }
     if (bRet)
         return bRet;


More information about the Libreoffice-commits mailing list