From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.bugs Subject: bug#19540: repeated ./././ in compiled modules Date: Thu, 23 Jun 2016 10:36:41 +0200 Message-ID: <871t3oqp2e.fsf@pobox.com> References: <188846A3-246A-49DB-95F0-37FEE6903C85@alumni.caltech.edu> <877fwiy0q2.fsf@gnu.org> <093940B7-4480-4FD4-A0AD-0B19B6FEECDB@alumni.caltech.edu> <87iog117is.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1466671062 20580 80.91.229.3 (23 Jun 2016 08:37:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 23 Jun 2016 08:37:42 +0000 (UTC) Cc: 19540-done@debbugs.gnu.org, Matt Wette To: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Thu Jun 23 10:37:32 2016 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bG08i-0001DQ-6h for guile-bugs@m.gmane.org; Thu, 23 Jun 2016 10:37:32 +0200 Original-Received: from localhost ([::1]:35292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bG08h-0005zA-9H for guile-bugs@m.gmane.org; Thu, 23 Jun 2016 04:37:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bG08Q-0005s3-1H for bug-guile@gnu.org; Thu, 23 Jun 2016 04:37:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bG08E-00023D-JI for bug-guile@gnu.org; Thu, 23 Jun 2016 04:37:12 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bG08E-000234-Bs for bug-guile@gnu.org; Thu, 23 Jun 2016 04:37:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bG08E-0008BU-6M for bug-guile@gnu.org; Thu, 23 Jun 2016 04:37:02 -0400 Resent-From: Andy Wingo Original-Sender: "Debbugs-submit" Resent-To: bug-guile@gnu.org Resent-Date: Thu, 23 Jun 2016 08:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 19540 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Mail-Followup-To: 19540@debbugs.gnu.org, wingo@pobox.com, mwette@alumni.caltech.edu Original-Received: via spool by 19540-done@debbugs.gnu.org id=D19540.146667101331440 (code D ref 19540); Thu, 23 Jun 2016 08:37:01 +0000 Original-Received: (at 19540-done) by debbugs.gnu.org; 23 Jun 2016 08:36:53 +0000 Original-Received: from localhost ([127.0.0.1]:51759 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bG085-0008B2-H9 for submit@debbugs.gnu.org; Thu, 23 Jun 2016 04:36:53 -0400 Original-Received: from pb-sasl2.pobox.com ([64.147.108.67]:61328 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bG084-0008Au-5e for 19540-done@debbugs.gnu.org; Thu, 23 Jun 2016 04:36:52 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id 4ABD81EFAE; Thu, 23 Jun 2016 04:36:49 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; s=sasl; bh=mBm3JbusKNyv offUh9yVD2BzuLI=; b=heXHCdhEy9MrjOzObb5Ju6GTy9NNdZIdN6azR/4LO44Q uO2gpqX+At5PwqJX4s99DYoVXiIShz9zyNMTfpHyybgB+UgfVgrFkmGASNbMsaIB FnvwFE+zwSHeYpOcA3TA/MoWU+a+nCfZBZJAX0DXnBX/JtL4sP8L4IzvPrneDQE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=sasl; b=cv5htG kcDLpZ1TtWhRYiVuI4G8R7YK4MjINDe4WRbDf/Q/PDtVCsmOHolhbj/JoLupMPx0 dBx3Yva5KTi3MpvkJihslrmfLuLKlv2ZGkp0WFHX0m1l+VCGW5cFUnmI2p3VoaEO 30wywUC4cyxTycPKbd+kyqbUCtpyFsVhoQe3M= Original-Received: from pb-sasl2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl2.pobox.com (Postfix) with ESMTP id 41E041EFAB; Thu, 23 Jun 2016 04:36:49 -0400 (EDT) Original-Received: from clucks (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl2.pobox.com (Postfix) with ESMTPSA id 4644F1EFAA; Thu, 23 Jun 2016 04:36:48 -0400 (EDT) In-Reply-To: <87iog117is.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Tue, 20 Jan 2015 22:12:11 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-Pobox-Relay-ID: A02FD256-391D-11E6-BEB6-28A6F1301B6D-02397024!pb-sasl2.pobox.com 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: 208.118.235.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.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.org gmane.lisp.guile.bugs:8147 Archived-At: Hi! On Tue 20 Jan 2015 22:12, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > scheme@(guile-user)> (add-to-load-path ".") > scheme@(guile-user)> %load-path > $2 =3D ("." [...]) > scheme@(guile-user)> (getcwd) > $3 =3D "/home/ludo/src/guile/module/ice-9" > scheme@(guile-user)> (open-input-file (search-path %load-path "boot-9.scm= ")) > $4 =3D # > scheme@(guile-user)> (open-input-file (search-path %load-path "./boot-9.s= cm")) > $5 =3D # > scheme@(guile-user)> (open-input-file (search-path %load-path "././boot-9= .scm")) > $6 =3D # > > This could be fixed either in =E2=80=98search-path=E2=80=99 or in > =E2=80=98scm_i_relativize_path=E2=80=99, but the former sounds like a bet= ter place. I think the latter is actually better. `relativize-path' tries to find an element of %load-path which is a prefix of *the canonicalized version of* a file name. We can't expect that to work unless we also canonicalize the elements of %load-path, for the purposes of relativizing. We don't want to canonicalize them eagerly or persistently, as that would access symlinks at the wrong time; just as needed inside relativize-path. I pushed the attached fix to master. If it sounds good to you let's push it to stable-2.0 as well. WDYT? Andy commit 9a951678713557b548415d32eae6d63d039bf652 Author: Andy Wingo Date: Thu Jun 23 10:03:10 2016 +0200 Fix relative file name canonicalization on paths with "." =20=20=20=20 * libguile/filesys.c (scm_i_relativize_path): Canonicalize the file names elements that we will be using as prefixes. Fixes the case where a load path contains a relative file name: #19540. * test-suite/tests/ports.test ("%file-port-name-canonicalization"): Add tests that elements of the load path are canonicalized. diff --git a/libguile/filesys.c b/libguile/filesys.c index 7674498..25501ef 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -1614,22 +1614,40 @@ SCM_DEFINE (scm_canonicalize_path, "canonicalize-pa= th", 1, 0, 0, SCM scm_i_relativize_path (SCM path, SCM in_path) { - char *str, *canon; SCM scanon; =20=20=20 - str =3D scm_to_locale_string (path); - canon =3D canonicalize_file_name (str); - free (str); -=20=20 - if (!canon) - return SCM_BOOL_F; + { + char *str, *canon; =20 - scanon =3D scm_take_locale_string (canon); + str =3D scm_to_locale_string (path); + canon =3D canonicalize_file_name (str); + free (str); =20 + if (!canon) + return SCM_BOOL_F; + + scanon =3D scm_take_locale_string (canon); + } +=20=20 for (; scm_is_pair (in_path); in_path =3D scm_cdr (in_path)) { SCM dir =3D scm_car (in_path); - size_t len =3D scm_c_string_length (dir); + size_t len; + + /* Try to canonicalize DIR, since we have canonicalized PATH. */ + { + char *str, *canon; + + str =3D scm_to_locale_string (dir); + canon =3D canonicalize_file_name (str); + free (str); +=20=20 + if (canon) + dir =3D scm_from_locale_string (canon); + free (canon); + } + + len =3D scm_c_string_length (dir); =20 /* When DIR is empty, it means "current working directory". We could set DIR to (getcwd) in that case, but then the diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test index dfa430e..ea8eaa7 100644 --- a/test-suite/tests/ports.test +++ b/test-suite/tests/ports.test @@ -1865,14 +1865,15 @@ (with-fluids ((%file-port-name-canonicalization 'relative)) (port-filename (open-input-file "/dev/null"))))) =20 + (pass-if-equal "relative canonicalization with /dev/.." "dev/null" + (with-load-path (cons "/dev/.." %load-path) + (with-fluids ((%file-port-name-canonicalization 'relative)) + (port-filename (open-input-file "/dev/null"))))) + (pass-if-equal "relative canonicalization from ice-9" "ice-9/q.scm" - ;; If an entry in %LOAD-PATH is not canonical, then - ;; `scm_i_relativize_path' is unable to do its job. - (if (equal? (map canonicalize-path %load-path) %load-path) - (with-fluids ((%file-port-name-canonicalization 'relative)) - (port-filename - (open-input-file (%search-load-path "ice-9/q.scm")))) - (throw 'unresolved))) + (with-fluids ((%file-port-name-canonicalization 'relative)) + (port-filename + (open-input-file (%search-load-path "ice-9/q.scm"))))) =20 (pass-if-equal "absolute canonicalization from ice-9" (canonicalize-path