Fix :file-length method of stream-from-stdio-file

It positioned the stream to 0 by accident
This commit is contained in:
Douglas Katzman 2024-12-17 22:00:13 -05:00
parent 36c3659322
commit 2063bcf9a3
2 changed files with 5 additions and 1 deletions

View file

@ -2857,7 +2857,7 @@
(:file-length
;; there are at least 2 ways to do this: stat() or lseek() a few times
(let* ((fd (stdio-file-fd stdio-file))
(cur (sb-unix:unix-lseek fd 0 sb-unix:L_SET)) ; SEEK-SET
(cur (sb-unix:unix-lseek fd 0 sb-unix:L_INCR)) ; SEEK-CUR
(end (sb-unix:unix-lseek fd 0 sb-unix:L_XTND))) ; SEEK-END
;; go back to where it was
(sb-unix:unix-lseek fd cur sb-unix:L_SET)

View file

@ -3,7 +3,11 @@
(multiple-value-bind (output warn err)
(sb-c:compile-form-to-file '(progn (defvar *foo* 3)) tmpfile)
(assert (and output (not warn) (not err)))
(assert (eq (sb-int:info :variable :kind '*foo*) :special))
(sb-int:clear-info :variable :kind '*foo*)
(let ((stream (sb-impl::stream-from-stdio-file tmpfile :input t)))
;; compile-form-to-file leaves the file positioned to its end.
(file-position stream 0)
(sb-fasl::load-as-fasl stream nil nil)
(sb-unix:unix-fclose tmpfile)
(assert (eq (sb-int:info :variable :kind '*foo*) :special))