From bf9765ecd018ea350057603a23a2f45907e0a48c Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 17 Dec 2005 14:17:01 +0000 Subject: [PATCH] fixed for v300 and SLIB 3a2 svn: r1636 --- collects/slibinit/doc.txt | 2 +- collects/slibinit/init.ss | 42 +++++++++++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/collects/slibinit/doc.txt b/collects/slibinit/doc.txt index fb21635dda..80a3226cb1 100644 --- a/collects/slibinit/doc.txt +++ b/collects/slibinit/doc.txt @@ -3,7 +3,7 @@ _SLIB_ Initialization File -------------------------- The "init.ss" file in the _slibinit_ collection is an SLIB -initialization file (tested with version 2d2). +initialization file (tested with version 3a2). To use SLIB in MzScheme: diff --git a/collects/slibinit/init.ss b/collects/slibinit/init.ss index 3afbdf6366..9506e8238f 100644 --- a/collects/slibinit/init.ss +++ b/collects/slibinit/init.ss @@ -73,7 +73,7 @@ (lambda (x) (error 'slib-init "can't find SCHEME_LIBRARY_PATH environment variable or \"slib\" collection"))]) - (collection-path "slib"))))) + (path->string (collection-path "slib")))))) (lambda () library-path))) ;;; (home-vicinity) should return the vicinity of the user's HOME @@ -81,7 +81,22 @@ ;;; customize a computer environment for a user. (define (home-vicinity) - (find-system-path 'home-dir)) + (path->string (find-system-path 'home-dir))) + +(define (user-vicinity) + (path->string (build-path 'same))) + +(define (program-vicinity) + (path->string + (or (current-load-relative-directory) + (current-directory)))) + +(define with-load-pathname + (lambda (a thunk) (thunk))) + +(define sub-vicinity + (lambda (vic name) + (path->string (build-path vic name)))) ;;; *FEATURES* should be set to a list of symbols describing features ;;; of this implementation. Suggestions for features are: @@ -266,9 +281,13 @@ (define (defmacro:load ) (slib:eval-load defmacro:eval)) +(define (ensure-path-string p) + (if (path? p) (path->string p) p)) + (define (slib:eval-load evl) (if (not (file-exists? )) - (set! (string-append (scheme-file-suffix)))) + (set! (string-append (ensure-path-string ) + (scheme-file-suffix)))) (call-with-input-file (lambda (port) (let ((old-load-pathname *load-pathname*)) @@ -303,12 +322,13 @@ (define in-vicinity (lambda args - (let loop ([args args]) - (cond - [(null? (cdr args)) (car args)] - [(string=? "" (car args)) (loop (cdr args))] - [else (let ([v (loop (cdr args))]) - (build-path (car args) v))])))) + (path->string + (let loop ([args args]) + (cond + [(null? (cdr args)) (car args)] + [(string=? "" (car args)) (loop (cdr args))] + [else (let ([v (loop (cdr args))]) + (build-path (car args) v))]))))) ;;; Define SLIB:EXIT to be the implementation procedure to exit or ;;; return if exitting not supported. @@ -324,13 +344,13 @@ ;;; (SLIB:LOAD-SOURCE "foo") should load "foo.scm" or with whatever ;;; suffix all the module files in SLIB have. See feature 'SOURCE. -(define (slib:load-source f) (load (string-append f ".scm"))) +(define (slib:load-source f) (load (string-append (ensure-path-string f) ".scm"))) ;;; (SLIB:LOAD-COMPILED "foo") should load the file that was produced ;;; by compiling "foo.scm" if this implementation can compile files. ;;; See feature 'COMPILED. -(define (slib:load-compiled f) (load (string-append f ".zo"))) +(define (slib:load-compiled f) (load (string-append (ensure-path-string f) ".zo"))) ;;; At this point SLIB:LOAD must be able to load SLIB files.