X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-posix%2Fmacros.lisp;h=02855f8dfe4562fd4dd69a92f8f5ec3005b88c54;hb=c9b36f04557bd6c7208863e73bae7b1bc6e64842;hp=2e0d4bf09c7d4850307602b012bceaa1f91c0648;hpb=4898ef32c639b1c7f4ee13a5ba566ce6debd03e6;p=sbcl.git diff --git a/contrib/sb-posix/macros.lisp b/contrib/sb-posix/macros.lisp index 2e0d4bf..02855f8 100644 --- a/contrib/sb-posix/macros.lisp +++ b/contrib/sb-posix/macros.lisp @@ -1,34 +1,8 @@ -(in-package :sb-posix-internal) - -;;; some explanation may be necessary. The namestring "[foo]" -;;; denotes a wild pathname. When there's a file on the disk whose -;;; Unix name is "[foo]", the appropriate CL namestring for it is -;;; "\\[foo]". So, don't call NAMESTRING, instead call a function -;;; that gets us the Unix name -(defun native-filename (pathname) - (let ((directory (pathname-directory pathname)) - (name (pathname-name pathname)) - (type (pathname-type pathname))) - (with-output-to-string (s nil :element-type 'base-char) - (etypecase directory - (string (write-string directory s)) - (list - (when (eq (car directory) :absolute) - (write-char #\/ s)) - (dolist (piece (cdr directory)) - (etypecase piece - (string (write-string piece s) (write-char #\/ s)) - ((member :up) (write-string "../" s)))))) - (etypecase name - (null) - (string (write-string name s))) - (etypecase type - (null) - (string (write-char #\. s) (write-string type s)))))) +(in-package :sb-posix) (define-designator filename c-string (pathname - (native-filename (translate-logical-pathname filename))) + (sb-ext:native-namestring (translate-logical-pathname filename))) (string filename)) (define-designator file-descriptor (integer 32) @@ -44,7 +18,8 @@ ((alien (* t)) alien-pointer-to-anything-or-nil)) (defun lisp-for-c-symbol (s) - (intern (substitute #\- #\_ (string-upcase s)) :sb-posix)) + (let ((root (if (eql #\_ (char s 0)) (subseq s 1) s))) + (intern (substitute #\- #\_ (string-upcase root)) :sb-posix))) (defmacro define-call-internally (lisp-name c-name return-type error-predicate &rest arguments)