diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2013-06-11 16:15:34 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2013-06-11 16:15:34 -0700 |
commit | 399b4b6a5082aa6f14a98bc50b29baeca686aa39 (patch) | |
tree | fcf71aad074e38aecc2a13a192756791a1e02783 /lib.c | |
parent | a6b0130ceaeadce6845d698fb68712dc2786e918 (diff) | |
download | txr-399b4b6a5082aa6f14a98bc50b29baeca686aa39.tar.gz txr-399b4b6a5082aa6f14a98bc50b29baeca686aa39.tar.bz2 txr-399b4b6a5082aa6f14a98bc50b29baeca686aa39.zip |
* eval.c (eval_init): tok-str acquires new parameter
* lib.c (tok_str): New parameter, keep_sep.
* lib.h (tok_str): Declaration updated.
* txr.1: Documentation for tok-str updated.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -2060,7 +2060,7 @@ val split_str_set(val str, val set) return out; } -val tok_str(val str, val tok_regex) +val tok_str(val str, val tok_regex, val keep_sep) { list_collect_decl (out, iter); val pos = zero; @@ -2069,11 +2069,17 @@ val tok_str(val str, val tok_regex) cons_bind (new_pos, len, search_regex(str, tok_regex, pos, nil)); val end; - if (!len) + if (!len) { + if (keep_sep) + list_collect(iter, sub_str(str, pos, t)); break; + } end = plus(new_pos, len); + if (keep_sep) + list_collect(iter, sub_str(str, pos, new_pos)); + list_collect(iter, sub_str(str, new_pos, end)); pos = end; |