Author Topic: Bug fix for GetGCCCompilerDirs failed in Archlinux  (Read 6303 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Bug fix for GetGCCCompilerDirs failed in Archlinux
« on: April 18, 2010, 11:18:40 am »
My Linux's locale is zh_CN.UTF-8, under the system,  CB' GCC header file search will fail!
The reason is: when locale is not 'english', the: _("#include <...> search starts here:") contains some non-English charactes.

Code
Index: src/plugins/codecompletion/nativeparser.cpp

===================================================================

--- src/plugins/codecompletion/nativeparser.cpp (revision 6204)

+++ src/plugins/codecompletion/nativeparser.cpp (working copy)

@@ -453,45 +453,27 @@

     // action time  (everything shows up on the error stream
     wxArrayString Output, Errors;
     wxExecute(Command, Output, Errors, wxEXEC_NODISABLE);
-    int nCount = Errors.GetCount();
-    // the include dir (1 per line) show up between the lines
-    // #include <...> search starts here:
-    // End of search list
-    //   let's hope this does not change too quickly, otherwise we need
+
+    // start from "#include <...>", and the path followed
+    // let's hope this does not change too quickly, otherwise we need
     // to adjust our search code (for several versions ...)
-    bool bStart = false;
-    for (int idxCount = 0; idxCount < nCount; ++idxCount)
+    bool start = false;
+    for (size_t idxCount = 0; idxCount < Errors.GetCount(); ++idxCount)
     {
-        if (!bStart && Errors[idxCount] == _("#include <...> search starts here:"))
+        wxString path = Errors[idxCount].Trim(true).Trim(false);
+        if (!start)
         {
-            bStart = true;
+            if (!path.StartsWith(_T("#include <...>")))
+                continue;
+            path = Errors[++idxCount].Trim(true).Trim(false);
+            start = true;
         }
-        else if (bStart && Errors[idxCount] == _("End of search list."))
-        {
-            bStart = false; // could jump out of for loop if we want
-        }
-        else if (bStart)
-        {
-//                Manager::Get()->GetLogManager()->DebugLog("include dir " + Errors[idxCount]);
-            // get rid of the leading space (more general : any whitespace)in front
-            wxRegEx reg(_T("^[ \t]*(.*)"));
-            if (reg.Matches(Errors[idxCount]))
-            {
-                wxString out = reg.GetMatch(Errors[idxCount], 1);
-                if (!out.IsEmpty())
-                {
-                    wxFileName dir(out);
-                    if (NormalizePath(dir,base))
-                    {
-                        Manager::Get()->GetLogManager()->DebugLog(_T("Caching GCC dir: ") + dir.GetFullPath());
-                        gcc_compiler_dirs.Add(dir.GetFullPath());
-                    }
-                    else
-                        Manager::Get()->GetLogManager()->DebugLog(F(_T("Error normalizing path: '%s' from '%s'"),out.wx_str(),base.wx_str()));
 
-                }
-            }
-        }
+        if (!wxDirExists(path))
+            break;
+
+        Manager::Get()->GetLogManager()->DebugLog(_T("Caching GCC dir: ") + path);
+        gcc_compiler_dirs.Add(path);
     } // end for : idx : idxCount
 
     return gcc_compiler_dirs;

[attachment deleted by admin]