From ffbae2c090fb8d1ac95b168967c1797c32939ec9 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 7 Mar 2016 14:28:06 -0700 Subject: [PATCH] fix `resolve-path` to always return a path (not a string) Closes #1132 --- pkgs/racket-test-core/tests/racket/file.rktl | 25 ++++++++++++++++++++ racket/src/racket/src/file.c | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pkgs/racket-test-core/tests/racket/file.rktl b/pkgs/racket-test-core/tests/racket/file.rktl index 85b8cfc41a..23a44ba285 100644 --- a/pkgs/racket-test-core/tests/racket/file.rktl +++ b/pkgs/racket-test-core/tests/racket/file.rktl @@ -1814,4 +1814,29 @@ ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(let ([tf (make-temporary-file)]) + (test tf resolve-path (path->string tf)) + (unless (eq? 'windows (system-type)) + (delete-file tf) + (make-file-or-directory-link "other.txt" tf) + (test (string->path "other.txt") resolve-path tf)) + (delete-file tf) + (case (system-path-convention-type) + [(unix) + (test (string->path "/testing-root/testing-dir/testing-file") + resolve-path + "//testing-root/testing-dir/testing-file") + (test (string->path "/testing-root/testing-dir/testing-file") + resolve-path + "//testing-root////testing-dir//testing-file")] + [(windows) + (test (string->path "C:/testing-root/testing-dir/testing-file") + resolve-path + "C://testing-root/testing-dir/testing-file") + (test (string->path "C:/testing-root/testing-dir\\testing-file") + resolve-path + "C://testing-root////testing-dir\\\\testing-file")])) + +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + (report-errs) diff --git a/racket/src/racket/src/file.c b/racket/src/racket/src/file.c index f834767196..d00d199b66 100644 --- a/racket/src/racket/src/file.c +++ b/racket/src/racket/src/file.c @@ -4617,7 +4617,7 @@ static Scheme_Object *do_resolve_path(int argc, Scheme_Object *argv[], int guard return scheme_make_sized_path(buffer, len, 1); } - if (!expanded) + if (!expanded && SCHEME_PATHP(argv[0])) return argv[0]; else return scheme_make_sized_path(filename, strlen(filename), 1);