* Read translations from SYS:SITE;HOST.TRANSLATIONS.NEWEST.
Patch by Michael Weber on sbcl-devel.
stack frame thrown from.
* enhancement: WITH-COMPILATION-UNIT :POLICY allows restricting changes to
compiler optimization qualities inside dynamic extent of its body.
+ * enhancement: LOAD-LOGICAL-PATHNAME-TRANSLATIONS can be used to load
+ translations from SYS:SITE;<HOST>.TRANSLATIONS.NEWEST (thanks to Michael
+ Weber)
* optimization: SLOT-VALUE and (SETF SLOT-VALUE) take advantage of
constraint propgation, allowing better compilation eg. when used to
access structures with WITH-SLOTS. (lp#520366)
(defun translate-pathname (source from-wildname to-wildname &key)
#!+sb-doc
"Use the source pathname to translate the from-wildname's wild and
- unspecified elements into a completed to-pathname based on the to-wildname."
+unspecified elements into a completed to-pathname based on the to-wildname."
(declare (type pathname-designator source from-wildname to-wildname))
(with-pathname (source source)
(with-pathname (from from-wildname)
(defun load-logical-pathname-translations (host)
#!+sb-doc
+ "Reads logical pathname translations from SYS:SITE;HOST.TRANSLATIONS.NEWEST,
+with HOST replaced by the supplied parameter. Returns T on success.
+
+If HOST is already defined as logical pathname host, no file is loaded and NIL
+is returned.
+
+The file should contain a single form, suitable for use with
+\(SETF LOGICAL-PATHNAME-TRANSLATIONS).
+
+Note: behaviour of this function is higly implementation dependent, and
+historically it used to be a no-op in SBcL -- the current approach is somewhat
+experimental and subject to change."
(declare (type string host)
(values (member t nil)))
(if (find-logical-host host nil)
;; This host is already defined, all is well and good.
nil
;; ANSI: "The specific nature of the search is
- ;; implementation-defined." SBCL: doesn't search at all
- ;;
- ;; FIXME: now that we have a SYS host that the system uses, it
- ;; might be cute to search in "SYS:TRANSLATIONS;<name>.LISP"
- (error "logical host ~S not found" host)))
+ ;; implementation-defined."
+ (prog1 t
+ (setf (logical-pathname-translations host)
+ (with-open-file (lpt (make-pathname :host "SYS"
+ :directory '(:absolute "SITE")
+ :name host
+ :type "TRANSLATIONS"
+ :version :newest))
+ (read lpt))))))
(defun !pathname-cold-init ()
(let* ((sys *default-pathname-defaults*)
(assert (equal (make-pathname :directory '(:absolute))
(read-from-string "#p\"\\\\\\\\\""))))
+(with-test (:name :load-logical-pathname-translations)
+ (let* ((cwd (truename "."))
+ (foo (merge-pathnames "llpnt-foo.translations" cwd))
+ (bar (merge-pathnames "llpnt-bar.translations" cwd))
+ (translations (logical-pathname-translations "SYS")))
+ (unwind-protect
+ (progn
+ (with-open-file (f foo :direction :output)
+ (prin1 (list (list "*.TEXT" (make-pathname
+ :directory '(:absolute "my" "foo")
+ :name :wild :type "txt")))
+ f))
+ (with-open-file (f bar :direction :output)
+ (prin1 (list (list "*.CL" (make-pathname
+ :directory '(:absolute "my" "bar")
+ :name :wild :type "lisp"))) f))
+ (setf (logical-pathname-translations "SYS")
+ (list* (list "SITE;LLPNT-FOO.TRANSLATIONS.NEWEST" foo)
+ (list "SITE;LLPNT-BAR.TRANSLATIONS.NEWEST" bar)
+ translations))
+ (assert (load-logical-pathname-translations "LLPNT-FOO"))
+ (assert (load-logical-pathname-translations "LLPNT-BAR"))
+ (assert
+ (and
+ (equal "/my/bar/quux.lisp"
+ (namestring (translate-logical-pathname "LLPNT-BAR:QUUX.CL")))
+ (equal "/my/foo/quux.txt"
+ (namestring (translate-logical-pathname "LLPNT-FOO:QUUX.TEXT"))))))
+ (ignore-errors (delete-file foo))
+ (ignore-errors (delete-file bar))
+ (setf (logical-pathname-translations "SYS") translations))))
+
;;;; success
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.36.27"
+"1.0.36.28"