Commit 57e770d617e15e217b6c175a1c64f46a2a34e8ff

Thomas de Grivel 2024-08-03T14:35:31

list_has

diff --git a/libkc3/env.c b/libkc3/env.c
index 012e680..472d9f8 100644
--- a/libkc3/env.c
+++ b/libkc3/env.c
@@ -1200,6 +1200,7 @@ bool env_eval_ident (s_env *env, const s_ident *ident, s_tag *dest)
   s_ident tmp_ident;
   assert(env);
   assert(ident);
+  assert(dest);
   if ((tag = env_frames_get(env, ident->sym))) {
     tag_init_copy(dest, tag);
     return true;
diff --git a/libkc3/list.c b/libkc3/list.c
index 1a3b6ae..e9c1af1 100644
--- a/libkc3/list.c
+++ b/libkc3/list.c
@@ -17,6 +17,7 @@
 #include "buf.h"
 #include "buf_inspect.h"
 #include "buf_parse.h"
+#include "compare.h"
 #include "data.h"
 #include "list.h"
 #include "sym.h"
@@ -57,6 +58,18 @@ void list_f_clean (s_list **list)
     l = list_delete(l);
 }
 
+bool list_has (const s_list *list, const s_tag *tag)
+{
+  const s_list *l;
+  l = list;
+  while (l) {
+    if (! compare_tag(tag, &l->tag))
+      return true;
+    l = list_next(l);
+  }
+  return false;
+}
+
 s_list * list_init (s_list *list, s_list *next)
 {
   assert(list);