[Git][cmucl/cmucl][issue-365-add-strerror] Simplify implmentation of strerror by using string-decode

Raymond Toy pushed to branch issue-365-add-strerror at cmucl / cmucl Commits: 251232c4 by Raymond Toy at 2025-02-15T08:14:50-08:00 Simplify implmentation of strerror by using string-decode I was stupid. We can use `string-decode` to get the proper Lisp string from the C string returned by `strerror`. - - - - - 1 changed file: - src/code/unix.lisp Changes: ===================================== src/code/unix.lisp ===================================== @@ -2631,17 +2631,6 @@ (let ((result (alien-funcall (extern-alien "strerror" - (function (* unsigned-char) int)) + (function (* char) int)) errno))) - ;; We need to convert the set of octets to a Lisp string according - ;; to the appropriate external format. Copy the C string out to - ;; an array which we can then convert to a string. - (let* ((octets (make-array 100 :element-type '(unsigned-byte 8) :fill-pointer 0))) - (loop for k from 0 - for byte = (deref result k) - until (zerop byte) - do - (vector-push-extend byte octets)) - (lisp::with-array-data ((data octets) (start) (end)) - (declare (ignore start end)) - (values (stream:octets-to-string data :end (length octets))))))) + (string-decode (cast result c-string) :default))) View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/251232c46e3dc7a9a1f268e3... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/251232c46e3dc7a9a1f268e3... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)