diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-10-26 00:20:57 -0400 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-10-26 00:20:57 -0400 |
commit | 6d7e225fa1dded120dd959074c0d269c38459713 (patch) | |
tree | d399065394b3dcf5228e0a253036029125ab5206 /match.c | |
parent | 2987f69f690d8433ad3aaa9e9f41949455ada2cb (diff) | |
download | txr-6d7e225fa1dded120dd959074c0d269c38459713.tar.gz txr-6d7e225fa1dded120dd959074c0d269c38459713.tar.bz2 txr-6d7e225fa1dded120dd959074c0d269c38459713.zip |
Fixed lame @(cat) directive, without obsolescence phase.
* match.c (v_cat): Rewritten.
* txr.1: Documented.
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 31 |
1 files changed, 15 insertions, 16 deletions
@@ -2242,25 +2242,24 @@ static val v_set(match_files_ctx c, match_files_ctx *cout) static val v_cat(match_files_ctx c, match_files_ctx *cout) { spec_bind (specline, spec_linenum, first_spec, c.spec); - val iter; + val sym = second(first_spec); + val sep_form = third(first_spec); - for (iter = rest(first_spec); iter; iter = rest(iter)) { - val sym = first(iter); + if (rest(specline)) + sem_error(spec_linenum, lit("cat: obsolete syntax")); - if (!bindable(sym)) { - sem_error(spec_linenum, - lit("cat: ~s is not a bindable symbol"), sym, nao); + if (!bindable(sym)) { + sem_error(spec_linenum, + lit("cat: ~s is not a bindable symbol"), sym, nao); + } else { + val existing = assoc(c.bindings, sym); + if (existing) { + val sep = if3(sep_form, + cdr(eval_form(spec_linenum, sep_form, c.bindings)), + lit(" ")); + *cdr_l(existing) = cat_str(flatten(cdr(existing)), sep); } else { - val existing = assoc(c.bindings, sym); - val sep = nil; - - if (rest(specline)) { - val sub = subst_vars(rest(specline), c.bindings, nil); - sep = cat_str(sub, nil); - } - - if (existing) - *cdr_l(existing) = cat_str(flatten(cdr(existing)), sep); + sem_error(spec_linenum, lit("cat: unbound variable ~s"), sym, nao); } } |