Commit 60e70442 authored by GILLES Sebastien's avatar GILLES Sebastien

#1498 Use a cleaner way to handle the '<=' and '>=' cases in LuaOptionFile.

parent d6e0a7be
......@@ -296,21 +296,23 @@ namespace MoReFEM
void ExtractKeysFromFile::ComputeDelimiterPositions()
{
const auto size = content_.size();
// Using a copy to avoid ambiguities with <= and >= symbols.
auto copy = content_;
Utilities::String::Replace("<=", "LE", copy);
Utilities::String::Replace(">=", "GE", copy);
const auto size = copy.size();
bool is_last_non_space_character_close_bracket = false;
int inside_map = 0;
assert(!content_.empty());
if (content_[0] == '=')
throw Exception("Content should not begin with '='!", __FILE__, __LINE__);
for (auto i = 0ul; i < size; ++i)
{
// We want to avoid taking in the process symbols <= and >=
if (content_[i] == '=' && content_[i - 1] != '>' && content_[i - 1] != '<')
char current_char = copy[i];
// We want to avoid taking in the process symbols <= and >=
if (current_char == '=')
{
if (!is_last_non_space_character_close_bracket)
equal_position_list_.push_back(i);
......@@ -320,18 +322,18 @@ namespace MoReFEM
if (inside_map == 1)
brace_position_list_.pop_back(); // cancel the last opening brace.
}
else if (content_[i] == '{')
else if (current_char == '{')
brace_position_list_.push_back(static_cast<int>(i));
else if (content_[i] == '}')
else if (current_char == '}')
{
if (inside_map)
inside_map = 0;
else
brace_position_list_.push_back(-static_cast<int>(i));
}
if (content_[i] == ']')
if (current_char == ']')
is_last_non_space_character_close_bracket = true;
else if (content_[i] == ' ')
else if (current_char == ' ')
;
else
is_last_non_space_character_close_bracket = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment