From b9b253086f91f26c53954118f9907eb5d104ab8e Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Sun, 8 Mar 2009 18:07:46 -0700 Subject: [PATCH] Repair recently broken cfg_has_section(). --- lib/cfg.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/cfg.c b/lib/cfg.c index 6ad62021..00d355ef 100644 --- a/lib/cfg.c +++ b/lib/cfg.c @@ -47,7 +47,7 @@ /* XXX This file really needs a unit test! For a while, cfg_get_string(0, * "bridge.a.controller") would return the value of * "bridge.a.controller.in-band", if it existed, and I'm really not certain - * that the fix didn't break other things (e.g. cfg_has_section()). */ + * that the fix didn't break other things. */ /* List of configuration files. */ static struct svec cfg_files = SVEC_EMPTY_INITIALIZER; @@ -197,7 +197,7 @@ bool cfg_has_section(const char *section_, ...) { struct ds section; - bool retval; + bool retval = false; va_list args; char **p; @@ -207,8 +207,12 @@ cfg_has_section(const char *section_, ...) ds_put_char(§ion, '.'); va_end(args); - p = find_key_le(ds_cstr(§ion)); - retval = *p && !strncmp(section.string, *p, section.length); + for (p = cfg.names; *p; p++) { /* XXX this is inefficient */ + if (!strncmp(section.string, *p, section.length)) { + retval = true; + break; + } + } ds_destroy(§ion); return retval; -- 2.30.2