hyperrealm / libconfig

C/C++ library for processing configuration files
https://hyperrealm.github.io/libconfig/
GNU Lesser General Public License v2.1
1.1k stars 359 forks source link

Setting::exists and Setting::lookup do not agree for some path strings #220

Closed sgibbs-DSI closed 1 year ago

sgibbs-DSI commented 2 years ago

If a path to a scalar setting is expressed with .[0] at the end of the path, Setting::exists will return true, but Setting::lookup will throw SettingNotFoundException.

This appears to relate to the underlying calls:

Note: This issue does not occur with Config::exists and Config::lookup, which both use config_lookup method.

So, simple config file that contains only one key:

parameter = 100

config_setting_get_member(s, "parameter.[0]") will return the setting for "parameter" rather than NULL

hyperrealm commented 1 year ago

There were various bugs here, which are fixed in 5ff6aecbdb7f85a8e7a2ea7fd63c03b4bdd42076