diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-10-21 00:30:19 -0400 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-10-21 00:30:19 -0400 |
commit | 1de2a7dd87744dd7a14ce67081b32b7920c345e7 (patch) | |
tree | e4717f5a1834e8d25e8cd4b0b73be885fe1e5d0f /lib.c | |
parent | c3874aa95d260547711ed3bad4167642f51971ee (diff) | |
download | txr-1de2a7dd87744dd7a14ce67081b32b7920c345e7.tar.gz txr-1de2a7dd87744dd7a14ce67081b32b7920c345e7.tar.bz2 txr-1de2a7dd87744dd7a14ce67081b32b7920c345e7.zip |
* lib.c (proper_plist_to_alist, improper_plist_to_alist): New
functions.
* lib.h (proper_plist_to_alist, improper_plist_to_alist): New
functions declared.
* match.c (append_k): New keyword symbol variable.
(complex_open): New append argument.
(v_output): Streamlined parsing of keywords.
Support :append keyword.
* txr.1: Output directive's keyword documentation revised.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -661,6 +661,38 @@ val getplist(val list, val key) return nil; } +val proper_plist_to_alist(val list) +{ + list_collect_decl (out, tail); + + for (; list; list = cdr(cdr(list))) { + val ind = first(list); + val prop = second(list); + list_collect (tail, cons(ind, prop)); + } + + return out; +} + +val improper_plist_to_alist(val list, val boolean_keys) +{ + list_collect_decl (out, tail); + + for (; list; list = cdr(list)) { + val ind = first(list); + + if (memqual(ind, boolean_keys)) { + list_collect (tail, cons(ind, t)); + } else { + val prop = second(list); + list_collect (tail, cons(ind, prop)); + list = cdr(list); + } + } + + return out; +} + val num(cnum n) { numeric_assert (n >= NUM_MIN && n <= NUM_MAX); |