From d2193d89db7a93de9874115a6f4481d0aba99c60 Mon Sep 17 00:00:00 2001 From: Andreas Fuchs Date: Mon, 8 Jan 2007 14:29:41 +0000 Subject: [PATCH] 1.0.1.14: Make sb-posix:mkstemp return both the FD and the file name. mkstemp(3) takes a template string as an "out" parameter. The sb-posix README states that this should be returned as a second value, so we do that. (From a user report that the template string would not get properly clobbered in post-1.0 sbcls. Ow.) --- contrib/sb-posix/interface.lisp | 21 +++++++++++++++++++-- version.lisp-expr | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/contrib/sb-posix/interface.lisp b/contrib/sb-posix/interface.lisp index aef75cd..349c74d 100644 --- a/contrib/sb-posix/interface.lisp +++ b/contrib/sb-posix/interface.lisp @@ -126,7 +126,7 @@ (define-call "fchdir" int minusp (fd file-descriptor)) (define-call "fchmod" int minusp (fd file-descriptor) (mode mode-t)) (define-call "fchown" int minusp (fd file-descriptor) - (owner uid-t) (group gid-t)) + (owner uid-t) (group gid-t)) (define-call "fdatasync" int minusp (fd file-descriptor)) (define-call ("ftruncate" :options :largefile) int minusp (fd file-descriptor) (length off-t)) @@ -141,7 +141,24 @@ int minusp (pathname filename) (length off-t)) ;; FIXME: Windows does have _mktemp, which has a slightlty different ;; interface - (define-call "mkstemp" int minusp (template c-string)) + (defun mkstemp (template) + ;; we are emulating sb-alien's charset conversion for strings + ;; here, to accommodate for the call-by-reference nature of + ;; mkstemp's template strings. + (let ((arg (sb-ext:string-to-octets + (filename template) + :external-format sb-alien::*default-c-string-external-format*))) + (sb-sys:with-pinned-objects (arg) + (let ((result (alien-funcall (extern-alien "mkstemp" + (function int c-string)) + (sap-alien (sb-alien::vector-sap arg) + (* char))))) + (when (minusp result) + (syscall-error)) + (values result + (sb-ext:octets-to-string + arg + :external-format sb-alien::*default-c-string-external-format*)))))) (define-call-internally ioctl-without-arg "ioctl" int minusp (fd file-descriptor) (cmd int)) (define-call-internally ioctl-with-int-arg "ioctl" int minusp diff --git a/version.lisp-expr b/version.lisp-expr index 0020338..5479fa1 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; 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.1.13" +"1.0.1.14" -- 1.7.10.4