diff --git a/src/ProjectManipulation/ParseFiles.cpp b/src/ProjectManipulation/ParseFiles.cpp index cfb469e..d474b85 100644 --- a/src/ProjectManipulation/ParseFiles.cpp +++ b/src/ProjectManipulation/ParseFiles.cpp @@ -387,7 +387,50 @@ static string shiftLines(const string &in, const map &m return newStr; } -static int dumpErrors(const vector& listOfProject, const vector& errors) +static void addMessage(const string& in, const map& mapOfFiles, + const FileInfo* currF, map>& messages, typeMessage type) +{ + int byNum = 0; + + auto it = in.find("on line "); + if (it != string::npos) + it += strlen("on line "); + + int line = 0; + sscanf(in.c_str() + it, "%d", &line); + + auto it1 = in.find("of", it + 1); + if (it1 == string::npos) + return; + it1 += 3; + + string fileN = in.substr(it1, in.find(':', it1) - it1); + auto itF = mapOfFiles.find(fileN); + if (itF != mapOfFiles.end() && itF->second != currF) + { + byNum = itF->second->includesAdded; + if (byNum != 0) + { + if (line - byNum <= 0) + { + //return in; + printInternalError(convertFileName(__FILE__).c_str(), __LINE__); + } + else + line -= byNum; + } + } + + const string newStr = in.substr(0, it) + std::to_string(line) + in.substr(in.find(' ', it + 1)); + + wstring messageE, messageR; + __spf_printToLongBuf(messageE, L"%s", to_wstring(newStr).c_str()); + __spf_printToLongBuf(messageR, L"%s", to_wstring(newStr).c_str()); + + messages[fileN].push_back(Messages(type, line, messageR, messageE, 6000)); +} + +static int dumpErrors(const vector& listOfProject, const vector& errors, map>& messages) { int errorsCount = 0; map mapOfFiles; @@ -420,9 +463,13 @@ static int dumpErrors(const vector& listOfProject, const vector& errors, vector& listOfProject, v return rethrow; } -int parseFiles(const char* proj, vector& filesCompilationOrder, int parseForInlining) +int parseFiles(const char* proj, vector& filesCompilationOrder, int parseForInlining, map>& messages) { FILE* list = fopen(proj, "r"); if (!list) @@ -723,7 +770,7 @@ int parseFiles(const char* proj, vector& filesCompilationOrder, int pars vector errors; int rethrow = parseFiles(errors, listOfProject, filesCompilationOrder, parseForInlining); - int errCount = dumpErrors(listOfProject, errors); + int errCount = dumpErrors(listOfProject, errors, messages); if (rethrow != 0) throw rethrow; @@ -732,6 +779,8 @@ int parseFiles(const char* proj, vector& filesCompilationOrder, int pars void parseFiles(int argc, char** argv) { + map> messages; + bool isInline = false; auto result = splitCommandLineForParse(argv, argc, isInline); if (result.second.size() == 0) diff --git a/src/ProjectManipulation/ParseFiles.h b/src/ProjectManipulation/ParseFiles.h index c9f908b..05fb68a 100644 --- a/src/ProjectManipulation/ParseFiles.h +++ b/src/ProjectManipulation/ParseFiles.h @@ -3,5 +3,5 @@ #include #include -int parseFiles(const char* proj, std::vector& filesCompilationOrder, int parseForInlining); +int parseFiles(const char* proj, std::vector& filesCompilationOrder, int parseForInlining, std::map>& messages); void parseFiles(int argc, char** argv); diff --git a/src/Sapfor.cpp b/src/Sapfor.cpp index 66d2010..c424b3c 100644 --- a/src/Sapfor.cpp +++ b/src/Sapfor.cpp @@ -2389,7 +2389,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam break; case PARSE_FILES: { - int err = parseFiles(proj_name, filesCompilationOrder, parseForInlining); + int err = parseFiles(proj_name, filesCompilationOrder, parseForInlining, SPF_messages); if (err != 0) throw err; } diff --git a/src/Utils/errors.h b/src/Utils/errors.h index 3eb0a7c..274e779 100644 --- a/src/Utils/errors.h +++ b/src/Utils/errors.h @@ -145,6 +145,9 @@ enum typeMessage { WARR, ERROR, NOTE }; // 06 "%s clause can be used only once." // 07 "Variable '%s' can't be used in FILES and EXCEPT clauses at the same time." +// 6000 PARSER GROUP +// + extern int langOfMessages; struct Messages {