Skip to content

Commit

Permalink
Fix shadowing issues (fixes skystrife#46) (skystrife#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
sloede authored and skystrife committed Jun 4, 2018
1 parent 05252dc commit a8158d1
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions include/cpptoml.h
Original file line number Diff line number Diff line change
Expand Up @@ -1404,11 +1404,11 @@ class table : public base
auto last_key = parts.back();
parts.pop_back();

auto table = this;
auto cur_table = this;
for (const auto& part : parts)
{
table = table->get_table(part).get();
if (!table)
cur_table = cur_table->get_table(part).get();
if (!cur_table)
{
if (!p)
return false;
Expand All @@ -1418,9 +1418,9 @@ class table : public base
}

if (!p)
return table->map_.count(last_key) != 0;
return cur_table->map_.count(last_key) != 0;

*p = table->map_.at(last_key);
*p = cur_table->map_.at(last_key);
return true;
}

Expand Down Expand Up @@ -2109,53 +2109,54 @@ class parser
std::shared_ptr<value<std::string>> ret;

auto handle_line
= [&](std::string::iterator& it, std::string::iterator& end) {
= [&](std::string::iterator& local_it,
std::string::iterator& local_end) {
if (consuming)
{
it = std::find_if_not(it, end, is_ws);
local_it = std::find_if_not(local_it, local_end, is_ws);

// whole line is whitespace
if (it == end)
if (local_it == local_end)
return;
}

consuming = false;

while (it != end)
while (local_it != local_end)
{
// handle escaped characters
if (delim == '"' && *it == '\\')
if (delim == '"' && *local_it == '\\')
{
auto check = it;
auto check = local_it;
// check if this is an actual escape sequence or a
// whitespace escaping backslash
++check;
consume_whitespace(check, end);
if (check == end)
consume_whitespace(check, local_end);
if (check == local_end)
{
consuming = true;
break;
}

ss << parse_escape_code(it, end);
ss << parse_escape_code(local_it, local_end);
continue;
}

// if we can end the string
if (std::distance(it, end) >= 3)
if (std::distance(local_it, local_end) >= 3)
{
auto check = it;
auto check = local_it;
// check for """
if (*check++ == delim && *check++ == delim
&& *check++ == delim)
{
it = check;
local_it = check;
ret = make_value<std::string>(ss.str());
break;
}
}

ss << *it++;
ss << *local_it++;
}
};

Expand Down

0 comments on commit a8158d1

Please sign in to comment.