1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-12 06:41:13 +02:00

* boot-9.scm (load): rewritten again.

Append "." to the default %load-path.
(feature?): new function: checks for a symbol in the features list.
(module-local-variable): remove apparently useless (caddr (list m v
...))
(%load-announce): minor formatting change.
(file-exists?): use access? if posix is featured.
(file-is-directory?): use stat if i/o-extensions is featured.
(try-module-autoload module-name): use file-exists? before
file-is-directory?
This commit is contained in:
Gary Houston 1996-10-06 06:33:11 +00:00
parent 52f4f4d6aa
commit 6fa8995c39
2 changed files with 80 additions and 40 deletions

View file

@ -1,3 +1,16 @@
Sun Oct 6 03:54:59 1996 Gary Houston <ghouston@actrix.gen.nz>
* boot-9.scm (load): rewritten again.
Append "." to the default %load-path.
(feature?): new function: checks for a symbol in the features list.
(module-local-variable): remove apparently useless (caddr (list m v
...))
(%load-announce): minor formatting change.
(file-exists?): use access? if posix is featured.
(file-is-directory?): use stat if i/o-extensions is featured.
(try-module-autoload module-name): use file-exists? before
file-is-directory?
Sat Oct 5 18:54:03 1996 Mikael Djurfeldt <mdj@kenneth> Sat Oct 5 18:54:03 1996 Mikael Djurfeldt <mdj@kenneth>
* boot-9.scm: Added conditional loading of threads.scm. * boot-9.scm: Added conditional loading of threads.scm.

View file

@ -555,20 +555,34 @@
;;; !!!! these should be implemented using Tcl commands, not fports. ;;; !!!! these should be implemented using Tcl commands, not fports.
;;; ;;;
(define (file-exists? str) (define (feature? feature)
;; we don't have false-if-exception (or defmacro) yet. (and (memq feature *features*) #t))
(let ((port (catch 'system-error (lambda () (open-file str OPEN_READ))
(lambda args #f))))
(if port (begin (close-port port) #t)
#f)))
(define (file-is-directory? str) (define file-exists?
(let ((port (catch 'system-error (if (feature? 'posix)
(lambda () (open-file (string-append str "/.") (lambda (str)
OPEN_READ)) (access? str F_OK))
(lambda args #f)))) (lambda (str)
(if port (begin (close-port port) #t) (let ((port (catch 'system-error (lambda () (open-file str OPEN_READ))
#f))) (lambda args #f))))
(if port (begin (close-port port) #t)
#f)))))
(define file-is-directory?
(if (feature? 'i/o-extensions)
(lambda (str)
(> (logand S_IFDIR
(vector-ref (stat str) 2))
0))
(lambda (str)
(display str)
(newline)
(let ((port (catch 'system-error
(lambda () (open-file (string-append str "/.")
OPEN_READ))
(lambda args #f))))
(if port (begin (close-port port) #t)
#f)))))
(define (has-suffix? str suffix) (define (has-suffix? str suffix)
(let ((sufl (string-length suffix)) (let ((sufl (string-length suffix))
@ -576,8 +590,6 @@
(and (> sl sufl) (and (> sl sufl)
(string=? (substring str (- sl sufl) sl) suffix)))) (string=? (substring str (- sl sufl) sl) suffix))))
;;; {Error Handling} ;;; {Error Handling}
;;; ;;;
@ -657,7 +669,7 @@
(let ((sig-pair (assoc n signal-messages))) (let ((sig-pair (assoc n signal-messages)))
(scm-error 'error-signal #f (scm-error 'error-signal #f
(cdr (or sig-pair (cdr (or sig-pair
(cons n "Unknow signal: %s"))) (cons n "Unknown signal: %s")))
(if sig-pair (if sig-pair
#f #f
(list n)) (list n))
@ -821,7 +833,6 @@
(display ";;; ") (display ";;; ")
(display "loading ") (display "loading ")
(display file) (display file)
(display "...")
(newline) (newline)
(force-output))))) (force-output)))))
@ -832,7 +843,6 @@
(display ";;; ") (display ";;; ")
(display "...loaded ") (display "...loaded ")
(display file) (display file)
(display ".")
(newline) (newline)
(force-output))))) (force-output)))))
@ -857,22 +867,36 @@
; #t) ; #t)
(define (load name) (define (load name)
(current-module) (let* ((full-path-supplied (eq? (string-ref name 0) #\/))
(%load-announce name) (full-path
(cond ((and (file-exists? name) (cond (full-path-supplied
(not (file-is-directory? name))) (or (and (file-exists? name)
(primitive-load name #t read-sharp) (not (file-is-directory? name))
(%load-announce-win name)) name)
(else (and (not (has-suffix? name (scheme-file-suffix)))
(let ((name.scm (string-append name (scheme-file-suffix)))) (let ((name.scm
(cond ((and (not (has-suffix? name (scheme-file-suffix))) (string-append name
(file-exists? name.scm) (scheme-file-suffix))))
(not (file-is-directory? name.scm))) (and (file-exists? name.scm)
(primitive-load name.scm #t read-sharp) (not (file-is-directory? name.scm))
(%load-announce-win name.scm)) name.scm)))))
(else (else
(%try-load-path name #t read-sharp) ;; we find name before name.scm even if the latter
(%load-announce-win name))))))) ;; occurs earlier in %load-path (?).
(or (%search-load-path name)
(and (not (has-suffix? name (scheme-file-suffix)))
(%search-load-path (string-append
name
(scheme-file-suffix)))))))))
(cond (full-path
(%load-announce full-path)
(primitive-load full-path #t read-sharp))
(else
(if full-path-supplied
(scm-error 'misc-error "load" "Unable to find file %S"
(list name) #f)
(scm-error 'misc-error "load" "Unable to find file %S in %S"
(list name %load-path) #f))))))
;;; {Transcendental Functions} ;;; {Transcendental Functions}
@ -1468,12 +1492,13 @@
;;; If the symbol is not found at all, return #f. ;;; If the symbol is not found at all, return #f.
;;; ;;;
(define (module-local-variable m v) (define (module-local-variable m v)
(caddr ; (caddr
(list m v ; (list m v
(let ((b (module-obarray-ref (module-obarray m) v))) (let ((b (module-obarray-ref (module-obarray m) v)))
(or (and (variable? b) b) (or (and (variable? b) b)
(and (module-binder m) (and (module-binder m)
((module-binder m) m v #f))))))) ((module-binder m) m v #f)))))
;))
;; module-variable module symbol ;; module-variable module symbol
;; ;;
@ -1911,7 +1936,7 @@
(define autoloads-in-progress '()) (define autoloads-in-progress '())
(define (try-module-autoload module-name) (define (try-module-autoload module-name)
(define (sfx name) (string-append name (scheme-file-suffix))) (define (sfx name) (string-append name (scheme-file-suffix)))
(let* ((reverse-name (reverse module-name)) (let* ((reverse-name (reverse module-name))
(name (car reverse-name)) (name (car reverse-name))
@ -1935,8 +1960,8 @@
(and (or-map (lambda (f) (and (or-map (lambda (f)
(let ((full (in-vicinity d f))) (let ((full (in-vicinity d f)))
full full
(and (not (file-is-directory? full)) (and (file-exists? full)
(file-exists? full) (not (file-is-directory? full))
(begin (begin
(save-module-excursion (save-module-excursion
(lambda () (lambda ()
@ -3573,3 +3598,5 @@
(define-module (guile) :use-module (ice-9 threads))) (define-module (guile) :use-module (ice-9 threads)))
(define-module (guile)) (define-module (guile))
(append! %load-path (cons "." ()))