Include file information in input reader error messages

This commit is contained in:
Tim Wojtulewicz 2021-12-09 12:08:33 -07:00
parent 8184073ef8
commit 098a5d3348
13 changed files with 179 additions and 57 deletions

View file

@ -55,9 +55,10 @@ Ascii::Ascii(ReaderFrontend* frontend) : ReaderBackend(frontend)
fail_on_invalid_lines = false;
}
Ascii::~Ascii() { }
void Ascii::DoClose() { }
void Ascii::DoClose()
{
read_location.reset();
}
bool Ascii::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fields)
{
@ -156,6 +157,9 @@ bool Ascii::OpenFile()
return ! fail_on_file_problem;
}
read_location = std::make_unique<zeek::detail::Location>();
read_location->filename = util::copy_string(fname.c_str());
StopWarningSuppression();
return true;
}
@ -253,6 +257,12 @@ bool Ascii::GetLine(string& str)
{
while ( getline(file, str) )
{
if ( read_location )
{
read_location->first_line++;
read_location->last_line++;
}
if ( ! str.size() )
continue;
@ -278,6 +288,12 @@ bool Ascii::DoUpdate()
if ( ! OpenFile() )
return ! fail_on_file_problem;
if ( read_location )
{
read_location->first_line = 0;
read_location->last_line = 0;
}
switch ( Info().mode )
{
case MODE_REREAD: