diff options
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | RELNOTES | 4 | ||||
-rw-r--r-- | lib.c | 14 | ||||
-rw-r--r-- | lib.h | 1 | ||||
-rw-r--r-- | match.c | 5 | ||||
-rw-r--r-- | tests/008/soundex.txr | 2 |
6 files changed, 38 insertions, 3 deletions
@@ -1,5 +1,20 @@ 2011-11-24 Kaz Kylheku <kaz@kylheku.com> + * lib.c (getplist_f): New function. + + * lib.h (getplist_f): Declared. + + * match.c (v_collect, h_coll): Use getplist_f to distinguish + the case that :vars is explicitly specified as (). In this + case, no bindings escape from the collect. + + * tests/008/soundex.txr: This test case broke due to using + :vars () and yet counting on the variable to exist. + + * RELNOTES: Updated. + +2011-11-24 Kaz Kylheku <kaz@kylheku.com> + * match.c (match_funcall): Set source location info for generated function call. @@ -6,6 +6,10 @@ - Fixed regression in source location tracking (line numbers shown in debugger and trace output). + - Fixed :vars () in collect/coll not working as intended. + This should prevent any bindings from being collected, and + allows iteration with collect without accumulating memory. + TXR 043 2011-11-23 @@ -677,6 +677,20 @@ val getplist(val list, val key) return nil; } +val getplist_f(val list, val key, val *found) +{ + for (; list; list = cdr(cdr(list))) { + val ind = first(list); + if (eq(ind, key)) { + *found = t; + return second(list); + } + } + + *found = nil; + return nil; +} + val proper_plist_to_alist(val list) { list_collect_decl (out, tail); @@ -315,6 +315,7 @@ val listp(val obj); val proper_listp(val obj); val length(val list); val getplist(val list, val key); +val getplist_f(val list, val key, val *found); val proper_plist_to_alist(val list); val improper_plist_to_alist(val list, val boolean_keys); val num(cnum val); @@ -2261,7 +2261,8 @@ static val v_collect(match_files_ctx *c) val mintimes = getplist(args, mintimes_k); val maxtimes = getplist(args, maxtimes_k); val lines = getplist(args, lines_k); - val vars = getplist(args, vars_k); + val have_vars; + val vars = getplist_f(args, vars_k, &have_vars); cnum cmax = nump(gap) ? c_num(gap) : (nump(max) ? c_num(max) : 0); cnum cmin = nump(gap) ? c_num(gap) : (nump(min) ? c_num(min) : 0); cnum mincounter = cmin, maxcounter = 0; @@ -2356,7 +2357,7 @@ static val v_collect(match_files_ctx *c) val binding = car(iter); val vars_binding = assoc(vars, car(binding)); - if (!vars || vars_binding) { + if (!have_vars || vars_binding) { val existing = assoc(bindings_coll, car(binding)); bindings_coll = acons_new(bindings_coll, car(binding), diff --git a/tests/008/soundex.txr b/tests/008/soundex.txr index d01fb76d..b192bb62 100644 --- a/tests/008/soundex.txr +++ b/tests/008/soundex.txr @@ -56,7 +56,7 @@ @### @# process arguments and list soundex codes @### -@(collect :vars ()) +@(collect :vars (input)) @input @ (output :filter (:fun soundex)) @input |