From d4e550ede8beccef4312e621a644b89f9d76f74d Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Fri, 18 Jul 2003 14:47:50 +0000 Subject: [PATCH] 0.8.1.44: Merge patch from Nikodemus Siivola for FILE-POSITION on STRING-INPUT-STREAMs ... :START and :END are valid file position designators, so accept them. --- src/code/stream.lisp | 6 +++++- tests/stream.pure.lisp | 22 +++++++++++++++++----- version.lisp-expr | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/code/stream.lisp b/src/code/stream.lisp index edfc4ed..c35f45f 100644 --- a/src/code/stream.lisp +++ b/src/code/stream.lisp @@ -1147,7 +1147,11 @@ (case operation (:file-position (if arg1 - (setf (string-input-stream-current stream) arg1) + (setf (string-input-stream-current stream) + (case arg1 + (:start 0) + (:end (string-input-stream-end stream)) + (t arg1))) (string-input-stream-current stream))) (:file-length (length (string-input-stream-string stream))) (:unread (decf (string-input-stream-current stream))) diff --git a/tests/stream.pure.lisp b/tests/stream.pure.lisp index 70fc40d..016b31c 100644 --- a/tests/stream.pure.lisp +++ b/tests/stream.pure.lisp @@ -53,7 +53,7 @@ (return))))) ;;; Entomotomy PEEK-CHAR-WRONGLY-ECHOS-TO-ECHO-STREAM bug, fixed by -;;; by MRD patch sbcl-devel 2002-11-02 merged ca. sbcl-0.7.9.32... +;;; MRD patch sbcl-devel 2002-11-02 merged ca. sbcl-0.7.9.32... (assert (string= (with-output-to-string (out) (peek-char #\] @@ -74,15 +74,15 @@ ;; (Before the fix, the LET* expression just signalled an error.) "a")) -;; 0.7.12 doesn't advance current stream in concatenated streams -;; correctly when searching a stream for a char to read. +;;; 0.7.12 doesn't advance current stream in concatenated streams +;;; correctly when searching a stream for a char to read. (with-input-from-string (p "") (with-input-from-string (q "foo") (let* ((r (make-concatenated-stream p q))) (peek-char nil r)))) -;; 0.7.14 and previous SBCLs don't have a working INTERACTIVE-STREAM-P -;; because it called UNIX-ISATTY, which wasn't defined. +;;; 0.7.14 and previous SBCLs don't have a working INTERACTIVE-STREAM-P +;;; because it called UNIX-ISATTY, which wasn't defined. (with-input-from-string (s "a non-interactive stream") (assert (not (interactive-stream-p s)))) ;;; KLUDGE: Unfortunately it's hard to find a reliably interactive @@ -90,3 +90,15 @@ ;;; from a script, conceivably even as something like a cron job. ;;; Ideas? #+nil (assert (eq (interactive-stream-p *terminal-io*) t)) + +;;; FILE-POSITION on string-input-streams should work, even with +;;; :START or :END new positions. +(let ((stream (make-string-input-stream "abc"))) + (assert (char= (read-char stream) #\a)) + (assert (= (file-position stream) 1)) + (assert (file-position stream 0)) + (assert (char= (read-char stream) #\a)) + (assert (file-position stream :start)) + (assert (char= (read-char stream) #\a)) + (assert (file-position stream :end)) + (assert (eq (read-char stream nil 'foo) 'foo))) diff --git a/version.lisp-expr b/version.lisp-expr index 80bb600..d97fdf9 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.8.1.43" +"0.8.1.44" -- 1.7.10.4