From: Jan Nieuwenhuizen <janneke@gnu.org>
To: 39162@debbugs.gnu.org
Subject: bug#39162: [PATCH] Fix file lookup of modules with a dot in their name.
Date: Fri, 17 Jan 2020 16:21:47 +0100 [thread overview]
Message-ID: <875zhartv8.fsf@gnu.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 934 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-file-lookup-of-modules-with-a-dot-in-their-name.patch --]
[-- Type: text/x-patch, Size: 2402 bytes --]
From ad64e3e93b3f5f749d3e3949458ef9d19710b2ee Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@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
[-- Attachment #3: Type: text/plain, Size: 152 bytes --]
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
next reply other threads:[~2020-01-17 15:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-17 15:21 Jan Nieuwenhuizen [this message]
2020-03-21 21:46 ` bug#39162: [PATCH] Fix file lookup of modules with a dot in their name Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=875zhartv8.fsf@gnu.org \
--to=janneke@gnu.org \
--cc=39162@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).