Commit 8014ec3b88151e5aa770a5285ba2091d0c5936c3

Baptiste 2024-08-06T15:07:46

wip tests asan

diff --git a/libkc3/buf_parse.c b/libkc3/buf_parse.c
index bb7a0eb..9b7755c 100644
--- a/libkc3/buf_parse.c
+++ b/libkc3/buf_parse.c
@@ -2265,8 +2265,7 @@ sw buf_parse_integer_unsigned_dec (s_buf *buf, s_integer *dest)
   if ((r = buf_parse_digit_dec(buf, &digit)) <= 0)
     goto clean;
   result += r;
-  integer_init_zero(dest);
-  if (mp_add_d(&dest->mp_int, digit, &dest->mp_int) != MP_OKAY)
+  if (! integer_init_u8(dest, digit))
     goto error;
   while ((r = buf_read_1(buf, "_")) >= 0 &&
          (result += r,
diff --git a/libkc3/env.c b/libkc3/env.c
index f637c00..b24b6bc 100644
--- a/libkc3/env.c
+++ b/libkc3/env.c
@@ -188,6 +188,7 @@ void env_clean (s_env *env)
 void env_clean_globals (s_env *env)
 {
   frame_clean(&env->global_frame);
+  frame_clean(&env->read_time_frame);
 }
 
 void env_clean_toplevel (s_env *env)
diff --git a/libkc3/tag.c b/libkc3/tag.c
index 7f82832..8e34552 100644
--- a/libkc3/tag.c
+++ b/libkc3/tag.c
@@ -569,22 +569,54 @@ s_tag * tag_integer_reduce (s_tag *tag)
     i = &tag->data.integer;
     if (compare_integer(i, &u64_max) > 0)
       return tag;
-    if (compare_integer(i, &u32_max) > 0)
-      return tag_init_u64(tag, integer_to_u64(i));
-    if (compare_integer(i, &u16_max) > 0)
-      return tag_init_u32(tag, integer_to_u32(i));
-    if (compare_integer(i, &u8_max) > 0)
-      return tag_init_u16(tag, integer_to_u16(i));
-    if (compare_integer(i, &zero) >= 0)
-      return tag_init_u8(tag, integer_to_u8(i));
-    if (compare_integer(i, &s8_min) >= 0)
-      return tag_init_s8(tag, integer_to_s8(i));
-    if (compare_integer(i, &s16_min) >= 0)
-      return tag_init_s16(tag, integer_to_s16(i));
-    if (compare_integer(i, &s32_min) >= 0)
-      return tag_init_s32(tag, integer_to_s32(i));
-    if (compare_integer(i, &s64_min) >= 0)
-      return tag_init_s64(tag, integer_to_s64(i));
+    if (compare_integer(i, &u32_max) > 0) {
+      j = tag->data.integer;
+      tag_init_u64(tag, integer_to_u64(&j));
+      integer_clean(&j);
+      return tag;
+    }
+    if (compare_integer(i, &u16_max) > 0) {
+      j = tag->data.integer;
+      tag_init_u32(tag, integer_to_u32(&j));
+      integer_clean(&j);
+      return tag;
+    }
+    if (compare_integer(i, &u8_max) > 0) {
+      j = tag->data.integer;
+      tag_init_u16(tag, integer_to_u16(&j));
+      integer_clean(&j);
+      return tag;
+    }
+    if (compare_integer(i, &zero) >= 0) {
+      j = tag->data.integer;
+      tag_init_u8(tag, integer_to_u8(&j));
+      integer_clean(&j);
+      return tag;
+    }
+    if (compare_integer(i, &s8_min) >= 0) {
+      j = tag->data.integer;
+      tag_init_s8(tag, integer_to_s8(&j));
+      integer_clean(&j);
+      return tag;
+    }
+    if (compare_integer(i, &s16_min) >= 0) {
+      j = tag->data.integer;
+      tag_init_s16(tag, integer_to_s16(&j));
+      integer_clean(&j);
+      return tag;
+    }
+    if (compare_integer(i, &s32_min) >= 0) {
+      j = tag->data.integer;
+      tag_init_s32(tag, integer_to_s32(&j));
+      integer_clean(&j);
+      return tag;
+    }
+    if (compare_integer(i, &s64_min) >= 0) {
+      j = tag->data.integer;
+      tag_init_s64(tag, integer_to_s64(&j));
+      integer_clean(&j);
+      return tag;
+    }
     return tag;
   case TAG_S8:
     integer_init_s8(&j, tag->data.s8);
diff --git a/misc/Makefile b/misc/Makefile
index 359fe4e..a233ae0 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -30,7 +30,7 @@ http_response_offsets: http_response_offsets.c
 	${CC} ${CPPFLAGS} -I.. http_response_offsets.c -o http_response_offsets
 
 print_limits: print_limits.c
-	libtool --mode=link ${CC} ${CPPFLAGS} -I.. print_limits.c -L../libkc3 -lkc3 -o print_limits
+	libtool --mode=link --tag=CC ${CC} ${CPPFLAGS} -I.. print_limits.c -L../libkc3 -lkc3 -o print_limits
 
 .PHONY: \
 	all \