more cfg fixes
authorBen Pfaff <blp@nicira.com>
Thu, 5 Mar 2009 20:25:10 +0000 (12:25 -0800)
committerBen Pfaff <blp@nicira.com>
Thu, 5 Mar 2009 20:25:10 +0000 (12:25 -0800)
lib/cfg.c

index 1fba0a173a300eda67bcef67220930817960926f..6ad620215b9f2d8a14ac3969f2d26df20c8e43f5 100644 (file)
--- 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(&section));
-         *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(&section);
@@ -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) {