|
From: | GNU bug Tracking System |
Subject: | [debbugs-tracker] bug#19540: closed (minor: module path picking up ./././...) |
Date: | Thu, 23 Jun 2016 08:37:02 +0000 |
Your message dated Thu, 23 Jun 2016 10:36:41 +0200 with message-id <address@hidden> and subject line Re: bug#19540: repeated ./././ in compiled modules has caused the debbugs.gnu.org bug report #19540, regarding minor: module path picking up ./././... to be marked as done. (If you believe you have received this mail in error, please contact address@hidden) -- 19540: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=19540 GNU Bug Tracking System Contact address@hidden with problems
--- Begin Message ---Subject: minor: module path picking up ./././... Date: Thu, 08 Jan 2015 20:13:18 -0800
guile 2.0.11 on macos (darwin) 10.9.5.This seems very minor to but I thought I'd report it. If I ",reload" a module in the current directory it seems to pick up extra "./" parts in the path....;;; compiling ././././././././././././lalr1.scm;;; compiled /Users/mwette/.cache/guile/ccache/2.0-LE-8-2.0/Users/mwette/proj/scheme/myproj/lalr1/lalr1.scm.goscheme@(guile-user)> (system "touch lalr1.scm")$5 = 0scheme@(guile-user)> ,reload (lalr1);;; note: source file ./././././././././././././lalr1.scm;;; newer than compiled /Users/mwette/.cache/guile/ccache/2.0-LE-8-2.0/Users/mwette/proj/scheme/myproj/lalr1/lalr1.scm.go;;; compiling ./././././././././././././lalr1.scm;;; compiled /Users/mwette/.cache/guile/ccache/2.0-LE-8-2.0/Users/mwette/proj/scheme/myproj/lalr1/lalr1.scm.goscheme@(guile-user)> (system "touch lalr1.scm")$6 = 0scheme@(guile-user)> ,reload (lalr1);;; note: source file ././././././././././././././lalr1.scm;;; newer than compiled /Users/mwette/.cache/guile/ccache/2.0-LE-8-2.0/Users/mwette/proj/scheme/myproj/lalr1/lalr1.scm.go;;; compiling ././././././././././././././lalr1.scm;;; compiled /Users/mwette/.cache/guile/ccache/2.0-LE-8-2.0/Users/mwette/proj/scheme/myproj/lalr1/lalr1.scm.goscheme@(guile-user)>
--- End Message ---
--- Begin Message ---Subject: Re: bug#19540: repeated ./././ in compiled modules Date: Thu, 23 Jun 2016 10:36:41 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Hi! On Tue 20 Jan 2015 22:12, address@hidden (Ludovic Courtès) writes: > scheme@(guile-user)> (add-to-load-path ".") > scheme@(guile-user)> %load-path > $2 = ("." [...]) > scheme@(guile-user)> (getcwd) > $3 = "/home/ludo/src/guile/module/ice-9" > scheme@(guile-user)> (open-input-file (search-path %load-path "boot-9.scm")) > $4 = #<input: ./boot-9.scm 11> > scheme@(guile-user)> (open-input-file (search-path %load-path "./boot-9.scm")) > $5 = #<input: ././boot-9.scm 12> > scheme@(guile-user)> (open-input-file (search-path %load-path > "././boot-9.scm")) > $6 = #<input: ./././boot-9.scm 13> > > This could be fixed either in ‘search-path’ or in > ‘scm_i_relativize_path’, but the former sounds like a better 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 <address@hidden> Date: Thu Jun 23 10:03:10 2016 +0200 Fix relative file name canonicalization on paths with "." * 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-path", 1, 0, 0, SCM scm_i_relativize_path (SCM path, SCM in_path) { - char *str, *canon; SCM scanon; - str = scm_to_locale_string (path); - canon = canonicalize_file_name (str); - free (str); - - if (!canon) - return SCM_BOOL_F; + { + char *str, *canon; - scanon = scm_take_locale_string (canon); + str = scm_to_locale_string (path); + canon = canonicalize_file_name (str); + free (str); + if (!canon) + return SCM_BOOL_F; + + scanon = scm_take_locale_string (canon); + } + for (; scm_is_pair (in_path); in_path = scm_cdr (in_path)) { SCM dir = scm_car (in_path); - size_t len = scm_c_string_length (dir); + size_t len; + + /* Try to canonicalize DIR, since we have canonicalized PATH. */ + { + char *str, *canon; + + str = scm_to_locale_string (dir); + canon = canonicalize_file_name (str); + free (str); + + if (canon) + dir = scm_from_locale_string (canon); + free (canon); + } + + len = scm_c_string_length (dir); /* 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"))))) + (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"))))) (pass-if-equal "absolute canonicalization from ice-9" (canonicalize-path
--- End Message ---
[Prev in Thread] | Current Thread | [Next in Thread] |