(profile_add_node): Move variable CMP into inner block where it's used. Clear
deleted flag.
(profile_find_node): Skip deleted nodes.
(profile_remove_node): Just set the deleted flag, don't modify the tree.
* Makefile.in (profile_tcl.c): Target should be in srcdir.
(profile_tcl.o): Depend on profile.h.
(DO_TCL): New variable.
(check-unix-tcl-, check-unix-tcl-ok): New targets.
(check-unix): Depend on one of them, based on DO_TCL.
* configure.in: Set and substitute DO_TCL.
* prof_test1: New file.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16784
dc483132-0cff-0310-8789-
dd5450dbe970
2004-09-23 Ken Raeburn <raeburn@mit.edu>
+ * prof_tree.c (struct profile_node): Add new bitfield DELETED.
+ (profile_add_node): Move variable CMP into inner block where it's
+ used. Clear deleted flag.
+ (profile_find_node): Skip deleted nodes.
+ (profile_remove_node): Just set the deleted flag, don't modify the
+ tree.
+ * Makefile.in (profile_tcl.c): Target should be in srcdir.
+ (profile_tcl.o): Depend on profile.h.
+ (DO_TCL): New variable.
+ (check-unix-tcl-, check-unix-tcl-ok): New targets.
+ (check-unix): Depend on one of them, based on DO_TCL.
+ * configure.in: Set and substitute DO_TCL.
+ * prof_test1: New file.
+
* profile.swg: Only include tclsh.i if building for Tcl.
(Tcl_SetResult, my_tcl_setresult): Compile hack only if building
for Tcl.
scripting language. Add Python code.
(%typemap errcode_t, errcode_t*): Add placeholders for Python
support.
+ * profile_tcl.c: Regenerated.
2004-08-28 Ken Raeburn <raeburn@mit.edu>
prof_err.o: prof_err.c
# not built by default, but may be useful for testing
-profile_tcl.c: profile.swg
+$(srcdir)/profile_tcl.c: profile.swg
(cd $(srcdir) && swig -tcl8 -o profile_tcl.c profile.swg)
-profile_tcl.o: $(srcdir)/profile_tcl.c
+profile_tcl.o: $(srcdir)/profile_tcl.c profile.h
profile_tcl: profile_tcl.o libprofile.a
$(CC_LINK) -o profile_tcl profile_tcl.o \
$(TCL_MAYBE_RPATH) \
check-unix:: test_parse test_profile
+DO_TCL=@DO_TCL@
+check-unix:: check-unix-tcl-$(DO_TCL)
+
+check-unix-tcl-:
+ @echo "+++"
+ @echo "+++ Tcl not available, some profile tests not run."
+ @echo "+++"
+
+check-unix-tcl-ok: profile_tcl
+ cp $(srcdir)/test.ini test2.ini
+ ./profile_tcl $(srcdir)/prof_test1
+
check-windows:: $(OUTPRE)test_profile.exe $(OUTPRE)test_parse.exe
$(RM) $(OUTPRE)*.obj
$(OUTPRE)test_parse test.ini
AC_CHECK_FUNCS(stat access strdup getpwuid_r)
AC_PROG_AWK
AC_KRB5_TCL
+DO_TCL=
+test "$TCL_LIBS" != "" && DO_TCL=ok
+AC_SUBST(DO_TCL)
KRB5_BUILD_LIBOBJS
KRB5_BUILD_PROGRAM
KRB5_BUILD_LIBRARY_WITH_DEPS
profile_unlock_global();
retval = profile_update_file(file);
-
+
return retval;
}
--- /dev/null
+set wd [pwd]
+set p [profile_init_path $wd/test2.ini]
+set verbose 0
+
+proc test1 {} {
+ global wd p verbose
+ set sect {{test section 1} child_section child}
+ set iter [profile_iterator_create $p $sect 0]
+ set done 0
+ if $verbose { puts "Iterating over {$sect} entries:" }
+ while {!$done} {
+ set pair [profile_iterator $iter]
+ if [string match $pair {{} {}}] {
+ set done 1
+ } else {
+ set val [lindex $pair 1]
+ if $verbose { puts -nonewline "\t$val" }
+ }
+ }
+ if $verbose { puts "" }
+ #profile_iterator_free $iter
+
+ set iter [profile_iterator_create $p $sect 0]
+ set done 0
+ if $verbose { puts "Iterating again, deleting:" }
+ while {!$done} {
+ set pair [profile_iterator $iter]
+ if [string match $pair {{} {}}] {
+ set done 1
+ } else {
+ set val [lindex $pair 1]
+ if $verbose { puts -nonewline "\t$val" }
+ profile_update_relation $p $sect $val
+ }
+ }
+ if $verbose { puts "" }
+ #profile_iterator_free $iter
+ profile_flush $p
+
+ if $verbose { puts "Reloading profile" }
+ set p [profile_init_path $wd/test2.ini]
+ set iter [profile_iterator_create $p $sect 0]
+ set done 0
+ if $verbose { puts "Iterating again:" }
+ set found_some 0
+ while {!$done} {
+ set pair [profile_iterator $iter]
+ if [string match $pair {{} {}}] {
+ set done 1
+ } else {
+ set found_some 1
+ set val [lindex $pair 1]
+ if $verbose { puts -nonewline "\t$val" }
+ }
+ }
+ #profile_iterator_free $iter
+ profile_abandon $p
+
+ if {$found_some} {
+ if $verbose { puts "" }
+ puts stderr "Error: Deleting in iterator didn't get them all."
+ exit 1
+ } else {
+ puts "OK: Deleting in iteration got rid of all entries."
+ }
+}
+
+test1
+
+exit 0
char *value;
int group_level;
int final:1; /* Indicate don't search next file */
+ int deleted:1;
struct profile_node *first_child;
struct profile_node *parent;
struct profile_node *next, *prev;
{
errcode_t retval;
struct profile_node *p, *last, *new;
- int cmp = -1;
CHECK_MAGIC(section);
* order matters.
*/
for (p=section->first_child, last = 0; p; last = p, p = p->next) {
+ int cmp;
cmp = strcmp(p->name, name);
if (cmp > 0)
break;
if (retval)
return retval;
new->group_level = section->group_level+1;
+ new->deleted = 0;
new->parent = section;
new->prev = last;
new->next = p;
if (value && (strcmp(p->value, value)))
continue;
}
+ if (p->deleted)
+ continue;
/* A match! */
if (node)
*node = p;
if (node->parent == 0)
return PROF_EINVAL; /* Can't remove the root! */
- if (node->prev)
- node->prev->next = node->next;
- else
- node->parent->first_child = node->next;
-
- if (node->next)
- node->next->prev = node->prev;
-
- profile_free_node(node);
+ node->deleted = 1;
return 0;
}