1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Use the column to point the location.

Use the received column to point the locatio of the error in the line of code included as debug information.
This commit is contained in:
Sandu Liviu Catalin 2019-06-16 03:22:53 +03:00
parent 806bb2ba9d
commit 6919e38866

View File

@ -902,11 +902,26 @@ bool Core::CompilerErrorHandlerEx(CSStr desc, CSStr src, SQInteger line, SQInteg
{
// Grab the associated line of code
String code = FetchCodeLine(src, line, true);
// Contains an arrow pointing at the exact column
String point;
// Do we have a valid column?
if (column >= 0)
{
// The `=>Code: ` is included as white space
point.resize(8, ' ');
// The line towards the arrow
point.resize(column+7, '-');
// Append the actual arrow
point.push_back('^');
// Include the new line here
point.push_back('\n');
}
// Valid line of code?
if (!code.empty())
{
// Display the error message with the code included
LogFtl("Message: %s\n[\n=>Location: %s\n=>Line: %" PRINT_SZ_FMT "\n=>Column: %" PRINT_INT_FMT "\n=>Code: %s\n]", desc, src, ++line, column, code.c_str());
LogFtl("Message: %s\n[\n=>Location: %s\n=>Line: %" PRINT_SZ_FMT "\n=>Column: %" PRINT_INT_FMT "\n=>Code: %s\n%s]",
desc, src, ++line, column, code.c_str(), point.c_str());
// We displayed the information
return true;
}