From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Jan Nieuwenhuizen Newsgroups: gmane.lisp.guile.bugs Subject: bug#39162: [PATCH] Fix file lookup of modules with a dot in their name. Date: Fri, 17 Jan 2020 16:21:47 +0100 Message-ID: <875zhartv8.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="86088"; mail-complaints-to="usenet@ciao.gmane.io" To: 39162@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Fri Jan 17 16:29:54 2020 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1isTZJ-000MJz-2k for guile-bugs@m.gmane-mx.org; Fri, 17 Jan 2020 16:29:53 +0100 Original-Received: from localhost ([::1]:59114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isTZI-0006fI-1i for guile-bugs@m.gmane-mx.org; Fri, 17 Jan 2020 10:29:52 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36595) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isTYV-000615-PL for bug-guile@gnu.org; Fri, 17 Jan 2020 10:29:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1isTYU-0002fq-8F for bug-guile@gnu.org; Fri, 17 Jan 2020 10:29:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33978) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1isTYU-0002fb-4Q for bug-guile@gnu.org; Fri, 17 Jan 2020 10:29:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1isTYU-0007QN-0S for bug-guile@gnu.org; Fri, 17 Jan 2020 10:29:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jan Nieuwenhuizen Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 17 Jan 2020 15:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 39162 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.157927492928513 (code B ref -1); Fri, 17 Jan 2020 15:29:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 Jan 2020 15:28:49 +0000 Original-Received: from localhost ([127.0.0.1]:39950 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1isTYC-0007Pe-Uv for submit@debbugs.gnu.org; Fri, 17 Jan 2020 10:28:49 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:40280) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1isTYB-0007PX-Aw for submit@debbugs.gnu.org; Fri, 17 Jan 2020 10:28:43 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36515) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1isTY9-0005mH-6W for bug-guile@gnu.org; Fri, 17 Jan 2020 10:28:43 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:33321) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1isTY9-0002Rr-0X; Fri, 17 Jan 2020 10:28:41 -0500 Original-Received: from [2001:980:1b4f:1:42d2:832d:bb59:862] (port=50894 helo=dundal.peder.onsbrabantnet.nl) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1isTY6-0004u7-RF; Fri, 17 Jan 2020 10:28:39 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:9516 Archived-At: --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Fix-file-lookup-of-modules-with-a-dot-in-their-name.patch >From ad64e3e93b3f5f749d3e3949458ef9d19710b2ee Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen 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 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar=C2=AE http://AvatarAcademy.com --=-=-=--