summaryrefslogtreecommitdiffstats
path: root/match.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-03-24 21:10:35 -0700
committerKaz Kylheku <kaz@kylheku.com>2012-03-24 21:10:35 -0700
commit97f8a48e8aca3ab9837051d0d07e129fa41d7f17 (patch)
treebedc83b03835cea4ee98f4a754737272a42972e9 /match.c
parent108a4fd92f79a47261e1ad5e06f6333ac03b91d5 (diff)
downloadtxr-97f8a48e8aca3ab9837051d0d07e129fa41d7f17.tar.gz
txr-97f8a48e8aca3ab9837051d0d07e129fa41d7f17.tar.bz2
txr-97f8a48e8aca3ab9837051d0d07e129fa41d7f17.zip
* lib.c (rebind_s): New symbol variable.
* lib.h (rebind_s): Declared. * match.c (v_rebind): New static function. (dir_tables_init): Registered rebind_s to v_rebind, and also to hv_trampoline in the horizontal directive table. * txr.1: Documented it.
Diffstat (limited to 'match.c')
-rw-r--r--match.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/match.c b/match.c
index 19366350..01b4562a 100644
--- a/match.c
+++ b/match.c
@@ -2920,6 +2920,21 @@ static val v_set(match_files_ctx *c)
return next_spec_k;
}
+static val v_rebind(match_files_ctx *c)
+{
+ spec_bind (specline, first_spec, c->spec);
+ val args = rest(first_spec);
+ val pattern = first(args);
+ val form = second(args);
+ val val = txeval(specline, form, c->bindings);
+
+ c->bindings = alist_remove(c->bindings, args);
+ c->bindings = dest_bind(specline, c->bindings,
+ pattern, val, equal_f);
+
+ return next_spec_k;
+}
+
static val v_cat(match_files_ctx *c)
{
spec_bind (specline, first_spec, c->spec);
@@ -3735,6 +3750,7 @@ static void dir_tables_init(void)
sethash(v_directive_table, local_s, cptr((mem_t *) v_forget_local));
sethash(v_directive_table, merge_s, cptr((mem_t *) v_merge));
sethash(v_directive_table, bind_s, cptr((mem_t *) v_bind));
+ sethash(v_directive_table, rebind_s, cptr((mem_t *) v_rebind));
sethash(v_directive_table, set_s, cptr((mem_t *) v_set));
sethash(v_directive_table, cat_s, cptr((mem_t *) v_cat));
sethash(v_directive_table, output_s, cptr((mem_t *) v_output));
@@ -3757,6 +3773,7 @@ static void dir_tables_init(void)
sethash(h_directive_table, local_s, cptr((mem_t *) hv_trampoline));
sethash(h_directive_table, merge_s, cptr((mem_t *) hv_trampoline));
sethash(h_directive_table, bind_s, cptr((mem_t *) hv_trampoline));
+ sethash(h_directive_table, rebind_s, cptr((mem_t *) hv_trampoline));
sethash(h_directive_table, set_s, cptr((mem_t *) hv_trampoline));
sethash(h_directive_table, cat_s, cptr((mem_t *) hv_trampoline));
sethash(h_directive_table, filter_s, cptr((mem_t *) hv_trampoline));