Commit 56fef92e91630520e9ec5d0126a194a9970f902e

Thomas de Grivel 2023-08-29T15:21:38

wip

diff --git a/ic3/configure b/ic3/configure
index 338d290..8a0c883 100755
--- a/ic3/configure
+++ b/ic3/configure
@@ -43,6 +43,9 @@ CPPFLAGS="${CPPFLAGS:=}"
 ENV_CFLAGS="${CFLAGS:=}"
 DEFAULT_CFLAGS="-O2 -pipe -fPIC"
 LDFLAGS="${LDFLAGS}"
+if [ "x$CC" != "xtcc" ]; then
+    LDFLAGS="-Wl,--allow-shlib-undefined ${LDFLAGS}"
+fi
 LIBS="${LIBS:=-lm}"
 
 # Common config for all targets
diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index 79cd2b9..bbe3a6e 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -444,9 +444,6 @@ sw buf_parse_brackets (s_buf *buf, s_call *dest)
     goto restore;
   result += r;
   while (1) {
-    if ((r = buf_ignore_spaces(buf)) < 0)
-      goto restore;
-    result += r;
     if ((r = buf_read_1(buf, "[")) < 0)
       goto restore;
     if (! r)
diff --git a/libc3/call.c b/libc3/call.c
index 90255aa..c9a99a8 100644
--- a/libc3/call.c
+++ b/libc3/call.c
@@ -68,7 +68,6 @@ bool call_get (s_call *call, s_facts *facts)
   tag_init_sym(  &tag_sym, call->ident.sym);
   tag_init_1(    &tag_symbol,   ":symbol");
   tag_init_var(  &tag_var);
-  facts_with_cursor_clean(&cursor);
   facts_with(facts, &cursor, (t_facts_spec) {
       &tag_module_name,
       &tag_symbol, &tag_ident,    /* module exports symbol */
diff --git a/libc3/ident.c b/libc3/ident.c
index 2959628..1641321 100644
--- a/libc3/ident.c
+++ b/libc3/ident.c
@@ -14,6 +14,7 @@
 #include "buf.h"
 #include "buf_inspect.h"
 #include "character.h"
+#include "env.h"
 #include "facts_with.h"
 #include "facts_with_cursor.h"
 #include "module.h"
@@ -61,6 +62,7 @@ bool ident_first_character_is_reserved (character c)
 s_tag * ident_get (const s_ident *ident, s_facts *facts, s_tag *dest)
 {
   s_facts_with_cursor cursor;
+  const s_sym *module;
   s_tag tag_cfn;
   s_tag tag_fn;
   s_tag tag_ident;
@@ -71,7 +73,10 @@ s_tag * ident_get (const s_ident *ident, s_facts *facts, s_tag *dest)
   s_tag tag_sym;
   s_tag tag_symbol;
   s_tag tag_var;
-  if (! module_ensure_loaded(ident->module_name, facts))
+  module = ident->module_name;
+  if (! module)
+    module = g_c3_env.current_module;
+  if (! module_ensure_loaded(module, facts))
     return NULL;
   tag_init_1(    &tag_cfn,      ":cfn");
   tag_init_1(    &tag_fn,       ":fn");
@@ -82,15 +87,14 @@ s_tag * ident_get (const s_ident *ident, s_facts *facts, s_tag *dest)
   tag_init_sym(  &tag_sym, ident->sym);
   tag_init_1(    &tag_symbol,   ":symbol");
   tag_init_var(  &tag_var);
-  facts_with_cursor_clean(&cursor);
   facts_with(facts, &cursor, (t_facts_spec) {
       &tag_module_name,
       &tag_symbol, &tag_ident,    /* module exports symbol */
       NULL, NULL });
   if (! facts_with_cursor_next(&cursor)) {
-    warnx("symbol %s not found in module %s",
+    /*warnx("symbol %s not found in module %s",
           ident->sym->str.ptr.ps8,
-          ident->module_name->str.ptr.ps8);
+          module->str.ptr.ps8);*/
     facts_with_cursor_clean(&cursor);
     return NULL;
   }
@@ -101,7 +105,7 @@ s_tag * ident_get (const s_ident *ident, s_facts *facts, s_tag *dest)
   if (facts_with_cursor_next(&cursor)) {
     if (tag_var.type != TAG_CFN) {
       warnx("%s.%s is not a C function",
-            ident->module_name->str.ptr.ps8,
+            module->str.ptr.ps8,
             ident->sym->str.ptr.ps8);
       facts_with_cursor_clean(&cursor);
       return NULL;
@@ -115,7 +119,7 @@ s_tag * ident_get (const s_ident *ident, s_facts *facts, s_tag *dest)
     if (facts_with_cursor_next(&cursor)) {
       if (tag_var.type != TAG_FN) {
         warnx("%s.%s is not a function",
-              ident->module_name->str.ptr.ps8,
+              module->str.ptr.ps8,
               ident->sym->str.ptr.ps8);
         facts_with_cursor_clean(&cursor);
         return NULL;
diff --git a/test/configure b/test/configure
index c2addd4..096292d 100755
--- a/test/configure
+++ b/test/configure
@@ -43,6 +43,9 @@ CPPFLAGS="${CPPFLAGS:=}"
 ENV_CFLAGS="${CFLAGS:=}"
 DEFAULT_CFLAGS="-O2 -pipe"
 LDFLAGS="${LDFLAGS}"
+if [ "x$CC" != "xtcc" ]; then
+    LDFLAGS="-Wl,--allow-shlib-undefined ${LDFLAGS}"
+fi
 LIBS="${LIBS:=} -lm"
 
 # Common config for all targets