Accessing non-groups as if they were a group leads to accessing the element itself and not an error
Let's say you have the following configuration file
a = 0
Now if you try to access a.v
for example, you end up being returned a pointer to a
not an error that a.v
can't be found. This is unexpected behavior and should be fixed.
This error is pretty well understood. In the skvconfig_find_element
function we call strtok
to split the string by periods. This means, in the first run a.v
becomes a
. Then in the loop, when finding the element a
we break and afterwards just check whether the current iteration (a
) matches what the current element has (which is also a
).
The fix is relatively simple: Compare the current value against the end of the query string. This wouldn't help in edge cases such as a.a.a.a
as in that case it always matches. However, in such a case it would always return a group, which is also not okay. The best fix for that is to keep track of the depth and only if the depth is zero we accept the found result. This also means we don't have to write a replacement for strtok
which is good.
However this leads to a dilemma: Should we allow groups and values of the same name? For now I think it's good to just implement a fix and keep the current behavior, which is no, groups and values of the same name aren't allowed.