
Raymond Toy pushed to branch master at cmucl / cmucl Commits: f370206e by Raymond Toy at 2025-02-21T13:25:03+00:00 Fix #365: Add Unix interface to strerror and use in get-unix-error-msg - - - - - 8ea8e2a0 by Raymond Toy at 2025-02-21T13:25:03+00:00 Merge branch 'issue-365-get-unix-error-msg-uses-strerror' into 'master' Fix #365: Add Unix interface to strerror and use in get-unix-error-msg Closes #365 See merge request cmucl/cmucl!272 - - - - - 1 changed file: - src/code/unix.lisp Changes: ===================================== src/code/unix.lisp ===================================== @@ -2053,9 +2053,7 @@ _N"Returns a string describing the error number which was returned by a UNIX system call." (declare (type integer error-number)) - (if (array-in-bounds-p *unix-errors* error-number) - (svref *unix-errors* error-number) - (format nil _"Unknown error [~d]" error-number))) + (unix::unix-strerror error-number)) ;;;; Lisp types used by syscalls. @@ -2975,3 +2973,14 @@ (if (null-alien result) (values nil (unix-errno)) (%file->name (cast result c-call:c-string))))))) + +(defun unix-strerror (errno) + _N"Returns a string that describes the error code Errno" + (let ((result + (alien-funcall + (extern-alien "strerror" + (function (* char) int)) + errno))) + ;; Result from strerror can be localized so we need to decode + ;; those octets to get a proper Lisp string. + (string-decode (cast result c-string) :default))) View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/f21c6507bda7fd20f7f3271... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/f21c6507bda7fd20f7f3271... You're receiving this email because of your account on gitlab.common-lisp.net.