MCPcopy Create free account
hub / github.com/NetSys/bess / FetchLine

Function FetchLine

core/debug.cc:179–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177
178//
179static std::string FetchLine(std::string filename, int lineno, int context) {
180 std::ostringstream ret;
181 std::string line;
182
183 std::ifstream f(filename);
184 if (!f) {
185 return " (file/line not available)\n";
186 }
187
188 for (int curr = 1; std::getline(f, line) && curr <= lineno + context;
189 curr++) {
190 if (std::abs(curr - lineno) <= context) {
191 ret << " " << (curr == lineno ? "->" : " ") << " " << curr << ": "
192 << line << std::endl;
193 }
194 }
195
196 return ret.str();
197}
198
199// Run an external command and return its standard output.
200static std::string RunCommand(std::string cmd) {

Callers 1

PrintCodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected