marzer / tomlplusplus

Header-only TOML config file parser and serializer for C++17.
https://marzer.github.io/tomlplusplus/
MIT License
1.58k stars 152 forks source link

Fix typo in at_path #173

Closed ismagilli closed 2 years ago

ismagilli commented 2 years ago

What does this change do? Using a static code analyzer, a suspicious place was discovered:

if (c == ']')
{
    pos++;
    break;
}
else if TOML_UNLIKELY(c == '.' || c == '[')
//                    ^^^^^^^^
    break;
else if (c == '\t' || c == '.')
//                    ^^^^^^^^
    pos++;
else
    return false;

Obviously, a mistake was made in one of the places. It is easy to see that in the second case, whitespace characters are checked, so there should be a space (' ') instead of a dot ('.'). This PR fixing bug, adds a test.

Is it related to an exisiting bug report or feature request? No, I created a PR without creating an issue

Pre-merge checklist

marzer commented 2 years ago

Nice find, thanks!