Commit b068e0fe91a9a519c525b96562356a53446c3f95

Thomas de Grivel 2023-03-05T20:24:18

wip

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
diff --git a/libc3/cfn.c b/libc3/cfn.c
index 51cb348..c6df368 100644
--- a/libc3/cfn.c
+++ b/libc3/cfn.c
@@ -11,16 +11,75 @@
  * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
  * THIS SOFTWARE.
  */
+#include <assert.h>
+#include <err.h>
+#include <stdlib.h>
 #include "cfn.h"
+#include "list.h"
+
+s_cfn * cfn_set_arg_types (s_cfn *cfn, s_list *arg_types)
+{
+  s_list *a;
+  ffi_type **arg_ffi_type = NULL;
+  sw arity;
+  ffi_cif cif;
+  u8 i = 0;
+  ffi_type *result_type;
+  assert(cfn);
+  if ((arity = list_length(arg_types))) {
+    if (arity > 255) {
+      assert(arity <= 255);
+      errx(1, "cfn_set_arg_types: arity > 255");
+    }
+    if (! (arg_types = malloc(sizeof(ffi_type *) * arity)))
+      err(1, "cfn_set_arg_types");
+    a = arg_types;
+    while (a) {
+      assert(i < arity);
+      arg_ffi_type[i] = cfn_arg_type_to_ffi_type(&a->tag);
+      i++;
+      a = list_next(a);
+    }
+  }
+  cfn->arg_types = arg_types;
+  cfn->arity = arity;
+  return cfn;
+}
+
+ffi_type * cfn_arg_type_to_ffi_type (const s_tag *tag)
+{
+  assert(tag);
+  assert(tag->type.type == TAG_SYM);
+  if (tag->data.sym == sym_1("s8"))
+    return &ffi_type_sint8;
+  if (tag->data.sym == sym_1("s16"))
+    return &ffi_type_sint16;
+  if (tag->data.sym == sym_1("s32"))
+    return &ffi_type_sint32;
+  if (tag->data.sym == sym_1("s64"))
+    return &ffi_type_sint64;
+  if (tag->data.sym == sym_1("sw"))
+    return &ffi_type_sint;
+  if (tag->data.sym == sym_1("u8"))
+    return &ffi_type_uint8;
+  if (tag->data.sym == sym_1("u16"))
+    return &ffi_type_uint16;
+  if (tag->data.sym == sym_1("u32"))
+    return &ffi_type_uint32;
+  if (tag->data.sym == sym_1("u64"))
+    return &ffi_type_uint64;
+  if (tag->data.sym == sym_1("uw"))
+    return &ffi_type_uint;
+}
+
 
 s_tag * cfn_apply (s_cfn *cfn, s_list *args) {
-  ffi_type **arg_types;
   void **arg_values;
-  ffi_cif cif;
   sw i;
   sw num_args;
   void* result;
-  ffi_type* result_type;
+  assert(cfn);
+  assert(args);
   num_args = list_length(args);
   if (! num_args) {
     /* TODO */
@@ -28,8 +87,6 @@ s_tag * cfn_apply (s_cfn *cfn, s_list *args) {
     err(1, "todo");
     return NULL;
   }
-  if (! (arg_types = malloc(sizeof(ffi_type *) * num_args)))
-    err(1, "cfn_apply");
   if (! (arg_values = malloc(sizeof(void *) * num_args)))
     err(1, "cfn_apply");
   while (args) {
diff --git a/libc3/compare.c b/libc3/compare.c
index 644973d..7e8cc24 100644
--- a/libc3/compare.c
+++ b/libc3/compare.c
@@ -51,7 +51,7 @@ s8 compare_call (const s_call *a, const s_call *b)
   return compare_list(a->arguments, b->arguments);
 }
 
-s8 compare_cfn (const s_fn *a, const s_fn *b)
+s8 compare_cfn (const s_cfn *a, const s_cfn *b)
 {
   s8 r;
   if (a == b)
@@ -60,7 +60,7 @@ s8 compare_cfn (const s_fn *a, const s_fn *b)
     return -1;
   if (!b)
     return 1;
-  if ((r = compare_sym(&a->name, &b->name)))
+  if ((r = compare_sym(a->name, b->name)))
     return r;
   return compare_list(a->arg_types, b->arg_types);
 }
@@ -153,15 +153,25 @@ s8 compare_fact_osp (const s_fact *a, const s_fact *b)
 s8 compare_fn (const s_fn *a, const s_fn *b)
 {
   s8 r;
-  if (a == b)
-    return 0;
-  if (!a)
-    return -1;
-  if (!b)
-    return 1;
-  if ((r = compare_ident(&a->ident, &b->ident)))
-    return r;
-  return compare_list(a->arguments, b->arguments);
+  assert(a);
+  assert(b);
+  while (1) {
+    if (a == b)
+      return 0;
+    if (!a)
+      return -1;
+    if (!b)
+      return 1;
+    if ((r = compare_list(a->pattern, b->pattern)))
+      return r;
+    if ((r = compare_list(a->algo, b->algo)))
+      return r;
+    a = a->next_clause;
+    b = b->next_clause;
+  }
+  assert(! "compare_fn");
+  err(1, "compare_fn");
+  return 0;
 }
 
 s8 compare_ident (const s_ident *a, const s_ident *b)
diff --git a/libc3/sources.mk b/libc3/sources.mk
index a3dec1f..1933266 100644
--- a/libc3/sources.mk
+++ b/libc3/sources.mk
@@ -12,6 +12,7 @@ HEADERS = \
 	c3.h \
 	c_types.h \
 	call.h \
+	cfn.h \
 	character.h \
 	compare.h \
 	config.h \
@@ -64,6 +65,7 @@ SOURCES = \
 	buf_save.c \
 	c3.c \
 	call.c \
+	cfn.c \
 	character.c \
 	compare.c \
 	env.c \
@@ -113,6 +115,7 @@ LO_SOURCES = \
 	buf_save.c \
 	c3.c \
 	call.c \
+	cfn.c \
 	character.c \
 	compare.c \
 	env.c \
diff --git a/libc3/sources.sh b/libc3/sources.sh
index a4196f9..eb2f7de 100644
--- a/libc3/sources.sh
+++ b/libc3/sources.sh
@@ -1,4 +1,4 @@
 # sources.sh generated by update_sources
-HEADERS='arg.h binding.h bool.h buf.h buf_file.h buf_inspect.h buf_parse.h buf_parse_c.h buf_save.h c3.h c_types.h call.h character.h compare.h config.h env.h error.h error_handler.h eval.h fact.h facts.h facts_cursor.h facts_spec.h facts_spec_cursor.h facts_with.h facts_with_cursor.h fn.h frame.h hash.h ident.h integer.h io.h list.h log.h module.h quote.h set__fact.h set__tag.h set_cursor__fact.h set_cursor__tag.h set_item__fact.h set_item__tag.h sha1.h skiplist__fact.h skiplist_node__fact.h str.h sym.h tag.h tuple.h types.h ucd.h '
-SOURCES='arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c io.c list.c log.c module.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c '
-LO_SOURCES='arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c character.c compare.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c io.c list.c log.c module.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c ../libtommath/bn_cutoffs.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_rand_platform.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c '
+HEADERS='arg.h binding.h bool.h buf.h buf_file.h buf_inspect.h buf_parse.h buf_parse_c.h buf_save.h c3.h c_types.h call.h cfn.h character.h compare.h config.h env.h error.h error_handler.h eval.h fact.h facts.h facts_cursor.h facts_spec.h facts_spec_cursor.h facts_with.h facts_with_cursor.h fn.h frame.h hash.h ident.h integer.h io.h list.h log.h module.h quote.h set__fact.h set__tag.h set_cursor__fact.h set_cursor__tag.h set_item__fact.h set_item__tag.h sha1.h skiplist__fact.h skiplist_node__fact.h str.h sym.h tag.h tuple.h types.h ucd.h '
+SOURCES='arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c cfn.c character.c compare.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c io.c list.c log.c module.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c '
+LO_SOURCES='arg.c binding.c bool.c buf.c buf_file.c buf_inspect.c buf_parse.c buf_parse_c.c buf_save.c c3.c call.c cfn.c character.c compare.c env.c error.c error_handler.c eval.c fact.c facts.c facts_cursor.c facts_spec.c facts_spec_cursor.c facts_with.c facts_with_cursor.c fn.c frame.c hash.c ident.c integer.c io.c list.c log.c module.c quote.c set__fact.c set__tag.c set_cursor__fact.c set_cursor__tag.c set_item__fact.c set_item__tag.c skiplist__fact.c skiplist_node__fact.c str.c sym.c tag.c tuple.c ucd.c ../libtommath/bn_cutoffs.c ../libtommath/bn_mp_2expt.c ../libtommath/bn_mp_abs.c ../libtommath/bn_mp_add.c ../libtommath/bn_mp_add_d.c ../libtommath/bn_mp_and.c ../libtommath/bn_mp_clamp.c ../libtommath/bn_mp_clear.c ../libtommath/bn_mp_clear_multi.c ../libtommath/bn_mp_cmp.c ../libtommath/bn_mp_cmp_d.c ../libtommath/bn_mp_cmp_mag.c ../libtommath/bn_mp_cnt_lsb.c ../libtommath/bn_mp_complement.c ../libtommath/bn_mp_copy.c ../libtommath/bn_mp_count_bits.c ../libtommath/bn_mp_div.c ../libtommath/bn_mp_div_2.c ../libtommath/bn_mp_div_2d.c ../libtommath/bn_mp_div_3.c ../libtommath/bn_mp_div_d.c ../libtommath/bn_mp_dr_is_modulus.c ../libtommath/bn_mp_dr_reduce.c ../libtommath/bn_mp_dr_setup.c ../libtommath/bn_mp_error_to_string.c ../libtommath/bn_mp_exch.c ../libtommath/bn_mp_exptmod.c ../libtommath/bn_mp_gcd.c ../libtommath/bn_mp_get_i32.c ../libtommath/bn_mp_get_i64.c ../libtommath/bn_mp_get_mag_u32.c ../libtommath/bn_mp_get_mag_u64.c ../libtommath/bn_mp_grow.c ../libtommath/bn_mp_init.c ../libtommath/bn_mp_init_copy.c ../libtommath/bn_mp_init_multi.c ../libtommath/bn_mp_init_size.c ../libtommath/bn_mp_invmod.c ../libtommath/bn_mp_lcm.c ../libtommath/bn_mp_lshd.c ../libtommath/bn_mp_mod.c ../libtommath/bn_mp_mod_2d.c ../libtommath/bn_mp_montgomery_calc_normalization.c ../libtommath/bn_mp_montgomery_reduce.c ../libtommath/bn_mp_montgomery_setup.c ../libtommath/bn_mp_mul.c ../libtommath/bn_mp_mul_2.c ../libtommath/bn_mp_mul_2d.c ../libtommath/bn_mp_mul_d.c ../libtommath/bn_mp_mulmod.c ../libtommath/bn_mp_neg.c ../libtommath/bn_mp_or.c ../libtommath/bn_mp_radix_size.c ../libtommath/bn_mp_reduce.c ../libtommath/bn_mp_reduce_2k.c ../libtommath/bn_mp_reduce_2k_l.c ../libtommath/bn_mp_reduce_2k_setup.c ../libtommath/bn_mp_reduce_2k_setup_l.c ../libtommath/bn_mp_reduce_is_2k.c ../libtommath/bn_mp_reduce_is_2k_l.c ../libtommath/bn_mp_reduce_setup.c ../libtommath/bn_mp_rshd.c ../libtommath/bn_mp_set.c ../libtommath/bn_mp_sqr.c ../libtommath/bn_mp_sqrt.c ../libtommath/bn_mp_sub.c ../libtommath/bn_mp_sub_d.c ../libtommath/bn_mp_xor.c ../libtommath/bn_mp_zero.c ../libtommath/bn_s_mp_add.c ../libtommath/bn_s_mp_balance_mul.c ../libtommath/bn_s_mp_exptmod.c ../libtommath/bn_s_mp_exptmod_fast.c ../libtommath/bn_s_mp_invmod_fast.c ../libtommath/bn_s_mp_invmod_slow.c ../libtommath/bn_s_mp_karatsuba_mul.c ../libtommath/bn_s_mp_karatsuba_sqr.c ../libtommath/bn_s_mp_montgomery_reduce_fast.c ../libtommath/bn_s_mp_mul_digs.c ../libtommath/bn_s_mp_mul_digs_fast.c ../libtommath/bn_s_mp_mul_high_digs.c ../libtommath/bn_s_mp_mul_high_digs_fast.c ../libtommath/bn_s_mp_rand_platform.c ../libtommath/bn_s_mp_sqr.c ../libtommath/bn_s_mp_sqr_fast.c ../libtommath/bn_s_mp_sub.c ../libtommath/bn_s_mp_toom_mul.c ../libtommath/bn_s_mp_toom_sqr.c '
diff --git a/sources.mk b/sources.mk
index f46a5f5..85e6bb7 100644
--- a/sources.mk
+++ b/sources.mk
@@ -9,8 +9,8 @@ C3_CONFIGURES = \
 	libc3/update_sources \
 	libtommath/configure \
 	libtommath/update_sources \
-	test/configure \
 	test/update_sources \
+	test/configure \
 	ucd2c/configure \
 
 C3_MAKEFILES = \
@@ -30,142 +30,147 @@ C3_C_SOURCES = \
 	c3s/c3s.c \
 	c3s/buf_readline.h \
 	ic3/buf_linenoise.c \
-	ic3/buf_linenoise.h \
 	ic3/ic3.c \
+	ic3/buf_linenoise.h \
 	ic3/linenoise.c \
+	libc3/set__tag.c \
+	libc3/set_item__tag.c \
 	libc3/arg.c \
 	libc3/arg.h \
+	libc3/skiplist_node__fact.c \
+	libc3/set_cursor__tag.c \
 	libc3/binding.c \
 	libc3/binding.h \
-	libc3/bool.c \
-	libc3/bool.h \
-	libc3/set__tag.c \
 	libc3/set__tag.h \
 	libc3/set_item__tag.h \
-	libc3/set_item__tag.c \
-	libc3/set_cursor__tag.c \
-	libc3/set_cursor__tag.h \
-	libc3/skiplist_node__fact.c \
-	libc3/buf.c \
-	libc3/buf.h \
-	libc3/buf_file.c \
-	libc3/buf_file.h \
-	libc3/buf_inspect.c \
-	libc3/buf_inspect.h \
-	libc3/buf_parse.c \
-	libc3/buf_parse.h \
-	libc3/buf_parse_c.c \
-	libc3/buf_parse_c.h \
-	libc3/buf_save.c \
-	libc3/log.h \
 	libc3/skiplist_node__fact.h \
+	libc3/facts.c \
 	libc3/skiplist__fact.c \
 	libc3/skiplist__fact.h \
-	libc3/set_item__fact.c \
 	libc3/set_item__fact.h \
+	libc3/facts_with_cursor.c \
+	libc3/set_item__fact.c \
 	libc3/set__fact.c \
+	libc3/set_cursor__fact.c \
 	libc3/set__fact.h \
+	libc3/buf_file.c \
+	libc3/buf_file.h \
+	libc3/bool.c \
+	libc3/io.h \
+	libc3/call.h \
+	libc3/io.c \
+	libc3/buf_parse_c.c \
+	libc3/buf_parse_c.h \
+	libc3/buf_save.c \
+	libc3/buf_parse.c \
+	libc3/buf_parse.h \
+	libc3/buf_save.h \
+	libc3/fact.h \
+	libc3/c_types.h \
+	libc3/list.h \
+	libc3/buf_inspect.h \
+	libc3/bool.h \
+	libc3/c3.h \
+	libc3/character.h \
 	libc3/compare.c \
 	libc3/compare.h \
-	libc3/buf_save.h \
 	libc3/env.c \
-	libc3/env.h \
-	libc3/c_types.h \
-	libc3/call.c \
-	libc3/call.h \
-	libc3/character.c \
-	libc3/log.c \
+	libc3/ident.c \
 	libc3/error.c \
 	libc3/error.h \
 	libc3/error_handler.c \
+	libc3/buf.c \
+	libc3/env.h \
+	libc3/frame.c \
 	libc3/error_handler.h \
 	libc3/eval.c \
 	libc3/eval.h \
-	libc3/fact.h \
-	libc3/facts.c \
+	libc3/fact.c \
 	libc3/facts.h \
 	libc3/facts_cursor.c \
+	libc3/fn.h \
+	libc3/types.h \
+	libc3/call.c \
+	libc3/cfn.c \
 	libc3/facts_cursor.h \
 	libc3/facts_spec.c \
+	libc3/frame.h \
 	libc3/facts_spec.h \
 	libc3/facts_spec_cursor.c \
+	libc3/hash.c \
 	libc3/facts_spec_cursor.h \
-	libc3/character.h \
-	libc3/set_cursor__fact.c \
-	libc3/set_cursor__fact.h \
-	libc3/c3.c \
 	libc3/facts_with.c \
 	libc3/facts_with.h \
-	libc3/facts_with_cursor.c \
-	libc3/facts_with_cursor.h \
-	libc3/fn.c \
-	libc3/fn.h \
-	libc3/frame.c \
-	libc3/frame.h \
-	libc3/hash.c \
 	libc3/hash.h \
-	libc3/ident.c \
+	libc3/buf.h \
+	libc3/cfn.h \
+	libc3/facts_with_cursor.h \
 	libc3/ident.h \
+	libc3/str.c \
+	libc3/c3.c \
 	libc3/integer.c \
-	libc3/integer.h \
 	libc3/list.c \
-	libc3/list.h \
-	libc3/module.h \
+	libc3/log.c \
+	libc3/log.h \
+	libc3/sym.h \
+	libc3/tag.c \
+	libc3/module.c \
 	libc3/quote.c \
 	libc3/quote.h \
-	libc3/types.h \
-	libc3/c3.h \
+	libc3/integer.h \
+	libc3/character.c \
+	libc3/fn.c \
+	libc3/module.h \
 	libc3/set.c.in \
+	libc3/buf_inspect.c \
+	libc3/set_cursor__fact.h \
+	libc3/set_cursor__tag.h \
 	libc3/set.h.in \
 	libc3/set_cursor.c.in \
+	libc3/str.h \
+	libc3/tuple.h \
+	libc3/sym.c \
 	libc3/set_cursor.h.in \
-	libc3/str.c \
+	libc3/ucd.c \
+	libc3/ucd.h \
 	libc3/set_item.c.in \
 	libc3/set_item.h.in \
-	libc3/fact.c \
+	libc3/sha1.h \
 	libc3/skiplist.c.in \
 	libc3/skiplist.h.in \
 	libc3/skiplist_node.c.in \
 	libc3/skiplist_node.h.in \
-	libc3/str.h \
-	libc3/sym.c \
-	libc3/sym.h \
-	libc3/tag.c \
-	libc3/tuple.c \
-	libc3/tuple.h \
-	libc3/ucd.c \
-	libc3/ucd.h \
 	libc3/tag.h \
-	libc3/module.c \
-	libc3/sha1.h \
+	libc3/tuple.c \
 	test/bool_test.c \
 	test/buf_file_test.c \
-	test/buf_inspect_test.c \
 	test/buf_parse_test.c \
-	test/buf_test.c \
-	test/call_test.c \
 	test/character_test.c \
-	test/hash_test.c \
+	test/facts_test.c \
+	test/buf_inspect_test.c \
+	test/test.c \
+	test/tag_test.c \
+	test/env_test.c \
 	test/fact_test.c \
+	test/compare_test.h \
 	test/fact_test.h \
-	test/facts_cursor_test.c \
-	test/facts_test.c \
+	test/str_test.c \
+	test/list_test.c \
 	test/facts_with_test.c \
+	test/test.h \
+	test/call_test.c \
 	test/ident_test.c \
 	test/libc3_test.c \
-	test/tuple_test.c \
-	test/list_test.c \
+	test/skiplist__fact_test.c \
 	test/set__fact_test.c \
 	test/set__tag_test.c \
-	test/compare_test.h \
-	test/skiplist__fact_test.c \
-	test/str_test.c \
-	test/test.c \
-	test/test.h \
-	test/sym_test.c \
-	test/tag_test.c \
+	test/facts_cursor_test.c \
 	test/tag_test.h \
+	test/sym_test.c \
+	test/hash_test.c \
+	test/tuple_test.c \
 	test/types_test.c \
+	test/buf_test.c \
 	test/compare_test.c \
 	ucd2c/ucd.h \
 	ucd2c/ucd2c.c \
diff --git a/sources.sh b/sources.sh
index f2ab60d..74566be 100644
--- a/sources.sh
+++ b/sources.sh
@@ -1,4 +1,4 @@
 # sources.sh generated by update_sources
-C3_CONFIGURES='c3c/configure c3s/configure c3s/update_sources ic3/configure ic3/update_sources libc3/configure libc3/update_sources libtommath/configure libtommath/update_sources test/configure test/update_sources ucd2c/configure '
+C3_CONFIGURES='c3c/configure c3s/configure c3s/update_sources ic3/configure ic3/update_sources libc3/configure libc3/update_sources libtommath/configure libtommath/update_sources test/update_sources test/configure ucd2c/configure '
 C3_MAKEFILES='c3c/Makefile c3s/Makefile ic3/Makefile libc3/Makefile libc3/gen.mk libtommath/logs/Makefile libtommath/Makefile test/Makefile ucd2c/Makefile '
-C3_C_SOURCES='c3c/c3c.c c3s/buf_readline.c c3s/c3s.c c3s/buf_readline.h ic3/buf_linenoise.c ic3/buf_linenoise.h ic3/ic3.c ic3/linenoise.c libc3/arg.c libc3/arg.h libc3/binding.c libc3/binding.h libc3/bool.c libc3/bool.h libc3/set__tag.c libc3/set__tag.h libc3/set_item__tag.h libc3/set_item__tag.c libc3/set_cursor__tag.c libc3/set_cursor__tag.h libc3/skiplist_node__fact.c libc3/buf.c libc3/buf.h libc3/buf_file.c libc3/buf_file.h libc3/buf_inspect.c libc3/buf_inspect.h libc3/buf_parse.c libc3/buf_parse.h libc3/buf_parse_c.c libc3/buf_parse_c.h libc3/buf_save.c libc3/log.h libc3/skiplist_node__fact.h libc3/skiplist__fact.c libc3/skiplist__fact.h libc3/set_item__fact.c libc3/set_item__fact.h libc3/set__fact.c libc3/set__fact.h libc3/compare.c libc3/compare.h libc3/buf_save.h libc3/env.c libc3/env.h libc3/c_types.h libc3/call.c libc3/call.h libc3/character.c libc3/log.c libc3/error.c libc3/error.h libc3/error_handler.c libc3/error_handler.h libc3/eval.c libc3/eval.h libc3/fact.h libc3/facts.c libc3/facts.h libc3/facts_cursor.c libc3/facts_cursor.h libc3/facts_spec.c libc3/facts_spec.h libc3/facts_spec_cursor.c libc3/facts_spec_cursor.h libc3/character.h libc3/set_cursor__fact.c libc3/set_cursor__fact.h libc3/c3.c libc3/facts_with.c libc3/facts_with.h libc3/facts_with_cursor.c libc3/facts_with_cursor.h libc3/fn.c libc3/fn.h libc3/frame.c libc3/frame.h libc3/hash.c libc3/hash.h libc3/ident.c libc3/ident.h libc3/integer.c libc3/integer.h libc3/list.c libc3/list.h libc3/module.h libc3/quote.c libc3/quote.h libc3/types.h libc3/c3.h libc3/set.c.in libc3/set.h.in libc3/set_cursor.c.in libc3/set_cursor.h.in libc3/str.c libc3/set_item.c.in libc3/set_item.h.in libc3/fact.c libc3/skiplist.c.in libc3/skiplist.h.in libc3/skiplist_node.c.in libc3/skiplist_node.h.in libc3/str.h libc3/sym.c libc3/sym.h libc3/tag.c libc3/tuple.c libc3/tuple.h libc3/ucd.c libc3/ucd.h libc3/tag.h libc3/module.c libc3/sha1.h test/bool_test.c test/buf_file_test.c test/buf_inspect_test.c test/buf_parse_test.c test/buf_test.c test/call_test.c test/character_test.c test/hash_test.c test/fact_test.c test/fact_test.h test/facts_cursor_test.c test/facts_test.c test/facts_with_test.c test/ident_test.c test/libc3_test.c test/tuple_test.c test/list_test.c test/set__fact_test.c test/set__tag_test.c test/compare_test.h test/skiplist__fact_test.c test/str_test.c test/test.c test/test.h test/sym_test.c test/tag_test.c test/tag_test.h test/types_test.c test/compare_test.c ucd2c/ucd.h ucd2c/ucd2c.c '
+C3_C_SOURCES='c3c/c3c.c c3s/buf_readline.c c3s/c3s.c c3s/buf_readline.h ic3/buf_linenoise.c ic3/ic3.c ic3/buf_linenoise.h ic3/linenoise.c libc3/set__tag.c libc3/set_item__tag.c libc3/arg.c libc3/arg.h libc3/skiplist_node__fact.c libc3/set_cursor__tag.c libc3/binding.c libc3/binding.h libc3/set__tag.h libc3/set_item__tag.h libc3/skiplist_node__fact.h libc3/facts.c libc3/skiplist__fact.c libc3/skiplist__fact.h libc3/set_item__fact.h libc3/facts_with_cursor.c libc3/set_item__fact.c libc3/set__fact.c libc3/set_cursor__fact.c libc3/set__fact.h libc3/buf_file.c libc3/buf_file.h libc3/bool.c libc3/io.h libc3/call.h libc3/io.c libc3/buf_parse_c.c libc3/buf_parse_c.h libc3/buf_save.c libc3/buf_parse.c libc3/buf_parse.h libc3/buf_save.h libc3/fact.h libc3/c_types.h libc3/list.h libc3/buf_inspect.h libc3/bool.h libc3/c3.h libc3/character.h libc3/compare.c libc3/compare.h libc3/env.c libc3/ident.c libc3/error.c libc3/error.h libc3/error_handler.c libc3/buf.c libc3/env.h libc3/frame.c libc3/error_handler.h libc3/eval.c libc3/eval.h libc3/fact.c libc3/facts.h libc3/facts_cursor.c libc3/fn.h libc3/types.h libc3/call.c libc3/cfn.c libc3/facts_cursor.h libc3/facts_spec.c libc3/frame.h libc3/facts_spec.h libc3/facts_spec_cursor.c libc3/hash.c libc3/facts_spec_cursor.h libc3/facts_with.c libc3/facts_with.h libc3/hash.h libc3/buf.h libc3/cfn.h libc3/facts_with_cursor.h libc3/ident.h libc3/str.c libc3/c3.c libc3/integer.c libc3/list.c libc3/log.c libc3/log.h libc3/sym.h libc3/tag.c libc3/module.c libc3/quote.c libc3/quote.h libc3/integer.h libc3/character.c libc3/fn.c libc3/module.h libc3/set.c.in libc3/buf_inspect.c libc3/set_cursor__fact.h libc3/set_cursor__tag.h libc3/set.h.in libc3/set_cursor.c.in libc3/str.h libc3/tuple.h libc3/sym.c libc3/set_cursor.h.in libc3/ucd.c libc3/ucd.h libc3/set_item.c.in libc3/set_item.h.in libc3/sha1.h libc3/skiplist.c.in libc3/skiplist.h.in libc3/skiplist_node.c.in libc3/skiplist_node.h.in libc3/tag.h libc3/tuple.c test/bool_test.c test/buf_file_test.c test/buf_parse_test.c test/character_test.c test/facts_test.c test/buf_inspect_test.c test/test.c test/tag_test.c test/env_test.c test/fact_test.c test/compare_test.h test/fact_test.h test/str_test.c test/list_test.c test/facts_with_test.c test/test.h test/call_test.c test/ident_test.c test/libc3_test.c test/skiplist__fact_test.c test/set__fact_test.c test/set__tag_test.c test/facts_cursor_test.c test/tag_test.h test/sym_test.c test/hash_test.c test/tuple_test.c test/types_test.c test/buf_test.c test/compare_test.c ucd2c/ucd.h ucd2c/ucd2c.c '