solenv/gcc-wrappers/wrapper.cxx |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

New commits:
commit 19de52a0a66323eefd9f82f148ff1751dc6af08e
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Wed Jan 19 16:48:45 2022 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Wed Jan 19 18:35:32 2022 +0100

    Fix processing of first path in SOLARINC
    
    ...which does not have a space before the -I, so copying starting at pos+3
    dropped the leading character from the path.  This was apparently never a
    problem in practice, as the first path in SOLARINC happens to always be
    SRCDIR/include, which should not be needed anyway when building external
    projects with this GCC wrapper on Windows.
    
    (So this commit is a change in behavior, making SRCDIR/include available to
    those external project builds on Windows, but the follow-up commit
    <https://gerrit.libreoffice.org/c/core/+/128615> "Decouple SRCDIR/include 
from
    SOLARINC" will change the behavior back again.)
    
    Change-Id: I3f82a83683ed381b791d221fe1da78b9797aea94
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128621
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/solenv/gcc-wrappers/wrapper.cxx b/solenv/gcc-wrappers/wrapper.cxx
index fbf3f5378ae5..c97b57808be9 100644
--- a/solenv/gcc-wrappers/wrapper.cxx
+++ b/solenv/gcc-wrappers/wrapper.cxx
@@ -60,8 +60,11 @@ void setupccenv() {
     std::string inctmp(incbuf);
     free(incbuf);
 
-    // 3 = strlen(" -I")
+    // 2 = strlen("-I")
     for(size_t pos=0,len=0;pos<inctmp.length();) {
+        while (pos != inctmp.length() && inctmp[pos] == ' ') {
+            ++pos;
+        }
         size_t endpos=inctmp.find(" -I",pos+1);
         if(endpos==std::string::npos)
             endpos=inctmp.length();
@@ -70,9 +73,9 @@ void setupccenv() {
         while(len>0&&inctmp[pos+len-1]==' ')
             --len;
 
-        if(len>3) {
+        if(len>2) {
             includepath.append(";");
-            includepath.append(inctmp,pos+3,len-3);
+            includepath.append(inctmp,pos+2,len-2);
         }
         pos=endpos;
     }

Reply via email to