diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/util/profile/ChangeLog | 15 | ||||
-rw-r--r-- | src/util/profile/Makefile.in | 16 | ||||
-rw-r--r-- | src/util/profile/configure.in | 3 | ||||
-rw-r--r-- | src/util/profile/prof_set.c | 2 | ||||
-rw-r--r-- | src/util/profile/prof_test1 | 70 | ||||
-rw-r--r-- | src/util/profile/prof_tree.c | 16 |
6 files changed, 109 insertions, 13 deletions
diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index a08a610..a1cdc5b 100644 --- a/src/util/profile/ChangeLog +++ b/src/util/profile/ChangeLog @@ -1,5 +1,19 @@ 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. @@ -7,6 +21,7 @@ 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> diff --git a/src/util/profile/Makefile.in b/src/util/profile/Makefile.in index 6735909..76540a3 100644 --- a/src/util/profile/Makefile.in +++ b/src/util/profile/Makefile.in @@ -112,9 +112,9 @@ prof_err.c: $(srcdir)/prof_err.et 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) \ @@ -129,6 +129,18 @@ clean-windows:: 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 diff --git a/src/util/profile/configure.in b/src/util/profile/configure.in index da9d921..17e8b58 100644 --- a/src/util/profile/configure.in +++ b/src/util/profile/configure.in @@ -8,6 +8,9 @@ AC_CHECK_HEADERS(unistd.h stdlib.h pwd.h) 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 diff --git a/src/util/profile/prof_set.c b/src/util/profile/prof_set.c index f1e3daf..310949b 100644 --- a/src/util/profile/prof_set.c +++ b/src/util/profile/prof_set.c @@ -81,7 +81,7 @@ static errcode_t rw_setup(profile_t profile) profile_unlock_global(); retval = profile_update_file(file); - + return retval; } diff --git a/src/util/profile/prof_test1 b/src/util/profile/prof_test1 new file mode 100644 index 0000000..42a6021 --- /dev/null +++ b/src/util/profile/prof_test1 @@ -0,0 +1,70 @@ +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 diff --git a/src/util/profile/prof_tree.c b/src/util/profile/prof_tree.c index cf7f33f..1d96ffb 100644 --- a/src/util/profile/prof_tree.c +++ b/src/util/profile/prof_tree.c @@ -33,6 +33,7 @@ struct profile_node { 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; @@ -149,7 +150,6 @@ errcode_t profile_add_node(struct profile_node *section, const char *name, { errcode_t retval; struct profile_node *p, *last, *new; - int cmp = -1; CHECK_MAGIC(section); @@ -162,6 +162,7 @@ errcode_t profile_add_node(struct profile_node *section, const char *name, * 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; @@ -170,6 +171,7 @@ errcode_t profile_add_node(struct profile_node *section, const char *name, if (retval) return retval; new->group_level = section->group_level+1; + new->deleted = 0; new->parent = section; new->prev = last; new->next = p; @@ -262,6 +264,8 @@ errcode_t profile_find_node(struct profile_node *section, const char *name, if (value && (strcmp(p->value, value))) continue; } + if (p->deleted) + continue; /* A match! */ if (node) *node = p; @@ -570,15 +574,7 @@ errcode_t profile_remove_node(struct profile_node *node) 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; } |