hyperrealm / libconfig

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

config_setting_lookup: documentation does not match code #173

Closed georeth closed 1 year ago

georeth commented 4 years ago

in the doc, the signature of config_setting_lookup is:

config_setting_t *config_setting_lookup(const config_setting_t *setting, const char *path)

this is problematic, since it can return its argument directly. thus, the const qualifier is removed. and i expect it does not change the config_setting_t since the argument is const.


in the code, the signature is:

config_setting_t *config_setting_lookup(config_setting_t *setting, const char *path)

I think the right way is providing both a mutable version and a const version:

const config_setting_t *config_setting_lookup_const(const config_setting_t *setting, const char *path)
config_setting_t *config_setting_lookup(config_setting_t *setting, const char *path)

In my application, i passes const config_setting_t * to do some initialization without change the config, so I want a const version.

hyperrealm commented 1 year ago

Fixed in cca09fa1115512fd7b68a170e18c20d0843e8066