From: Ben Pfaff Date: Thu, 5 Mar 2009 20:25:10 +0000 (-0800) Subject: more cfg fixes X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa34effe258dc4833af0082a36fc98330adcf7a2;p=openvswitch more cfg fixes --- diff --git a/lib/cfg.c b/lib/cfg.c index 1fba0a17..6ad62021 100644 --- a/lib/cfg.c +++ b/lib/cfg.c @@ -246,12 +246,12 @@ cfg_get_subsections(struct svec *svec, const char *section_, ...) va_end(args); svec_clear(svec); - for (p = find_key_le(ds_cstr(§ion)); - *p && !strncmp(section.string, *p, section.length); - p++) { - const char *ss = *p + section.length; - size_t ss_len = strcspn(ss, ".="); - svec_add_nocopy(svec, xmemdup0(ss, ss_len)); + for (p = cfg.names; *p; p++) { /* XXX this is inefficient */ + if (!strncmp(section.string, *p, section.length)) { + const char *ss = *p + section.length; + size_t ss_len = strcspn(ss, ".="); + svec_add_nocopy(svec, xmemdup0(ss, ss_len)); + } } svec_unique(svec); ds_destroy(§ion); @@ -667,8 +667,8 @@ static int compare_key(const char *a, const char *b) { for (;;) { - int ac = *a == '=' ? INT_MAX : *a; - int bc = *b == '=' ? INT_MAX : *b; + int ac = *a == '\0' || *a == '=' ? INT_MAX : *a; + int bc = *b == '\0' || *b == '=' ? INT_MAX : *b; if (ac != bc) { return ac < bc ? -1 : 1; } else if (ac == INT_MAX) {