Raymond Toy pushed to branch issue-375-mkstemp-return-filename at cmucl / cmucl

Commits:

2 changed files:

Changes:

  • src/code/unix.lisp
    ... ... @@ -2930,7 +2930,7 @@
    2930 2930
     		     ;; Convert the array of octets in BUFFER back to
    
    2931 2931
     		     ;; a Lisp string.
    
    2932 2932
     		     (stream:octets-to-string buffer
    
    2933
    -					      :end (1- length)
    
    2933
    +					      :end length
    
    2934 2934
     					      :external-format format))
    
    2935 2935
     	     (sys:vector-sap buffer))))
    
    2936 2936
     
    
    ... ... @@ -2965,6 +2965,4 @@
    2965 2965
           ;; resulting name.  Otherwise, return NIL and the errno.
    
    2966 2966
           (if (null-alien result)
    
    2967 2967
     	  (values nil (unix-errno))
    
    2968
    -	  (values (stream:octets-to-string buffer
    
    2969
    -					   :end (1- length)
    
    2970
    -					   :external-format format))))))
    2968
    +	  (%file->name (cast result c-call:c-string))))))

  • tests/unix.lisp
    ... ... @@ -17,6 +17,26 @@
    17 17
           (when fd
    
    18 18
     	(unix:unix-unlink name)))))
    
    19 19
     
    
    20
    +(define-test mkstemp.name-returned.2
    
    21
    +  (:tag :issues)
    
    22
    +  (let ((unix::*filename-encoding* :utf-8)
    
    23
    +	fd name)
    
    24
    +    (unwind-protect
    
    25
    +	 (progn
    
    26
    +	   ;; Temp name starts with a lower case alpha character.
    
    27
    +	   (let* ((template (concatenate 'string (string #\u+3b1)
    
    28
    +					 "test-XXXXXX"))
    
    29
    +		  (x-posn (position #\X template)))
    
    30
    +	     (multiple-value-setq (fd name)
    
    31
    +	       (unix::unix-mkstemp template))
    
    32
    +	     (assert-true fd)
    
    33
    +	     (assert-false (search "XXXXXX" name)
    
    34
    +			   name)
    
    35
    +	     (assert-true (string= name template :end1 x-posn :end2 x-posn)
    
    36
    +			  name)))
    
    37
    +      (when fd
    
    38
    +	(unix:unix-unlink name)))))
    
    39
    +
    
    20 40
     (define-test mkstemp.bad-path
    
    21 41
       (:tag :issues)
    
    22 42
       (multiple-value-bind (fd errno)
    
    ... ... @@ -52,6 +72,25 @@
    52 72
           (when name
    
    53 73
     	(unix:unix-rmdir name)))))
    
    54 74
     
    
    75
    +(define-test mkdtemp.name-returned.2
    
    76
    +  (:tag :issues)
    
    77
    +  (let ((unix::*filename-encoding* :utf-8)
    
    78
    +	name)
    
    79
    +    (unwind-protect
    
    80
    +	 (progn
    
    81
    +	   ;; Temp name starts with a lower case alpha character.
    
    82
    +	   (let* ((template (concatenate 'string (string #\u+3b1)
    
    83
    +					 "dir-XXXXXX"))
    
    84
    +		  (x-posn (position #\X template)))
    
    85
    +	     (setf name (unix::unix-mkdtemp template))
    
    86
    +	     ;; Verify that the dir name no longer has X's.
    
    87
    +	     (assert-true (stringp name))
    
    88
    +	     (assert-false (search "XXXXXX" name))
    
    89
    +	     (assert-true (string= name template :end1 x-posn :end2 x-posn)
    
    90
    +			  name x-posn)))
    
    91
    +      (when name
    
    92
    +	(unix:unix-rmdir name)))))
    
    93
    +
    
    55 94
     (define-test mkdtemp.bad-path
    
    56 95
       (:tag :issues)
    
    57 96
       (multiple-value-bind (result errno)