Skip to content

Commit

Permalink
toml: Fixed error in table array comments.
Browse files Browse the repository at this point in the history
Fixes #3474
The problem was, that when having comments associated to
table array declarations in a TOML file, the table element root key (eg.
tablearray/#0), which normally is not emitted in the keyset, has to be added to it.
This caused trouble in the building of the file tree for writing.
Fixed the table array index loop, to handle the element root key
appropriatly.
  • Loading branch information
bauhaus93 committed Sep 2, 2020
1 parent 66cbf47 commit ee9b9cd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/plugins/toml/node.c
Expand Up @@ -74,6 +74,16 @@ static Node * buildTreeTableArray (Node * parent, Key * root, KeySet * keys)
for (size_t i = 0; i <= max; i++)
{
Key * elementName = keyAppendIndex (i, root);

// Check if, we have got the array element root in the keyset
// This happens, if comments are associated to the table array declaration in a TOML file.
// If we have, use this key as root instead.and forward to the next key in the keyset
if (keyCmp (ksCurrent (keys), elementName) == 0)
{
keyDel (elementName);
elementName = ksCurrent (keys);
ksNext (keys);
}
Node * element = buildTree (node, elementName, keys);
if (!addChild (node, element))
{
Expand Down

0 comments on commit ee9b9cd

Please sign in to comment.