Commit 48ef7ecdb6df1c55052a70d9952f9c4c725de4df

Thomas de Grivel 2024-08-05T13:52:44

fix httpd

diff --git a/libkc3/buf_parse.c b/libkc3/buf_parse.c
index 823fd36..bb7a0eb 100644
--- a/libkc3/buf_parse.c
+++ b/libkc3/buf_parse.c
@@ -3874,11 +3874,18 @@ sw buf_parse_tag_fn (s_buf *buf, s_tag *dest)
 sw buf_parse_tag_ident (s_buf *buf, s_tag *dest)
 {
   sw r;
+  const s_tag *tag;
   assert(buf);
   assert(dest);
   r = buf_parse_ident(buf, &dest->data.ident);
-  if (r > 0)
-    dest->type = TAG_IDENT;
+  if (r > 0) {
+    if (! dest->data.ident.module &&
+        (tag = frame_get(&g_kc3_env.read_time_frame,
+                         dest->data.ident.sym)))
+      tag_init_copy(dest, tag);
+    else
+      dest->type = TAG_IDENT;
+  }
   return r;
 }
 
diff --git a/libkc3/env.c b/libkc3/env.c
index 89c6da5..f637c00 100644
--- a/libkc3/env.c
+++ b/libkc3/env.c
@@ -2094,17 +2094,21 @@ s_env * env_init_globals (s_env *env)
 {
   s_tag *file_dir;
   s_tag *file_path;
-  if (! frame_init(&env->global_frame, NULL))
+  if (! frame_init(&env->read_time_frame, NULL))
     return NULL;
-  if (! (file_dir = frame_binding_new(&env->global_frame, &g_sym___DIR__)))
+  if (! (file_dir = frame_binding_new(&env->read_time_frame,
+                                      &g_sym___DIR__)))
     return NULL;
-  if (! (file_path = frame_binding_new(&env->global_frame, &g_sym___FILE__)))
+  if (! (file_path = frame_binding_new(&env->read_time_frame,
+                                       &g_sym___FILE__)))
     return NULL;
   file_dir->type = TAG_STR;
   if (! file_pwd(&file_dir->data.str))
     return NULL;
   if (! tag_init_str_1(file_path, NULL, "stdin"))
     return NULL;
+  if (! frame_init(&env->global_frame, &env->read_time_frame))
+    return NULL;
   return env;
 }
 
diff --git a/libkc3/frame.h b/libkc3/frame.h
index 5a97cac..fddd721 100644
--- a/libkc3/frame.h
+++ b/libkc3/frame.h
@@ -26,6 +26,9 @@ s_frame * frame_new (s_frame *next);
 s_frame * frame_delete (s_frame *frame);
 void      frame_delete_all (s_frame *frame);
 
+/* Observers. */
+const s_tag * frame_get (const s_frame *frame, const s_sym *sym);
+
 /* Operators. */
 s_tag *   frame_binding_new (s_frame *frame, const s_sym *name);
 s_frame * frame_binding_new_copy (s_frame *frame, const s_sym *name,
@@ -37,7 +40,4 @@ s_tag *   frame_get_w (s_frame *frame, const s_sym *sym);
 s_frame * frame_replace (s_frame *frame, const s_sym *sym,
                          const s_tag *value);
 
-/* Observers. */
-const s_tag * frame_get (const s_frame *frame, const s_sym *sym);
-
 #endif /* LIBKC3_FRAME_H */
diff --git a/libkc3/hash.c b/libkc3/hash.c
index b43842a..507e596 100644
--- a/libkc3/hash.c
+++ b/libkc3/hash.c
@@ -411,20 +411,17 @@ bool hash_update_struct (t_hash *hash, const s_struct *s)
       return false;
     if (! tag_type(s->type->map.value + i, &sym))
       return false;
-    if (s->data)
+    if (s->data) {
       data = (s8 *) s->data + s->type->offset[i];
+      if (! data_hash_update(sym, hash, data))
+        return false;
+    }
     else {
       if (s->tag) {
-        if (! tag_to_const_pointer(s->tag + i, sym, &data))
-          return false;
-      }
-      else {
-        if (! tag_to_const_pointer(s->type->map.value + i, sym, &data))
+        if (! hash_update_tag(hash, s->tag + i))
           return false;
       }
     }
-    if (! data_hash_update(sym, hash, data))
-      return false;
     i++;
   }
   return true;
diff --git a/libkc3/types.h b/libkc3/types.h
index c5caff9..e1e6c81 100644
--- a/libkc3/types.h
+++ b/libkc3/types.h
@@ -674,6 +674,7 @@ struct env {
   s_buf             out;
   s_list           *path;
   uw                quote_level;
+  s_frame           read_time_frame;
   s_list           *search_modules;
   s_list           *search_modules_default;
   uw                unquote_level;