summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-10-18 00:26:07 -0400
committerKaz Kylheku <kaz@kylheku.com>2011-10-18 00:26:07 -0400
commite8c1b45226fcd493c1faf18bbc2c3cc668b01141 (patch)
treeed0564d7c0dbd766bd2bfb27d335c88ed08dc26e /lib.c
parent3cdd67db736815caafc8007df6930777691316a4 (diff)
downloadtxr-e8c1b45226fcd493c1faf18bbc2c3cc668b01141.tar.gz
txr-e8c1b45226fcd493c1faf18bbc2c3cc668b01141.tar.bz2
txr-e8c1b45226fcd493c1faf18bbc2c3cc668b01141.zip
Task #11425.
Vertical skip directive moved into function dispatched via hash table. Test suite passes. * lib.c (cptr_s): New symbol variable. (cptr_equal_op): New static function. (cptr_equal_op, cptr, cptr_get): New functions. (cptr_ops): New static structure. (obj_init): New variable initialized. * lib.h (cptr_s, cptr, cptr_get): Declared. * match.c (decline_k, same_data_k): New symbol variables. (v_match_func): New typedef. (v_skip): New function. (match_files): Check symbol in v_directive_table and dispatch the associated function if an entry exists. Skip directive handling moved to v_skip function. (syms_init): Initialize new symbol variables. (dir_tables_init): Enter v_skip into v_directive_table under skip_s symbol.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index 87a03c06..e490228c 100644
--- a/lib.c
+++ b/lib.c
@@ -51,7 +51,7 @@ val packages;
val system_package, keyword_package, user_package;
val null, t, cons_s, str_s, chr_s, num_s, sym_s, pkg_s, fun_s, vec_s;
-val stream_s, hash_s, hash_iter_s, lcons_s, lstr_s, cobj_s;
+val stream_s, hash_s, hash_iter_s, lcons_s, lstr_s, cobj_s, cptr_s;
val var_s, expr_s, regex_s, chset_s, set_s, cset_s, wild_s, oneplus_s;
val nongreedy_s, compiled_regex_s;
val zeroplus_s, optional_s, compl_s, compound_s, or_s, and_s, quasi_s;
@@ -1872,6 +1872,29 @@ void cobj_print_op(val obj, val out)
format(out, lit(": ~p>"), obj->co.handle, nao);
}
+static val cptr_equal_op(val left, val right)
+{
+ return (left->co.handle == right->co.handle) ? t : nil;
+}
+
+static struct cobj_ops cptr_ops = {
+ cptr_equal_op,
+ cobj_print_op,
+ cobj_destroy_stub_op,
+ cobj_mark_op,
+ cobj_hash_op
+};
+
+val cptr(mem_t *ptr)
+{
+ return cobj(ptr, cptr_s, &cptr_ops);
+}
+
+mem_t *cptr_get(val cptr)
+{
+ return cobj_handle(cptr, cptr_s);
+}
+
val assoc(val list, val key)
{
while (list) {
@@ -2160,6 +2183,7 @@ static void obj_init(void)
lcons_s = intern(lit("lcons"), user_package);
lstr_s = intern(lit("lstr"), user_package);
cobj_s = intern(lit("cobj"), user_package);
+ cptr_s = intern(lit("cptr"), user_package);
var_s = intern(lit("var"), system_package);
expr_s = intern(lit("expr"), system_package);
regex_s = intern(lit("regex"), system_package);