Commit 70a222098351c0d950e347c9f9e91b6890d9500a

Thomas de Grivel 2023-02-10T18:53:58

wip

diff --git a/config.subr b/config.subr
index ff5a421..b8166bf 100644
--- a/config.subr
+++ b/config.subr
@@ -64,6 +64,10 @@ config_asan() {
     rm .config_asan.c
 }
 
+config_define () {
+    echo "#define $1 $2" >> "${CONFIG_H}"
+}
+
 config_gnu() {
     if grep -q _GNU_SOURCE /usr/include/features.h 2>/dev/null; then
 	CFLAGS="$CFLAGS -D_GNU_SOURCE"
diff --git a/lib/c3.facts b/lib/c3.facts
deleted file mode 100644
index 71b747a..0000000
--- a/lib/c3.facts
+++ /dev/null
@@ -1,9 +0,0 @@
-%{module: C3.Facts.Dump,
-  version: 0x0000000000000001,
-  count: 0x0000000000000005}
-{C3, :is-a, :module}
-{C3, :name, "C3"}
-{C3, :path, "c3.facts"}
-{C3, :function, C3.first}
-{C3.first, :fn, fn ([a | _b]) { a }}
-%{hash: 0x08854B651E330862}
diff --git a/lib/c3/0.1/c3.facts b/lib/c3/0.1/c3.facts
new file mode 100644
index 0000000..71b747a
--- /dev/null
+++ b/lib/c3/0.1/c3.facts
@@ -0,0 +1,9 @@
+%{module: C3.Facts.Dump,
+  version: 0x0000000000000001,
+  count: 0x0000000000000005}
+{C3, :is-a, :module}
+{C3, :name, "C3"}
+{C3, :path, "c3.facts"}
+{C3, :function, C3.first}
+{C3.first, :fn, fn ([a | _b]) { a }}
+%{hash: 0x08854B651E330862}
diff --git a/libc3/configure b/libc3/configure
index eb7a470..3b4bb90 100755
--- a/libc3/configure
+++ b/libc3/configure
@@ -48,6 +48,7 @@ pkg_config libmd
 config_lib libmd -lmd
 config_include sha_h sys/types.h sha.h HAVE_SHA_H
 config_include sha1_h sys/types.h sha1.h HAVE_SHA1_H
+config_define PREFIX "\"${PREFIX}\""
 update_config_h
 
 # Address Sanitizer config
diff --git a/libc3/env.c b/libc3/env.c
index d4e9191..2945bb7 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -154,10 +154,11 @@ s_tag * env_eval_call_fn (s_env *env, const s_call *call, s_tag *dest)
   frame_init(&frame, env->frame);
   env->frame = &frame;
   args = env_eval_call_arguments(env, call->arguments);
-  env_eval_equal_list(env, fn->pattern, args, &tmp);
-  env_eval_progn(env, fn->algo, dest);
+  if (env_eval_equal_list(env, fn->pattern, args, &tmp)) {
+    env_eval_progn(env, fn->algo, dest);
+    list_delete_all(tmp);
+  }
   env->frame = frame_clean(&frame);
-  list_delete_all(tmp);
   return dest;
 }
 
@@ -375,7 +376,7 @@ s_env * env_init (s_env *env)
   buf_init_alloc(&env->err, BUF_SIZE);
   buf_file_open_w(&env->err, stderr);
   facts_init(&env->facts);
-  str_init_1(&env->module_path, NULL, "/home/dx/c/c3-lang/c3/lib");
+  str_init_1(&env->module_path, NULL, PREFIX "/lib/c3/0.1");
   if (! module_load(&env->c3_module, sym_1("C3"), &env->facts))
     return NULL;
   env->current_module = &env->c3_module;