Fix file-position on copmosite streams

concatenated-stream wasn't processing buffered input correctly.
two-way-stream and echo-stream should just return NIL, as
file-position can't apply to both streams.
This commit is contained in:
Stas Boukarev 2026-08-03 23:51:48 +03:00
parent 8ee5b24141
commit bf87e9ab2c
6 changed files with 39 additions and 4 deletions

View file

@ -779,8 +779,7 @@ Nothing to see here, move along.")
(deftest two-way-stream-16
;; FILE-POSITION (via STREAM-MISC-DISPATCH)
(with-sc-test-stream (synonym)
(eql (file-position (make-two-way-stream synonym synonym))
(file-position synonym)))
(null (file-position (make-two-way-stream synonym synonym))))
T)
;; SYNONYM-STREAM tests repeated for ECHO-STREAM, where applicable
@ -850,8 +849,7 @@ Nothing to see here, move along.")
(deftest echo-stream-16
;; FILE-POSITION (via STREAM-MISC-DISPATCH)
(with-sc-test-stream (*synonym*)
(eql (file-position (make-echo-stream *synonym* *synonym*))
(file-position *synonym*)))
(null (file-position (make-echo-stream *synonym* *synonym*))))
T)
;; SYNONYM-STREAM tests repeated for CONCATENATED-STREAM, where applicable

View file

@ -1121,6 +1121,9 @@
in-mode)))
(:close
(set-closed-flame stream))
((:get-file-position :set-file-position)
;; Unclear to which stream it should apply
nil)
(t
(or (if in-ansi-stream-p
(call-ansi-stream-misc in operation arg1)
@ -1217,6 +1220,9 @@
(:unread (when left (unread-char arg1 current)))
(:close
(set-closed-flame stream))
(:get-file-position
(when current
(file-position current)))
(t
(when left
(if (ansi-stream-p current)

View file

@ -220,6 +220,9 @@
in-mode)))
(:close
(set-closed-flame stream))
((:get-file-position :set-file-position)
;; Unclear to which stream it should apply
nil)
(t
(or (if in-ansi-stream-p
(call-ansi-stream-misc in operation arg1)

View file

@ -118,8 +118,14 @@
"../contrib/sb-simd/test-suite/utilities.lisp"
"../contrib/sb-simd/test-suite/test-suite.lisp"
"../contrib/sb-simd/test-suite/test-arefs.lisp"
"../contrib/sb-simd/test-suite/test-arefs-arm64.lisp"
"../contrib/sb-simd/test-suite/test-arefs-x86-64.lisp"
"../contrib/sb-simd/test-suite/test-simple-simd-functions.lisp"
"../contrib/sb-simd/test-suite/test-simple-simd-functions-arm64.lisp"
"../contrib/sb-simd/test-suite/test-simple-simd-functions-x86-64.lisp"
"../contrib/sb-simd/test-suite/test-horizontal-functions.lisp"
"../contrib/sb-simd/test-suite/test-horizontal-functions-arm64.lisp"
"../contrib/sb-simd/test-suite/test-horizontal-functions-x86-64.lisp"
"../contrib/sb-simd/test-suite/test-hairy-simd-functions.lisp"
"../contrib/sb-simd/test-suite/test-packages.lisp")
("sb-simple-streams.impure.lisp" "contrib/sb-simple-streams.fasl" "contrib/sb-bsd-sockets.fasl"

View file

@ -545,3 +545,19 @@
(assert (= (read-sequence x s) 1))
(assert (equalp d #(1 0 1)))
(assert (equalp x #(0))))))
(with-test (:name :composite-streams-file-position)
(with-open-file (str (or #+win32 "zero" "/dev/zero"))
(read-char str)
(assert (= (file-position (make-concatenated-stream str))
(file-position str))))
(with-open-file (str (or #+win32 "/dev/null" "/dev/zero") :if-exists :append :direction :output)
(write-char #\a str)
(assert (= (file-position (make-broadcast-stream str))
(file-position str))))
(with-open-file (i (or #+win32 "zero" "/dev/zero"))
(with-open-file (o (or #+win32 "/dev/null" "/dev/zero") :if-exists :append :direction :output)
(assert (null (file-position (make-echo-stream i o))))))
(with-open-file (i (or #+win32 "zero" "/dev/zero"))
(with-open-file (o (or #+win32 "/dev/null" "/dev/zero") :if-exists :append :direction :output)
(assert (null (file-position (make-two-way-stream i o)))))))

View file

@ -1788,5 +1788,11 @@
(#(A49305EF D0241AE7 E55E7F8C EE9A5410)
"(SB-PCL::%CLASS SB-PCL::%PARAMETER SB-PCL::%VARIABLE-REBINDING SPECIAL)"
"((& (>> val 8) 3))")
(#(0 2 A 1A 1E)
"(5 15 1 13 0)"
"((let ((tab #a((4) (unsigned-byte 8) 2 0 0 7)))
(let ((b (& (>> val 1) #x3)))
(let ((a (>> (<< val 27) 30)))
(^ a (aref tab b))))))")
)
;; EOF