Hello Guile! Much to my surprise, Guile (v2.2 and 3.0 alike) fail to load a module that has a dot in its base name. Directory names with dots (e.g. ice.10/boot-10.scm => (ice.10 boot-10)) are fine.
The attached patch now makes this work: --8<---------------cut here---------------start------------->8--- ;;; foo.bar.scm (display "foo.bar\n") (define-module (foo.bar)) (display "module: foo.bar\n") 16:15:31 janneke@dundal:~/src/guile [env] $ GUILE=meta/guile ./meta/guild compile foo.bar.scm -o foo.bar.go wrote `foo.bar.go' 16:15:46 janneke@dundal:~/src/guile [env] $ ./meta/guile -q -L . -C . -c '(use-modules (foo.bar))' foo.bar module: foo.bar 16:16:03 janneke@dundal:~/src/guile [env] --8<---------------cut here---------------end--------------->8--- The patch applies to 2.2 as 3.0 as well. The code that I removed has some comments about what the code is doing, but I fail to grasp any sort of why. Greetings, janneke
>From ad64e3e93b3f5f749d3e3949458ef9d19710b2ee Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen <jann...@gnu.org> Date: Fri, 17 Jan 2020 16:03:13 +0100 Subject: [PATCH] Fix file lookup of modules with a dot in their name. This fixes lookup of file foo.bar.go, loading (define-module (foo.bar)) ... * libguile/load.c (load_thunk_from_path): Remove code that decides foo.bar is not a valid module file base name. --- libguile/load.c | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/libguile/load.c b/libguile/load.c index e95c36db1..23409ebd5 100644 --- a/libguile/load.c +++ b/libguile/load.c @@ -649,7 +649,6 @@ load_thunk_from_path (SCM filename, SCM source_file_name, struct stringbuf buf; struct stat stat_buf; char *filename_chars; - size_t filename_len; SCM path, extensions; SCM result = SCM_BOOL_F; char initial_buffer[256]; @@ -667,7 +666,6 @@ load_thunk_from_path (SCM filename, SCM source_file_name, scm_dynwind_begin (0); filename_chars = scm_to_locale_string (filename); - filename_len = strlen (filename_chars); scm_dynwind_free (filename_chars); /* If FILENAME is absolute and is still valid, return it unchanged. */ @@ -680,38 +678,7 @@ load_thunk_from_path (SCM filename, SCM source_file_name, goto end; } - /* If FILENAME has an extension, don't try to add EXTENSIONS to it. */ - { - char *endp; - - for (endp = filename_chars + filename_len - 1; - endp >= filename_chars; - endp--) - { - if (*endp == '.') - { - if (!string_has_an_ext (filename, extensions)) - { - /* This filename has an extension, but not one of the right - ones... */ - goto end; - } - /* This filename already has an extension, so cancel the - list of extensions. */ - extensions = SCM_EOL; - break; - } - else if (is_file_name_separator (SCM_MAKE_CHAR (*endp))) - /* This filename has no extension, so keep the current list - of extensions. */ - break; - } - } - - /* This simplifies the loop below a bit. - */ - if (scm_is_null (extensions)) - extensions = scm_listofnullstr; + extensions = scm_append (scm_list_2 (extensions, scm_listofnullstr)); buf.buf_len = sizeof initial_buffer; buf.buf = initial_buffer; -- 2.24.1
-- Jan Nieuwenhuizen <jann...@gnu.org> | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com