GNU bug report logs - #39162
[PATCH] Fix file lookup of modules with a dot in their name.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guile; Reported by: Jan Nieuwenhuizen <janneke@HIDDEN>; Keywords: patch; dated Fri, 17 Jan 2020 15:29:01 UTC; Maintainer for guile is bug-guile@HIDDEN.

Message received at 39162 <at> debbugs.gnu.org:


Received: (at 39162) by debbugs.gnu.org; 21 Mar 2020 21:46:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 21 17:46:34 2020
Received: from localhost ([127.0.0.1]:48312 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jFlww-0007cb-Iz
	for submit <at> debbugs.gnu.org; Sat, 21 Mar 2020 17:46:34 -0400
Received: from eggs.gnu.org ([209.51.188.92]:40501)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1jFlwv-0007cM-Ek
 for 39162 <at> debbugs.gnu.org; Sat, 21 Mar 2020 17:46:33 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:51567)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>)
 id 1jFlwq-0008BI-8T; Sat, 21 Mar 2020 17:46:28 -0400
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=56246 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1jFlwn-0002sa-31; Sat, 21 Mar 2020 17:46:28 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Jan Nieuwenhuizen <janneke@HIDDEN>
Subject: Re: bug#39162: [PATCH] Fix file lookup of modules with a dot in their
 name.
References: <875zhartv8.fsf@HIDDEN>
Date: Sat, 21 Mar 2020 22:46:20 +0100
In-Reply-To: <875zhartv8.fsf@HIDDEN> (Jan Nieuwenhuizen's message of "Fri, 17
 Jan 2020 16:21:47 +0100")
Message-ID: <878sjtxtxv.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 39162
Cc: 39162 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Hi!

Jan Nieuwenhuizen <janneke@HIDDEN> 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 =3D> (ice.10 boot-10)) are fine.

[...]

> -  /* If FILENAME has an extension, don't try to add EXTENSIONS to it.  */
> -  {
> -    char *endp;
> -
> -    for (endp =3D filename_chars + filename_len - 1;
> -	 endp >=3D filename_chars;
> -	 endp--)
> -      {
> -	if (*endp =3D=3D '.')
> -	  {
> -            if (!string_has_an_ext (filename, extensions))
> -              {
> -                /* This filename has an extension, but not one of the ri=
ght
> -                   ones... */
> -                goto end;
> -              }
> -	    /* This filename already has an extension, so cancel the
> -               list of extensions.  */
> -	    extensions =3D 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 =E2=80=98%load-extensions=E2=80=99 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=E2=80=99t thin=
k 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=E2=80=99.




Information forwarded to bug-guile@HIDDEN:
bug#39162; Package guile. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 17 Jan 2020 15:28:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jan 17 10:28:49 2020
Received: from localhost ([127.0.0.1]:39950 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1isTYC-0007Pe-Uv
	for submit <at> debbugs.gnu.org; Fri, 17 Jan 2020 10:28:49 -0500
Received: from lists.gnu.org ([209.51.188.17]:40280)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <janneke@HIDDEN>) id 1isTYB-0007PX-Aw
 for submit <at> debbugs.gnu.org; Fri, 17 Jan 2020 10:28:43 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:36515)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <janneke@HIDDEN>) id 1isTY9-0005mH-6W
 for bug-guile@HIDDEN; Fri, 17 Jan 2020 10:28:43 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00,
 URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:470:142:3::e]:33321)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <janneke@HIDDEN>)
 id 1isTY9-0002Rr-0X; Fri, 17 Jan 2020 10:28:41 -0500
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 <janneke@HIDDEN>)
 id 1isTY6-0004u7-RF; Fri, 17 Jan 2020 10:28:39 -0500
From: Jan Nieuwenhuizen <janneke@HIDDEN>
To: bug-guile@HIDDEN
Subject: [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@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

--=-=-=
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 <janneke@HIDDEN>
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 <janneke@HIDDEN> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar=C2=AE http://AvatarAcademy.com

--=-=-=--




Acknowledgement sent to Jan Nieuwenhuizen <janneke@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guile@HIDDEN. Full text available.
Report forwarded to bug-guile@HIDDEN:
bug#39162; Package guile. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 21 Mar 2020 22:00:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.