~ chicken-core (chicken-5) 179f6fa30a737605adefd23578ed63ec559122f9
commit 179f6fa30a737605adefd23578ed63ec559122f9
Author: felix <felix@call-with-current-continuation.org>
AuthorDate: Wed Dec 15 11:56:17 2010 +0100
Commit: felix <felix@call-with-current-continuation.org>
CommitDate: Wed Dec 15 11:56:17 2010 +0100
fixed brokenness in normalize-pathname
diff --git a/files.scm b/files.scm
index 943a6de4..52bd0d87 100644
--- a/files.scm
+++ b/files.scm
@@ -351,7 +351,11 @@ EOF
(let ((bldplt (if (memq (build-platform) '(msvc mingw32)) 'windows 'unix)) )
(define (addpart part parts)
(cond ((string=? "." part) parts)
- ((string=? ".." part) (if (null? parts) '("..") (cdr parts)))
+ ((string=? ".." part)
+ (if (or (null? parts)
+ (string=? ".." (car parts)))
+ (cons part parts)
+ (cdr parts)))
(else (cons part parts) ) ) )
(lambda (path #!optional (platform bldplt))
(let ((sep (if (eq? platform 'windows) #\\ #\/)))
diff --git a/tests/path-tests.scm b/tests/path-tests.scm
index ebeb835c..a1d5ee64 100644
--- a/tests/path-tests.scm
+++ b/tests/path-tests.scm
@@ -53,6 +53,7 @@
(test "a/b" (normalize-pathname "a/./././b" 'unix))
(test "a/b" (normalize-pathname "a/b/c/d/../.." 'unix))
(test "a/b/" (normalize-pathname "a/b/c/d/../../" 'unix))
+(test "../../foo" (normalize-pathname "../../foo" 'unix))
(define home (get-environment-variable "HOME"))
Trap