Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression on config_lookup() in 1.7.3 #196

Closed
yrutschle opened this issue Jun 22, 2021 · 2 comments
Closed

Regression on config_lookup() in 1.7.3 #196

yrutschle opened this issue Jun 22, 2021 · 2 comments

Comments

@yrutschle
Copy link

Hi,
I used to be able to call config_lookup on the root of a configuration (config_lookup(c,"/");). This works in 1.7.2, and older versions, but returns NULL on 1.7.3.

Here's a minimal test case:

#include <libconfig.h>

const char* filename = "test.cfg";

int main(void)
{
    config_t c;
    config_setting_t* s;

    config_init(&c);
    if (config_read_file(&c, filename) == CONFIG_FALSE) {
        if (config_error_line(&c) != 0) {
           printf( "%s:%d:%s", 
                    filename,
                    config_error_line(&c),
                    config_error_text(&c));
           return 0;
        }
        printf( "%s:%s", filename, config_error_text(&c));
        return 0;
    }

    s = config_lookup(&c, "/");
    printf("%p\n", s);
    return 0;
}

I can't see a change in the documentation: do we need to adapt the call?

@hyperrealm
Copy link
Owner

I think you were relying on a bug which was fixed in 1.7.3. "/" isn't really a valid path, and there is a dedicated method to get the root setting so this kind of usage shouldn't be necessary.

@yrutschle
Copy link
Author

a bug that's been around for a decade and is relied upon by projects is a feature :-)

Fair enough. For others who would get the same issue, the correct API is:

    s = config_root_setting(&c);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants