summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--libguile/ChangeLog6
-rw-r--r--libguile/modules.c26
-rw-r--r--test-suite/ChangeLog6
-rw-r--r--test-suite/standalone/.cvsignore1
-rw-r--r--test-suite/standalone/Makefile.am6
6 files changed, 34 insertions, 12 deletions
diff --git a/NEWS b/NEWS
index 170a558c8..9babe4da5 100644
--- a/NEWS
+++ b/NEWS
@@ -48,6 +48,7 @@ backtrace of a stack with a promise object (made by `delay') in it.
** Fixed a build problem on AIX (use of func_data identifier)
** Fixed a segmentation fault which occurred when hashx-ref or hashx-set! was
called with an associator proc that returns neither a pair nor #f.
+** Secondary threads now always return a valid module for (current-module).
* New modules (see the manual for details)
diff --git a/libguile/ChangeLog b/libguile/ChangeLog
index 3b53a1817..8626580d1 100644
--- a/libguile/ChangeLog
+++ b/libguile/ChangeLog
@@ -1,3 +1,9 @@
+2008-02-01 Neil Jerram <neil@ossau.uklinux.net>
+
+ * modules.c (the_root_module): Moved before scm_current_module.
+ (scm_current_module): Return the root module if `the-module' fluid
+ gives #f.
+
2008-01-22 Neil Jerram <neil@ossau.uklinux.net>
* COPYING: Removed.
diff --git a/libguile/modules.c b/libguile/modules.c
index 003fbd37b..ea7305c17 100644
--- a/libguile/modules.c
+++ b/libguile/modules.c
@@ -40,12 +40,25 @@ scm_t_bits scm_module_tag;
static SCM the_module;
+static SCM the_root_module_var;
+
+static SCM
+the_root_module ()
+{
+ if (scm_module_system_booted_p)
+ return SCM_VARIABLE_REF (the_root_module_var);
+ else
+ return SCM_BOOL_F;
+}
+
SCM_DEFINE (scm_current_module, "current-module", 0, 0, 0,
(),
"Return the current module.")
#define FUNC_NAME s_scm_current_module
{
- return scm_fluid_ref (the_module);
+ SCM curr = scm_fluid_ref (the_module);
+
+ return scm_is_true (curr) ? curr : the_root_module ();
}
#undef FUNC_NAME
@@ -230,17 +243,6 @@ scm_env_top_level (SCM env)
SCM_SYMBOL (sym_module, "module");
-static SCM the_root_module_var;
-
-static SCM
-the_root_module ()
-{
- if (scm_module_system_booted_p)
- return SCM_VARIABLE_REF (the_root_module_var);
- else
- return SCM_BOOL_F;
-}
-
SCM
scm_lookup_closure_module (SCM proc)
{
diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog
index b8b717e6a..5040c164d 100644
--- a/test-suite/ChangeLog
+++ b/test-suite/ChangeLog
@@ -1,3 +1,9 @@
+2008-02-01 Neil Jerram <neil@ossau.uklinux.net>
+
+ * standalone/Makefile.am: Add stanza for test-with-guile-module.
+
+ * standalone/test-with-guile-module.c: New test.
+
2008-01-22 Neil Jerram <neil@ossau.uklinux.net>
* COPYING: Removed.
diff --git a/test-suite/standalone/.cvsignore b/test-suite/standalone/.cvsignore
index 49fe7fee0..4b495e986 100644
--- a/test-suite/standalone/.cvsignore
+++ b/test-suite/standalone/.cvsignore
@@ -11,3 +11,4 @@ test-num2integral
test-round
test-unwind
test-list
+test-with-guile-module
diff --git a/test-suite/standalone/Makefile.am b/test-suite/standalone/Makefile.am
index 13a4c3935..44bf0f04b 100644
--- a/test-suite/standalone/Makefile.am
+++ b/test-suite/standalone/Makefile.am
@@ -110,6 +110,12 @@ TESTS += test-conversion
check_SCRIPTS += test-use-srfi
TESTS += test-use-srfi
+# test-with-guile-module
+test_with_guile_module_CFLAGS = ${test_cflags}
+test_with_guile_module_LDADD = ${top_builddir}/libguile/libguile.la
+check_PROGRAMS += test-with-guile-module
+TESTS += test-with-guile-module
+
all-local:
cd ${srcdir} && chmod u+x ${check_SCRIPTS}