>From 83948be1f7014c81d8064250e2ba467f3b13ed3d Mon Sep 17 00:00:00 2001 From: Evan Hanson Date: Fri, 15 Sep 2017 18:16:45 +1200 Subject: [PATCH 1/2] Drop `##sys#platform-fixup-pathname` This was used in a couple of places to trim a single trailing slash from pathnames on MinGW, but it wasn't used consistently and it isn't necessary to access paths with *one* trailing slash on modern Windows distributions. Since accessing "/foo/" will work fine without it, and since it doesn't solve the problem of trailing slashes in general (i.e. accessing "/foo///" will fail even with it), we simply remove it. --- file.scm | 5 ++--- library.scm | 24 ++---------------------- posix-common.scm | 5 +---- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/file.scm b/file.scm index 0f8f2ea3..31f122b5 100644 --- a/file.scm +++ b/file.scm @@ -115,9 +115,8 @@ EOF ;;; Like `delete-file', but does nothing if the file doesn't exist: -(define delete-file* - (lambda (file) - (and (file-exists? file) (delete-file file)))) +(define (delete-file* filename) + (and (file-exists? filename) (delete-file filename))) (define (rename-file old new) (##sys#check-string old 'rename-file) diff --git a/library.scm b/library.scm index d75635a9..584e539c 100644 --- a/library.scm +++ b/library.scm @@ -2749,20 +2749,6 @@ EOF (define (##sys#port-data port) (##sys#slot port 9)) (define (##sys#set-port-data! port data) (##sys#setslot port 9 data)) -(define ##sys#platform-fixup-pathname - (let* ([bp (string->symbol ((##core#primitive "C_build_platform")))] - [fixsuffix (eq? bp 'mingw32)]) - (lambda (name) - (if fixsuffix - (let ([end (fx- (##sys#size name) 1)]) - (if (fx>= end 0) - (let ([c (##core#inline "C_subchar" name end)]) - (if (or (eq? c #\\) (eq? c #\/)) - (##sys#substring name 0 end) - name) ) - name) ) - name) ) ) ) - (define open-input-file) (define open-output-file) (define close-input-port) @@ -2858,17 +2844,11 @@ EOF (define (file-exists? name) (##sys#check-string name 'file-exists?) - (and (##sys#file-exists? - (##sys#platform-fixup-pathname name) - #f #f 'file-exists?) - name) ) + (and (##sys#file-exists? name #f #f 'file-exists?) name)) (define (directory-exists? name) (##sys#check-string name 'directory-exists?) - (and (##sys#file-exists? - (##sys#platform-fixup-pathname name) - #f #t 'directory-exists?) - name) ) + (and (##sys#file-exists? name #f #t 'directory-exists?) name)) (define (##sys#flush-output port) ((##sys#slot (##sys#slot port 2) 5) port) ; flush-output diff --git a/posix-common.scm b/posix-common.scm index b0a8b5be..ca2a8ee0 100644 --- a/posix-common.scm +++ b/posix-common.scm @@ -251,10 +251,7 @@ EOF (let ((r (cond ((fixnum? file) (##core#inline "C_fstat" file)) ((port? file) (##core#inline "C_fstat" (port->fileno file))) ((string? file) - (let ((path (##sys#make-c-string - (##sys#platform-fixup-pathname - file) - loc))) + (let ((path (##sys#make-c-string file loc))) (if link (##core#inline "C_lstat" path) (##core#inline "C_stat" path) ) ) ) -- 2.11.0