GNU bug report logs -
#39162
[PATCH] Fix file lookup of modules with a dot in their name.
Previous Next
To reply to this bug, email your comments to 39162 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guile <at> gnu.org
:
bug#39162
; Package
guile
.
(Fri, 17 Jan 2020 15:29:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Jan Nieuwenhuizen <janneke <at> gnu.org>
:
New bug report received and forwarded. Copy sent to
bug-guile <at> gnu.org
.
(Fri, 17 Jan 2020 15:29:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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 <at> 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 <at> dundal:~/src/guile [env]
$ ./meta/guile -q -L . -C . -c '(use-modules (foo.bar))'
foo.bar
module: foo.bar
16:16:03 janneke <at> 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
[0001-Fix-file-lookup-of-modules-with-a-dot-in-their-name.patch (text/x-patch, inline)]
From ad64e3e93b3f5f749d3e3949458ef9d19710b2ee Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke <at> 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
[Message part 3 (text/plain, inline)]
--
Jan Nieuwenhuizen <janneke <at> gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com
Information forwarded
to
bug-guile <at> gnu.org
:
bug#39162
; Package
guile
.
(Sat, 21 Mar 2020 21:47:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 39162 <at> debbugs.gnu.org (full text, mbox):
Hi!
Jan Nieuwenhuizen <janneke <at> gnu.org> skribis:
> 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.
[...]
> - /* 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 code mostly dates back to 1999 (commit
563841768b8659dad87296be4ae9ce589cbe99d4). It has to do with the fact
that you can omit the extension when loading a file, in which case one
of those in ‘%load-extensions’ is picked up:
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (primitive-load-path "ice-9/q")
scheme@(ice-9 q)>
--8<---------------cut here---------------end--------------->8---
The usefulness of this mechanism is debatable :-), but I don’t think we
can change it during a stable release.
I wonder if there are other ways we could support file names with dots.
However, note that symbols containing dots are non-standard (R5RS does
not allow it.)
Thoughts?
Ludo’.
This bug report was last modified 5 years and 83 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.