sal/rtl/bootstrap.cxx |   46 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 36 insertions(+), 10 deletions(-)

New commits:
commit 2ad97afee0b71f9f2fa304bcbcf6850f626c716c
Author:     shlok3640 <[email protected]>
AuthorDate: Wed Dec 31 16:55:01 2025 +0000
Commit:     Stephan Bergmann <[email protected]>
CommitDate: Thu Jan 22 08:17:58 2026 +0100

    tdf#49602: Implement manual parsing of .ini files in bootstrap.cxx
    
    Replaced legacy osl::profile with manual parser using osl::file. The
    code now reads .ini file line by line to find section and keys. Added
    SAL_WARN to alert if a profile file fails to open. Also, section headers
    are matched by looking at the content between brackets.
    
    Change-Id: I67ede84cde5911cd35d3944de1cebeef03f82ee0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196192
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <[email protected]>

diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx
index e926ad9b8365..56005632192f 100644
--- a/sal/rtl/bootstrap.cxx
+++ b/sal/rtl/bootstrap.cxx
@@ -24,7 +24,6 @@
 #include <osl/process.h>
 #include <osl/file.hxx>
 #include <osl/mutex.hxx>
-#include <osl/profile.hxx>
 #include <osl/security.hxx>
 #include <rtl/string.hxx>
 #include <rtl/ustrbuf.hxx>
@@ -982,15 +981,42 @@ OUString expandMacros(
                 }
                 else
                 {
-                    buf.append(
-                        OStringToOUString(
-                            osl::Profile(seg[0]).readString(
-                                OUStringToOString(
-                                    seg[1], RTL_TEXTENCODING_UTF8),
-                                OUStringToOString(
-                                    seg[2], RTL_TEXTENCODING_UTF8),
-                                OString()),
-                            RTL_TEXTENCODING_UTF8));
+                    osl::File aFile(seg[0]);
+                    if (aFile.open(osl_File_OpenFlag_Read) != 
osl::FileBase::E_None)
+                    {
+                        SAL_WARN("vcl", "failed to open profile: " << seg[0]);
+                    }
+                    rtl::ByteSequence seq;
+                    bool bInSection = false;
+                    while (aFile.readLine(seq) == osl::FileBase::E_None)
+                    {
+                        OString line(reinterpret_cast<const 
char*>(seq.getConstArray()),
+                                     seq.getLength());
+                        std::string_view trimmed = o3tl::trim(line);
+                        if (trimmed.size() >= 2 && trimmed.front() == '[' && 
trimmed.back() == ']')
+                        {
+                            OUString sCurrent = OStringToOUString(
+                                trimmed.substr(1, trimmed.size() - 2), 
RTL_TEXTENCODING_UTF8);
+                            bInSection = (sCurrent == seg[1]);
+                            continue;
+                        }
+                        if (bInSection)
+                        {
+                            sal_Int32 nIndex = line.indexOf('=');
+                            if (nIndex >= 1)
+                            {
+                                OUString sKey = OStringToOUString(
+                                    o3tl::trim(line.subView(0, nIndex)), 
RTL_TEXTENCODING_ASCII_US);
+                                if (sKey == seg[2])
+                                {
+                                    buf.append(
+                                        
OStringToOUString(o3tl::trim(line.subView(nIndex + 1)),
+                                                          
RTL_TEXTENCODING_UTF8));
+                                    break;
+                                }
+                            }
+                        }
+                    }
                 }
             }
             else
  • core.git: sal/rtl Stephan Bergmann (via logerrit)
    • core.git: sal/rtl shlok3640 (via logerrit)

Reply via email to