* prof_tree.c (profile_node_iterator): Fix bug where it will loop
authorTheodore Tso <tytso@mit.edu>
Mon, 8 Mar 1999 19:45:10 +0000 (19:45 +0000)
committerTheodore Tso <tytso@mit.edu>
Mon, 8 Mar 1999 19:45:10 +0000 (19:45 +0000)
endlessly when searching an empty section.

* test_profile.c: Add code so that the "add" code will interpret
"NULL" as calling profile_add_relation with a null pointer
for the value.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11245 dc483132-0cff-0310-8789-dd5450dbe970

src/util/profile/ChangeLog
src/util/profile/prof_tree.c
src/util/profile/test_profile.c

index 835a00b592de9e7eaa7f2853932f2b2817858dce..bd0dc6199a502e5295bf889c1f4107d7825d473d 100644 (file)
@@ -1,3 +1,12 @@
+Mon Mar  8 14:38:24 1999  Theodore Y. Ts'o  <tytso@mit.edu>
+
+       * prof_tree.c (profile_node_iterator): Fix bug where it will loop
+               endlessly when searching an empty section.
+
+       * test_profile.c: Add code so that the "add" code will interpret
+               "NULL" as calling profile_add_relation with a null pointer
+               for the value.
+
 Wed Mar  3 18:23:47 1999  Theodore Y. Ts'o  <tytso@mit.edu>
 
        * prof_file.c (profile_flush_file): On the Macintosh, fopen()
index 47160906acfdefbe63e016e461d92d0baa5a857a..77018bba7dc016badbabbeb64acd9ddb448c7e82 100644 (file)
@@ -476,7 +476,7 @@ errcode_t profile_node_iterator(iter_p, ret_node, ret_name, ret_value)
                iter->node = 0;
        }
 get_new_file:
-       while (iter->node == 0) {
+       if (iter->node == 0) {
                if (iter->file == 0 ||
                    (iter->flags & PROFILE_ITER_FINAL_SEEN)) {
                        profile_node_iterator_free(iter_p);
@@ -513,7 +513,7 @@ get_new_file:
                if (!section) {
                        iter->file = iter->file->next;
                        skip_num = 0;
-                       continue;
+                       goto get_new_file;
                }
                iter->name = *cpp;
                iter->node = section->first_child;
index a36b778bc3fcc764d632596a0d471775d5261d6b..da81a20e0b7418af63f796b4ec9c2e93ada419b3 100644 (file)
@@ -83,8 +83,11 @@ static void do_batchmode(profile)
                        retval = profile_rename_section(profile, names+1,
                                                        *names);
                } else if (!strcmp(cmd, "add")) {
+                       value = *names;
+                       if (strcmp(value, "NULL") == 0)
+                               value = NULL;
                        retval = profile_add_relation(profile, names+1,
-                                                     *names);
+                                                     value);
                } else if (!strcmp(cmd, "flush")) {
                        retval = profile_flush(profile);
                } else {