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

Commits:

2 changed files:

Changes:

  • src/code/unix.lisp
    ... ... @@ -2904,26 +2904,11 @@
    2904 2904
     			  (function (* char))))
    
    2905 2905
     	c-string))
    
    2906 2906
     
    
    2907
    -(defun check-template (template)
    
    2908
    -  ;; Make sure the template ends with exactly 6 X's and no more.
    
    2909
    -  (let ((last-non-x (position-if-not #'(lambda (c)
    
    2910
    -					 (char= c #\X))
    
    2911
    -				     template
    
    2912
    -				     :from-end t)))
    
    2913
    -    (and last-non-x
    
    2914
    -	 (= last-non-x (- (length template) 7)))))
    
    2915
    -
    
    2916 2907
     (defun unix-mkstemp (template)
    
    2917 2908
       _N"Generates a unique temporary file name from TEMPLATE, and creates
    
    2918 2909
       and opens the file.  On success, the corresponding file descriptor
    
    2919 2910
       and name of the file is returned.  Otherwise, NIL and the UNIX error
    
    2920
    -  code is returned.
    
    2921
    -
    
    2922
    -  The last six characters of the template must be \"XXXXXX\"."
    
    2923
    -  ;; Make sure the template is valid.
    
    2924
    -  (unless (check-template template)
    
    2925
    -    (return-from unix-mkstemp
    
    2926
    -      (values nil einval)))
    
    2911
    +  code is returned."
    
    2927 2912
       (let* ((format (if (eql *filename-encoding* :null)
    
    2928 2913
     		     :iso8859-1
    
    2929 2914
     		     *filename-encoding*))
    
    ... ... @@ -2955,10 +2940,6 @@
    2955 2940
     
    
    2956 2941
       If the directory cannot be created NIL and the UNIX error code is
    
    2957 2942
       returned."
    
    2958
    -  ;; Make sure the template is valid.
    
    2959
    -  (unless (check-template template)
    
    2960
    -    (return-from unix-mkdtemp
    
    2961
    -      (values nil einval)))
    
    2962 2943
       (let* ((format (if (eql *filename-encoding* :null)
    
    2963 2944
     		     :iso8859-1
    
    2964 2945
     		     *filename-encoding*))
    

  • tests/unix.lisp
    ... ... @@ -56,6 +56,8 @@
    56 56
         (assert-false fd)
    
    57 57
         (assert-true (and (integerp errno) (plusp errno)))))
    
    58 58
     
    
    59
    +;; Darwin allows any number of X's.
    
    60
    +#-darwin
    
    59 61
     (define-test mkstemp.bad-template.2
    
    60 62
       (:tag :issues)
    
    61 63
       (multiple-value-bind (fd errno)
    
    ... ... @@ -111,6 +113,8 @@
    111 113
         (assert-false result)
    
    112 114
         (assert-true (and (integerp errno) (plusp errno)))))
    
    113 115
     
    
    116
    +;; Darwin allows any number of X's.
    
    117
    +#-darwin
    
    114 118
     (define-test mkdtemp.bad-template
    
    115 119
       (:tag :issues)
    
    116 120
       (multiple-value-bind (result errno)
    
    ... ... @@ -119,6 +123,8 @@
    119 123
         (assert-false result)
    
    120 124
         (assert-true (and (integerp errno) (plusp errno)))))
    
    121 125
     
    
    126
    +;; Darwin allows any number of X's.
    
    127
    +#-darwin
    
    122 128
     (define-test mkdtemp.bad-template.2
    
    123 129
       (:tag :issues)
    
    124 130
       (multiple-value-bind (result errno)