mirror of https://github.com/Icinga/icinga2.git
parent
0b90444dd8
commit
c286c25183
|
@ -51,6 +51,8 @@ DebugInfo icinga::DebugInfoRange(const DebugInfo& start, const DebugInfo& end)
|
|||
return result;
|
||||
}
|
||||
|
||||
#define EXTRA_LINES 2
|
||||
|
||||
void icinga::ShowCodeFragment(std::ostream& out, const DebugInfo& di)
|
||||
{
|
||||
if (di.Path.IsEmpty())
|
||||
|
@ -62,18 +64,19 @@ void icinga::ShowCodeFragment(std::ostream& out, const DebugInfo& di)
|
|||
int lineno = 1;
|
||||
char line[1024];
|
||||
|
||||
while (ifs.good() && lineno <= di.LastLine) {
|
||||
while (ifs.good() && lineno <= di.LastLine + EXTRA_LINES) {
|
||||
ifs.getline(line, sizeof(line));
|
||||
|
||||
for (int i = 0; line[i]; i++)
|
||||
if (line[i] == '\t')
|
||||
line[i] = ' ';
|
||||
|
||||
if (lineno >= di.FirstLine && lineno <= di.LastLine) {
|
||||
if (lineno >= di.FirstLine - EXTRA_LINES && lineno <= di.LastLine + EXTRA_LINES) {
|
||||
String pathInfo = di.Path + "(" + Convert::ToString(lineno) + "): ";
|
||||
out << pathInfo;
|
||||
out << line << "\n";
|
||||
|
||||
if (lineno >= di.FirstLine && lineno <= di.LastLine) {
|
||||
int start, end;
|
||||
|
||||
start = 0;
|
||||
|
@ -91,6 +94,7 @@ void icinga::ShowCodeFragment(std::ostream& out, const DebugInfo& di)
|
|||
|
||||
out << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
lineno++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue