load, ...: make sure load handlers receive paths

This commit is contained in:
Matthew Flatt 2018-03-01 07:54:12 -07:00
parent c59c961ebc
commit 618d362f09

View File

@ -11,17 +11,19 @@
(define/who (load s) (define/who (load s)
(check who path-string? s) (check who path-string? s)
(define p (->path s))
(call-with-current-load-relative-directory (call-with-current-load-relative-directory
s p
(lambda () (lambda ()
((current-load) s #f)))) ((current-load) p #f))))
(define/who (load-extension s) (define/who (load-extension s)
(check who path-string? s) (check who path-string? s)
(define p (->path s))
(call-with-current-load-relative-directory (call-with-current-load-relative-directory
s p
(lambda () (lambda ()
((current-load-extension) s #f)))) ((current-load-extension) p #f))))
(define (call-with-current-load-relative-directory p thunk) (define (call-with-current-load-relative-directory p thunk)
(define-values (base name dir?) (split-path p)) (define-values (base name dir?) (split-path p))
@ -35,7 +37,8 @@
(define/who (load/use-compiled f) (define/who (load/use-compiled f)
(check who path-string? f) (check who path-string? f)
((current-load/use-compiled) f #f)) (define p (->path f))
((current-load/use-compiled) p #f))
;; used for the -k command-line argument: ;; used for the -k command-line argument:
(define (embedded-load start end str as-predefined?) (define (embedded-load start end str as-predefined?)
@ -60,3 +63,8 @@
(parameterize ([current-module-declare-as-predefined as-predefined?]) (parameterize ([current-module-declare-as-predefined as-predefined?])
((current-eval) e)) ((current-eval) e))
(loop)))))) (loop))))))
;; ----------------------------------------
(define (->path s)
(if (string? s) (string->path s) s))