
Raymond Toy pushed to branch issue-375-mkstemp-return-filename at cmucl / cmucl Commits: e9f2fd2d by Raymond Toy at 2025-02-07T10:06:23-08:00 Remove check on template As discussed, we remove the check on the template format. Update the tests because Darwin allows any number of X's in the string. This tests won't be run on Darwin. - - - - - 2 changed files: - src/code/unix.lisp - tests/unix.lisp Changes: ===================================== src/code/unix.lisp ===================================== @@ -2904,26 +2904,11 @@ (function (* char)))) c-string)) -(defun check-template (template) - ;; Make sure the template ends with exactly 6 X's and no more. - (let ((last-non-x (position-if-not #'(lambda (c) - (char= c #\X)) - template - :from-end t))) - (and last-non-x - (= last-non-x (- (length template) 7))))) - (defun unix-mkstemp (template) _N"Generates a unique temporary file name from TEMPLATE, and creates and opens the file. On success, the corresponding file descriptor and name of the file is returned. Otherwise, NIL and the UNIX error - code is returned. - - The last six characters of the template must be \"XXXXXX\"." - ;; Make sure the template is valid. - (unless (check-template template) - (return-from unix-mkstemp - (values nil einval))) + code is returned." (let* ((format (if (eql *filename-encoding* :null) :iso8859-1 *filename-encoding*)) @@ -2955,10 +2940,6 @@ If the directory cannot be created NIL and the UNIX error code is returned." - ;; Make sure the template is valid. - (unless (check-template template) - (return-from unix-mkdtemp - (values nil einval))) (let* ((format (if (eql *filename-encoding* :null) :iso8859-1 *filename-encoding*)) ===================================== tests/unix.lisp ===================================== @@ -56,6 +56,8 @@ (assert-false fd) (assert-true (and (integerp errno) (plusp errno))))) +;; Darwin allows any number of X's. +#-darwin (define-test mkstemp.bad-template.2 (:tag :issues) (multiple-value-bind (fd errno) @@ -111,6 +113,8 @@ (assert-false result) (assert-true (and (integerp errno) (plusp errno))))) +;; Darwin allows any number of X's. +#-darwin (define-test mkdtemp.bad-template (:tag :issues) (multiple-value-bind (result errno) @@ -119,6 +123,8 @@ (assert-false result) (assert-true (and (integerp errno) (plusp errno))))) +;; Darwin allows any number of X's. +#-darwin (define-test mkdtemp.bad-template.2 (:tag :issues) (multiple-value-bind (result errno) View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/e9f2fd2d72127b06de55ae25... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/e9f2fd2d72127b06de55ae25... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)