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