guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.5-155-g20e2d


From: Ludovic Courtès
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.5-155-g20e2d63
Date: Tue, 15 May 2012 17:12:52 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=20e2d6380426088c21d0c7bd8211f2bee780a26c

The branch, stable-2.0 has been updated
       via  20e2d6380426088c21d0c7bd8211f2bee780a26c (commit)
       via  2ae7b7b6c3e049aaba43c884d5c1d0c5f741cd16 (commit)
      from  4eaf64cd462ef7730e17299e60f578100ff9c032 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 20e2d6380426088c21d0c7bd8211f2bee780a26c
Author: Ludovic Courtès <address@hidden>
Date:   Tue May 15 19:12:39 2012 +0200

    Add more `%file-port-name-canonicalization' tests.
    
    * test-suite/tests/ports.test ("%file-port-name-canonicalization")["relative
      canonicalization with /", "relative canonicalization from ice-9",
      "absolute canonicalization from ice-9"]: New tests.

commit 2ae7b7b6c3e049aaba43c884d5c1d0c5f741cd16
Author: Ludovic Courtès <address@hidden>
Date:   Tue May 15 19:05:37 2012 +0200

    Fix relative file name canonicalization with empty %LOAD-PATH entries.
    
    * libguile/filesys.c (scm_i_relativize_path): Don't attempt to
      canonicalize when encountering an entry of IN_PATH that is the empty
      string.
    
    * test-suite/tests/ports.test (with-load-path): New macro.
      ("%file-port-name-canonicalization"): New test prefix.

-----------------------------------------------------------------------

Summary of changes:
 libguile/filesys.c          |   52 ++++++++++++++++++++++++------------------
 test-suite/tests/ports.test |   44 ++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 22 deletions(-)

diff --git a/libguile/filesys.c b/libguile/filesys.c
index 0211010..514c1ae 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -1587,32 +1587,40 @@ scm_i_relativize_path (SCM path, SCM in_path)
   scanon = scm_take_locale_string (canon);
 
   for (; scm_is_pair (in_path); in_path = scm_cdr (in_path))
-    if (scm_is_true (scm_string_prefix_p (scm_car (in_path),
-                                          scanon,
-                                          SCM_UNDEFINED, SCM_UNDEFINED,
-                                          SCM_UNDEFINED, SCM_UNDEFINED)))
-      {
-        size_t len = scm_c_string_length (scm_car (in_path));
-
-        /* The path either has a trailing delimiter or doesn't. scanon will be
-           delimited by single delimiters. In the case in which the path does
-           not have a trailing delimiter, add one to the length to strip off 
the
-           delimiter within scanon. */
-        if (!len
+    {
+      SCM dir = scm_car (in_path);
+      size_t 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
+        canonicalization would depend on the current directory, which
+        is not what we want in the context of `compile-file', for
+        instance.  */
+      if (len > 0
+         && scm_is_true (scm_string_prefix_p (dir, scanon,
+                                              SCM_UNDEFINED, SCM_UNDEFINED,
+                                              SCM_UNDEFINED, SCM_UNDEFINED)))
+       {
+         /* DIR either has a trailing delimiter or doesn't.  SCANON
+            will be delimited by single delimiters.  When DIR does not
+            have a trailing delimiter, add one to the length to strip
+            off the delimiter within SCANON.  */
+         if (
 #ifdef __MINGW32__
-            || (scm_i_string_ref (scm_car (in_path), len - 1) != '/'
-                && scm_i_string_ref (scm_car (in_path), len - 1) != '\\')
+             (scm_i_string_ref (dir, len - 1) != '/'
+              && scm_i_string_ref (dir, len - 1) != '\\')
 #else
-            || scm_i_string_ref (scm_car (in_path), len - 1) != '/'
+             scm_i_string_ref (dir, len - 1) != '/'
 #endif
-            )
-          len++;
+             )
+           len++;
 
-        if (scm_c_string_length (scanon) > len)
-          return scm_substring (scanon, scm_from_size_t (len), SCM_UNDEFINED);
-        else
-          return SCM_BOOL_F;
-      }
+         if (scm_c_string_length (scanon) > len)
+           return scm_substring (scanon, scm_from_size_t (len), SCM_UNDEFINED);
+         else
+           return SCM_BOOL_F;
+       }
+    }
 
   return SCM_BOOL_F;
 }
diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test
index 5ca416d..2aec1f0 100644
--- a/test-suite/tests/ports.test
+++ b/test-suite/tests/ports.test
@@ -1087,8 +1087,52 @@
                         (and (= line line*)
                              (= col col*)))))))))))
 
+
+
+(define-syntax-rule (with-load-path path body ...)
+  (let ((new path)
+        (old %load-path))
+    (dynamic-wind
+      (lambda ()
+        (set! %load-path new))
+      (lambda ()
+        body ...)
+      (lambda ()
+        (set! %load-path old)))))
+
+(with-test-prefix "%file-port-name-canonicalization"
+
+  (pass-if "absolute file name & empty %load-path entry"
+    ;; In Guile 2.0.5 and earlier, this would return "dev/null" instead
+    ;; of "/dev/null".  See
+    ;; <http://lists.gnu.org/archive/html/guile-devel/2012-05/msg00059.html>
+    ;; for a discussion.
+    (equal? "/dev/null"
+            (with-load-path (cons "" (delete "/" %load-path))
+              (with-fluids ((%file-port-name-canonicalization 'relative))
+                (port-filename (open-input-file "/dev/null"))))))
+
+  (pass-if "relative canonicalization with /"
+    (equal? "dev/null"
+            (with-load-path (cons "/" %load-path)
+              (with-fluids ((%file-port-name-canonicalization 'relative))
+                (port-filename (open-input-file "/dev/null"))))))
+
+  (pass-if "relative canonicalization from ice-9"
+    (equal? "ice-9/q.scm"
+            (with-fluids ((%file-port-name-canonicalization 'relative))
+              (port-filename
+               (open-input-file (%search-load-path "ice-9/q.scm"))))))
+
+  (pass-if "absolute canonicalization from ice-9"
+    (equal? (string-append (assoc-ref %guile-build-info 'top_srcdir)
+                           "/module/ice-9/q.scm")
+            (with-fluids ((%file-port-name-canonicalization 'absolute))
+              (port-filename (open-input-file (%search-load-path 
"ice-9/q.scm")))))))
+
 (delete-file (test-file))
 
 ;;; Local Variables:
 ;;; eval: (put 'test-decoding-error 'scheme-indent-function 3)
+;;; eval: (put 'with-load-path 'scheme-indent-function 1)
 ;;; End:


hooks/post-receive
-- 
GNU Guile



reply via email to

[Prev in Thread] Current Thread [Next in Thread]