summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-10-03 09:43:30 -0700
committerKaz Kylheku <kaz@kylheku.com>2011-10-03 09:43:30 -0700
commit53b4090be0ed161aadf9a7c36ebc896f3e131a1f (patch)
tree30e7554d93d4f0a45a64ab813092b30565791ecd /lib.c
parentd1a8b58b39e131df4a9fdc748cda449c0447bd19 (diff)
downloadtxr-53b4090be0ed161aadf9a7c36ebc896f3e131a1f.tar.gz
txr-53b4090be0ed161aadf9a7c36ebc896f3e131a1f.tar.bz2
txr-53b4090be0ed161aadf9a7c36ebc896f3e131a1f.zip
Implemented new last clause for collect and coll.
Bugfix in cases inside coll: was not collecting bindings. Bugfix for until inside coll: was not seeing bindings from main clause. * lib.c (ldiff): New function. * lib.h (ldiff): Declared. * match.c (match_line): Implemented last clause. Fixed cases handling by moving misplaced termination check. (match_files): Implemented last clause. * parser.y (until_last): New nonterminal symbol. (collect_clause): Refactored syntax to support until and last. (elem): Likewise. * txr.1: Updated.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 932fecde..29e661d2 100644
--- a/lib.c
+++ b/lib.c
@@ -354,6 +354,18 @@ val nappend2(val list1, val list2)
return list1;
}
+val ldiff(val list1, val list2)
+{
+ list_collect_decl (out, tail);
+
+ while (list1 && list1 != list2) {
+ list_collect (tail, car(list1));
+ list1 = cdr(list1);
+ }
+
+ return out;
+}
+
static val flatten_helper(val env, val item)
{
return flatten(item);