ide: fixed go to error didn't work with "In file included from" error message.
authorRejean Loyer <rejean.loyer@gmail.com>
Tue, 27 Mar 2012 20:34:55 +0000 (16:34 -0400)
committerRejean Loyer <rejean.loyer@gmail.com>
Tue, 27 Mar 2012 20:50:49 +0000 (16:50 -0400)
ide/src/project/Project.ec
ide/src/project/ProjectView.ec

index de3a474..6a31b3d 100644 (file)
@@ -379,6 +379,8 @@ enum GenMakefilePrintTypes { objects, cObjects, symbols, imports, sources, resou
 define WorkspaceExtension = "ews";
 define ProjectExtension = "epj";
 
+define stringInFileIncludedFrom = "In file included from ";
+
 void ReplaceSpaces(char * output, char * source)
 {
    int c, dc;
@@ -1165,7 +1167,6 @@ private:
             //printf("Peeking and GetLine...\n");
             if((result = f.Peek()) && (result = f.GetLine(line, sizeof(line)-1)))
             {
-               const char * stringInFileIncludedFrom = "In file included from ";
                char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
                if(strstr(line, compiler.makeCommand) == line && line[lenMakeCommand] == ':')
                {
index dc26819..4eb2a1a 100644 (file)
@@ -1355,9 +1355,13 @@ class ProjectView : Window
             char * bracket;
             if(colon)
             {
+               char * inFileIncludedFrom = strstr(line, stringInFileIncludedFrom);
+               char * start = inFileIncludedFrom ? line + strlen(stringInFileIncludedFrom) : line;
+               int len = (int)(colon - start);
+               len = Min(len, MAX_LOCATION-1);
                // Cut module name
-               strncpy(moduleName, line, colon - line);
-               moduleName[colon - line] = '\0';
+               strncpy(moduleName, start, len);
+               moduleName[len] = '\0';
             }
             else
                strcpy(moduleName, line);