Skip to content

Commit

Permalink
do not fail parsing when finding an attribute w/ a name but no value …
Browse files Browse the repository at this point in the history
…in misc/info file
  • Loading branch information
nam20485 committed Oct 30, 2023
1 parent 46e0196 commit 8632831
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions OdbDesignLib/FileModel/Design/MiscInfoFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "../../Constants.h"
#include "timestamp.h"
#include "Logger.h"
#include "../parse_error.h"

using namespace std::chrono;

Expand All @@ -26,9 +27,12 @@ namespace Odb::Lib::FileModel::Design
infoFile.open(infoFilePath, std::ios::in);
if (!infoFile.is_open()) return false;

int lineNumber = 0;
std::string line;
while (std::getline(infoFile, line))
{
lineNumber++;

// trim whitespace from beginning and end of line
Utils::str_trim(line);
if (!line.empty())
Expand All @@ -45,7 +49,12 @@ namespace Odb::Lib::FileModel::Design
std::string value;

if (! std::getline(lineStream, attribute, '=')) return false;
if (! std::getline(lineStream, value)) return false;
// attribute value may be blank?

if (!std::getline(lineStream, value))
{
logwarn("misc/info file: no value for attribute: " + attribute);
}

Utils::str_trim(attribute);
Utils::str_trim(value);
Expand Down Expand Up @@ -127,7 +136,11 @@ namespace Odb::Lib::FileModel::Design
}
else
{
return false;
// unknown attribute
parse_error pe(m_path, line, attribute, lineNumber, __LINE__, __FILE__);
logwarn(pe.buildMessage("unrecognized line in misc/info file:"));

//return false;
}
}
}
Expand Down

0 comments on commit 8632831

Please sign in to comment.